Fix inconsistent host and service flags

fixes #13243
This commit is contained in:
Eric Lippmann 2016-11-21 10:26:35 +01:00
parent 78be71bc92
commit 429405be0c
11 changed files with 19 additions and 76 deletions

View File

@ -1,9 +1,6 @@
<?php
/* Icinga Web 2 | (c) 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)
@ -31,6 +28,6 @@ class Zend_View_Helper_HostFlags extends Zend_View_Helper_Abstract
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active Checks Disabled'));
}
}
return $icons;
return implode(' ', $icons);
}
}

View File

@ -3,30 +3,31 @@
class Zend_View_Helper_ServiceFlags extends Zend_View_Helper_Abstract
{
public function serviceFlags($service) {
public function serviceFlags($service)
{
$icons = array();
if (!$service->service_handled && $service->service_state > 0) {
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) {
if ($service->service_acknowledged) {
$icons[] = $this->view->icon('ok', $this->view->translate('Acknowledged'));
}
if ($service->service_is_flapping) {
$icons[] = $this->view->icon('flapping', $this->view->translate('Flapping'));
}
if (!$service->service_notifications_enabled) {
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 (!$service->service_active_checks_enabled) {
if (!$service->service_passive_checks_enabled) {
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'));
$icons[] = $this->view->icon('eye-off', $this->view->translate('Active Checks Disabled'));
}
}
return $icons;
return implode(' ', $icons);
}
}
}

View File

@ -82,7 +82,7 @@ if (! $this->compact): ?>
)
) ?>&#41;</span>
<?php endif ?>
<span class="state-icons"><?= implode(' ', $this->hostFlags($host)) ?></span>
<span class="state-icons"><?= $this->hostFlags($host) ?></span>
</div>
<p class="overview-plugin-output"><?= $this->pluginOutput($this->ellipsis($host->host_output, 10000), true) ?></p>
</td>

View File

@ -82,7 +82,7 @@ if (! $this->compact): ?>
'class' => 'rowaction'
)
) ?>
<span class="state-icons"><?= implode(' ', $this->serviceFlags($service)) ?></span>
<span class="state-icons"><?= $this->serviceFlags($service) ?></span>
</div>
<div class="overview-plugin-output-container">
<div class="overview-performance-data">

View File

@ -20,7 +20,7 @@ if (! ($hostCount = count($objects))): return; endif ?>
$host->host_name,
$host->host_display_name
) ?>
<?= implode(' ', $this->hostFlags($host)) ?>
<?= $this->hostFlags($host) ?>
</td>
</tr>
<?php endforeach ?>

View File

@ -1,28 +0,0 @@
<?php
$icons = array();
if (! $this->object->host_handled && $this->object->host_state > 0) {
$icons[] = $this->icon('attention-alt', $this->translate('Unhandled'));
}
if ($this->object->host_acknowledged && !$this->object->host_in_downtime) {
$icons[] = $this->icon('ok', $this->translate('Acknowledged'));
}
if (! $this->object->host_notifications_enabled) {
$icons[] = $this->icon('bell-off-empty', $this->translate('Notifications Disabled'));
}
if ($this->object->host_in_downtime) {
$icons[] = $this->icon('plug', $this->translate('In Downtime'));
}
if (! $this->object->host_active_checks_enabled) {
if ($this->object->host_passive_checks_enabled) {
$icons[] = $this->icon('eye-off', $this->translate('Active Checks Disabled'));
} else {
$icons[] = $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled'));
}
}
?><?= implode("\n", $icons); ?>

View File

@ -24,7 +24,7 @@ use Icinga\Module\Monitoring\Object\Host;
<?= $this->escape($this->translate('Alias', 'host') . ': ' . $object->host_alias) ?>
</div>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml') ?>
<?= $this->hostFlags($object) ?>
<?php if ($object->host_address6 && $object->host_address6 !== $object->host_name): ?>
<div class="selectable host-meta" title="<?= $this->translate('IPv6 address') ?>">
<?= $this->escape($object->host_address6) ?>

View File

@ -20,7 +20,7 @@ use Icinga\Module\Monitoring\Object\Service;
<?php if ($object->host_display_name !== $object->host_name): ?>
<span class="selectable host-meta">&#40;<?= $this->escape($object->host_name) ?>&#41;</span>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml') ?>
<?= $this->hostFlags($object) ?>
<?php if ($object->host_address6 && $object->host_address6 !== $object->host_name): ?>
<div class="selectable host-meta" title="<?= $this->translate('IPv6 address') ?>">
<?= $this->escape($object->host_address6) ?>
@ -49,7 +49,7 @@ use Icinga\Module\Monitoring\Object\Service;
<?php if ($object->service_display_name !== $object->service_description): ?>
<span class="selectable service-meta">&#40;<?= $this->escape($object->service_description) ?>&#41;</span>
<?php endif ?>
<?= $this->render('partials/service/statusicons.phtml') ?>
<?= $this->serviceFlags($object) ?>
</td>
</tr>
</table>

View File

@ -24,7 +24,7 @@ if (! ($serviceCount = count($objects))): return; endif ?>
$service->host_display_name
. ($service->host_state != 0 ? ' (' . Host::getStateText($service->host_state, true) . ')' : '')
) ?>
<?= implode(' ', $this->serviceFlags($service)) ?>
<?= $this->serviceFlags($service) ?>
</td>
</tr>
<?php endforeach ?>

View File

@ -1,28 +0,0 @@
<?php
$icons = array();
if (! $this->object->service_handled && $this->object->service_state > 0) {
$icons[] = $this->icon('attention-alt', $this->translate('Unhandled'));
}
if ($this->object->service_acknowledged && !$this->object->service_in_downtime) {
$icons[] = $this->icon('ok', $this->translate('Acknowledged'));
}
if (! $this->object->service_notifications_enabled) {
$icons[] = $this->icon('bell-off-empty', $this->translate('Notifications Disabled'));
}
if ($this->object->service_in_downtime) {
$icons[] = $this->icon('plug', $this->translate('In Downtime'));
}
if (! $this->object->service_active_checks_enabled) {
if ($this->object->service_passive_checks_enabled) {
$icons[] = $this->icon('eye-off', $this->translate('Active Checks Disabled'));
} else {
$icons[] = $this->icon('eye-off', $this->translate('Active And Passive Checks Disabled'));
}
}
?><?= implode("\n", $icons); ?>

View File

@ -118,6 +118,7 @@ class Service extends MonitoredObject
'host_display_name',
'host_handled',
'host_in_downtime',
'host_is_flapping',
'host_last_state_change',
'host_name',
'host_notifications_enabled',