monitoring/commands: Let detail snippets use the new command forms
refs #6593
This commit is contained in:
parent
17e04e9937
commit
9b5c1f06d0
|
@ -1,40 +1,39 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Module\Monitoring\Object\Host;
|
||||
use Icinga\Module\Monitoring\Object\Service;
|
||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||
|
||||
if (in_array((int) $object->state, array(0, 99))) {
|
||||
// Ignore this markup if the object is in a non-problem state or pending
|
||||
return;
|
||||
}
|
||||
|
||||
$cf = $this->getHelper('CommandForm');
|
||||
|
||||
$data = array('host' => $object->host_name);
|
||||
if ($object->service_description) {
|
||||
$data['service'] = $object->service_description;
|
||||
if ($object->getType() === $object::TYPE_HOST) {
|
||||
$ackLink = $this->href(
|
||||
'monitoring/host/acknowledge-problem',
|
||||
array('host' => $object->getHost())
|
||||
);
|
||||
} else {
|
||||
$ackLink = $this->href(
|
||||
'monitoring/service/acknowledge-problem',
|
||||
array('host' => $object->getHost(), 'service' => $object->getService())
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<?php
|
||||
|
||||
if ($object instanceof Host && $object->host_acknowledged
|
||||
|| $object instanceof Service && $object->service_acknowledged): ?>
|
||||
<th>Issue acknowledged</th>
|
||||
<td data-base-target="_self"><?= $cf->labelSubmitForm(
|
||||
$this->translate('Remove Acknowledgement'),
|
||||
$this->translate('Remove problem acknowledgement'),
|
||||
'link-like',
|
||||
'removeacknowledgement',
|
||||
$data
|
||||
) ?>
|
||||
if ($object->acknowledged): ?>
|
||||
<tr>
|
||||
<th><?= $this->translate('Acknowledged') ?></th>
|
||||
<td><?= $removeAckForm ?></td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<th><?= $this->translate('Not acknowledged') ?></th>
|
||||
<td>
|
||||
<a href="<?= $this->href(
|
||||
'monitoring/command/acknowledgeproblem',
|
||||
$data
|
||||
) ?>"><?= $this->icon('acknowledgement_petrol.png') ?> <?= $this->translate('Acknowledge') ?></a>
|
||||
</td>
|
||||
<tr>
|
||||
<th><?= $this->translate('Not acknowledged') ?></th>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
?>
|
||||
<a href="<?= $ackLink ?>">
|
||||
<?= $this->icon('acknowledgement_petrol.png') ?> <?= $this->translate('Acknowledge') ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
</tr>
|
||||
|
|
|
@ -1,31 +1,36 @@
|
|||
<?php
|
||||
|
||||
$cf = $this->getHelper('CommandForm');
|
||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||
|
||||
?><tr>
|
||||
<th><?= $this->translate('Last check') ?></th>
|
||||
<td data-base-target="_self"><?= $this->img('img/icons/refresh_petrol.png') ?> <?= $cf->labelSubmitForm(
|
||||
$this->translate('Check now'),
|
||||
$this->translate('Reschedule next check immediately'),
|
||||
'link-like',
|
||||
'reschedulenextcheck',
|
||||
array(
|
||||
'host' => $this->object->host_name,
|
||||
'service' => $this->object->service_description,
|
||||
'checktime' => time(),
|
||||
'forcecheck' => '1'
|
||||
)
|
||||
) ?> <?= $this->timeSince($object->last_check) ?></td>
|
||||
if ($object->getType() === $object::TYPE_HOST) {
|
||||
$reschedule = $this->href(
|
||||
'monitoring/host/reschedule-check',
|
||||
array('host' => $object->getHost())
|
||||
);
|
||||
} else {
|
||||
$reschedule = $this->href(
|
||||
'monitoring/service/reschedule-check',
|
||||
array('host' => $object->getHost(), 'service' => $object->getService())
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<th><?= $this->translate('Last check') ?></th>
|
||||
<td data-base-target="_self">
|
||||
<?= $checkNowForm ?>
|
||||
<?= $this->timeSince($object->last_check) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $this->translate('Next check') ?></th>
|
||||
<td><!--<input type="submit" value="Reschedule" style="width: 7em;" /> --><a href="<?= $this->href(
|
||||
'monitoring/command/reschedulenextcheck',
|
||||
array(
|
||||
'host' => $object->host_name,
|
||||
'service' => $object->service_description
|
||||
)
|
||||
) ?>"><?= $this->img('img/icons/reschedule_petrol.png') ?> <?= $this->translate('Reschedule') ?></a> <?= $this->timeUntil($object->next_check) ?></td>
|
||||
<td>
|
||||
<a href="<?= $reschedule ?>">
|
||||
<?= $this->icon('reschedule_petrol.png') ?> <?= $this->translate('Reschedule') ?>
|
||||
</a>
|
||||
<?= $this->timeUntil($object->next_check) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($object->check_execution_time): ?>
|
||||
<tr>
|
||||
|
@ -39,4 +44,3 @@ $cf = $this->getHelper('CommandForm');
|
|||
<td><?= $object->check_latency ?>s</td>
|
||||
</tr>
|
||||
<?php endif ?>
|
||||
|
||||
|
|
|
@ -1,15 +1,32 @@
|
|||
<tr>
|
||||
<th><?= $this->translate('Comments') ?></th>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||
|
||||
if ($object->getType() === $object::TYPE_HOST) {
|
||||
$addCommentLink = $this->href(
|
||||
'monitoring/host/add-comment',
|
||||
array('host' => $object->getHost())
|
||||
);
|
||||
} else {
|
||||
$addCommentLink = $this->href(
|
||||
'monitoring/service/add-comment',
|
||||
array('host' => $object->getHost(), 'service' => $object->getService())
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
<a href="<?= $addCommentLink ?>">
|
||||
<?= $this->icon('comment_petrol.png') ?> <?= $this->translate('Add comment') ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
$cf = $this->getHelper('CommandForm');
|
||||
|
||||
$data = array('host' => $object->host_name);
|
||||
if ($object->service_description) {
|
||||
$data['service'] = $object->service_description;
|
||||
}
|
||||
|
||||
$list = array();
|
||||
foreach ($object->comments as $comment) {
|
||||
|
||||
// Ticket hook sample
|
||||
$text = $this->tickets ? preg_replace_callback(
|
||||
$this->tickets->getPattern(),
|
||||
|
@ -17,34 +34,26 @@ foreach ($object->comments as $comment) {
|
|||
$this->escape($comment->comment)
|
||||
) : $this->escape($comment->comment);
|
||||
|
||||
$deleteData = $data;
|
||||
$deleteData['commentid'] = $comment->id;
|
||||
|
||||
// $iconForm = $cf->iconSubmitForm(
|
||||
// 'img/icons/remove_petrol.png',
|
||||
$iconForm = $cf->labelSubmitForm(
|
||||
'X',
|
||||
'Remove comment',
|
||||
'link-like',
|
||||
'removecomment',
|
||||
$deleteData
|
||||
);
|
||||
$form = clone $delCommentForm;
|
||||
$form->populate(array('comment_id' => $comment->id));
|
||||
|
||||
$list[] = sprintf(
|
||||
'<tr><th>%s (%s)</th><td><table><tr><td style="vertical-align: top;" data-base-target="_self">%s (%s):</td><td style="padding-left: .5em;">%s</td></tr></table></td></tr>',
|
||||
$this->escape($comment->author),
|
||||
$this->timeSince($comment->timestamp),
|
||||
$iconForm,
|
||||
ucfirst($comment->type),
|
||||
str_replace(array('\r\n', '\n'), '<br>', $text)
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<th><?= $this->translate('Comments') ?></th>
|
||||
<td>
|
||||
<a href="<?= $this->href('monitoring/command/addComment', $data) ?>"><?= $this->icon('comment_petrol.png') ?> <?= $this->translate('Add comment') ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?= implode("\n", $list) ?>
|
||||
<tr>
|
||||
<th><?= $this->escape($comment->author) ?> (<?= $this->timeSince($comment->timestamp) ?>)</th>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="vertical-align: top;" data-base-target="_self">
|
||||
<?= $form ?> (<?= ucfirst($comment->type) ?>):
|
||||
</td>
|
||||
<td style="padding-left: .5em;">
|
||||
<?= str_replace(array('\r\n', '\n'), '<br>', $text) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } // endforeach ?>
|
||||
|
|
|
@ -1,39 +1,31 @@
|
|||
<tr>
|
||||
<th><?= $this->translate('Downtimes') ?></th>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||
|
||||
if ($object->getType() === $object::TYPE_HOST) {
|
||||
$scheduleDowntimeLink = $this->href(
|
||||
'monitoring/host/schedule-downtime',
|
||||
array('host' => $object->getHost())
|
||||
);
|
||||
} else {
|
||||
$scheduleDowntimeLink = $this->href(
|
||||
'monitoring/service/schedule-downtime',
|
||||
array('host' => $object->getHost(), 'service' => $object->getService())
|
||||
);
|
||||
}
|
||||
?>
|
||||
<a href="<?= $scheduleDowntimeLink ?>">
|
||||
<?= $this->icon('in_downtime_petrol.png') ?> <?= $this->translate('Schedule downtime') ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
$cf = $this->getHelper('CommandForm');
|
||||
|
||||
$data = array('host' => $object->host_name);
|
||||
if ($object->service_description) {
|
||||
$data['service'] = $object->service_description;
|
||||
}
|
||||
|
||||
|
||||
$list = array();
|
||||
foreach ($object->downtimes as $downtime) {
|
||||
$deleteData = $data;
|
||||
$deleteData['downtimeid'] = $downtime->id;
|
||||
|
||||
// TODO: This needs improvement
|
||||
if ((int) $downtime->is_in_effect) {
|
||||
$state = 'in downtime since ' . $this->timeSince($downtime->start);
|
||||
} else {
|
||||
if ($downtime->is_fixed) {
|
||||
$state = 'scheduled ' . $this->timeUntil($downtime->start);
|
||||
} else {
|
||||
$state = 'scheduled flexible ' . $this->timeUntil($downtime->start);
|
||||
}
|
||||
}
|
||||
|
||||
// $iconForm = $cf->iconSubmitForm(
|
||||
// 'img/icons/remove_petrol.png',
|
||||
$iconForm = $cf->labelSubmitForm(
|
||||
'X',
|
||||
'Remove Downtime',
|
||||
'link-like',
|
||||
'removedowntime',
|
||||
$deleteData
|
||||
);
|
||||
|
||||
// Ticket hook sample
|
||||
$text = $this->tickets ? preg_replace_callback(
|
||||
$this->tickets->getPattern(),
|
||||
|
@ -41,20 +33,35 @@ foreach ($object->downtimes as $downtime) {
|
|||
$this->escape($downtime->comment)
|
||||
) : $this->escape($downtime->comment);
|
||||
|
||||
$list[] = sprintf(
|
||||
'<tr><th>%s</th><td><table><tr><td style="vertical-align: top;" data-base-target="_self">%s %s:</td><td style="padding-left: .5em;">%s</td></tr></table></td></tr>',
|
||||
$this->escape($downtime->author),
|
||||
$iconForm,
|
||||
$state,
|
||||
str_replace(array('\r\n', '\n'), '<br>', $text)
|
||||
);
|
||||
}
|
||||
$form = clone $delDowntimeForm;
|
||||
$form->populate(array('downtime_id' => $downtime->id));
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<th><?= $this->translate('Downtimes') ?></th>
|
||||
<td>
|
||||
<a href="<?= $this->href('monitoring/command/scheduleDowntime', $data) ?>"><?= $this->icon('in_downtime_petrol.png') ?> <?= $this->translate('Schedule downtime') ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?= implode("\n", $list) ?>
|
||||
if ((bool) $downtime->is_in_effect) {
|
||||
$state = 'in downtime since ' . $this->timeSince($downtime->start);
|
||||
} else {
|
||||
if ((bool) $downtime->is_fixed) {
|
||||
$state = 'scheduled ' . $this->timeUntil($downtime->start);
|
||||
} else {
|
||||
$state = 'scheduled flexible ' . $this->timeUntil($downtime->start);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<th><?= $this->escape($downtime->author) ?></th>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="vertical-align: top;" data-base-target="_self">
|
||||
<?= $form ?> <?= $state ?>
|
||||
</td>
|
||||
<td style="padding-left: .5em;">
|
||||
<?= str_replace(array('\r\n', '\n'), '<br>', $text) ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } // endforeach ?>
|
||||
|
|
|
@ -1,77 +1,3 @@
|
|||
<?php
|
||||
|
||||
$o = $this->object;
|
||||
$cf = $this->getHelper('CommandForm');
|
||||
|
||||
$data = array(
|
||||
'host' => $o->host_name,
|
||||
'service' => $o->service_description
|
||||
);
|
||||
|
||||
?>
|
||||
<tr class="newsection">
|
||||
<th><?= $this->translate('Passive Checks') ?></th>
|
||||
<td data-base-target="_self"><?= $cf->toggleSubmitForm(
|
||||
'',
|
||||
$o->passive_checks_enabled,
|
||||
'startacceptingpassivechecks',
|
||||
'stopacceptingpassivechecks',
|
||||
$o->passive_checks_enabled_changed === '1',
|
||||
$data
|
||||
) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $this->translate('Active Checks') ?></th>
|
||||
<td data-base-target="_self"><?= $cf->toggleSubmitForm(
|
||||
'',
|
||||
$o->active_checks_enabled,
|
||||
'enableactivechecks',
|
||||
'disableactivechecks',
|
||||
$o->active_checks_enabled_changed === '1',
|
||||
$data
|
||||
) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $this->translate('Notifications') ?></th>
|
||||
<td data-base-target="_self"><?= $cf->toggleSubmitForm(
|
||||
'',
|
||||
$o->notifications_enabled,
|
||||
'enablenotifications',
|
||||
'disablenotifications',
|
||||
$o->notifications_enabled_changed === '1',
|
||||
$data
|
||||
) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $this->translate('Event Handler') ?></th>
|
||||
<td data-base-target="_self"><?= $cf->toggleSubmitForm(
|
||||
'',
|
||||
$o->event_handler_enabled,
|
||||
'enableeventhandler',
|
||||
'disableeventhandler',
|
||||
$o->event_handler_enabled_changed === '1',
|
||||
$data
|
||||
) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $this->translate('Flap Detection') ?></th>
|
||||
<td data-base-target="_self"><?= $cf->toggleSubmitForm(
|
||||
'',
|
||||
$o->flap_detection_enabled,
|
||||
'enableflapdetection',
|
||||
'disableflapdetection',
|
||||
$o->flap_detection_enabled_changed === '1',
|
||||
$data
|
||||
) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $this->translate('Obsessing') ?></th>
|
||||
<td data-base-target="_self"><?= $cf->toggleSubmitForm(
|
||||
'',
|
||||
$o->obsessing,
|
||||
'startobsessing',
|
||||
'stopobsessing',
|
||||
$o->obsessing_changed === '1',
|
||||
$data
|
||||
) ?></td>
|
||||
</tr>
|
||||
<tr class="newsection">
|
||||
<td colspan="2" data-base-target="_self"><?= $toggleFeaturesForm ?></td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue