Introduce new object- and command-view scripts
Represents how we plan to handle view scripts that are re-usable. Should supersede all <action>/component/* view scripts in the upcoming future.
This commit is contained in:
parent
67a426580d
commit
afa3431aed
|
@ -0,0 +1,13 @@
|
||||||
|
<div class="controls">
|
||||||
|
<?php if ($object->getType() === $object::TYPE_HOST): ?>
|
||||||
|
<?= $this->render('partials/host/object-header.phtml'); ?>
|
||||||
|
<?= $this->render('partials/host/servicesummary.phtml'); ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?= $this->render('partials/service/object-header.phtml'); ?>
|
||||||
|
<hr class="command-separator">
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<h1 class="command-title"><?= $title; ?> <?= /** @var \Icinga\Module\Monitoring\Forms\Command\CommandForm $form */ $this->icon('help', $form->getHelp()); ?></h1>
|
||||||
|
<?= $form ?>
|
||||||
|
</div>
|
|
@ -0,0 +1,32 @@
|
||||||
|
<div class="controls">
|
||||||
|
<?php if (isset($serviceStates)): ?>
|
||||||
|
<?= $this->render('partials/service/objects-header.phtml'); ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?= $this->render('partials/host/objects-header.phtml'); ?>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<table class="objectlist">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?= $this->icon('host'); ?> <?= $this->translate('Host'); ?></th>
|
||||||
|
<th><?= $this->icon('conf'); ?> <?= $this->translate('Service'); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($form->getObjects() as $object): /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ ?>
|
||||||
|
<tr>
|
||||||
|
<?php if ($object->getType() === $object::TYPE_HOST): ?>
|
||||||
|
<td colspan="2"><?= $this->escape($object->getName()); ?></td>
|
||||||
|
<?php else: ?>
|
||||||
|
<td><?= $this->escape($object->getHost()->getName()); ?></td>
|
||||||
|
<td><?= $this->escape($object->getName()); ?></td>
|
||||||
|
<?php endif ?>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr class="command-separator">
|
||||||
|
<h1 class="command-title"><?= $title ?> <?= /** @var \Icinga\Module\Monitoring\Forms\Command\CommandForm $form */ $this->icon('help', $form->getHelp()) ?></h1>
|
||||||
|
<?= $form ?>
|
||||||
|
</div>
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Icinga\Module\Monitoring\Object\Host;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if (! $this->compact): ?>
|
||||||
|
<?= $tabs; ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<table class="objectstate">
|
||||||
|
<tr class="state <?= Host::getStateText($object->host_state); ?><?= $object->host_handled ? ' handled' : ''; ?>">
|
||||||
|
<td class="state">
|
||||||
|
<strong><?= Host::getStateText($object->host_state, true); ?></strong><br>
|
||||||
|
<?= $this->prefixedTimeSince($object->host_last_state_change, true); ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong><?= $this->escape($object->host_display_name); ?></strong>
|
||||||
|
<?php if ($object->host_display_name !== $object->host_name): ?>
|
||||||
|
<small>(<?= $this->escape($object->host_name); ?>)</small>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
|
||||||
|
<br>
|
||||||
|
<?= $this->escape($object->host_address); ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<?= $this->render('partials/host/statusicons.phtml'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php if (! $this->compact): ?>
|
||||||
|
<?= $tabs; ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if (($hostCount = count($objects)) > 0): ?>
|
||||||
|
<div class="hbox-item">
|
||||||
|
<strong><?= sprintf($this->translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?></strong>
|
||||||
|
</div>
|
||||||
|
<div class="hbox-item">
|
||||||
|
<?= $hostStatesPieChart; ?>
|
||||||
|
</div>
|
||||||
|
<div class="hbox-item" style="font-size: 14px">
|
||||||
|
<?php foreach (array_filter($hostStates) as $text => $count): ?>
|
||||||
|
<?= sprintf('%s: %u', $this->translate(strtoupper($text)), $count); ?><br>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
$selfUrl = Url::fromPath('monitoring/show/services', array('host' => $this->object->host_name));
|
||||||
|
$currentUrl = Url::fromRequest()->without('limit')->getRelativeUrl();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<h1 class="tinystatesummary" <?= $this->compact ? ' data-base-target="col1"' : '' ?>>
|
||||||
|
<?php if ($object->stats->services_total > 0): ?>
|
||||||
|
<?= $this->qlink(sprintf($this->translatePlural('%d configured service:', '%d configured services:', $object->stats->services_total), $object->stats->services_total), $selfUrl) ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?= $this->translate('No services configured on this host'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<span class="badges">
|
||||||
|
<?php if ($object->stats->services_ok > 0): ?>
|
||||||
|
<span class="state ok<?= $currentUrl === $selfUrl->with('service_state', 0)->getRelativeUrl() ? ' active' : '' ?>"><?= $this->qlink(
|
||||||
|
$object->stats->services_ok,
|
||||||
|
$selfUrl,
|
||||||
|
array('service_state' => 0),
|
||||||
|
array('title' => sprintf($this->translate('Services with state %s'), $this->translate('OK')))
|
||||||
|
) ?></span>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
foreach (array(2 => 'critical', 3 => 'unknown', 1 => 'warning') as $stateId => $state) {
|
||||||
|
$pre = 'services_' . $state;
|
||||||
|
if ($object->stats->$pre) {
|
||||||
|
$handled = $pre . '_handled';
|
||||||
|
$unhandled = $pre . '_unhandled';
|
||||||
|
$paramsHandled = array('service_state' => $stateId, 'service_handled' => 1);
|
||||||
|
$paramsUnhandled = array('service_state' => $stateId, 'service_handled' => 0);
|
||||||
|
if ($object->stats->$unhandled) {
|
||||||
|
$compareUrl = $selfUrl->with($paramsUnhandled)->getRelativeUrl();
|
||||||
|
} else {
|
||||||
|
$compareUrl = $selfUrl->with($paramsHandled)->getRelativeUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($compareUrl === $currentUrl) {
|
||||||
|
$active = ' active';
|
||||||
|
} else {
|
||||||
|
$active = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<span class="state ' . $state . $active . ($object->stats->$unhandled ? '' : ' handled') . '">';
|
||||||
|
if ($object->stats->$unhandled) {
|
||||||
|
|
||||||
|
echo $this->qlink(
|
||||||
|
$object->stats->$unhandled,
|
||||||
|
$selfUrl,
|
||||||
|
$paramsUnhandled,
|
||||||
|
array('title' => sprintf($this->translate('Unhandled services with state %s'), $this->translate(strtoupper($state))))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ($object->stats->$handled) {
|
||||||
|
|
||||||
|
if ($selfUrl->with($paramsHandled)->getRelativeUrl() === $currentUrl) {
|
||||||
|
$active = ' active';
|
||||||
|
} else {
|
||||||
|
$active = '';
|
||||||
|
}
|
||||||
|
if ($object->stats->$unhandled) {
|
||||||
|
echo '<span class="state handled ' . $state . $active . '">';
|
||||||
|
}
|
||||||
|
echo $this->qlink(
|
||||||
|
$object->stats->$handled,
|
||||||
|
$selfUrl,
|
||||||
|
$paramsHandled,
|
||||||
|
array('title' => sprintf($this->translate('Handled services with state %s'), $this->translate(strtoupper($state))))
|
||||||
|
);
|
||||||
|
if ($object->stats->$unhandled) {
|
||||||
|
echo "</span>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</span>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($object->stats->services_pending): ?>
|
||||||
|
<span class="state pending<?= $currentUrl === $selfUrl->with('service_state', 99)->getRelativeUrl() ? ' active' : '' ?>"><?= $this->qlink(
|
||||||
|
$object->stats->services_pending,
|
||||||
|
$selfUrl,
|
||||||
|
array('service_state' => 99),
|
||||||
|
array('title' => sprintf($this->translate('Services with state %s'), $this->translate('PENDING')))
|
||||||
|
) ?></span>
|
||||||
|
<?php endif ?>
|
||||||
|
</span>
|
||||||
|
</h1>
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?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); ?>
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Icinga\Module\Monitoring\Object\Host;
|
||||||
|
use Icinga\Module\Monitoring\Object\Service;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if (! $this->compact): ?>
|
||||||
|
<?= $tabs; ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<table class="objectstate">
|
||||||
|
<tr class="state <?= Host::getStateText($object->host_state); ?><?= $object->host_handled ? ' handled' : ''; ?>">
|
||||||
|
<td class="state">
|
||||||
|
<strong><?= Host::getStateText($object->host_state, true); ?></strong><br>
|
||||||
|
<?= $this->prefixedTimeSince($object->host_last_state_change, true); ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong><?= $this->escape($object->host_display_name); ?></strong>
|
||||||
|
<?php if ($object->host_display_name !== $object->host_name): ?>
|
||||||
|
<small>(<?= $this->escape($object->host_name); ?>)</small>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
|
||||||
|
<br>
|
||||||
|
<?= $this->escape($object->host_address); ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<?= $this->render('partials/host/statusicons.phtml'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="state <?= Service::getStateText($object->service_state); ?><?= $object->service_handled ? ' handled' : ''; ?>">
|
||||||
|
<td class="state">
|
||||||
|
<strong><?= Service::getStateText($object->service_state, true); ?></strong><br>
|
||||||
|
<?= $this->prefixedTimeSince($object->service_last_state_change, true); ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<strong><?= $this->translate('Service'); ?>: <?= $this->escape($object->service_display_name); ?></strong>
|
||||||
|
<?php if ($object->service_display_name !== $object->service_description): ?>
|
||||||
|
<small>(<?= $this->escape($object->service_description); ?>)</small>
|
||||||
|
<?php endif ?>
|
||||||
|
<?= $this->render('partials/service/statusicons.phtml'); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php if (! $this->compact): ?>
|
||||||
|
<?= $tabs; ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if (($serviceCount = count($objects)) > 0): ?>
|
||||||
|
<div class="hbox">
|
||||||
|
<div class="hbox-item" style="width: 6em;">
|
||||||
|
<strong><?= sprintf($this->translatePlural('Service (%u)', 'Services (%u)', $serviceCount), $serviceCount); ?></strong>
|
||||||
|
</div>
|
||||||
|
<div class="hbox-item">
|
||||||
|
<?= $serviceStatesPieChart; ?>
|
||||||
|
</div>
|
||||||
|
<div class="hbox-item" style="font-size: 14px">
|
||||||
|
<?php foreach (array_filter($serviceStates) as $text => $count): ?>
|
||||||
|
<?= sprintf('%s: %u', $this->translate(strtoupper($text)), $count); ?><br>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="hbox">
|
||||||
|
<div class="hbox-item" style="width: 6em;">
|
||||||
|
<?php $hostCount = array_sum(array_values($hostStates)); ?>
|
||||||
|
<strong><?= sprintf($this->translatePlural('Host (%u)', 'Hosts (%u)', $hostCount), $hostCount); ?></strong>
|
||||||
|
</div>
|
||||||
|
<div class="hbox-item">
|
||||||
|
<?= $hostStatesPieChart; ?>
|
||||||
|
</div>
|
||||||
|
<div class="hbox-item" style="font-size: 14px">
|
||||||
|
<?php foreach (array_filter($hostStates) as $text => $count): ?>
|
||||||
|
<?= sprintf('%s: %u', $this->translate(strtoupper($text)), $count); ?><br>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?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); ?>
|
Loading…
Reference in New Issue