Skip to content

Commit

Permalink
Add tiny statesummary to service multi-view
Browse files Browse the repository at this point in the history
refs #8565
  • Loading branch information
majentsch committed Mar 6, 2015
1 parent 2591f05 commit 9c45e99
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 18 deletions.
19 changes: 12 additions & 7 deletions modules/monitoring/application/controllers/HostsController.php
Expand Up @@ -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());
}
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Expand Up @@ -8,12 +8,7 @@ use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
<?= $tabs; ?>
<?php endif ?>

<h1>
<?= $this->qlink(
sprintf($this->translate('%d Hosts Selected'), count($objects)),
$listAllLink
); ?>
</h1>
<?= $this->render('partials/host/objects-tinysummary.phtml') ?>
<?= $this->render('partials/host/objects-header.phtml'); ?>

</div>
Expand Down
Expand Up @@ -2,14 +2,12 @@
use Icinga\Module\Monitoring\Object\Host;
?>


<?php
$i = 0;
$hidden = array();
$hiddenRich = array();
?>


<?php if (($hostCount = count($objects)) > 0): ?>

<p>
Expand Down Expand Up @@ -71,8 +69,8 @@ $hiddenRich = array();

<?php if (count($hidden)): ?>
<tr>
<td>
<div class="selection-info" data-title-rich="<span align='left'><?= join('<br>', $hiddenRich) ?></span>"
<td class="state">
<div data-title-rich="<span align='left'><?= join('<br>', $hiddenRich) ?></span>"
title="<?= join(', ', $hidden) ?>">
<?= sprintf($this->translate('%d more ...'), count($hidden)) ?>
</div>
Expand Down
@@ -0,0 +1,44 @@
<?php
use Icinga\Web\Url;
?>

<h1 class="tinystatesummary">
<?= $this->qlink(
sprintf($this->translate('%d Hosts Selected:'), count($objects)),
$listAllLink
); ?>

<span class="badges">
<?php if ($hostStates->hosts_up): ?>

<?php $selfUrl = Url::fromPath('monitoring/list/hosts'); ?>
<span class="state up"><b>
<?= $hostStates->hosts_up ?>
</b></span>
<?php endif ?>


<?php
foreach (
array(
1 => 'down',
2 => 'unreachable',
99 => 'pending'
) as $stateId => $state) {

$stateName = 'hosts_' . $state;
$unhandledStateName = $stateName . '_unhandled';
if ($hostStates->$unhandledStateName) {
echo '<span class="state ' . $state . '"><b>' . $hostStates->$unhandledStateName . '</b>';
}
if ($hostStates->$stateName) {
echo '<span class="state ' . $state . ' handled"><b>' . $hostStates->$stateName . '</b></span>';
}
if ($hostStates->$unhandledStateName) {
echo '</span>';
}
$stateName .= '_unhandled';
}?>

</span>
</h1>
@@ -1,6 +1,5 @@
<?php
use Icinga\Module\Monitoring\Object\Service;
use Icinga\Web\Url;
?>

<?php
Expand Down
12 changes: 12 additions & 0 deletions modules/monitoring/public/css/module.less
Expand Up @@ -129,14 +129,26 @@ span.state.ok {
background: @colorOk;
}

span.state.up {
background: @colorOk;
}

span.state.critical {
background: @colorCritical;
}

span.state.down {
background: @colorCritical;
}

span.state.handled.critical {
background: @colorCriticalHandled;
}

span.state.handled.down {
background: @colorCriticalHandled;
}

span.state.warning {
background: @colorWarning;
}
Expand Down

0 comments on commit 9c45e99

Please sign in to comment.