Deduplicate service and host flags icon handling in multi-view
refs #8565
This commit is contained in:
parent
0312d8d6da
commit
f2eb20945e
|
@ -113,11 +113,11 @@ class Monitoring_HostsController extends Controller
|
|||
'host_is_flapping',
|
||||
'host_last_comment',
|
||||
'host_output',
|
||||
'host_notifications_enabled',/*,
|
||||
'host_passive_checks_enabled',
|
||||
'host_event_handler_enabled',
|
||||
'host_flap_detection_enabled',
|
||||
'host_notifications_enabled',
|
||||
'host_active_checks_enabled',
|
||||
'host_passive_checks_enabled'
|
||||
/*'host_event_handler_enabled',
|
||||
'host_flap_detection_enabled',
|
||||
'host_obsessing'*/
|
||||
));
|
||||
|
||||
|
|
|
@ -78,7 +78,9 @@ class Monitoring_ServicesController extends Controller
|
|||
'service_notifications_enabled',
|
||||
'service_output',
|
||||
'service_last_ack',
|
||||
'service_last_comment'
|
||||
'service_last_comment',
|
||||
'service_active_checks_enabled',
|
||||
'service_passive_checks_enabled'
|
||||
));
|
||||
|
||||
$form
|
||||
|
@ -129,12 +131,12 @@ class Monitoring_ServicesController extends Controller
|
|||
'service_is_flapping',
|
||||
'service_notifications_enabled',
|
||||
'service_last_comment',
|
||||
'service_last_ack'
|
||||
/*,
|
||||
'service_passive_checks_enabled',
|
||||
'service_last_ack',
|
||||
'service_active_checks_enabled',
|
||||
'service_passive_checks_enabled'
|
||||
/*
|
||||
'service_event_handler_enabled',
|
||||
'service_flap_detection_enabled',
|
||||
'service_active_checks_enabled',
|
||||
'service_obsessing'*/
|
||||
));
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
/**
|
||||
* Generate icons to describe a given hosts state
|
||||
*/
|
||||
class Zend_View_Helper_HostFlags extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public function hostFlags($host)
|
||||
{
|
||||
$icons = array();
|
||||
if (! $host->host_handled && $host->host_state > 0) {
|
||||
$icons[] = $this->view->icon('attention-alt', $this->view->translate('Unhandled'));
|
||||
}
|
||||
if ($host->host_acknowledged) {
|
||||
$icons[] = $this->view->icon('ok', $this->view->translate('Acknowledged'));
|
||||
}
|
||||
if ($host->host_is_flapping) {
|
||||
$icons[] = $this->view->icon('flapping', $this->view->translate('Flapping'));
|
||||
}
|
||||
if (! $host->host_notifications_enabled) {
|
||||
$icons[] = $this->view->icon('bell-off-empty', $this->view->translate('Notifications Disabled'));
|
||||
}
|
||||
if ($host->host_in_downtime) {
|
||||
$icons[] = $this->view->icon('plug', $this->view->translate('In Downtime'));
|
||||
}
|
||||
if (! $host->host_active_checks_enabled) {
|
||||
if (! $host->host_passive_checks_enabled) {
|
||||
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active And Passive Checks Disabled'));
|
||||
} else {
|
||||
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active Checks Disabled'));
|
||||
}
|
||||
}
|
||||
if (isset($host->host_last_comment) && $host->host_last_comment !== null) {
|
||||
$icons[] = $this->view->icon('comment', $this->view->translate('Last Comment: ') . $host->host_last_comment);
|
||||
}
|
||||
return $icons;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
class Zend_View_Helper_SelectionToolbar extends Zend_View_Helper_Abstract
|
||||
{
|
||||
/**
|
||||
* Create a selection toolbar
|
||||
*
|
||||
* @param $type
|
||||
* @param null $target
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function selectionToolbar($type, $target = null)
|
||||
{
|
||||
return '';
|
||||
if ($type == 'multi') {
|
||||
return '<div class="selection-toolbar">'
|
||||
. '<a href="' . $target . '" data-base-target="_next"> Show All </a> </div>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
class Zend_View_Helper_ServiceFlags extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public function serviceFlags($service) {
|
||||
$icons = array();
|
||||
if (!$service->service_handled && $service->service_state > 0) {
|
||||
$icons[] = $this->view->icon('attention-alt', $this->view->translate('Unhandled'));
|
||||
}
|
||||
if ($service->service_acknowledged && !$service->service_in_downtime) {
|
||||
$icons[] = $this->view->icon('ok', $this->view->translate('Acknowledged') . (
|
||||
$service->service_last_ack ? ': ' . $service->service_last_ack : ''
|
||||
));
|
||||
}
|
||||
if ($service->service_is_flapping) {
|
||||
$icons[] = $this->view->icon('flapping', $this->view->translate('Flapping')) ;
|
||||
}
|
||||
if (!$service->service_notifications_enabled) {
|
||||
$icons[] = $this->view->icon('bell-off-empty', $this->view->translate('Notifications Disabled'));
|
||||
}
|
||||
if ($service->service_in_downtime) {
|
||||
$icons[] = $this->view->icon('plug', $this->view->translate('In Downtime'));
|
||||
}
|
||||
if (isset($service->service_last_comment) && $service->service_last_comment !== null) {
|
||||
$icons[] = $this->view->icon(
|
||||
'comment',
|
||||
$this->view->translate('Last Comment: ') . $service->service_last_comment
|
||||
);
|
||||
}
|
||||
if (!$service->service_active_checks_enabled) {
|
||||
if (!$service->service_passive_checks_enabled) {
|
||||
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active And Passive Checks Disabled'));
|
||||
} else {
|
||||
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active Checks Disabled'));
|
||||
}
|
||||
}
|
||||
return $icons;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ if ($this->compact): ?>
|
|||
<?= $this->sortControl->render($this) ?>
|
||||
<?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?>
|
||||
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?>
|
||||
<?= $this->selectionToolbar('multi', $this->href('monitoring/hosts/show?' . $this->filter->toQueryString())) ?>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
|
@ -43,38 +42,7 @@ if ($hosts->count() === 0) {
|
|||
$hostStateName = Host::getStateText($host->host_state);
|
||||
$hostLink = $this->href('monitoring/host/show', array('host' => $host->host_name));
|
||||
|
||||
$icons = array();
|
||||
if (! $host->host_handled && $host->host_state > 0){
|
||||
$icons[] = $this->icon('attention-alt', $this->translate('Unhandled'));
|
||||
}
|
||||
|
||||
if ($host->host_acknowledged) {
|
||||
$icons[] = $this->icon('ok', $this->translate('Acknowledged'));
|
||||
}
|
||||
|
||||
if ($host->host_is_flapping) {
|
||||
$icons[] = $this->icon('flapping', $this->translate('Flapping'));
|
||||
}
|
||||
|
||||
if (! $host->host_notifications_enabled) {
|
||||
$icons[] = $this->icon('bell-off-empty', $this->translate('Notifications Disabled'));
|
||||
}
|
||||
|
||||
if ($host->host_in_downtime) {
|
||||
$icons[] = $this->icon('plug', $this->translate('In Downtime'));
|
||||
}
|
||||
|
||||
if (! $host->host_active_checks_enabled) {
|
||||
if (! $host->host_passive_checks_enabled) {
|
||||
$icons[] = $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled'));
|
||||
} else {
|
||||
$icons[] = $this->icon('eye-off', $this->translate('Active Checks Disabled'));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($host->host_last_comment) && $host->host_last_comment !== null) {
|
||||
$icons[] = $this->icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment);
|
||||
}
|
||||
?>
|
||||
<tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">
|
||||
<!-- State -->
|
||||
|
@ -94,7 +62,7 @@ if ($hosts->count() === 0) {
|
|||
<?php if ($host->host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?>
|
||||
<?= $this->icon($this->resolveMacros($host->host_icon_image, $host)) ?>
|
||||
<?php endif ?>
|
||||
<?= implode(' ', $icons) ?>
|
||||
<?= implode(' ', $this->hostFlags($host)) ?>
|
||||
<?= $this->qlink(
|
||||
$host->host_display_name,
|
||||
$hostLink,
|
||||
|
|
|
@ -66,39 +66,7 @@ foreach ($services as $service):
|
|||
<td>
|
||||
<div class="sparkline-box"><?= $this->perfdata($service->service_perfdata, true, 8) ?> </div>
|
||||
|
||||
<?php if (!$service->service_handled && $service->service_state > 0): ?>
|
||||
<?= $this->icon('attention-alt', $this->translate('Unhandled')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($service->service_acknowledged && !$service->service_in_downtime): ?>
|
||||
<?= $this->icon('ok', $this->translate('Acknowledged') . (
|
||||
$service->service_last_ack ? ': ' . $service->service_last_ack : ''
|
||||
)) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($service->service_is_flapping): ?>
|
||||
<?= $this->icon('flapping', $this->translate('Flapping')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (!$service->service_notifications_enabled): ?>
|
||||
<?= $this->icon('bell-off-empty', $this->translate('Notifications Disabled')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($service->service_in_downtime): ?>
|
||||
<?= $this->icon('plug', $this->translate('In Downtime')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (isset($service->service_last_comment) && $service->service_last_comment !== null): ?>
|
||||
<?= $this->icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (!$service->service_active_checks_enabled): ?>
|
||||
<?php if (!$service->service_passive_checks_enabled): ?>
|
||||
<?= $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled')) ?>
|
||||
<?php else: ?>
|
||||
<?= $this->icon('eye-off', $this->translate('Active Checks Disabled')) ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<?= implode(' ', $this->serviceFlags($service)); ?>
|
||||
|
||||
<?php if ($service->service_icon_image && ! preg_match('/[\'"]/', $service->service_icon_image)): ?>
|
||||
<?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
|
||||
|
|
|
@ -15,7 +15,7 @@ $hiddenRich = array();
|
|||
|
||||
<?php if (($hostCount = count($objects)) > 0): ?>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<table class="state statesummary">
|
||||
|
||||
<tbody>
|
||||
|
@ -23,71 +23,30 @@ $hiddenRich = array();
|
|||
<?php
|
||||
$i++;
|
||||
if ($i > 5) {
|
||||
$desc = $host->getName();
|
||||
$hidden[] = $desc;
|
||||
$hiddenRich[] = sprintf("<div class='color-box badge-%s'></div>%s", $host->getStateText($host->host_state) ,$desc);
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
|
||||
<tr class="state <?= Host::getStateText($host->host_state); ?><?= $host->host_handled ? ' handled' : '' ?>">
|
||||
<td class="state"><?= Host::getStateText($host->host_state, true); ?><br /></td>
|
||||
<td>
|
||||
<?php if (!$host->host_handled && $host->host_state > 0): ?>
|
||||
<?= $this->icon('attention-alt', $this->translate('Unhandled')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($host->host_acknowledged && !$host->host_in_downtime): ?>
|
||||
<?= $this->icon('ok', $this->translate('Acknowledged') . (
|
||||
$host->host_last_ack ? ': ' . $host->host_last_ack : ''
|
||||
)) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($host->host_is_flapping): ?>
|
||||
<?= $this->icon('flapping', $this->translate('Flapping')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (!$host->host_notifications_enabled): ?>
|
||||
<?= $this->icon('bell-off-empty', $this->translate('Notifications Disabled')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($host->host_in_downtime): ?>
|
||||
<?= $this->icon('plug', $this->translate('In Downtime')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (isset($host->host_last_comment) && $host->host_last_comment !== null): ?>
|
||||
<?= $this->icon('comment', $this->translate('Last Comment: ') . $host->host_last_comment) ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td><?= implode(' ', $this->hostFlags($host)) ?></td>
|
||||
<td class="name oneline"><?= $this->escape($host->getName()); ?></td>
|
||||
<td><?= $this->escape($host->host_output) ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
|
||||
<tr>
|
||||
<td class="state">
|
||||
<div <?= count($hidden) ?
|
||||
'data-title-rich="<span align=\'left\'>' . join('<br>', $hiddenRich) . '</span>"' : ''; ?>
|
||||
title="<?= join(', ', $hidden) ?>">
|
||||
<?php
|
||||
echo $this->qlink(
|
||||
count($hidden) ? sprintf(
|
||||
$this->translate('%d more ...'),
|
||||
count($hidden)
|
||||
) : $this->translate('list all ...'),
|
||||
$listAllLink,
|
||||
null,
|
||||
array('data-base-target' => '_next')
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<div class="hbox-item">
|
||||
<?=
|
||||
$this->qlink(
|
||||
sprintf($this->translate('list all %d hosts ...'), $i),
|
||||
$listAllLink,
|
||||
null,
|
||||
array('data-base-target' => '_next')
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</p>
|
||||
|
||||
<?php endif ?>
|
||||
|
||||
|
|
|
@ -22,77 +22,29 @@ use Icinga\Module\Monitoring\Object\Service;
|
|||
<tbody>
|
||||
<?php foreach ($objects as $service): /** @var Service $service */ ?>
|
||||
<?php
|
||||
$i++;
|
||||
if ($i > 5 && $i < 20) {
|
||||
$desc = $service->getName() . ' on ' . $service->getHost()->getName();
|
||||
$hidden[] = $desc;
|
||||
$hiddenRich[] = sprintf("<div class='color-box badge-%s'></div>%s", $service->getStateText($service->service_state) ,$desc);
|
||||
}
|
||||
if ($i == 20) {
|
||||
$hiddenRich[] = '...';
|
||||
}
|
||||
if ($i > 5) {
|
||||
if ($i ++ > 5) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
|
||||
<tr class="state <?= Service::getStateText($service->service_state); ?><?= $service->service_handled ? ' handled' : '' ?>">
|
||||
<td class="state"><?= Service::getStateText($service->service_state, true); ?><br /></td>
|
||||
<td>
|
||||
<?php if (!$service->service_handled && $service->service_state > 0): ?>
|
||||
<?= $this->icon('attention-alt', $this->translate('Unhandled')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($service->service_acknowledged && !$service->service_in_downtime): ?>
|
||||
<?= $this->icon('ok', $this->translate('Acknowledged') . (
|
||||
$service->service_last_ack ? ': ' . $service->service_last_ack : ''
|
||||
)) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($service->service_is_flapping): ?>
|
||||
<?= $this->icon('flapping', $this->translate('Flapping')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (!$service->service_notifications_enabled): ?>
|
||||
<?= $this->icon('bell-off-empty', $this->translate('Notifications Disabled')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($service->service_in_downtime): ?>
|
||||
<?= $this->icon('plug', $this->translate('In Downtime')) ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (isset($service->service_last_comment) && $service->service_last_comment !== null): ?>
|
||||
<?= $this->icon('comment', $this->translate('Last Comment: ') . $service->service_last_comment) ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td><?= implode(' ', $this->serviceFlags($service)) ?></td>
|
||||
<td class="name oneline"><?= $this->escape($service->getName()); ?></td>
|
||||
<td class="name oneline"><?= $this->escape($service->getHost()->getName()); ?></b></td>
|
||||
<td><?= $this->escape($service->service_output) ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
|
||||
<tr>
|
||||
<td class="state">
|
||||
<div <?= count($hidden) ?
|
||||
'data-title-rich="<span align=\'left\'>' . join('<br>', $hiddenRich) . '</span>"' : ''; ?>
|
||||
title="<?= join(', ', $hidden) ?>">
|
||||
|
||||
<?php
|
||||
echo $this->qlink(
|
||||
count($hidden) ? sprintf(
|
||||
$this->translate('%d more ...'),
|
||||
count($hidden)
|
||||
) : $this->translate('list all ...'),
|
||||
$listAllLink,
|
||||
null,
|
||||
array('data-base-target' => '_next')
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="hbox-item">
|
||||
<?php
|
||||
echo $this->qlink(
|
||||
sprintf($this->translate('List all %d services ...'), $i),
|
||||
$listAllLink,
|
||||
null,
|
||||
array('data-base-target' => '_next')
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</p>
|
||||
<?php endif ?>
|
||||
|
|
Loading…
Reference in New Issue