Skip to content

Commit

Permalink
Improve order and content of downtime properties
Browse files Browse the repository at this point in the history
Add rows for missing properties, reorder and group related properties.

refs #8902
  • Loading branch information
majentsch committed May 7, 2015
1 parent 7b6641d commit ff47b89
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 57 deletions.
40 changes: 37 additions & 3 deletions modules/monitoring/application/controllers/DowntimeController.php
Expand Up @@ -19,13 +19,15 @@ class Monitoring_DowntimeController extends Controller
{
protected $downtime;

protected $isService;

/**
* Add tabs
*/
public function init()
{
$downtimeId = $this->params->get('downtime_id');

$this->downtime = $this->backend->select()->from('downtime', array(
'id' => 'downtime_internal_id',
'objecttype' => 'downtime_objecttype',
Expand All @@ -50,6 +52,12 @@ public function init()
'service_display_name'
))->where('downtime_internal_id', $downtimeId)->getQuery()->fetchRow();

if (isset($this->downtime->service_description)) {
$this->isService = true;
} else {
$this->isService = false;
}

$this->getTabs()
->add(
'downtime',
Expand All @@ -67,13 +75,39 @@ public function init()
public function showAction()
{
$this->view->downtime = $this->downtime;
$this->view->delDowntimeForm = new DeleteDowntimeCommandForm();
$this->view->delDowntimeForm->setObjects($this->downtime);
$this->view->isService = $this->isService;
$this->view->delDowntimeForm = $this->createDelDowntimeForm();
$this->view->listAllLink = Url::fromPath('monitoring/list/downtimes');
$this->view->showHostLink = Url::fromPath('monitoring/host/show')
->setParam('host', $this->downtime->host);
$this->view->showServiceLink = Url::fromPath('monitoring/service/show')
->setParam('host', $this->downtime->host)
->setParam('service', $this->downtime->service_description);
}

private function createDelDowntimeForm()
{
$delDowntimeForm = new DeleteDowntimeCommandForm();
$delDowntimeForm->setObjects($this->downtime);
$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;
}
}
64 changes: 10 additions & 54 deletions modules/monitoring/application/views/scripts/downtime/show.phtml
@@ -1,22 +1,9 @@
<?php
use Icinga\Module\Monitoring\Object\Service;
use Icinga\Module\Monitoring\Object\Host;

if (isset($downtime->service_description)) {
$isService = true;
$stateName = Service::getStateText($downtime->service_state);
} else {
$isService = false;
$stateName = Host::getStateText($downtime->host_state);
}
?>

<div class="controls">
<?php if (! $this->compact): ?>
<?= $this->tabs; ?>
<?php endif ?>
<h1>
<?php if ($isService): ?>
<h1 data-base-target="_next">
<?php if ($this->isService): ?>
<?php
$link = $this->link()->service(
$downtime->service_description,
Expand All @@ -34,7 +21,7 @@ if (isset($downtime->service_description)) {
<?php endif ?>
<?= sprintf(
$this->translate(
'Downtime for %s',
'Downtime on %s',
'Downtime for host or service.'
),
$link
Expand All @@ -43,12 +30,12 @@ if (isset($downtime->service_description)) {
</h1>
</div>

<div class="content" data-base-target="_next">
<div class="content">
<small>
<?php if ($downtime->is_flexible): ?>
<?php if ($downtime->is_in_effect): ?>
<?= sprintf(
$isService
$this->isService
? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.')
: $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'),
date('d.m.y', $downtime->start),
Expand All @@ -59,7 +46,7 @@ if (isset($downtime->service_description)) {
); ?>
<?php else: ?>
<?= sprintf(
$isService
$this->isService
? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.')
: $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'),
date('d.m.y H:i', $downtime->scheduled_start),
Expand All @@ -70,7 +57,7 @@ if (isset($downtime->service_description)) {
<?php else: ?>
<?php if ($downtime->is_in_effect): ?>
<?= sprintf(
$isService
$this->isService
? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.')
: $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'),
date('d.m.y', $downtime->start),
Expand All @@ -80,7 +67,7 @@ if (isset($downtime->service_description)) {
); ?>
<?php else: ?>
<?= sprintf(
$isService
$this->isService
? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.')
: $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
date('d.m.y', $downtime->scheduled_start),
Expand Down Expand Up @@ -132,43 +119,12 @@ if (isset($downtime->service_description)) {
?>
</td>
</tr>

<?php if ($this->downtime->is_flexible && $this->downtime->is_in_effect): ?>
<tr>
<th><?= $this->translate('Start') ?></th>
<td><?= date('d.m.y H:i', $downtime->start); ?></td>
</tr>
<tr>
<th><?= $this->translate('End') ?></th>
<td><?= date('d.m.y H:i', $downtime->end); ?></td>
</tr>
<?php endif; ?>
<tr>
<th><?= $this->translate('Duration') ?></th>
<td><?= $this->format()->duration($this->escape($this->downtime->duration)); ?></td>
</tr>


<?php if (isset($delDowntimeForm)): // Form is unset if the current user lacks the respective permission ?>
<tr class="newsection">
<th><?= $this->translate('Commands') ?></th>
<td>
<?php
$delDowntimeForm->populate(array('downtime_id' => $downtime->id, 'redirect' => $this->listAllLink));
if (! $isService) {
$delDowntimeForm->setAction(
$this->url('monitoring/host/delete-downtime',
array('host' => $downtime->host_name))
);
} else {
$delDowntimeForm->setAction(
$this->url('monitoring/service/delete-downtime', array(
'host' => $downtime->host_name,
'service' => $downtime->service_description
))
);
}
echo $delDowntimeForm;
?>
<?= $delDowntimeForm;?>
</td>
</tr>
<?php endif ?>
Expand Down

0 comments on commit ff47b89

Please sign in to comment.