list/hosts: cleanup, should look like list/services
Quite some changes here: * Compact view should show icons too * Ignore host icons with legacy HTML hacks * Remove duplicate code * Reduce HTML * Reduce intendation for better readability * Show attempts on soft states only, even in compact view * Use the same HTML tags and styles as in list/services * Fixes nesting error on compact view
This commit is contained in:
parent
09412d03b6
commit
49cd55eddd
|
@ -1,27 +1,31 @@
|
|||
<?php
|
||||
$helper = $this->getHelper('MonitoringState');
|
||||
|
||||
if (! $this->compact): ?>
|
||||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<div style="margin: 1em;" class="dontprint">
|
||||
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
|
||||
<?php if (! $this->filterEditor): ?>
|
||||
<?= $this->filterPreview ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
if ($this->compact): ?>
|
||||
<div class="content">
|
||||
<?php else: ?>
|
||||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<div style="margin: 1em;" class="dontprint">
|
||||
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
|
||||
<?php if (! $this->filterEditor): ?>
|
||||
<?= $this->filterPreview ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?>
|
||||
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?>
|
||||
<?= $this->selectionToolbar('multi', $this->href('monitoring/multi/host?' . $this->filter->toQueryString())) ?>
|
||||
</div>
|
||||
<div class="content">
|
||||
<?= $this->filterEditor ?>
|
||||
<?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?>
|
||||
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?>
|
||||
<?= $this->selectionToolbar('multi', $this->href('monitoring/multi/host?' . $this->filter->toQueryString())) ?>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<?= $this->filterEditor ?>
|
||||
<?php
|
||||
|
||||
endif;
|
||||
|
||||
if ($hosts->count() === 0) {
|
||||
echo t('No hosts matching the filter');
|
||||
echo $this->translate('No hosts matching the filter');
|
||||
if (! $this->compact) {
|
||||
echo '</div>';
|
||||
}
|
||||
|
@ -32,107 +36,90 @@ if ($hosts->count() === 0) {
|
|||
<table
|
||||
data-base-target="_next"
|
||||
class="action multiselect"
|
||||
data-icinga-multiselect-url="<?= $this->href("/monitoring/multi/host") ?>"
|
||||
data-icinga-multiselect-url="<?= $this->href('/monitoring/multi/host') ?>"
|
||||
data-icinga-multiselect-data="host"
|
||||
>
|
||||
<tbody>
|
||||
<?php foreach($hosts as $host):
|
||||
<tbody>
|
||||
<?php foreach($hosts as $host):
|
||||
|
||||
$hostStateName = strtolower($this->util()->getHostStateName($host->host_state));
|
||||
$hostLink = $this->href('/monitoring/show/host', array('host' => $host->host_name));
|
||||
$hostStateName = strtolower($this->util()->getHostStateName($host->host_state));
|
||||
$hostLink = $this->href('/monitoring/show/host', array('host' => $host->host_name));
|
||||
|
||||
if (! $this->compact) {
|
||||
$icons = array();
|
||||
if (! $host->host_handled && $host->host_state > 0){
|
||||
$icons[] = $this->icon('unhandled.png', 'Unhandled');
|
||||
}
|
||||
$icons = array();
|
||||
if (! $host->host_handled && $host->host_state > 0){
|
||||
$icons[] = $this->icon('unhandled.png', 'Unhandled');
|
||||
}
|
||||
|
||||
if ($host->host_acknowledged) {
|
||||
$icons[] = $this->icon('acknowledgement.png', 'Acknowledged');
|
||||
}
|
||||
if ($host->host_acknowledged) {
|
||||
$icons[] = $this->icon('acknowledgement.png', 'Acknowledged');
|
||||
}
|
||||
|
||||
if ($host->host_is_flapping) {
|
||||
$icons[] = $this->icon('flapping.png', 'Flapping');
|
||||
}
|
||||
if ($host->host_is_flapping) {
|
||||
$icons[] = $this->icon('flapping.png', 'Flapping');
|
||||
}
|
||||
|
||||
if (! $host->host_notifications_enabled) {
|
||||
$icons[] = $this->icon('notification_disabled.png', 'Notifications Disabled');
|
||||
}
|
||||
if (! $host->host_notifications_enabled) {
|
||||
$icons[] = $this->icon('notification_disabled.png', 'Notifications Disabled');
|
||||
}
|
||||
|
||||
if ($host->host_in_downtime) {
|
||||
$icons[] = $this->icon('in_downtime.png', 'In Downtime');
|
||||
}
|
||||
if ($host->host_in_downtime) {
|
||||
$icons[] = $this->icon('in_downtime.png', 'In Downtime');
|
||||
}
|
||||
|
||||
if (! $host->host_active_checks_enabled) {
|
||||
if (! $host->host_passive_checks_enabled) {
|
||||
$icons[] = $this->icon('active_passive_checks_disabled.png', 'Active And Passive Checks Disabled');
|
||||
} else {
|
||||
$icons[] = $this->icon('active_checks_disabled.png', 'Active Checks Disabled');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($host->host_last_comment) && $host->host_last_comment !== null) {
|
||||
$icons[] = $this->icon('comment.png', 'Comment: ' . $host->host_last_comment);
|
||||
}
|
||||
if (! $host->host_active_checks_enabled) {
|
||||
if (! $host->host_passive_checks_enabled) {
|
||||
$icons[] = $this->icon('active_passive_checks_disabled.png', 'Active And Passive Checks Disabled');
|
||||
} else {
|
||||
$icons[] = $this->icon('active_checks_disabled.png', 'Active Checks Disabled');
|
||||
}
|
||||
?>
|
||||
<tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">
|
||||
<!-- State -->
|
||||
<td class="state" title="<?= $helper->getStateTitle($host, 'host') ?>">
|
||||
<?php if (! $this->compact): ?>
|
||||
<div>
|
||||
<strong><?= ucfirst($helper->monitoringState($host, 'host')) ?></strong><br />
|
||||
<div class="small-row">
|
||||
<?php endif; ?>
|
||||
<?= $this->prefixedTimeSince($host->host_last_state_change, true) ?>
|
||||
<?php if (! $this->compact): ?>
|
||||
<?php if ($host->host_state > 0): ?>
|
||||
<br />
|
||||
<strong><?= $this->translate(
|
||||
($host->host_state_type === '1') ? 'Hard' : 'Soft'
|
||||
) ?> </strong> <!--
|
||||
--><?= $host->host_current_check_attempt ?>/<?= $host->host_max_check_attempts ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
}
|
||||
|
||||
<!-- Host / Status / Output -->
|
||||
<td>
|
||||
<?php if (! $this->compact): ?>
|
||||
<?php if ($host->host_icon_image): ?>
|
||||
<?= $this->img(
|
||||
$this->resolveMacros($host->host_icon_image, $host),
|
||||
array('align' => 'right')
|
||||
) ?>
|
||||
<?php endif; ?>
|
||||
<?= implode(' ', $icons) ?>
|
||||
<?php endif ?>
|
||||
<a href="<?= $this->compact ? $hostLink : $this->href(
|
||||
'monitoring/show/host',
|
||||
array('host' => $host->host_name)
|
||||
) ?>"><?= $host->host_name ?></a>
|
||||
<?php if (isset($host->host_unhandled_services) && $host->host_unhandled_services > 0): ?>
|
||||
<span style="font-weight: normal" title="<?=
|
||||
$host->host_unhandled_services
|
||||
?> Service Problems on Host"> (<?= $this->qlink(
|
||||
sprintf($this->translate('%d unhandled services'), $host->host_unhandled_services),
|
||||
'monitoring/show/services',
|
||||
array(
|
||||
'host' => $host->host_name,
|
||||
'service_problem' => 1,
|
||||
'service_acknowledged' => 0,
|
||||
'service_in_downtime' => 0
|
||||
),
|
||||
array('style' => 'font-weight: normal')
|
||||
) ?>)</span>
|
||||
<?php endif ?>
|
||||
<br />
|
||||
<?= $this->escape(substr(strip_tags($host->host_output), 0, 10000)) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
if (isset($host->host_last_comment) && $host->host_last_comment !== null) {
|
||||
$icons[] = $this->icon('comment.png', 'Comment: ' . $host->host_last_comment);
|
||||
}
|
||||
?>
|
||||
<tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">
|
||||
<!-- State -->
|
||||
<td class="state" title="<?= $helper->getStateTitle($host, 'host') ?>">
|
||||
<?php if (! $this->compact): ?>
|
||||
<strong><?= ucfirst($helper->monitoringState($host, 'host')) ?></strong><br />
|
||||
<?php endif ?>
|
||||
<?= $this->prefixedTimeSince($host->host_last_state_change, true) ?>
|
||||
<?php if ($host->host_state > 0 && (int) $host->host_state_type === 0): ?>
|
||||
<br />
|
||||
<strong>Soft <?= $host->host_attempt ?></strong>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
|
||||
<!-- Host / Status / Output -->
|
||||
<td>
|
||||
<?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) ?>
|
||||
<a href="<?= $hostLink ?>"><?= $host->host_name ?></a>
|
||||
<?php if (isset($host->host_unhandled_services) && $host->host_unhandled_services > 0): ?>
|
||||
<span title="<?=
|
||||
$host->host_unhandled_services
|
||||
?> Service Problems on Host"> (<?= $this->qlink(
|
||||
sprintf($this->translate('%d unhandled services'), $host->host_unhandled_services),
|
||||
'monitoring/show/services',
|
||||
array(
|
||||
'host' => $host->host_name,
|
||||
'service_problem' => 1,
|
||||
'service_acknowledged' => 0,
|
||||
'service_in_downtime' => 0
|
||||
),
|
||||
array('style' => 'font-weight: normal')
|
||||
) ?>)</span>
|
||||
<?php endif ?>
|
||||
<p class="pluginoutput"><?= $this->escape(substr(strip_tags($host->host_output), 0, 10000)) ?></p>
|
||||
</td>
|
||||
<?php foreach($this->extraColumns as $col): ?>
|
||||
<td><?= $this->escape($host->$col) ?></td>
|
||||
<?php endforeach ?>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue