From 9c45e99b5731b7b8336f066ce6e0f2b3c64ad4f4 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Fri, 6 Mar 2015 16:13:00 +0100 Subject: [PATCH] Add tiny statesummary to service multi-view refs #8565 --- .../controllers/HostsController.php | 19 +++++--- .../views/scripts/hosts/show.phtml | 7 +-- .../partials/host/objects-header.phtml | 6 +-- .../partials/host/objects-tinysummary.phtml | 44 +++++++++++++++++++ .../partials/service/objects-header.phtml | 1 - modules/monitoring/public/css/module.less | 12 +++++ 6 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index eaa3d03a45..ec4e470a20 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -111,14 +111,19 @@ public function showAction() $objectsInDowntime = array(); $downtimeFilterExpressions = array(); $hostStates = array( - Host::getStateText(Host::STATE_UP) => 0, - Host::getStateText(Host::STATE_DOWN) => 0, - Host::getStateText(Host::STATE_UNREACHABLE) => 0, - Host::getStateText(Host::STATE_PENDING) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UP) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UP) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_DOWN) => 0, + 'hosts_' . Host::getStateText(Host::STATE_DOWN) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) => 0, + 'hosts_' . Host::getStateText(Host::STATE_UNREACHABLE) . '_unhandled' => 0, + 'hosts_' . Host::getStateText(Host::STATE_PENDING) => 0, + 'hosts_' . Host::getStateText(Host::STATE_PENDING) . '_unhandled' => 0, ); foreach ($this->hostList as $host) { /** @var Host $host */ - if ((bool) $host->problem === true && (bool) $host->handled === false) { + $unhandled = (bool) $host->problem === true && (bool) $host->handled === false; + if ($unhandled) { $unhandledObjects[] = $host; $unhandledFilterExpressions[] = Filter::where('host', $host->getName()); } @@ -129,7 +134,7 @@ public function showAction() $objectsInDowntime[] = $host; $downtimeFilterExpressions[] = Filter::where('downtime_host', $host->getName()); } - ++$hostStates[$host::getStateText($host->state)]; + ++$hostStates['hosts_' . $host::getStateText($host->state) . ($unhandled ? '_unhandled' : '')]; } if (! empty($acknowledgedObjects)) { $removeAckForm = new RemoveAcknowledgementCommandForm(); @@ -145,7 +150,7 @@ public function showAction() $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); - $this->view->hostStates = $hostStates; + $this->view->hostStates = (object)$hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $unhandledObjects; $unhandledFilterQueryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString(); diff --git a/modules/monitoring/application/views/scripts/hosts/show.phtml b/modules/monitoring/application/views/scripts/hosts/show.phtml index c8a4f9484a..f4ac409041 100644 --- a/modules/monitoring/application/views/scripts/hosts/show.phtml +++ b/modules/monitoring/application/views/scripts/hosts/show.phtml @@ -8,12 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; -

- qlink( - sprintf($this->translate('%d Hosts Selected'), count($objects)), - $listAllLink - ); ?> -

+ render('partials/host/objects-tinysummary.phtml') ?> render('partials/host/objects-header.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml index c2f016ceb1..d535f367ea 100644 --- a/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/objects-header.phtml @@ -2,14 +2,12 @@ use Icinga\Module\Monitoring\Object\Host; ?> - - 0): ?>

@@ -71,8 +69,8 @@ $hiddenRich = array(); - -

+
translate('%d more ...'), count($hidden)) ?>
diff --git a/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml new file mode 100644 index 0000000000..fa841c6337 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/host/objects-tinysummary.phtml @@ -0,0 +1,44 @@ + + +

+ qlink( + sprintf($this->translate('%d Hosts Selected:'), count($objects)), + $listAllLink + ); ?> + + + hosts_up): ?> + + + + hosts_up ?> + + + + + 'down', + 2 => 'unreachable', + 99 => 'pending' + ) as $stateId => $state) { + + $stateName = 'hosts_' . $state; + $unhandledStateName = $stateName . '_unhandled'; + if ($hostStates->$unhandledStateName) { + echo '' . $hostStates->$unhandledStateName . ''; + } + if ($hostStates->$stateName) { + echo '' . $hostStates->$stateName . ''; + } + if ($hostStates->$unhandledStateName) { + echo ''; + } + $stateName .= '_unhandled'; + }?> + + +

\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml index 4501f0e7ed..dd206a6468 100644 --- a/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/objects-header.phtml @@ -1,6 +1,5 @@