Deduplicate code: lists/hosts.phtml VS lists/hosts-compact.phtml
fixes #6541
This commit is contained in:
parent
9c1ee57628
commit
1532594948
|
@ -78,7 +78,6 @@ class Monitoring_ListController extends Controller
|
|||
|
||||
$this->addTitleTab('hosts');
|
||||
$this->setAutorefreshInterval(10);
|
||||
$this->compactView = 'hosts-compact';
|
||||
$query = $this->backend->select()->from('hostStatus', array_merge(array(
|
||||
'host_icon_image',
|
||||
'host_name',
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
|
||||
if ($hosts->count() === 0) {
|
||||
echo '<p>No host found</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
?><table
|
||||
data-base-target="_next"
|
||||
class="action multiselect"
|
||||
data-icinga-multiselect-url="<?= $this->href("/monitoring/multi/host") ?>"
|
||||
data-icinga-multiselect-data="host"
|
||||
>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$helper = $this->getHelper('MonitoringState');
|
||||
foreach($hosts as $host):
|
||||
|
||||
$hostStateName = strtolower($this->util()->getHostStateName($host->host_state));
|
||||
$hostLink = $this->href('monitoring/show/host', array('host' => $host->host_name));
|
||||
|
||||
?>
|
||||
<tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">
|
||||
|
||||
<!-- Icons -->
|
||||
<!-- <td>
|
||||
<?php if (!$host->host_handled && $host->host_state > 0): ?>
|
||||
<a href="#" title="Unhandled">
|
||||
<i class="icon-table icinga-icon-unhandled"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($host->host_acknowledged && !$host->host_in_downtime): ?>
|
||||
<a href="#" title="Acknowledged">
|
||||
<i class="icon-table icinga-icon-acknowledgement"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($host->host_is_flapping): ?>
|
||||
<a href="#" title="Flapping">
|
||||
<i class="icon-table icinga-icon-flapping"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$host->host_notifications_enabled): ?>
|
||||
<a href="#" title="Notifications Disabled">
|
||||
<i class="icon-table icinga-icon-notification-disabled"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($host->host_in_downtime): ?>
|
||||
<a href="#" title="In Downtime">
|
||||
<i class="icon-table icinga-icon-in-downtime"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$host->host_active_checks_enabled): ?>
|
||||
<?php if (!$host->host_passive_checks_enabled): ?>
|
||||
<a href="#" title="Active And Passive Checks Disabled">
|
||||
<i class="icinga-icon-active-passive-checks-disabled"></i>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a href="#" title="Active Checks Disabled">
|
||||
<i class="icon-table icinga-icon-active-checks-disabled"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($host->host_last_comment) && $host->host_last_comment !== null): ?>
|
||||
<a href="#" title="Comments">
|
||||
<i class="icon-table icinga-icon-comment"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
-->
|
||||
<!-- State -->
|
||||
<td title="<?= $helper->getStateTitle($host, 'host') ?>" class="state">
|
||||
<?= $this->timeSince($host->host_last_state_change) ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="<?= $hostLink ?>"><?= $host->host_name ?></a><br />
|
||||
<?= $this->escape(substr(strip_tags($host->host_output), 0, 10000)); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
|
@ -1,27 +1,33 @@
|
|||
<?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); ?>
|
||||
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
|
||||
<?php if (! $this->filterEditor): ?>
|
||||
<?= $this->filterPreview ?>
|
||||
<?php endif ?>
|
||||
<?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())); ?>
|
||||
<?= $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 $this->translate('No host found') . '</div>';
|
||||
if ($hosts->count() === 0): ?>
|
||||
<?= $this->translate('No host found') ?>
|
||||
<?php if (! $this->compact): ?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
return;
|
||||
}
|
||||
endif;
|
||||
?>
|
||||
|
||||
<table
|
||||
|
@ -36,6 +42,7 @@ if ($hosts->count() === 0) {
|
|||
$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');
|
||||
|
@ -68,39 +75,62 @@ if ($hosts->count() === 0) {
|
|||
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'); ?>">
|
||||
<td class="state" title="<?= $helper->getStateTitle($host, 'host') ?>">
|
||||
<?php if (! $this->compact): ?>
|
||||
<div>
|
||||
<?php if (isset($host->host_unhandled_services) && $host->host_unhandled_services > 0): ?>
|
||||
<span class="badge pull-right" title="<?= $host->host_unhandled_services ?> Service Problems on Host">
|
||||
<a href="<?= $this->href('monitoring/show/services', array('host' => $host->host_name, 'service_problem' => 1)) ?>"><?= $host->host_unhandled_services ?></a>
|
||||
<span
|
||||
class="badge pull-right"
|
||||
title="<?= $host->host_unhandled_services ?> Service Problems on Host"
|
||||
>
|
||||
<a
|
||||
href="<?= $this->href(
|
||||
'monitoring/show/services',
|
||||
array('host' => $host->host_name, 'service_problem' => 1)
|
||||
) ?>"
|
||||
><?= $host->host_unhandled_services ?></a>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<strong><?= ucfirst($helper->monitoringState($host, 'host')); ?></strong><br />
|
||||
<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><?= ($host->host_state_type === '1') ? $this->translate('Hard') : $this->translate('Soft') ?> </strong> <?= $host->host_current_check_attempt; ?>/<?= $host->host_max_check_attempts; ?>
|
||||
<?php endif ?>
|
||||
<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 ?>
|
||||
<?= $this->img(
|
||||
$this->resolveMacros($host->host_icon_image, $host),
|
||||
array('align' => 'right')
|
||||
) ?>
|
||||
<?php endif; ?>
|
||||
<?= implode(' ', $icons) ?>
|
||||
<a href="<?= $this->href('monitoring/show/host', array('host' => $host->host_name)) ?>"><?= $host->host_name ?></a><br />
|
||||
<?= $this->escape(substr(strip_tags($host->host_output), 0, 10000)); ?>
|
||||
<?php endif; ?>
|
||||
<a href="<?= $this->compact ? $hostLink : $this->href(
|
||||
'monitoring/show/host',
|
||||
array('host' => $host->host_name)
|
||||
) ?>"><?= $host->host_name ?></a><br />
|
||||
<?= $this->escape(substr(strip_tags($host->host_output), 0, 10000)) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue