From 9cba03b0178e33f8aa36af991f201e7037daa73d Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 18 Oct 2013 09:59:06 +0200 Subject: [PATCH] Add actual links and buttons to the multi-views refs #3788 --- .../controllers/MultiController.php | 20 +++--- .../views/scripts/list/comments.phtml | 2 +- .../scripts/multi/components/comments.phtml | 72 ++++++++++++++----- .../scripts/multi/components/downtimes.phtml | 45 ++++++++---- .../scripts/multi/components/summary.phtml | 68 ++++++++++++++++-- .../views/scripts/multi/host.phtml | 5 +- .../views/scripts/multi/service.phtml | 6 ++ .../scripts/show/components/status.phtml | 2 +- public/js/icinga/components/mainDetailGrid.js | 42 ++++++++--- 9 files changed, 206 insertions(+), 56 deletions(-) diff --git a/modules/monitoring/application/controllers/MultiController.php b/modules/monitoring/application/controllers/MultiController.php index 53b8beb0c..a9b7a0075 100644 --- a/modules/monitoring/application/controllers/MultiController.php +++ b/modules/monitoring/application/controllers/MultiController.php @@ -27,13 +27,13 @@ // {{{ICINGA_LICENSE_HEADER}}} use \Icinga\Web\Form; +use \Icinga\Web\Controller\ActionController; use \Icinga\Module\Monitoring\Backend; use \Icinga\Module\Monitoring\Object\Host; use \Icinga\Module\Monitoring\Object\Service; use \Icinga\Module\Monitoring\Form\Command\MultiCommandFlagForm; use \Icinga\Module\Monitoring\DataView\HostAndServiceStatus as HostAndServiceStatusView; use \Icinga\Module\Monitoring\DataView\Comment as CommentView; -use \Icinga\Web\Controller\ActionController; /** * Displays aggregations collections of multiple objects. @@ -43,7 +43,6 @@ class Monitoring_MultiController extends ActionController public function init() { $this->view->queries = $this->getDetailQueries(); - $this->view->wildcard = false; $this->backend = Backend::createBackend($this->_getParam('backend')); } @@ -87,7 +86,7 @@ class Monitoring_MultiController extends ActionController } $this->view->objects = $this->view->hosts = $hosts; $this->view->comments = isset($comments) ? $comments : $this->getComments($hosts); - $this->view->hostnames = $this->getHostnames($hosts); + $this->view->hostnames = $this->getProperties($hosts, 'host_name'); $this->view->downtimes = $this->getDowntimes($hosts); $this->view->errors = $errors; @@ -108,7 +107,11 @@ class Monitoring_MultiController extends ActionController $unique = array(); foreach ($values as $value) { - $unique[$value->{$key}] = null; + if (is_array($value)) { + $unique[$value[$key]] = $value[$key]; + } else { + $unique[$value->{$key}] = $value->{$key}; + } } return $unique; } @@ -117,16 +120,16 @@ class Monitoring_MultiController extends ActionController { $unique = array(); foreach ($objects as $object) { - $unique = array_merge($this->getUniqueValues($object->comments, 'comment_id')); + $unique = array_merge($unique, $this->getUniqueValues($object->comments, 'comment_internal_id')); } return array_keys($unique); } - private function getHostnames($objects) + private function getProperties($objects, $property) { $objectnames = array(); foreach ($objects as $object) { - $objectnames[] = $object->host_name; + $objectnames[] = $object->{$property}; } return $objectnames; } @@ -190,7 +193,8 @@ class Monitoring_MultiController extends ActionController } $this->view->objects = $this->view->services = $services; $this->view->comments = isset($comments) ? $comments : $this->getComments($services); - $this->view->hostnames = $this->getHostnames($services); + $this->view->hostnames = $this->getProperties($services, 'host_name'); + $this->view->servicenames = $this->getProperties($services, 'service_description'); $this->view->downtimes = $this->getDowntimes($services); $this->view->errors = $errors; diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 895f76d3d..36c413424 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -12,7 +12,7 @@ $viewHelper = $this->getHelper('MonitoringState');

Comments

-
+
sortControl->render($this); ?> paginationControl($comments, null, null, array('preserve' => $this->preserve)); ?> diff --git a/modules/monitoring/application/views/scripts/multi/components/comments.phtml b/modules/monitoring/application/views/scripts/multi/components/comments.phtml index 2b81ad9e6..fc2fa6ab8 100644 --- a/modules/monitoring/application/views/scripts/multi/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/multi/components/comments.phtml @@ -1,24 +1,64 @@
- {{COMMENT_ICON}} Comments + Comments
- - comments are present in the selected items. - -
- {{REMOVE_COMMENTS_BUTTON}} - {{ADD_COMMENT_BUTTON}} - {{SEND_NOTIFICATION_BUTTON}} - {{DELAY_NOTIFICATION_BUTTON}} + +
+ 0) { ?> + + comments in the selected items. + + + + + + 0 comments in the selected items. + +
+ + + +
diff --git a/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml b/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml index 87c4989c4..134677625 100644 --- a/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/multi/components/downtimes.phtml @@ -1,20 +1,37 @@
- {{DOWNTIME_ICON}} Downtimes + Downtimes
- - Selected items are currently in downtime. - - -
- {{REMOVE_DOWNTIME_BUTTON}} - {{REMOVE_ACKNOWLEDGEMENTS_BUTTON}} -
+
+ 0) { ?> + + Selected items are currently in downtime. + + + + + + 0 Selected items are currently in downtime. + +
+ + Remove Acknowledgements +
diff --git a/modules/monitoring/application/views/scripts/multi/components/summary.phtml b/modules/monitoring/application/views/scripts/multi/components/summary.phtml index 07f4082d5..7424d4f68 100644 --- a/modules/monitoring/application/views/scripts/multi/components/summary.phtml +++ b/modules/monitoring/application/views/scripts/multi/components/summary.phtml @@ -1,9 +1,67 @@ +getHelper('CommandForm'); + +$servicequery = isset($this->servicequery) ? $this->servicequery : ''; +?> +

Selected objects.

-{{RECHECK_BUTTON}} -{{RESCHEDULE_BUTTON}} -{{ACKNOWLEDGE_PROBLEMS_BUTTON}} -{{SCHEDULE_DOWNTIMES}} -{{SUBMIT_PASSIVE_CHECK_RESULTS}} + + + + + + +
    is_service = false; +$this->hostquery = implode($this->hostnames, ','); +$this->target = array( + 'host' => $this->hostquery +); ?>
    - {{HOST_ICON}}

    Hosts

    diff --git a/modules/monitoring/application/views/scripts/multi/service.phtml b/modules/monitoring/application/views/scripts/multi/service.phtml index e8eb85d34..a8e84cacb 100644 --- a/modules/monitoring/application/views/scripts/multi/service.phtml +++ b/modules/monitoring/application/views/scripts/multi/service.phtml @@ -1,5 +1,11 @@ is_service = true; +$this->hostquery = implode($this->hostnames, ','); +$this->servicequery = implode($this->servicenames, ','); +$this->target = array( + 'host' => $this->hostquery, + 'service' => $this->servicequery +); ?>
    diff --git a/modules/monitoring/application/views/scripts/show/components/status.phtml b/modules/monitoring/application/views/scripts/show/components/status.phtml index cc138e307..e99f306e2 100644 --- a/modules/monitoring/application/views/scripts/show/components/status.phtml +++ b/modules/monitoring/application/views/scripts/show/components/status.phtml @@ -209,4 +209,4 @@
    -
\ No newline at end of file +
diff --git a/public/js/icinga/components/mainDetailGrid.js b/public/js/icinga/components/mainDetailGrid.js index 8ad24b28c..1d74edfd3 100644 --- a/public/js/icinga/components/mainDetailGrid.js +++ b/public/js/icinga/components/mainDetailGrid.js @@ -77,7 +77,7 @@ function(Container, $, logger, Selectable, TableMultiSelection, URI) { var controlForms; /** - * Handles a multi-selection of rows + * Handles multi-selection * * @type {TableMultiSelection} */ @@ -135,6 +135,15 @@ function(Container, $, logger, Selectable, TableMultiSelection, URI) { } }; + /** + * Show a 'hand' to indicate that the row is selectable, + * when hovering. + */ + this.showMousePointerOnRow = function(domContext) { + domContext = domContext || contentNode; + $('tbody tr', domContext).css('cursor' ,'pointer'); + } + /** * Activate a hover effect on all table rows, to indicate that * this table row is clickable. @@ -295,6 +304,27 @@ function(Container, $, logger, Selectable, TableMultiSelection, URI) { Container.getDetailContainer().registerOnUpdate(this.syncSelectionWithDetail.bind(this)); }; + /** + * Init all objects responsible for selection handling + * + * - Indicate selection by showing active and hovered rows + * - Handle click-events according to the selection mode + * - Create and follow links according to the row content + */ + this.initRowSelection = function() { + selectionMode = gridDomNode.data('icinga-grid-selection-type'); + if (selectionMode === 'multi' || selectionMode === 'single') { + // indicate selectable rows + this.showMousePointerOnRow(); + this.activateRowHovering(); + selection = new TableMultiSelection( + contentNode, + Container.getDetailContainer().getContainerHref() + ); + } + this.registerTableLinks(); + } + /** * Create this component, setup listeners and behaviour */ @@ -303,16 +333,8 @@ function(Container, $, logger, Selectable, TableMultiSelection, URI) { this.container.removeDefaultLoadIndicator(); controlForms = determineControlForms(); contentNode = determineContentTable(); - selectionMode = gridDomNode.data('icinga-grid-selection-type'); - if (selectionMode === 'multi' || selectionMode === 'single') { - this.activateRowHovering(); - selection = new TableMultiSelection( - contentNode, - Container.getDetailContainer().getContainerHref() - ); - } + this.initRowSelection(); this.registerControls(); - this.registerTableLinks(); this.registerHistoryChanges(); };