Style comments, cowntimes, properties, flags in detail pane [WIP]

refs #4869
This commit is contained in:
Marius Hein 2013-10-14 18:17:58 +02:00
parent caf4554023
commit a69c7498ec
12 changed files with 219 additions and 154 deletions

View File

@ -32,9 +32,21 @@
<div class="panel-body">
<table class="table table-condensed table-detail">
<tbody>
<?php if (empty($object->comments)): ?>
<tr>
<td>No comments</td>
</tr>
<?php endif; ?>
<?php foreach ($object->comments as $comment): ?>
<tr>
<td>
<div class="pull-right">
<form>
<button type="submit" value="1" class="button btn-small btn-common" title="Remove comment">
<i class="icinga-icon-remove"></i>
</button>
</form>
</div>
<?= $this->escape($comment->comment_author); ?>, <?= $comment->comment_type; ?>
(<?= $this->format()->timeSince($comment->comment_timestamp); ?>)
<div class="small-row">

View File

@ -1,23 +1,13 @@
<div class="panel panel-default">
<div>
<div class="panel-heading">
<span>Customvariables</span>
<div class="panel-hostname">
Custom Variables
</div>
</div>
<hr class="separator" />
<div class="panel-body">
<?php if (isset($object->customvars) && count($object->customvars)) { ?>
<table>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
<?php foreach ($object->customvars as $name => $value) { ?>
<tr>
<td><?= $this->escape($name) ?></td>
<td><?= $this->escape($value) ?></td>
</tr>
<?php } ?>
</table>
<?php } ?>
<?php var_dump($this->object); ?>
</div>
</div>

View File

@ -28,20 +28,68 @@
}
?>
<?php endif; ?>
<div class="panel panel-default">
<div>
<div class="panel-heading">
{{IN_DOWNTIME_ICON}}<span>Downtimes</span>
<div class="panel-hostname">
<div class="pull-right">
<?php
$scheduleDowntimeData = array(
'host' => $this->object->host_name,
'service' => $this->object->service_description
);
$scheduleDowntimeHref = $this->href('monitoring/command/scheduleDowntime', $scheduleDowntimeData);
?>
<a href="<?= $scheduleDowntimeHref; ?>" class="btn-common btn-small button" title="Schedule downtime">
<i class="icinga-icon-in-downtime"></i>
</a>
</div>
Downtimes
</div>
</div>
<hr class="separator" />
<div class="panel-body">
<a href="#" class="button">{{SCHEDULE_DOWNTIME_COMMAND_BUTTON}}</a><br/>
<?php if (!empty($this->downtimes)): ?>
<table>
<tr>
<?= implode('</tr><tr>', $list); ?>
</tr>
<table class="table table-condensed table-detail">
<tbody>
<?php if (empty($this->object->downtimes)): ?>
<tr>
<td>No Downtimes</td>
</tr>
<?php endif; ?>
<?php foreach ($this->object->downtimes as $downtime): ?>
<tr>
<td>
<div class="pull-right">
<form action="<?= $this->href('monitoring/command/removeDowntime'); ?>" data-icinga-component="app/ajaxPostSubmitForm">
<button type="submit" class="button btn-common btn-small" name="btn_submit" value="1">
<i class="icinga-icon-remove"></i>
</button>
<input type="hidden" name="host" value="<?= $downtime->host_name; ?>" />
<input type="hidden" name="service" value="<?= $downtime->service_description; ?>" />
<input type="hidden" name="downtimeid" value="<?= $downtime->downtime_internal_downtime_id; ?>" />
<input type="hidden" name="CSRFToken" value="" />
</form>
</div>
<?php if ($downtime->downtime_is_in_effect === '1'): ?>
Running since <?= $this->timeSince($downtime->downtime_actual_start_time); ?>
<?php else: ?>
<?php if ($downtime->downtime_is_fixed): ?>
Scheduled for <?= $downtime->downtime_scheduled_start_time; ?>
<?php else: ?>
Waiting
<?php endif; ?>
<?php endif; ?>
Triggered by <?= $downtime->downtime_author_name; ?>
<div class="small-row">
<?= $downtime->downtime_comment_data; ?>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
Not in downtime
<?php endif; ?>
</div>
</div>

View File

@ -1,22 +1,50 @@
<div class="panel panel-default">
<div class="panel-heading">Heading</div>
<?php
$o = $this->object;
?>
<div>
<div class="panel-heading">
<div class="panel-hostname">
Configuration
</div>
</div>
<hr class="separator" />
<div class="panel-body">
<table class="table table-condensed">
<?php foreach ($this->monitoringFlags($object) as $flag => $enabled): ?>
<tr>
<th><?= $flag; ?></th>
<td>
<?php if ($enabled === true): ?>
<span>{{ENABLED_ICON}} ENABLED</span>
<?php else: ?>
<span>{{DISABLED_ICON}} DISABLED</span>
<?php endif; ?>
</td>
<td>
<a class="button" href="#">{{{ENABLE_OR_DISABLE_COMMAND}}}</a>
</td>
</tr>
<?php endforeach; ?>
<table class="table table-condensed table-detail">
<tbody>
<tr>
<td>Passive Checks</td>
<td><div class="icon-table-hint icon-edit pull-left"></div></td>
<td><input type="checkbox" id="#" name="#" class="pull-right" <?= ($o->passive_checks_enabled === '1') ? 'checked="true"' : '' ?> /></td>
</tr>
<tr>
<td>Active Checks</td>
<td></td>
<td><input type="checkbox" id="#" name="#" class="pull-right" <?= ($o->active_checks_enabled === '1') ? 'checked="true"' : '' ?> /></td>
</tr>
<tr>
<td>Obsessing</td>
<td></td>
<td><input type="checkbox" id="#" name="#" class="pull-right" <?= ($o->obsessing === '1') ? 'checked="true"' : '' ?> /></td>
</tr>
<tr>
<td>Notifications</td>
<td></td>
<td><input type="checkbox" id="#" name="#" class="pull-right" <?= ($o->notifications_enabled === '1') ? 'checked="true"' : '' ?> /></td>
</tr>
<tr>
<td>Event Handler</td>
<td></div></td>
<td><input type="checkbox" id="#" name="#" class="pull-right" <?= ($o->event_handler_enabled === '1') ? 'checked="true"' : '' ?> /></td>
</tr>
<tr>
<td>Flap Detection</td>
<td></td>
<td><input type="checkbox" id="#" name="#" class="pull-right" <?= ($o->flap_detection_enabled === '1') ? 'checked="true"' : '' ?> /></td>
</tr>
</tbody>
</table>
</div>
</div>

View File

@ -1,93 +1,26 @@
<div class="panel panel-default">
<div class="panel-heading">Properties</div>
<div>
<div class="panel-heading">
<div class="panel-hostname">
Check Statistics
</div>
</div>
<hr class="separator" />
<div class="panel-body">
<table class="table table-bordered">
<tr>
<th>Current Attempt</th>
<td>
<?= sprintf(
'%s/%s (%s state)',
$object->current_check_attempt,
$object->max_check_attempts,
($object->state_type === '1') ? 'HARD' : 'SOFT'
); ?>
</td>
</tr>
<tr>
<th>Check Type</th>
<td>
<?php if ($object->passive_checks_enabled === '1' && $object->active_checks_enabled === '0'): ?>
PASSIVE
<?php elseif ($object->passive_checks_enabled === '0' && $object->active_checks_enabled === '0'): ?>
DISABLED
<?php else: ?>
ACTIVE
<?php endif; ?>
</td>
</tr>
<tr>
<th>Check Latency / Duration</th>
<td>
<?php if ($object->passive_checks_enabled === '0' && $object->active_checks_enabled === '0'): ?>
N/A
<?php else: ?>
<?= sprintf('%.4f', $object->check_latency); ?> / <?= sprintf('%.4f', $object->check_execution_time); ?> seconds
<?php endif; ?>
</td>
</tr>
<tr>
<th>Last Notification</th>
<td>
<?php
if ($object->service_description) {
$notificationsHref = $this->href('monitoring/list/notifications',
array(
'host' => $object->host_name,
'service' => $object->service_description
)
);
} else {
$notificationsHref = $this->href('monitoring/list/notifications',
array(
'host' => $object->host_name
)
);
}
?>
<a href="<?= $notificationsHref ?>">
<?php if ($object->last_notification === '0000-00-00 00:00:00'): ?>
N/A
<?php else: ?>
<?= $object->last_notification ?>
<?php if ($object->current_notification_number > 0): ?>
<br />
<?= $object->current_notification_number ?> notifications sent during current problem state
<?php endif ;?>
<?php endif; ?>
</a>
</td>
</tr>
<tr>
<th>Is This <?= $object->service_description ? 'Service' : 'Host' ?> Flapping?</th>
<td>
<?php if ($object->is_flapping === '1'): ?>
YES
<?php else: ?>
NO
<?php endif; ?>
<?= sprintf('%.2f', $object->percent_state_change); ?>% state change
</td>
</tr>
<tr>
<th>In Scheduled Downtime?</th>
<td>
<?php if ($object->in_downtime === '1'): ?>
YES
<?php else: ?>
NO
<?php endif; ?>
</td>
</tr>
</table>
<dl class="dl-horizontal">
<dt>Latency</dt>
<dd><?= sprintf('%.2f', $this->object->check_execution_time); ?>s</dd>
</dl>
<dl class="dl-horizontal">
<dt>Duration</dt>
<dd><?= sprintf('%.2f', $this->object->check_latency); ?>s</dd>
</dl>
<dl class="dl-horizontal">
<dt>Attempt</dt>
<dd>
<?= $this->object->current_check_attempt; ?>/<?= $this->object->max_check_attempts; ?>
(<?= ($this->object->host_state_type === '1') ? 'Hard' : 'Soft'; ?>)
</dd>
</dl>
</div>
</div>

View File

@ -1,17 +1,10 @@
<?= $this->tabs->render($this); ?>
<?= $this->render('show/components/status.phtml'); ?>
<?= $this->render('show/components/comments.phtml'); ?>
<?= $this->render('show/components/downtime.phtml'); ?>
<?= $this->render('show/components/properties.phtml'); ?>
<?= $this->render('show/components/flags.phtml'); ?>
<?= $this->render('show/components/hostgroups.phtml'); ?>
<?= $this->render('show/components/eventHistory.phtml'); ?>
<?= $this->render('show/components/contacts.phtml'); ?>
<?= $this->render('show/components/customvars.phtml'); ?>
<?= $this->render('show/components/command.phtml'); ?>
<?= $this->render('show/components/servicegroups.phtml'); ?>
<?= $this->render('show/components/contacts.phtml'); ?>
<?= $this->render('show/components/command.phtml') ?>

View File

@ -2,6 +2,7 @@
<?= $this->render('show/components/status.phtml'); ?>
<?= $this->render('show/components/comments.phtml'); ?>
<?= $this->render('show/components/downtime.phtml'); ?>
<?= $this->render('show/components/properties.phtml'); ?>
<?= $this->render('show/components/flags.phtml'); ?>
<?= $this->render('show/components/customvars.phtml'); ?>
<?= $this->render('show/components/servicegroups.phtml'); ?>

View File

@ -167,4 +167,33 @@ abstract class AbstractObject
);
return $this;
}
public function fetchDowtimes()
{
$this->foreign['downtimes'] = $this->applyObjectFilter(
$this->backend->select()->from('downtime', array(
'host_name',
'object_type',
'service_host_name',
'service_description',
'downtime_type',
'downtime_author_name',
'downtime_comment_data',
'downtime_is_fixed',
'downtime_duration',
'downtime_entry_time',
'downtime_scheduled_start_time',
'downtime_scheduled_end_time',
'downtime_was_started',
'downtime_actual_start_time',
'downtime_actual_start_time_usec',
'downtime_is_in_effect',
'downtime_trigger_time',
'downtime_triggered_by_id',
'downtime_internal_downtime_id'
)
)
)->fetchAll(9);
return $this;
}
}

View File

@ -12,6 +12,7 @@ class Host extends AbstractObject
'contactgroups' => null,
'customvars' => null,
'comments' => null,
'downtimes' => null
);
public function stateName()
@ -30,7 +31,8 @@ class Host extends AbstractObject
->fetchContacts()
->fetchContactgroups()
->fetchCustomvars()
->fetchComments();
->fetchComments()
->fetchDowtimes();
}
protected function fetchObject()
@ -41,6 +43,7 @@ class Host extends AbstractObject
'host_address',
'host_state',
'host_handled',
'host_in_downtime',
'in_downtime' => 'host_in_downtime',
'host_acknowledged',
'host_last_state_change',

View File

@ -12,6 +12,7 @@ class Service extends AbstractObject
'contactgroups' => null,
'customvars' => null,
'comments' => null,
'downtimes' => null
);
public function stateName()
@ -31,7 +32,8 @@ class Service extends AbstractObject
->fetchContacts()
->fetchContactgroups()
->fetchCustomvars()
->fetchComments();
->fetchComments()
->fetchDowtimes();
}
protected function fetchObject()

View File

@ -149,6 +149,22 @@ th {
border-bottom: 2px solid #ddd;
}
.table-detail th {
font-size: 16px;
border-top: 0;
}
.table-detail thead > tr > th, .table tbody > tr > th,
.table-detail tbody > tr > td, .table tfoot > tr > td {
border-top: 0 !important;
}
.table-detail > thead {
border-top: 0 !important;
}
td {
padding: 8px 10px 8px 8px !important;
border-bottom: 1px dotted #ddd !important;
@ -418,6 +434,16 @@ select.input-sm {
display: block;
}
.icon-table-hint {
width: 16px;
height: 20px;
display: block;
background-position: 50% 50%;
}
.icon-table-hint:after {
content: "edited";
padding-left: 22px;
}
.icon-flapping {
background-image: url('../img/icons/flapping.png');

View File

@ -54,7 +54,7 @@ define(['components/app/container', 'jquery'], function(Container, $) {
var submitHandler = function(e) {
var form = $(this);
var url = form.attr('action');
var submit = form.find('input[type="submit"]');
var submit = form.find('button[type="submit"]', 'input[type="submit"]');
var data = form.serialize();
e.preventDefault();