Using new PHP icon helper

This commit is contained in:
Alexander Klimov 2014-03-07 10:41:59 +01:00
parent 49127e3ac8
commit a4ed32d357
15 changed files with 122 additions and 222 deletions

View File

@ -116,7 +116,7 @@ class ReorderForm extends Form
'escape' => false,
'value' => 'btn_' . $this->getBackendName() . '_reorder_up',
'name' => 'btn_' . $this->getBackendName() . '_reorder_up',
'label' => $this->getView()->img('img/icons/up.png', array('title' => 'Move up in authentication order')),
'label' => $this->getView()->icon('up.png', 'Move up in authentication order'),
)
);
}
@ -138,7 +138,7 @@ class ReorderForm extends Form
'escape' => false,
'value' => 'btn_' . $this->getBackendName() . '_reorder_down',
'name' => 'btn_' . $this->getBackendName() . '_reorder_down',
'label' => $this->getView()->img('img/icons/down.png', array('title' => 'Move down in authentication order')),
'label' => $this->getView()->icon('down.png', 'Move down in authentication order'),
)
);

View File

@ -397,7 +397,7 @@ class GeneralForm extends Form
'type' => 'submit',
'escape' => false,
'value' => '1',
'label' => $this->getView()->img('img/icons/save.png', array('title' => 'Save Changes'))
'label' => $this->getView()->icon('save.png', 'Save Changes')
. ' Save changes',
)
);

View File

@ -14,9 +14,9 @@ $createDbBackend = $this->href('/config/createAuthenticationBackend', array('typ
<h1>Create Authentication Provider</h1>
<p>
<a href="<?= $createLdapBackend ?>"><?= $this->img('img/icons/create.png'); ?> Create A New LDAP Authentication Backend</a>
<a href="<?= $createLdapBackend ?>"><?= $this->icon('create.png'); ?> Create A New LDAP Authentication Backend</a>
<br />
<a href="<?= $createDbBackend ?>"><?= $this->img('img/icons/create.png'); ?> Create A New DB Authentication Backend</a>
<a href="<?= $createDbBackend ?>"><?= $this->icon('create.png'); ?> Create A New DB Authentication Backend</a>
</p>
<table class="configTable">
@ -31,10 +31,10 @@ $createDbBackend = $this->href('/config/createAuthenticationBackend', array('typ
<?= $backend->reorderForm; ?>
</div>
<a href="<?= $this->href('config/editAuthenticationBackend', array('auth_backend' => $backend->name));?>">
<?= $this->img('img/icons/edit.png'); ?> Edit</a>&emsp;
<?= $this->icon('edit.png'); ?> Edit</a>&emsp;
<?php if (count($this->backends) > 1): ?>
<a href="<?= $this->href('config/removeAuthenticationBackend', array('auth_backend' => $backend->name));?>">
<?= $this->img('img/icons/remove.png'); ?> Remove</a>&emsp;
<?= $this->icon('remove.png'); ?> Remove</a>&emsp;
<?php endif; ?>
</div>
</td>

View File

@ -12,7 +12,7 @@ $createResource = $this->href('/config/createresource');
<?php endif ?>
<h1>Create Resource</h1>
<p><a href="<?= $createResource ?>"><?= $this->img('img/icons/create.png'); ?> Create A New Resource</a></p>
<p><a href="<?= $createResource ?>"><?= $this->icon('create.png'); ?> Create A New Resource</a></p>
<table class="configTable">
<?php foreach ($this->resources as $name => $resource): ?>
@ -23,10 +23,10 @@ $createResource = $this->href('/config/createresource');
</div>
<div>
<a href="<?= $this->href('config/editresource', array('resource' => $name));?>">
<?= $this->img('img/icons/edit.png'); ?> Edit</a>&emsp;
<?= $this->icon('edit.png'); ?> Edit</a>&emsp;
<?php if (count($this->resources) > 1): ?>
<a href="<?= $this->href('config/removeresource', array('resource' => $name));?>">
<?= $this->img('img/icons/remove.png'); ?> Remove</a>&emsp;
<?= $this->icon('remove.png'); ?> Remove</a>&emsp;
<?php endif; ?>
</div>
</td>

View File

@ -86,7 +86,7 @@ class ConfirmRemovalForm extends Form
'escape' => false,
'value' => '1',
'class' => 'btn btn-cta btn-common',
'label' => $this->view->img('img/icons/remove.png') . ' Confirm Removal'
'label' => $this->view->icon('remove.png') . ' Confirm Removal'
)
);
}

View File

@ -12,7 +12,7 @@
<p>
<a href="<?= Url::fromPath('/monitoring/config/createbackend')->getAbsoluteUrl();?>">
<?= $this->img('img/icons/create.png'); ?> Create New Monitoring Backend
<?= $this->icon('create.png'); ?> Create New Monitoring Backend
</a>
</p>
@ -27,8 +27,8 @@
<b><?= $this->escape($backendName); ?></b>
<small>(Type: <?= $this->escape($config['type'] === 'ido' ? 'IDO' : ucfirst($config['type'])); ?>)</small>
<div>
<a href="<?= $removeUrl; ?>"><?= $this->img('img/icons/remove.png'); ?> Remove</a>&emsp;
<a href="<?= $editUrl; ?>"><?= $this->img('img/icons/edit.png'); ?> Edit</a>
<a href="<?= $removeUrl; ?>"><?= $this->icon('remove.png'); ?> Remove</a>&emsp;
<a href="<?= $editUrl; ?>"><?= $this->icon('edit.png'); ?> Edit</a>
</div>
</td>
</tr>
@ -39,7 +39,7 @@
<p>
<a href="<?= Url::fromPath('/monitoring/config/createinstance')->getAbsoluteUrl();?>">
<?= $this->img('img/icons/create.png'); ?> Create New Instance
<?= $this->icon('create.png'); ?> Create New Instance
</a>
</p>
@ -55,8 +55,8 @@
<b><?= $this->escape($instanceName); ?></b>
<small>(Type: <?= isset($config['host']) ? 'Remote' : 'Local'; ?>)</small>
<div>
<a href="<?= $removeUrl; ?>"><?= $this->img('img/icons/remove.png'); ?> Remove</a>&emsp;
<a href="<?= $editUrl; ?>"><?= $this->img('img/icons/edit.png'); ?> Edit</a>
<a href="<?= $removeUrl; ?>"><?= $this->icon('remove.png'); ?> Remove</a>&emsp;
<a href="<?= $editUrl; ?>"><?= $this->icon('edit.png'); ?> Edit</a>
</div>
</div>
</td>

View File

@ -45,9 +45,9 @@ $viewHelper = $this->getHelper('MonitoringState');
<td>
<?php if ($comment->comment_objecttype_id === '1'): ?>
<?= $this->img('img/icons/host.png', array('title' => 'Host comment')) ?>
<?= $this->icon('host.png', 'Host comment') ?>
<?php elseif ($comment->comment_objecttype_id === '2'): ?>
<?= $this->img('img/icons/service.png', array('title' => 'Service comment')) ?>
<?= $this->icon('service.png', 'Service comment') ?>
<?php endif; ?>
<small>
<?php
@ -68,7 +68,7 @@ $viewHelper = $this->getHelper('MonitoringState');
$tooltip = 'Comment was caused by an acknowledgement.';
}
?>
<?= $this->img('img/icons/' . $icon . '.png', array('title' => $tooltip)) ?>
<?= $this->icon($icon . '.png', $tooltip) ?>
</small>
</td>

View File

@ -32,52 +32,36 @@ if ($hosts->count() === 0) {
$icons = array();
if (!$host->host_handled && $host->host_state > 0){
$icons[] = $this->img('img/icons/unhandled.png', array(
'title' => 'Unhandled'
));
$icons[] = $this->icon('unhandled.png', 'Unhandled');
}
if ($host->host_acknowledged && !$host->host_in_downtime) {
$icons[] = $this->img('img/icons/acknowledgement.png', array(
'title' => 'Acknowledged'
));
$icons[] = $this->icon('acknowledgement.png', 'Acknowledged');
}
if ($host->host_is_flapping) {
$icons[] = $this->img('img/icons/flapping.png', array(
'title' => 'Flapping'
));
$icons[] = $this->icon('flapping.png', 'Flapping');
}
if (!$host->host_notifications_enabled) {
$icons[] = $this->img('img/icons/notification_disabled.png', array(
'title' => 'Notifications Disabled'
));
$icons[] = $this->icon('notification_disabled.png', 'Notifications Disabled');
}
if (!$host->host_in_downtime) {
$icons[] = $this->img('img/icons/in_downtime.png', array(
'title' => 'In Downtime'
));
$icons[] = $this->icon('in_downtime.png', 'In Downtime');
}
if (!$host->host_active_checks_enabled) {
if (!$host->host_passive_checks_enabled) {
$icons[] = $this->img('img/icons/active_passive_checks_disabled.png', array(
'title' => 'Active And Passive Checks Disabled'
));
$icons[] = $this->icon('active_passive_checks_disabled.png', 'Active And Passive Checks Disabled');
} else {
$icons[] = $this->img('img/icons/active_checks_disabled.png', array(
'title' => 'Active Checks Disabled'
));
$icons[] = $this->icon('active_checks_disabled.png', 'Active Checks Disabled');
}
}
// Not available right now:
if (isset($host->host_last_comment) && $host->host_last_comment !== null) {
$icons[] = $this->img('img/icons/comment.png', array(
'title' => 'Comments'
));
$icons[] = $this->icon('comment.png', 'Comments');
}
?>
<tr class="state <?= $hostStateName ?><?= $host->host_handled ? ' handled' : '' ?>">

View File

@ -1,115 +0,0 @@
<div class="row">
<div class="pull-left">
<h1>Servicegroups</h1>
</div>
<div class="pull-right">
<?= $this->tabs->render($this); ?>
</div>
</div>
<div data-icinga-component="app/mainDetailGrid" data-icinga-grid-selection-type="single">
<div class="container pull-left">
<div class="row">
<div class="col-md-12">
<?= $this->sortControl->render($this); ?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?= $this->paginationControl($servicegroups, null, null, array('preserve' => $this->preserve)); ?>
</div>
</div>
<br />
<div class="row">
<?= $this->selectionToolbar('single'); ?>
</div>
</div>
<table class="table table-condensed pull-left">
<tbody>
<?php foreach($servicegroups as $servicegroup): ?>
<tr>
<td>
<a href="<?= $this->href('monitoring/list/services', array('servicegroup' => $servicegroup->servicegroup)); ?>">
<?= $servicegroup->servicegroup; ?>
</a>
</td>
<td>
<div class="nav navbar-nav topbar-host-status-summary">
<span class="topbar-status-up">
<a href="<?= $this->href('monitoring/list/hosts', array('host_state' => 0, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Hosts Up">
<?= $servicegroup->hosts_up ?>
</a>
</span>
<span class="topbar-status-down">
<a href="<?= $this->href('monitoring/list/hosts', array('host_state' => 1, 'host_unhandled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Hosts Down Unhandled">
<?= $servicegroup->hosts_down_unhandled ?>
</a>/
<a href="<?= $this->href('monitoring/list/hosts', array('host_state' => 1, 'host_handled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Hosts Down Handled">
<?= $servicegroup->hosts_down_handled ?>
</a>
</span>
<span class="topbar-status-unreachable">
<a href="<?= $this->href('monitoring/list/hosts', array('host_state' => 2, 'host_unhandled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Hosts Unreachable Unhandled">
<?= $servicegroup->hosts_unreachable_unhandled ?>
</a>/
<a href="<?= $this->href('monitoring/list/hosts', array('host_state' => 2, 'host_handled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Hosts Unreachable Handled">
<?= $servicegroup->hosts_unreachable_handled ?>
</a>
</span>
<span class="topbar-status-pending">
<a href="<?= $this->href('monitoring/list/hosts', array('host_state' => 99)); ?>" title="Hosts Pending">
<?= $servicegroup->hosts_pending ?>
</a>
</span>
</div>
</td>
<td>
<div class="nav navbar-nav topbar-service-status-summary">
<span class="topbar-status-ok">
<a href="<?= $this->href('monitoring/list/services', array('service_state' => 0, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Services Ok">
<?= $servicegroup->services_ok ?>
</a>
</span>
<span class="topbar-status-critical">
<a href="<?= $this->href('monitoring/list/services', array('service_state' => 2, 'service_unhandled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Services Critical Unhandled">
<?= $servicegroup->services_critical_unhandled ?>
</a>/
<a href="<?= $this->href('monitoring/list/services', array('service_state' => 2, 'service_handled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Services Critical Handled">
<?= $servicegroup->services_critical_handled ?>
</a>
</span>
<span class="topbar-status-warning">
<a href="<?= $this->href('monitoring/list/services', array('service_state' => 1, 'service_unhandled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Services Warning Unhandled">
<?= $servicegroup->services_warning_unhandled ?>
</a>/
<a href="<?= $this->href('monitoring/list/services', array('service_state' => 1, 'service_handled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Services Warning Handled">
<?= $servicegroup->services_warning_handled ?>
</a>
</span>
<span class="topbar-status-unknown">
<a href="<?= $this->href('monitoring/list/services', array('service_state' => 3, 'service_unhandled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Services Unknown Unhandled">
<?= $servicegroup->services_unknown_unhandled ?>
</a>/
<a href="<?= $this->href('monitoring/list/services', array('service_state' => 3, 'service_handled' => 1, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Services Unknown Handled">
<?= $servicegroup->services_unknown_handled ?>
</a>
</span>
<span class="topbar-status-pending">
<a href="<?= $this->href('monitoring/list/services', array('service_state' => 99, 'servicegroup' => $servicegroup->servicegroup)); ?>" title="Services Pending">
<?= $servicegroup->services_pending ?>
</a>
</span>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="container pull-left">
<?= $this->paginationControl($servicegroups, null, null, array('preserve' => $this->preserve)); ?>
</div>
</div>

View File

@ -73,21 +73,18 @@ foreach ($services as $service):
<?php if (!$service->service_active_checks_enabled): ?>
<?php if (!$service->service_passive_checks_enabled): ?>
<?= $this->icon(
'active_passive_checks_disabled.png',
'Active And Passive Checks Disabled'
) ?>
<?= $this->icon('active_passive_checks_disabled.png', 'Active And Passive Checks Disabled') ?>
<?php else: ?>
<?= $this->icon('active_checks_disabled.png', 'Active Checks Disabled') ?>
<?= $this->icon('active_checks_disabled.png', 'Active Checks Disabled') ?>
<?php endif ?>
<?php endif ?>
<?php if ($service->service_icon_image): ?>
<?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
<?= $this->img($this->resolveMacros($service->service_icon_image, $service), array('align' => 'left')) ?>
<?php endif ?>
<a href="<?= $serviceLink ?>"><?= $service->service_display_name ?></a> on <a href="<?= $hostLink ?>"><?= $service->host_name; ?>
<?php if ($service->host_state != 0): ?>
(<?= ucfirst($helper->monitoringState($service, 'host')); ?>)
(<?= ucfirst($helper->monitoringState($service, 'host')); ?>)
<?php endif ?>
</a><br />
<p class="pluginoutput"><?= $this->escape(substr(strip_tags($service->service_output), 0, 10000)); ?></p>

View File

@ -8,7 +8,7 @@
$this->target
);
?>" class="btn-common btn-small button">
<?= $this->img('img/icons/comment.png') ?>
<?= $this->icon('comment.png') ?>
</a>
<a rel="tooltip" title="Send custom notifications for all selected hosts or services" href="<?=
@ -17,7 +17,7 @@
$this->target
);
?>" class="btn-common btn-small button">
<?= $this->img('img/icons/notification.png') ?>"></i>
<?= $this->icon('notification.png') ?>"></i>
</a>
</div>
@ -43,7 +43,7 @@
$this->target
);
?>" class="button btn-common btn-small input-sm pull-right">
<?= $this->img('img/icons/remove.png') ?>"></i>
<?= $this->icon('remove.png') ?>"></i>
</a>
<?php } else { ?>
There are 0 comments assigned to the selected items.

View File

@ -8,7 +8,7 @@
$this->target
);
?>" class="button btn-common btn-small input-sm pull-right">
<?= $this->img('img/icons/in_downtime.png') ?>
<?= $this->icon('in_downtime.png') ?>
</a>
</div>
@ -30,7 +30,7 @@
$this->target
);
?>" class="button btn-common btn-small input-sm pull-right">
<?= $this->img('img/icons/remove.png') ?>
<?= $this->icon('remove.png') ?>
</a>
<?php } else { ?>
0 Selected items are currently in downtime.

View File

@ -1,5 +1,6 @@
<?php
/** @var Zend_View_Helper_CommandForm $cf */
$cf = $this->getHelper('CommandForm');
$data = array('host' => $object->host_name);
@ -7,43 +8,59 @@ 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(),
array($this->tickets, 'createLink'),
$this->escape($comment->comment_data)
) : $this->escape($comment->comment_data);
$deleteData = $data;
$deleteData['commentid'] = $object->comment_internal_id;
$iconForm = $cf->iconSubmitForm(
'img/icons/remove.png',
'Remove comment',
'btn-small',
'removecomment',
$deleteData
);
$list[] = sprintf(
"<br />%s [%s] %s (%s): %s\n",
//'<input type="submit" value="x" style="width: 2em" />',
'<a href="#">' . $this->icon('remove_petrol.png') . '</a>' . $iconForm, // Test
$this->escape($comment->comment_author),
$this->timeSince($comment->comment_timestamp),
$comment->comment_type,
$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>
<?= implode('', $list) ?>
</td>
</tr>
<div>
<div class="panel-heading">
<div class="panel-hostname">
Comments
<?php
?>
<div class="pull-right">
<a rel="tooltip" title="Add a comment" href="<?= $this->href('monitoring/command/addComment', $data) ?>" class="btn-common btn-small button"><?=
$this->icon('comment.png')
?></a>
<a rel="tooltip" title="Send custom notification" href="<?= $this->href('monitoring/command/sendCustomNotification', $data
) ?>" class="btn-common btn-small button">
<?= $this->icon('notification.png') ?>
</a>
</div>
</div>
</div>
<hr class="separator" />
<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">
<?php
$deleteData = $data;
$deleteData['commentid'] = $comment->comment_internal_id;
echo $cf->iconSubmitForm(
'img/icons/remove.png',
'Remove comment',
'btn-small',
'removecomment',
$deleteData
);
?>
</div>
<?= $this->escape($comment->comment_author); ?>, <?= $comment->comment_type; ?>
(<?= $this->format()->timeSince($comment->comment_timestamp); ?>)
<div class="small-row">
<?= $this->escape($comment->comment_data); ?>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>

View File

@ -12,7 +12,7 @@
$scheduleDowntimeHref = $this->href('monitoring/command/scheduleDowntime', $scheduleDowntimeData);
?>
<a href="<?= $scheduleDowntimeHref; ?>" class="btn-common btn-small button" title="Schedule downtime">
<?= $this->img('img/icons/in_downtime.png') ?>
<?= $this->icon('in_downtime.png') ?>
</a>
</div>
Downtimes

View File

@ -1,10 +1,6 @@
<?php
use Icinga\Module\Monitoring\Object\Service;
$o = $this->object;
$isService = $o instanceof Service;
$isService = (isset($o->service_description)) ? true : false;
$obj = new \stdClass();
$obj->handled =
($isService) ? $o->service_handled : $o->host_handled;
@ -14,36 +10,57 @@ use Icinga\Module\Monitoring\Object\Service;
($isService) ? $o->service_acknowledged : $o->host_acknowledged;
$obj->in_downtime =
($isService) ? $o->in_downtime : $o->host_in_downtime;
$obj->is_flapping =
($isService) ? $o->is_flapping : $o->host_is_flapping;
$obj->notifications_enabled =
($isService) ? $o->notifications_enabled : $o->service_notifications_enabled;
$obj->active_checks_enabled =
($isService) ? $o->active_checks_enabled : $o->host_active_checks_enabled;
$obj->passive_checks_enabled =
($isService) ? $o->passive_checks_enabled : $o->host_passive_checks_enabled;
$obj->last_comment =
($isService) ? $o->last_comment : $o->host_last_comment;
$i = array();
if (! $obj->handled && $obj->state > 0) {
$i[] = $this->icon('unhandled.png', 'Unhandled');
$i[] = $this->img('img/icons/unhandled.png', array('title' => 'Unhandled'));
}
if ($obj->acknowledged && ! $obj->in_downtime) {
$i[] = $this->icon('acknowledgement.png', 'Acknowledged');
}
if ($obj->is_flapping) {
$i[] = $this->icon('flapping.png', 'Flapping');
}
if (!$obj->notifications_enabled) {
$i[] = $this->icon('notification_disabled.png', 'Notifications Disabled');
$i[] = $this->img('img/icons/notification_disabled.png', array('title' => 'Notifications Disabled'));
}
if ($obj->in_downtime) {
$i[] = $this->icon('in_downtime.png', 'In Downtime');
$i[] = $this->img('img/icons/in_downtime.png', array('title' => 'In Downtime'));
}
if (! $obj->active_checks_enabled) {
if ($obj->passive_checks_enabled) {
$i[] = $this->icon('active_checks_disabled.png', 'Active Checks Disabled');
$i[] = $this->img(
'img/icons/active_checks_disabled.png',
array('title' => 'Active Checks Disabled')
);
} else {
$i[] = $this->icon('active_passive_checks_disabled.png', 'Active And Passive Checks Disabled');
$i[] = $this->img(
'img/icons/active_passive_checks_disabled.png',
array('title' => 'Active And Passive Checks Disabled')
);
}
}
?><?= implode("\n", $i) ?>
if ($obj->last_comment !== null) {
$i[] = $this->icon('comment.png', 'Comments');
}
?><span>
<?= implode("\n ", $i) . "\n" ?>
</span>