/list/services

refs #27
This commit is contained in:
Alexander A. Klimov 2017-08-31 17:43:52 +02:00
parent 0d606dfc06
commit e4a58c4568
3 changed files with 88 additions and 0 deletions

View file

@ -17,6 +17,24 @@ class ListController extends Controller
$this->setupSortControl(['host_display_name' => mt('monitoring', 'Hostname')], $hosts);
}
public function servicesAction()
{
$this->view->services = $services = $this->backend->select()->from('servicestatus', [
'host_name',
'host_display_name',
'service_description',
'service_display_name'
]);
$this->applyRestriction('monitoring/filter/objects', $services);
$this->filterQuery($services);
$this->setupPaginationControl($services);
$this->setupLimitControl();
$this->setupSortControl([
'service_display_name' => mt('monitoring', 'Service Name'),
'host_display_name' => mt('monitoring', 'Hostname')
], $services);
}
/**
* Apply filters on a DataView
*

View file

@ -0,0 +1,60 @@
<?php
use Icinga\Web\Url;
/** @var \Icinga\Web\View $this */
/** @var \Icinga\Module\Monitoring\DataView\DataView $services */
if (! $compact): ?>
<div class="controls">
<?= $tabs ?>
<?= $paginator ?>
<div class="sort-controls-container">
<?= $limiter ?>
<?= $sortBox ?>
</div>
<?= $filterEditor ?>
</div>
<?php endif ?>
<div class="content">
<?php if (! $services->hasResult()): ?>
<p><?= mt('monitoring', 'No services found matching the filter.') ?></p>
</div>
<?php return; endif ?>
<?php foreach ($services->peekAhead($compact) as $service): ?>
<h2><?= $this->qlink(
$service->host_name === $service->host_display_name
? $service->host_display_name
: $service->host_display_name . ' (' . $this->escape($service->host_name) . ')',
Url::fromPath('monitoring/host/show', ['host' => $service->host_name])
) ?>&#58; <?= $this->qlink(
$service->service_description === $service->service_display_name
? $service->service_display_name
: $service->service_display_name . ' (' . $this->escape($service->service_description) . ')',
Url::fromPath('monitoring/service/show', [
'host' => $service->host_name,
'service' => $service->service_description
])
) ?></h2>
<div class="container" data-base-target="_main" data-last-update="-1" data-icinga-refresh="15" data-icinga-url="<?=
// TODO(ak): EL says "<div class="container" data-icinga-url="..." /> is enough", but this seems not to work for me
$this->href('graphite/show/service', [
'host' => $service->host_name,
'service' => $service->service_description,
'view' => 'compact'
])
?>"></div>
<?php endforeach ?>
<?php if ($services->hasMore()): ?>
<div class="action-links">
<?= $this->qlink(
mt('monitoring', 'Show More'),
$this->url()->without(array('view', 'limit')),
null,
[
'class' => 'action-link',
'data-base-target' => '_next'
]
) ?>
</div>
<?php endif ?>
</div>

View file

@ -1,7 +1,12 @@
<?php
/** @var \Icinga\Web\View $this */
if (! $compact): ?>
<div class="controls">
<?= $this->tabs ?>
<h1><?= $this->hostname ?>: <?= $this->service ?></h1>
</div>
<?php endif ?>
<div class="content">
<?php foreach ($this->images as $type => $imgs): ?>
@ -23,4 +28,9 @@
<?php endif ?>
<?php endforeach ?>
<?php if (! isset($title)): ?>
<p><?= $this->translate('No graphs found') ?></p>
<?php endif ?>
</div>