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:
Thomas Gelf 2014-08-22 11:06:45 +02:00
parent 09412d03b6
commit 49cd55eddd
1 changed files with 94 additions and 107 deletions

View File

@ -1,8 +1,10 @@
<?php <?php
$helper = $this->getHelper('MonitoringState'); $helper = $this->getHelper('MonitoringState');
if (! $this->compact): ?> if ($this->compact): ?>
<div class="controls"> <div class="content">
<?php else: ?>
<div class="controls">
<?= $this->tabs ?> <?= $this->tabs ?>
<div style="margin: 1em;" class="dontprint"> <div style="margin: 1em;" class="dontprint">
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?> <?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
@ -11,17 +13,19 @@ if (! $this->compact): ?>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?> <?= $this->widget('limiter')->setMaxLimit($this->hosts->count()) ?>
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?> <?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)) ?>
<?= $this->selectionToolbar('multi', $this->href('monitoring/multi/host?' . $this->filter->toQueryString())) ?> <?= $this->selectionToolbar('multi', $this->href('monitoring/multi/host?' . $this->filter->toQueryString())) ?>
</div> </div>
<div class="content">
<?= $this->filterEditor ?> <div class="content">
<?= $this->filterEditor ?>
<?php <?php
endif; endif;
if ($hosts->count() === 0) { if ($hosts->count() === 0) {
echo t('No hosts matching the filter'); echo $this->translate('No hosts matching the filter');
if (! $this->compact) { if (! $this->compact) {
echo '</div>'; echo '</div>';
} }
@ -32,7 +36,7 @@ if ($hosts->count() === 0) {
<table <table
data-base-target="_next" data-base-target="_next"
class="action multiselect" 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" data-icinga-multiselect-data="host"
> >
<tbody> <tbody>
@ -41,7 +45,6 @@ if ($hosts->count() === 0) {
$hostStateName = strtolower($this->util()->getHostStateName($host->host_state)); $hostStateName = strtolower($this->util()->getHostStateName($host->host_state));
$hostLink = $this->href('/monitoring/show/host', array('host' => $host->host_name)); $hostLink = $this->href('/monitoring/show/host', array('host' => $host->host_name));
if (! $this->compact) {
$icons = array(); $icons = array();
if (! $host->host_handled && $host->host_state > 0){ if (! $host->host_handled && $host->host_state > 0){
$icons[] = $this->icon('unhandled.png', 'Unhandled'); $icons[] = $this->icon('unhandled.png', 'Unhandled');
@ -74,47 +77,29 @@ if ($hosts->count() === 0) {
if (isset($host->host_last_comment) && $host->host_last_comment !== null) { if (isset($host->host_last_comment) && $host->host_last_comment !== null) {
$icons[] = $this->icon('comment.png', 'Comment: ' . $host->host_last_comment); $icons[] = $this->icon('comment.png', 'Comment: ' . $host->host_last_comment);
} }
}
?> ?>
<tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>"> <tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">
<!-- State --> <!-- State -->
<td class="state" title="<?= $helper->getStateTitle($host, 'host') ?>"> <td class="state" title="<?= $helper->getStateTitle($host, 'host') ?>">
<?php if (! $this->compact): ?> <?php if (! $this->compact): ?>
<div>
<strong><?= ucfirst($helper->monitoringState($host, 'host')) ?></strong><br /> <strong><?= ucfirst($helper->monitoringState($host, 'host')) ?></strong><br />
<div class="small-row"> <?php endif ?>
<?php endif; ?>
<?= $this->prefixedTimeSince($host->host_last_state_change, true) ?> <?= $this->prefixedTimeSince($host->host_last_state_change, true) ?>
<?php if (! $this->compact): ?> <?php if ($host->host_state > 0 && (int) $host->host_state_type === 0): ?>
<?php if ($host->host_state > 0): ?>
<br /> <br />
<strong><?= $this->translate( <strong>Soft <?= $host->host_attempt ?></strong>
($host->host_state_type === '1') ? 'Hard' : 'Soft' <?php endif ?>
) ?> </strong> <!--
--><?= $host->host_current_check_attempt ?>/<?= $host->host_max_check_attempts ?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</td> </td>
<!-- Host / Status / Output --> <!-- Host / Status / Output -->
<td> <td>
<?php if (! $this->compact): ?> <?php if ($host->host_icon_image && ! preg_match('/[\'"]/', $host->host_icon_image)): ?>
<?php if ($host->host_icon_image): ?> <?= $this->icon($this->resolveMacros($host->host_icon_image, $host)) ?>
<?= $this->img(
$this->resolveMacros($host->host_icon_image, $host),
array('align' => 'right')
) ?>
<?php endif; ?>
<?= implode(' ', $icons) ?>
<?php endif ?> <?php endif ?>
<a href="<?= $this->compact ? $hostLink : $this->href( <?= implode(' ', $icons) ?>
'monitoring/show/host', <a href="<?= $hostLink ?>"><?= $host->host_name ?></a>
array('host' => $host->host_name)
) ?>"><?= $host->host_name ?></a>
<?php if (isset($host->host_unhandled_services) && $host->host_unhandled_services > 0): ?> <?php if (isset($host->host_unhandled_services) && $host->host_unhandled_services > 0): ?>
<span style="font-weight: normal" title="<?= <span title="<?=
$host->host_unhandled_services $host->host_unhandled_services
?> Service Problems on Host"> (<?= $this->qlink( ?> Service Problems on Host"> (<?= $this->qlink(
sprintf($this->translate('%d unhandled services'), $host->host_unhandled_services), sprintf($this->translate('%d unhandled services'), $host->host_unhandled_services),
@ -128,11 +113,13 @@ if ($hosts->count() === 0) {
array('style' => 'font-weight: normal') array('style' => 'font-weight: normal')
) ?>)</span> ) ?>)</span>
<?php endif ?> <?php endif ?>
<br /> <p class="pluginoutput"><?= $this->escape(substr(strip_tags($host->host_output), 0, 10000)) ?></p>
<?= $this->escape(substr(strip_tags($host->host_output), 0, 10000)) ?>
</td> </td>
<?php foreach($this->extraColumns as $col): ?>
<td><?= $this->escape($host->$col) ?></td>
<?php endforeach ?>
</tr> </tr>
<?php endforeach; ?> <?php endforeach ?>
</tbody> </tbody>
</table> </table>
</div> </div>