Refactor acknowledgements, finally get rid of status component

This commit is contained in:
Thomas Gelf 2014-03-08 21:28:32 +01:00
parent a87925bbf6
commit e6fc6375b5
5 changed files with 43 additions and 53 deletions

View File

@ -984,6 +984,7 @@ class Monitoring_CommandController extends ActionController
if ($form->IsSubmittedAndValid() === true) {
$this->target->sendCommand($form->createCommand(), $this->view->objects);
Notification::success('Acknowledgement removal request has been requested');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service;
if (in_array((int) $object->state, array(0, 99))) {
return;
}
$cf = $this->getHelper('CommandForm');
$data = array('host' => $object->host_name);
if ($object->service_description) {
$data['service'] = $object->service_description;
}
?>
<tr>
<?php
if ($object instanceof Host && $object->host_acknowledged
|| $object instanceof Service && $object->service_acknowledged): ?>
<th>Issue acknowledged</th>
<td><?= $cf->labelSubmitForm(
'Remove Acknowledgement',
'Remove problem acknowledgement',
'link-like',
'removeacknowledgement',
$data
) ?>
<?php else: ?>
<th>Not acknowledged</th>
<td>
<a href="<?= $this->href(
'monitoring/command/acknowledgeproblem',
$data
) ?>"><?= $this->icon('acknowledgement_petrol.png') ?> Acknowledge now</a>
</td>
<?php endif ?>
</tr>

View File

@ -1,51 +0,0 @@
<?php
$type = $object->type === 2 ? 'service' : 'host';
/** @var Zend_View_Helper_CommandForm $cf */
$cf = $this->getHelper('CommandForm');
if ($type === 'host') {
$objectStateName = strtolower($this->util()->getHostStateName($this->object->host_state));
$objectState = (int) $object->host_state;
} else {
$objectStateName = strtolower($this->util()->getServiceStateName($this->object->service_state));
$objectState = (int) $object->service_state;
}
?>
<div>
<div class="panel-body">
<div class="panel-row">
<?php if ($objectState > 0): ?>
<?php if ($this->object->host_acknowledged || $this->object->service_acknowledged): ?>
<?= $cf->labelSubmitForm(
'Remove Ack',
'Remove problem acknowledgement',
'btn-cta btn-half-left',
'removeacknowledgement',
array(
'host' => $this->object->host_name,
'service' => $this->object->service_description
)
) ?>
<?php else: ?>
<a rel="tooltip" title="Acknowledge Problems" href="<?=
$this->href(
'monitoring/command/acknowledgeproblem',
array(
'host' => $this->object->host_name,
'service' => $this->object->service_description
)
);
?>" class="button btn-cta btn-half-left">
Acknowledge
</a>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>

View File

@ -4,10 +4,10 @@
</div>
<div class="content" data-base-target="col1">
<?= $this->render('show/components/output.phtml') ?>
<?= $this->render('show/components/status.phtml') ?>
<table class="avp">
<tbody>
<?= $this->render('show/components/acknowledgement.phtml') ?>
<?= $this->render('show/components/comments.phtml') ?>
<?= $this->render('show/components/notifications.phtml') ?>
<?= $this->render('show/components/downtime.phtml') ?>

View File

@ -3,11 +3,11 @@
<h1>This service's current state</h1>
</div>
<div class="content" data-base-target="col1">
<?= $this->render('show/components/status.phtml') ?>
<?= $this->render('show/components/output.phtml') ?>
<table class="avp">
<tbody>
<?= $this->render('show/components/acknowledgement.phtml') ?>
<?= $this->render('show/components/comments.phtml') ?>
<?= $this->render('show/components/notifications.phtml') ?>
<?= $this->render('show/components/downtime.phtml') ?>