parent
20b25e656b
commit
a87e1f91d9
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Module\Monitoring\Controller;
|
||||
use Icinga\Module\Monitoring\Object\Service;
|
||||
use Icinga\Module\Monitoring\Object\Host;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget\Tabextension\DashboardAction;
|
||||
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display detailed information about a downtime
|
||||
*/
|
||||
class Monitoring_DowntimesController extends Controller
|
||||
{
|
||||
protected $downtimes;
|
||||
|
||||
protected $isService;
|
||||
|
||||
protected $filter;
|
||||
|
||||
/**
|
||||
* Add tabs
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->filter = Filter::fromQueryString(str_replace(
|
||||
'downtime_id',
|
||||
'downtime_internal_id',
|
||||
(string)$this->params
|
||||
));
|
||||
$this->downtimes = $this->backend->select()->from('downtime', array(
|
||||
'id' => 'downtime_internal_id',
|
||||
'objecttype' => 'downtime_objecttype',
|
||||
'comment' => 'downtime_comment',
|
||||
'author_name' => 'downtime_author_name',
|
||||
'start' => 'downtime_start',
|
||||
'scheduled_start' => 'downtime_scheduled_start',
|
||||
'scheduled_end' => 'downtime_scheduled_end',
|
||||
'end' => 'downtime_end',
|
||||
'duration' => 'downtime_duration',
|
||||
'is_flexible' => 'downtime_is_flexible',
|
||||
'is_fixed' => 'downtime_is_fixed',
|
||||
'is_in_effect' => 'downtime_is_in_effect',
|
||||
'entry_time' => 'downtime_entry_time',
|
||||
'host_state' => 'downtime_host_state',
|
||||
'service_state' => 'downtime_service_state',
|
||||
'host_name',
|
||||
'host',
|
||||
'service',
|
||||
'service_description',
|
||||
'host_display_name',
|
||||
'service_display_name'
|
||||
))->addFilter($this->filter)->getQuery()->fetchAll();
|
||||
$this->getTabs()
|
||||
->add(
|
||||
'downtimes',
|
||||
array(
|
||||
'title' => $this->translate(
|
||||
'Display detailed information about multiple downtimes.'
|
||||
),
|
||||
'icon' => 'plug',
|
||||
'label' => $this->translate('Downtimes'),
|
||||
'url' =>'monitoring/downtimes/show'
|
||||
)
|
||||
)->activate('downtimes')->extend(new DashboardAction());
|
||||
}
|
||||
|
||||
public function showAction()
|
||||
{
|
||||
if (false === $this->downtimes) {
|
||||
return;
|
||||
}
|
||||
$this->view->downtimes = $this->downtimes;
|
||||
$this->view->isService = $this->isService;
|
||||
|
||||
// $this->view->delDowntimeForm = $this->createDelDowntimeForm();
|
||||
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes')
|
||||
->setQueryString($this->filter->toQueryString());
|
||||
$this->view->removeAllLink = Url::fromPath('monitoring/downtimes/removeAll')
|
||||
->setParams($this->params);
|
||||
}
|
||||
|
||||
public function removeAllAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function createDelDowntimeForm()
|
||||
{
|
||||
$delDowntimeForm = new DeleteDowntimeCommandForm();
|
||||
$delDowntimeForm->setObjects($this->downtimes);
|
||||
$delDowntimeForm->populate(
|
||||
array(
|
||||
'downtime_id' => $this->downtime->id,
|
||||
'redirect' => Url::fromPath('monitoring/list/downtimes')
|
||||
)
|
||||
);
|
||||
if (! $this->isService) {
|
||||
$delDowntimeForm->setAction(
|
||||
$this->view->url('monitoring/host/delete-downtime',
|
||||
array('host' => $this->downtime->host_name))
|
||||
);
|
||||
} else {
|
||||
$delDowntimeForm->setAction(
|
||||
$this->view->url('monitoring/service/delete-downtime', array(
|
||||
'host' => $this->downtime->host_name,
|
||||
'service' => $this->downtime->service_description
|
||||
))
|
||||
);
|
||||
}
|
||||
return $delDowntimeForm;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<div class="controls">
|
||||
<?php if (! isset($downtimes)): ?>
|
||||
<?= $this->translate('No scheduled downtimes matching the filter.') ?>
|
||||
</div>
|
||||
<?php return; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (! $this->compact): ?>
|
||||
<?= $this->tabs; ?>
|
||||
<?php endif ?>
|
||||
|
||||
<h1 data-base-target="_next">
|
||||
<?= sprintf('%d Downtimes', count($downtimes)) ?>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<p>
|
||||
<?= $this->translate('You have selected') ?>
|
||||
<?= $this->qlink(
|
||||
sprintf($this->translate('%d downtimes'), count($downtimes)),
|
||||
$listAllLink,
|
||||
null,
|
||||
array('title' => $this->translate('List all selected downtimes.'))
|
||||
) ?>
|
||||
<div>
|
||||
<?= $this->qlink(
|
||||
sprintf(
|
||||
$this->translate('Remove all %d downtimes.'),
|
||||
count($downtimes)
|
||||
),
|
||||
$removeAllLink,
|
||||
null,
|
||||
array(
|
||||
'icon' => 'trash',
|
||||
'title' => $this->translate('Remove all selected downtimes.')
|
||||
)
|
||||
) ?>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
Loading…
Reference in New Issue