From a69c7498ec088350a5c83bc015671b3deee54e1f Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Mon, 14 Oct 2013 18:17:58 +0200 Subject: [PATCH 1/5] Style comments, cowntimes, properties, flags in detail pane [WIP] refs #4869 --- .../scripts/show/components/comments.phtml | 12 ++ .../scripts/show/components/customvars.phtml | 26 ++-- .../scripts/show/components/downtime.phtml | 70 +++++++++-- .../views/scripts/show/components/flags.phtml | 64 +++++++--- .../scripts/show/components/properties.phtml | 117 ++++-------------- .../application/views/scripts/show/host.phtml | 17 +-- .../views/scripts/show/service.phtml | 1 + .../Monitoring/Object/AbstractObject.php | 29 +++++ .../library/Monitoring/Object/Host.php | 5 +- .../library/Monitoring/Object/Service.php | 4 +- public/css/main.css | 26 ++++ .../icinga/components/ajaxPostSubmitForm.js | 2 +- 12 files changed, 219 insertions(+), 154 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index adcb9e9d3..fff7bd1f9 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -32,9 +32,21 @@
+ comments)): ?> + + + + comments as $comment): ?> diff --git a/public/js/icinga/components/ajaxPostSubmitForm.js b/public/js/icinga/components/ajaxPostSubmitForm.js index f76882752..a6ece8fe8 100644 --- a/public/js/icinga/components/ajaxPostSubmitForm.js +++ b/public/js/icinga/components/ajaxPostSubmitForm.js @@ -70,13 +70,13 @@ define(['components/app/container', 'jquery'], function(Container, $) { type: 'POST', data: data, beforeSend: function() { - submit.prop('disabled', true); + submit.attr('disabled', true); } }).done(function() { var container = getOwnerContainer(form); container.replaceDomFromUrl(container.getContainerHref()); }).error(function() { - submit.removeProp('disabled'); + submit.removeAttr('disabled'); }); }; diff --git a/public/js/icinga/components/mainDetailGrid.js b/public/js/icinga/components/mainDetailGrid.js index cc6093794..da8232413 100644 --- a/public/js/icinga/components/mainDetailGrid.js +++ b/public/js/icinga/components/mainDetailGrid.js @@ -125,13 +125,17 @@ function(Container, $, logger, URI) { var targetEl = ev.target || ev.toElement || ev.relatedTarget, a = $(targetEl).closest('a'); + var nodeNames = []; + nodeNames.push($(targetEl).prop('nodeName').toLowerCase()); + nodeNames.push($(targetEl).parent().prop('nodeName').toLowerCase()); + if (a.length) { // test if the URL is on the current server, if not open it directly if (true || Container.isExternalLink(a.attr('href'))) { return true; } - } else if (targetEl.nodeName.toLowerCase() === 'input') { - var type = $(targetEl).attr('type'); + } else if ($.inArray('input', nodeNames) > -1 || $.inArray('button', nodeNames) > -1) { + var type = $(targetEl).attr('type') || $(targetEl).parent().attr('type'); if (type === 'submit') { return true; } From 6f51f40fc0f7c70e5c62676d31278ab421ffe97c Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 15 Oct 2013 16:23:46 +0200 Subject: [PATCH 4/5] Add real command button to detail panel refs #4869 --- .../forms/Command/ScheduleDowntimeForm.php | 2 +- .../application/views/helpers/CommandForm.php | 1 - .../scripts/show/components/comments.phtml | 21 +++++-- .../scripts/show/components/status.phtml | 61 +++++++++++++++---- .../Monitoring/Object/AbstractObject.php | 1 + 5 files changed, 68 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php b/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php index a07777778..d690091db 100644 --- a/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php +++ b/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php @@ -88,7 +88,7 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm $cfg = $this->getConfiguration(); $preferences = $this->getUserPreferences(); - $downtimes = Backend::getInstance($this->getRequest()->getParam('backend'))->select() + $downtimes = Backend::createBackend($this->getRequest()->getParam('backend'))->select() ->from( 'downtime', array( diff --git a/modules/monitoring/application/views/helpers/CommandForm.php b/modules/monitoring/application/views/helpers/CommandForm.php index d93f7eeff..66803128c 100644 --- a/modules/monitoring/application/views/helpers/CommandForm.php +++ b/modules/monitoring/application/views/helpers/CommandForm.php @@ -72,7 +72,6 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract public function labelSubmitForm($submitLabel, $submitTitle, $cls, $commandName, array $arguments = array()) { $form = $this->simpleForm($commandName, $arguments); - $button = new Zend_Form_Element_Button( array( 'name' => 'btn_submit', diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index fff7bd1f9..aa0d9a02f 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -1,3 +1,7 @@ +getHelper('CommandForm'); +?>
@@ -41,11 +45,18 @@
- + diff --git a/public/css/main.css b/public/css/main.css index 7726c1d6a..51bb1a7b0 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -83,6 +83,13 @@ a { text-decoration: none; } +a.button { + height: 30px; +} + +a.btn-small { + height: 25px; +} /** * Address `outline` inconsistency between Chrome and other browsers. */ @@ -239,6 +246,9 @@ td { Forms ========================================================================== */ +.panel-row form { + display: inline; +} .form-inline .form-group { display: inline-block; @@ -258,11 +268,7 @@ label { .input-sm { border-radius: 3px; font-size: 16px; - - padding: 5px; - margin-right: 15px; - } .form-control { background-color: #FFFFFF;
No comments
+
+
+ +
+
escape($comment->comment_author); ?>, comment_type; ?> (format()->timeSince($comment->comment_timestamp); ?>)
diff --git a/modules/monitoring/application/views/scripts/show/components/customvars.phtml b/modules/monitoring/application/views/scripts/show/components/customvars.phtml index a4419729f..093052245 100644 --- a/modules/monitoring/application/views/scripts/show/components/customvars.phtml +++ b/modules/monitoring/application/views/scripts/show/components/customvars.phtml @@ -1,23 +1,13 @@ - -
+
- Customvariables +
+ Custom Variables +
+
+
- customvars) && count($object->customvars)) { ?> - - - - - - customvars as $name => $value) { ?> - - - - - -
NameValue
escape($name) ?>escape($value) ?>
- + object); ?>
-
+
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 0eaa14b3d..9003e0184 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -28,20 +28,68 @@ } ?> -
+
- {{IN_DOWNTIME_ICON}}Downtimes +
+ +
+ $this->object->host_name, + 'service' => $this->object->service_description + ); + + $scheduleDowntimeHref = $this->href('monitoring/command/scheduleDowntime', $scheduleDowntimeData); + ?> + + + +
+ Downtimes +
+
- {{SCHEDULE_DOWNTIME_COMMAND_BUTTON}}
- downtimes)): ?> - - - ', $list); ?> - +
+ + object->downtimes)): ?> + + + + + object->downtimes as $downtime): ?> + + + + +
No Downtimes
+
+
+ + + + + +
+
+ downtime_is_in_effect === '1'): ?> + Running since timeSince($downtime->downtime_actual_start_time); ?> + + downtime_is_fixed): ?> + Scheduled for downtime_scheduled_start_time; ?> + + Waiting + + + + Triggered by downtime_author_name; ?> + +
+ downtime_comment_data; ?> +
+
- - Not in downtime -
diff --git a/modules/monitoring/application/views/scripts/show/components/flags.phtml b/modules/monitoring/application/views/scripts/show/components/flags.phtml index 68b50c44a..222e23c4e 100644 --- a/modules/monitoring/application/views/scripts/show/components/flags.phtml +++ b/modules/monitoring/application/views/scripts/show/components/flags.phtml @@ -1,22 +1,50 @@ -
-
Heading
+object; +?> +
+
+
+ Configuration +
+
+ +
+
- - monitoringFlags($object) as $flag => $enabled): ?> - - - - - - +
- - {{ENABLED_ICON}} ENABLED - - {{DISABLED_ICON}} DISABLED - - - {{{ENABLE_OR_DISABLE_COMMAND}}} -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Passive Checks
passive_checks_enabled === '1') ? 'checked="true"' : '' ?> />
Active Checksactive_checks_enabled === '1') ? 'checked="true"' : '' ?> />
Obsessingobsessing === '1') ? 'checked="true"' : '' ?> />
Notificationsnotifications_enabled === '1') ? 'checked="true"' : '' ?> />
Event Handlerevent_handler_enabled === '1') ? 'checked="true"' : '' ?> />
Flap Detectionflap_detection_enabled === '1') ? 'checked="true"' : '' ?> />
diff --git a/modules/monitoring/application/views/scripts/show/components/properties.phtml b/modules/monitoring/application/views/scripts/show/components/properties.phtml index 37fc1ebc1..23e71ac60 100644 --- a/modules/monitoring/application/views/scripts/show/components/properties.phtml +++ b/modules/monitoring/application/views/scripts/show/components/properties.phtml @@ -1,93 +1,26 @@ -
-
Properties
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
Current Attempt - current_check_attempt, - $object->max_check_attempts, - ($object->state_type === '1') ? 'HARD' : 'SOFT' - ); ?> -
Check Type - passive_checks_enabled === '1' && $object->active_checks_enabled === '0'): ?> - PASSIVE - passive_checks_enabled === '0' && $object->active_checks_enabled === '0'): ?> - DISABLED - - ACTIVE - -
Check Latency / Duration - passive_checks_enabled === '0' && $object->active_checks_enabled === '0'): ?> - N/A - - check_latency); ?> / check_execution_time); ?> seconds - -
Last Notification - 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 - ) - ); - } - ?> - - last_notification === '0000-00-00 00:00:00'): ?> - N/A - - last_notification ?> - current_notification_number > 0): ?> -
- current_notification_number ?> notifications sent during current problem state - - -
-
Is This service_description ? 'Service' : 'Host' ?> Flapping? - is_flapping === '1'): ?> - YES - - NO - - percent_state_change); ?>% state change -
In Scheduled Downtime? - in_downtime === '1'): ?> - YES - - NO - -
+
+
+
+ Check Statistics +
-
+ +
+
+
+
Latency
+
object->check_execution_time); ?>s
+
+
+
Duration
+
object->check_latency); ?>s
+
+
+
Attempt
+
+ object->current_check_attempt; ?>/object->max_check_attempts; ?> + (object->host_state_type === '1') ? 'Hard' : 'Soft'; ?>) +
+
+
+
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/host.phtml b/modules/monitoring/application/views/scripts/show/host.phtml index f54192e77..0b0166efd 100644 --- a/modules/monitoring/application/views/scripts/show/host.phtml +++ b/modules/monitoring/application/views/scripts/show/host.phtml @@ -1,17 +1,10 @@ +tabs->render($this); ?> render('show/components/status.phtml'); ?> - +render('show/components/comments.phtml'); ?> render('show/components/downtime.phtml'); ?> - render('show/components/properties.phtml'); ?> - render('show/components/flags.phtml'); ?> - -render('show/components/hostgroups.phtml'); ?> - -render('show/components/eventHistory.phtml'); ?> - -render('show/components/contacts.phtml'); ?> - render('show/components/customvars.phtml'); ?> - -render('show/components/command.phtml'); ?> +render('show/components/servicegroups.phtml'); ?> +render('show/components/contacts.phtml'); ?> +render('show/components/command.phtml') ?> diff --git a/modules/monitoring/application/views/scripts/show/service.phtml b/modules/monitoring/application/views/scripts/show/service.phtml index e3b322b08..0b0166efd 100644 --- a/modules/monitoring/application/views/scripts/show/service.phtml +++ b/modules/monitoring/application/views/scripts/show/service.phtml @@ -2,6 +2,7 @@ render('show/components/status.phtml'); ?> render('show/components/comments.phtml'); ?> render('show/components/downtime.phtml'); ?> +render('show/components/properties.phtml'); ?> render('show/components/flags.phtml'); ?> render('show/components/customvars.phtml'); ?> render('show/components/servicegroups.phtml'); ?> diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index 799fe171e..40ae632b5 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -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; + } } diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 1a2b69ca5..ad540d49d 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -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', diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 602380dcb..17e693acd 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -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() diff --git a/public/css/main.css b/public/css/main.css index d6422a464..7726c1d6a 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -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'); diff --git a/public/js/icinga/components/ajaxPostSubmitForm.js b/public/js/icinga/components/ajaxPostSubmitForm.js index 1547c816a..f76882752 100644 --- a/public/js/icinga/components/ajaxPostSubmitForm.js +++ b/public/js/icinga/components/ajaxPostSubmitForm.js @@ -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(); From d6fd3350e0c3d29ed229e0f30cc23304bac06508 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 15 Oct 2013 12:48:33 +0200 Subject: [PATCH 2/5] Apply style to detail refs #4869 --- .../scripts/show/components/command.phtml | 9 +- .../scripts/show/components/contacts.phtml | 34 ++-- .../scripts/show/components/customvars.phtml | 11 +- .../scripts/show/components/downtime.phtml | 3 +- .../scripts/show/components/hostgroups.phtml | 19 ++- .../scripts/show/components/properties.phtml | 4 - .../show/components/servicegroups.phtml | 17 +- .../application/views/scripts/show/host.phtml | 2 +- .../library/Monitoring/DataView/Customvar.php | 65 ++++++++ .../Monitoring/Object/AbstractObject.php | 144 +++++++++++------ .../library/Monitoring/Object/Host.php | 134 +++++++++++----- .../library/Monitoring/Object/Service.php | 150 ++++++++++++------ 12 files changed, 426 insertions(+), 166 deletions(-) create mode 100644 modules/monitoring/library/Monitoring/DataView/Customvar.php diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index 3e30b62e8..6e76bbfc6 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -1,9 +1,12 @@ -
+
- {{CHECK_COMMAND_ICON}} - Check Command +
+ Check Command +
+
+
diff --git a/modules/monitoring/application/views/scripts/show/components/contacts.phtml b/modules/monitoring/application/views/scripts/show/components/contacts.phtml index 3256d3ac6..cbd1a8bb4 100644 --- a/modules/monitoring/application/views/scripts/show/components/contacts.phtml +++ b/modules/monitoring/application/views/scripts/show/components/contacts.phtml @@ -1,4 +1,3 @@ -contacts)): ?> contacts as $contact) { @@ -14,17 +13,24 @@ foreach ($object->contacts as $contact) { . ''; } ?> -
+
- {{CONTACT_ICON}} Contacts +
+ Contacts +
+ +
+
- + + No Contacts + + +
- -contactgroups)): ?> contactgroups as $contactgroup) { @@ -40,12 +46,20 @@ foreach ($object->contactgroups as $contactgroup) { . ''; } ?> -
+
- {{CONTACTGROUP_ICON}} Contactgroups +
+ Contactgroups +
+ +
+
- + + No Contactgroups + + +
- diff --git a/modules/monitoring/application/views/scripts/show/components/customvars.phtml b/modules/monitoring/application/views/scripts/show/components/customvars.phtml index 093052245..e3ba9563b 100644 --- a/modules/monitoring/application/views/scripts/show/components/customvars.phtml +++ b/modules/monitoring/application/views/scripts/show/components/customvars.phtml @@ -8,6 +8,15 @@
- object); ?> + object->customvars)): ?> + No customvars + +
+ object->customvars as $varname => $varvalue): ?> +
+
+ +
+
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 9003e0184..e38b10a14 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -56,7 +56,7 @@
- + object->downtimes as $downtime): ?> +
No Downtimes
@@ -89,6 +89,7 @@
diff --git a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml index d33ccd590..ffc8c501f 100644 --- a/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/hostgroups.phtml @@ -1,4 +1,3 @@ -hostgroups)): ?> hostgroups as $name => $alias) { @@ -7,12 +6,20 @@ foreach ($object->hostgroups as $name => $alias) { . ''; } ?> -
+
- {{HOSTGROUP_ICON}} Hostgroups +
+ Hostgroups +
+ +
+
- + + No Hostgroups + + +
-
- +
\ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/show/components/properties.phtml b/modules/monitoring/application/views/scripts/show/components/properties.phtml index 23e71ac60..161031060 100644 --- a/modules/monitoring/application/views/scripts/show/components/properties.phtml +++ b/modules/monitoring/application/views/scripts/show/components/properties.phtml @@ -10,12 +10,8 @@
Latency
object->check_execution_time); ?>s
-
-
Duration
object->check_latency); ?>s
-
-
Attempt
object->current_check_attempt; ?>/object->max_check_attempts; ?> diff --git a/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml b/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml index d2fdbceaf..5f79db497 100644 --- a/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml +++ b/modules/monitoring/application/views/scripts/show/components/servicegroups.phtml @@ -1,4 +1,3 @@ -servicegroups)): ?> servicegroups as $name => $alias) { @@ -7,12 +6,20 @@ foreach ($object->servicegroups as $name => $alias) { . ''; } ?> -
+
- {{SERVICEGROUP_ICON}} Servicegroups +
+ Servicegroups +
+ +
+
- + + No Servicegroups + + +
- diff --git a/modules/monitoring/application/views/scripts/show/host.phtml b/modules/monitoring/application/views/scripts/show/host.phtml index 0b0166efd..8c482053b 100644 --- a/modules/monitoring/application/views/scripts/show/host.phtml +++ b/modules/monitoring/application/views/scripts/show/host.phtml @@ -5,6 +5,6 @@ render('show/components/properties.phtml'); ?> render('show/components/flags.phtml'); ?> render('show/components/customvars.phtml'); ?> -render('show/components/servicegroups.phtml'); ?> +render('show/components/hostgroups.phtml'); ?> render('show/components/contacts.phtml'); ?> render('show/components/command.phtml') ?> diff --git a/modules/monitoring/library/Monitoring/DataView/Customvar.php b/modules/monitoring/library/Monitoring/DataView/Customvar.php new file mode 100644 index 000000000..fab68204b --- /dev/null +++ b/modules/monitoring/library/Monitoring/DataView/Customvar.php @@ -0,0 +1,65 @@ + + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} + +namespace Icinga\Module\Monitoring\DataView; + +/** + * Represent customvar view + */ +class Customvar extends DataView +{ + /** + * Retrieve columns provided by this view + * + * @return array + */ + public function getColumns() + { + return array( + 'varname', + 'varvalue', + 'object_type' + ); + } + + /** + * Retrieve default sorting rules for particular columns. These involve sort order and potential additional to sort + * + * @return array + */ + public function getSortRules() + { + return array( + 'varname' => array( + 'varname' => self::SORT_ASC, + 'varvalue' => self::SORT_ASC, + ) + ); + } +} diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index 40ae632b5..33a653735 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -1,10 +1,40 @@ + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Module\Monitoring\Object; use Icinga\Data\AbstractQuery as Query; use \Icinga\Module\Monitoring\Backend; +/** + * Generic icinga object with belongings + */ abstract class AbstractObject { protected $backend; @@ -17,14 +47,7 @@ abstract class AbstractObject protected $properties; - protected $foreign = array( - // 'hostgroups' => null, - // 'contacts' => null, - // 'contactgroups' => null, - // 'servicegroups' => null, - // 'customvars' => null, - // 'comments' => null, - ); + protected $foreign = array(); public function __construct(Backend $backend, $name1, $name2 = null) { @@ -81,10 +104,13 @@ abstract class AbstractObject protected function fetchHostgroups() { $this->foreign['hostgroups'] = $this->applyObjectFilter( - $this->backend->select()->from('hostgroup', array( - 'hostgroup_name', - 'hostgroup_alias' - )) + $this->backend->select()->from( + 'hostgroup', + array( + 'hostgroup_name', + 'hostgroup_alias' + ) + ) )->fetchPairs(); return $this; } @@ -92,10 +118,13 @@ abstract class AbstractObject protected function fetchServicegroups() { $this->foreign['servicegroups'] = $this->applyObjectFilter( - $this->backend->select()->from('servicegroup', array( - 'servicegroup_name', - 'servicegroup_alias' - )) + $this->backend->select()->from( + 'servicegroup', + array( + 'servicegroup_name', + 'servicegroup_alias' + ) + ) )->fetchPairs(); return $this; } @@ -103,12 +132,15 @@ abstract class AbstractObject protected function fetchContacts() { $this->foreign['contacts'] = $this->applyObjectFilter( - $this->backend->select()->from('contact', array( - 'contact_name', - 'contact_alias', - 'contact_email', - 'contact_pager', - )) + $this->backend->select()->from( + 'contact', + array( + 'contact_name', + 'contact_alias', + 'contact_email', + 'contact_pager', + ) + ) )->fetchAll(); return $this; } @@ -116,10 +148,13 @@ abstract class AbstractObject protected function fetchContactgroups() { $this->foreign['contactgroups'] = $this->applyObjectFilter( - $this->backend->select()->from('contactgroup', array( - 'contactgroup_name', - 'contactgroup_alias', - )) + $this->backend->select()->from( + 'contactgroup', + array( + 'contactgroup_name', + 'contactgroup_alias', + ) + ) )->fetchAll(); return $this; } @@ -127,12 +162,15 @@ abstract class AbstractObject protected function fetchComments() { $this->foreign['comments'] = $this->applyObjectFilter( - $this->backend->select()->from('comment', array( - 'comment_timestamp', - 'comment_author', - 'comment_data', - 'comment_type', - ))->where('comment_objecttype_id', $this->type) + $this->backend->select()->from( + 'comment', + array( + 'comment_timestamp', + 'comment_author', + 'comment_data', + 'comment_type', + ) + )->where('comment_objecttype_id', $this->type) )->fetchAll(); return $this; } @@ -140,12 +178,13 @@ abstract class AbstractObject protected function fetchCustomvars() { $this->foreign['customvars'] = $this->applyObjectFilter( - $this->backend->select()->from('customvar', array( - 'varname', - 'varvalue' - )) - ->where('varname', '-*PW*,-*PASS*,-*COMMUNITY*') - ->where('object_type', 'host') + $this->backend->select()->from( + 'customvar', + array( + 'varname', + 'varvalue' + ) + )->where('varname', '-*PW*,-*PASS*,-*COMMUNITY*') )->fetchPairs(); return $this; } @@ -153,17 +192,20 @@ abstract class AbstractObject public function fetchEventHistory() { $this->foreign['eventHistory'] = $this->applyObjectFilter( - $this->backend->select()->from('eventHistory', array( - 'object_type', - 'host_name', - 'service_description', - 'timestamp', - 'state', - 'attempt', - 'max_attempts', - 'output', - 'type' - )) + $this->backend->select()->from( + 'eventHistory', + array( + 'object_type', + 'host_name', + 'service_description', + 'timestamp', + 'state', + 'attempt', + 'max_attempts', + 'output', + 'type' + ) + ) ); return $this; } @@ -171,7 +213,9 @@ abstract class AbstractObject public function fetchDowtimes() { $this->foreign['downtimes'] = $this->applyObjectFilter( - $this->backend->select()->from('downtime', array( + $this->backend->select()->from( + 'downtime', + array( 'host_name', 'object_type', 'service_host_name', diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index ad540d49d..13b312f13 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -1,9 +1,39 @@ + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Module\Monitoring\Object; use Icinga\Data\AbstractQuery as Query; +/** + * Represent a host object + */ class Host extends AbstractObject { protected $foreign = array( @@ -12,19 +42,35 @@ class Host extends AbstractObject 'contactgroups' => null, 'customvars' => null, 'comments' => null, - 'downtimes' => null + 'downtimes' => null, + 'customvars' => null ); + /** + * Statename + */ public function stateName() { // TODO } + /** + * Filter object belongings + * + * @param Query $query + * + * @return Query + */ protected function applyObjectFilter(Query $query) { return $query->where('host_name', $this->name1); } + /** + * Load foreign object data + * + * @return self + */ public function prefetch() { return $this->fetchHostgroups() @@ -32,48 +78,56 @@ class Host extends AbstractObject ->fetchContactgroups() ->fetchCustomvars() ->fetchComments() - ->fetchDowtimes(); + ->fetchDowtimes() + ->fetchCustomvars(); } + /** + * Load object data + * @return object + */ protected function fetchObject() { - return $this->backend->select()->from('status', array( - 'host_name', - 'host_alias', - 'host_address', - 'host_state', - 'host_handled', - 'host_in_downtime', - 'in_downtime' => 'host_in_downtime', - 'host_acknowledged', - 'host_last_state_change', - 'last_state_change' => 'host_last_state_change', - 'last_notification' => 'host_last_notification', - 'last_check' => 'host_last_check', - 'next_check' => 'host_next_check', - 'check_execution_time' => 'host_check_execution_time', - 'check_latency' => 'host_check_latency', - 'output' => 'host_output', - 'long_output' => 'host_long_output', - 'check_command' => 'host_check_command', - 'perfdata' => 'host_perfdata', - 'host_icon_image', - 'passive_checks_enabled' => 'host_passive_checks_enabled', - 'obsessing' => 'host_obsessing', - 'notifications_enabled' => 'host_notifications_enabled', - 'event_handler_enabled' => 'host_event_handler_enabled', - 'flap_detection_enabled' => 'host_flap_detection_enabled', - 'active_checks_enabled' => 'host_active_checks_enabled', - 'current_check_attempt' => 'host_current_check_attempt', - 'max_check_attempts' => 'host_max_check_attempts', - 'last_notification' => 'host_last_notification', - 'current_notification_number' => 'host_current_notification_number', - 'percent_state_change' => 'host_percent_state_change', - 'is_flapping' => 'host_is_flapping', - 'last_comment' => 'host_last_comment', - 'action_url' => 'host_action_url', - 'notes_url' => 'host_notes_url', - 'percent_state_change' => 'host_percent_state_change' - ))->where('host_name', $this->name1)->fetchRow(); + return $this->backend->select()->from( + 'status', + array( + 'host_name', + 'host_alias', + 'host_address', + 'host_state', + 'host_handled', + 'host_in_downtime', + 'in_downtime' => 'host_in_downtime', + 'host_acknowledged', + 'host_last_state_change', + 'last_state_change' => 'host_last_state_change', + 'last_notification' => 'host_last_notification', + 'last_check' => 'host_last_check', + 'next_check' => 'host_next_check', + 'check_execution_time' => 'host_check_execution_time', + 'check_latency' => 'host_check_latency', + 'output' => 'host_output', + 'long_output' => 'host_long_output', + 'check_command' => 'host_check_command', + 'perfdata' => 'host_perfdata', + 'host_icon_image', + 'passive_checks_enabled' => 'host_passive_checks_enabled', + 'obsessing' => 'host_obsessing', + 'notifications_enabled' => 'host_notifications_enabled', + 'event_handler_enabled' => 'host_event_handler_enabled', + 'flap_detection_enabled' => 'host_flap_detection_enabled', + 'active_checks_enabled' => 'host_active_checks_enabled', + 'current_check_attempt' => 'host_current_check_attempt', + 'max_check_attempts' => 'host_max_check_attempts', + 'last_notification' => 'host_last_notification', + 'current_notification_number' => 'host_current_notification_number', + 'percent_state_change' => 'host_percent_state_change', + 'is_flapping' => 'host_is_flapping', + 'last_comment' => 'host_last_comment', + 'action_url' => 'host_action_url', + 'notes_url' => 'host_notes_url', + 'percent_state_change' => 'host_percent_state_change' + ) + )->where('host_name', $this->name1)->fetchRow(); } } diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index 17e693acd..33cd4ff01 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -1,31 +1,82 @@ + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Module\Monitoring\Object; use Icinga\Data\AbstractQuery as Query; +/** + * Represent a single service + */ class Service extends AbstractObject { + /** + * Foreign references to objects + * + * @var array + */ protected $foreign = array( 'servicegroups' => null, 'contacts' => null, 'contactgroups' => null, 'customvars' => null, 'comments' => null, - 'downtimes' => null + 'downtimes' => null, + 'customvars' => null ); + /** + * Statename + */ public function stateName() { // TODO } + /** + * Filter foreign object belongings + * + * @param Query $query + * + * @return Query + */ protected function applyObjectFilter(Query $query) { return $query->where('service_host_name', $this->name1) ->where('service_description', $this->name2); } + /** + * Collect foreign data + * + * @return self + */ public function prefetch() { return $this->fetchServicegroups() @@ -33,54 +84,63 @@ class Service extends AbstractObject ->fetchContactgroups() ->fetchCustomvars() ->fetchComments() - ->fetchDowtimes(); + ->fetchDowtimes() + ->fetchCustomvars(); } + /** + * Load object data + * + * @return object + */ protected function fetchObject() { - return $this->backend->select()->from('status', array( - 'host_name', - 'host_alias', - 'host_address', - 'host_state', - 'host_handled', - 'host_in_downtime', - 'host_acknowledged', - 'host_last_state_change', - 'service_description', - 'service_state', - 'service_handled', - 'service_acknowledged', - 'service_in_downtime', - 'service_last_state_change', - 'last_check' => 'service_last_check', - 'next_check' => 'service_next_check', - 'check_execution_time' => 'service_check_execution_time', - 'check_latency' => 'service_check_latency', - 'output' => 'service_output', - 'long_output' => 'service_long_output', - 'check_command' => 'service_check_command', - 'perfdata' => 'service_perfdata', - 'current_check_attempt' => 'service_current_check_attempt', - 'max_check_attempts' => 'service_max_check_attempts', - 'state_type' => 'service_state_type', - 'passive_checks_enabled' => 'service_passive_checks_enabled', - 'last_state_change' => 'service_last_state_change', - 'last_notification' => 'service_last_notification', - 'current_notification_number' => 'service_current_notification_number', - 'is_flapping' => 'service_is_flapping', - 'percent_state_change' => 'service_percent_state_change', - 'in_downtime' => 'service_in_downtime', - 'passive_checks_enabled' => 'service_passive_checks_enabled', - 'obsessing' => 'service_obsessing', - 'notifications_enabled' => 'service_notifications_enabled', - 'event_handler_enabled' => 'service_event_handler_enabled', - 'flap_detection_enabled' => 'service_flap_detection_enabled', - 'active_checks_enabled' => 'service_active_checks_enabled', - 'last_comment' => 'service_last_comment', - 'action_url' => 'service_action_url', - 'notes_url' => 'service_notes_url' - )) + return $this->backend->select()->from( + 'status', + array( + 'host_name', + 'host_alias', + 'host_address', + 'host_state', + 'host_handled', + 'host_in_downtime', + 'host_acknowledged', + 'host_last_state_change', + 'service_description', + 'service_state', + 'service_handled', + 'service_acknowledged', + 'service_in_downtime', + 'service_last_state_change', + 'last_check' => 'service_last_check', + 'next_check' => 'service_next_check', + 'check_execution_time' => 'service_check_execution_time', + 'check_latency' => 'service_check_latency', + 'output' => 'service_output', + 'long_output' => 'service_long_output', + 'check_command' => 'service_check_command', + 'perfdata' => 'service_perfdata', + 'current_check_attempt' => 'service_current_check_attempt', + 'max_check_attempts' => 'service_max_check_attempts', + 'state_type' => 'service_state_type', + 'passive_checks_enabled' => 'service_passive_checks_enabled', + 'last_state_change' => 'service_last_state_change', + 'last_notification' => 'service_last_notification', + 'current_notification_number' => 'service_current_notification_number', + 'is_flapping' => 'service_is_flapping', + 'percent_state_change' => 'service_percent_state_change', + 'in_downtime' => 'service_in_downtime', + 'passive_checks_enabled' => 'service_passive_checks_enabled', + 'obsessing' => 'service_obsessing', + 'notifications_enabled' => 'service_notifications_enabled', + 'event_handler_enabled' => 'service_event_handler_enabled', + 'flap_detection_enabled' => 'service_flap_detection_enabled', + 'active_checks_enabled' => 'service_active_checks_enabled', + 'last_comment' => 'service_last_comment', + 'action_url' => 'service_action_url', + 'notes_url' => 'service_notes_url' + ) + ) ->where('host_name', $this->name1) ->where('service_description', $this->name2) ->fetchRow(); From d0fe1be7f7cdf0b749c53fb976ec1b04440b0b47 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 15 Oct 2013 15:17:30 +0200 Subject: [PATCH 3/5] Add command form helper for buttons with icons or labels refs #4869 --- .../application/views/helpers/CommandForm.php | 82 +++++++++++++++++-- .../views/scripts/list/comments.phtml | 12 ++- .../icinga/components/ajaxPostSubmitForm.js | 4 +- public/js/icinga/components/mainDetailGrid.js | 8 +- 4 files changed, 92 insertions(+), 14 deletions(-) diff --git a/modules/monitoring/application/views/helpers/CommandForm.php b/modules/monitoring/application/views/helpers/CommandForm.php index d2605cbb3..d93f7eeff 100644 --- a/modules/monitoring/application/views/helpers/CommandForm.php +++ b/modules/monitoring/application/views/helpers/CommandForm.php @@ -4,7 +4,6 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} -use Icinga\Application\Icinga; use Icinga\Web\Form; /** @@ -16,12 +15,11 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract * Creates a simple form without additional input fields * * @param string $commandName Name of command (icinga 2 web name) - * @param string $submitLabel Label of submit button * @param array $arguments Add parameter as hidden fields * - * @return string Html form content + * @return Form Form to modify */ - public function simpleForm($commandName, $submitLabel, array $arguments = array()) + private function simpleForm($commandName, array $arguments = array()) { $form = new Form(); @@ -29,7 +27,6 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract $form->setAttrib('data-icinga-component', 'app/ajaxPostSubmitForm'); $form->setRequest(Zend_Controller_Front::getInstance()->getRequest()); - $form->setSubmitLabel($submitLabel !== null ? $submitLabel : 'Submit'); $form->setAction($this->view->href('monitoring/command/' . $commandName)); foreach ($arguments as $elementName => $elementValue) { @@ -38,7 +35,80 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract $form->addElement($hiddenField); } - return $form->render(); + return $form; + } + + /** + * Creates an iconized submit form + * + * @param string $iconCls Css class of icon + * @param string $submitTitle Title of submit button + * @param string $cls Css class names + * @param string $commandName Name of command + * @param array $arguments Additional arguments + * + * @return Form + */ + public function iconSubmitForm($iconCls, $submitTitle, $cls, $commandName, array $arguments = array()) + { + $form = $this->labelSubmitForm('', $submitTitle, $cls, $commandName, $arguments); + $submit = $form->getElement('btn_submit'); + $submit->setLabel(sprintf('', $iconCls)); + + return $form; + } + + /** + * Renders a simple for with a labeled submit button + * + * @param string $submitLabel Label of submit button + * @param string $submitTitle Title of submit button + * @param string $cls Css class names + * @param string $commandName Name of command + * @param array $arguments Additional arguments + * + * @return Form + */ + public function labelSubmitForm($submitLabel, $submitTitle, $cls, $commandName, array $arguments = array()) + { + $form = $this->simpleForm($commandName, $arguments); + + $button = new Zend_Form_Element_Button( + array( + 'name' => 'btn_submit', + 'class' => $this->mergeClass('button btn-common', $cls), + 'escape' => false, + 'value' => '1', + 'type' => 'submit', + 'label' => $submitLabel, + 'title' => $submitTitle + ) + ); + + $button->setDecorators(array('ViewHelper')); + + $form->addElement($button); + + return $form; + } + + /** + * Merges css class names together + * + * @param string $base + * @param string $additional + * @param string ... + * + * @return string + */ + private function mergeClass($base, $additional) + { + $args = func_get_args(); + $base = explode(' ', array_shift($args)); + while (($additional = array_shift($args))) { + $base = array_merge($base, explode(' ', $additional)); + } + return implode(' ', $base); } } diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 65e76de09..998f2ede6 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -1,5 +1,7 @@ getHelper('DateFormat'); + + /** @var Zend_View_Helper_CommandForm $commandHelper */ $commandHelper = $this->getHelper('CommandForm'); ?> tabs->render($this); ?> @@ -114,10 +116,12 @@ $viewHelper = $this->getHelper('MonitoringState'); $data['service'] = $comment->service_name; } - echo $commandHelper->simpleForm( - 'removecomment', - 'Remove Comment', - $data + echo $commandHelper->iconSubmitForm( + 'icinga-icon-remove', + 'Remove comment', + 'btn-small', + 'removecomment', + $data ); ?>
-
- -
+ comment_internal_id; + + echo $cf->iconSubmitForm( + 'icinga-icon-remove', + 'Remove comment', + 'btn-small', + 'removecomment', + $deleteData + ); + ?>
escape($comment->comment_author); ?>, comment_type; ?> (format()->timeSince($comment->comment_timestamp); ?>) diff --git a/modules/monitoring/application/views/scripts/show/components/status.phtml b/modules/monitoring/application/views/scripts/show/components/status.phtml index bf282d762..cc138e307 100644 --- a/modules/monitoring/application/views/scripts/show/components/status.phtml +++ b/modules/monitoring/application/views/scripts/show/components/status.phtml @@ -2,6 +2,9 @@ $object = $this->object; $type = (isset($object->service_description) === true) ? '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; @@ -72,14 +75,44 @@

pluginOutput($object->output); ?>

-
- 0): ?> - + object->host_acknowledged || $this->object->service_acknowledged): ?> + labelSubmitForm( + 'Remove Ack', + 'Remove problem acknowledgement', + 'btn-cta btn-half-left', + 'removeacknowledgement', + array( + 'host' => $this->object->host_name, + 'service' => $this->object->service_description + ) + ) ?> + + + Acknowledge + - - -
+ + labelSubmitForm( + 'Recheck', + 'Reschedule next check immediately', + 'btn-cta ' . (($objectState > 0) ? 'btn-half-right' : 'btn-wide'), + 'reschedulenextcheck', + array( + 'host' => $this->object->host_name, + 'service' => $this->object->service_description, + 'checktime' => time(), + 'forcecheck' => '1' + ) + ) ?>
@@ -123,11 +156,17 @@ dateFormat()->formatDateTime($object->next_check); ?>
-
- -
+ + +
diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index 33a653735..cc8c09f29 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -169,6 +169,7 @@ abstract class AbstractObject 'comment_author', 'comment_data', 'comment_type', + 'comment_internal_id' ) )->where('comment_objecttype_id', $this->type) )->fetchAll(); From 7a406b313f74d61ea4b804904170f8156677426d Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 15 Oct 2013 18:09:16 +0200 Subject: [PATCH 5/5] Adjusted buttons and a tags refs #4869 --- library/Icinga/Web/Form.php | 8 ++++++++ .../application/views/helpers/CommandForm.php | 9 ++++++--- .../views/scripts/show/components/flags.phtml | 7 ++++++- public/css/main.css | 14 ++++++++++---- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 0e092693f..927c255d8 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -599,6 +599,14 @@ class Form extends Zend_Form { parent::addElement($element, $name, $options); $el = $name ? $this->getElement($name) : $element; + + // Do not add structural elements to invisible elements + // which produces ugly views + if (strpos(strtolower(get_class($el)), 'hidden') !== false) { + $el->setDecorators(array('ViewHelper')); + return $this; + } + if ($el) { $el->removeDecorator('HtmlTag'); $el->removeDecorator('Label'); diff --git a/modules/monitoring/application/views/helpers/CommandForm.php b/modules/monitoring/application/views/helpers/CommandForm.php index 66803128c..4f32d064c 100644 --- a/modules/monitoring/application/views/helpers/CommandForm.php +++ b/modules/monitoring/application/views/helpers/CommandForm.php @@ -22,7 +22,6 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract private function simpleForm($commandName, array $arguments = array()) { $form = new Form(); - $form->setIgnoreChangeDiscarding(true); $form->setAttrib('data-icinga-component', 'app/ajaxPostSubmitForm'); @@ -33,6 +32,8 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract $hiddenField = new Zend_Form_Element_Hidden($elementName); $hiddenField->setValue($elementValue); $form->addElement($hiddenField); + + $hiddenField = $form->getElement($elementName); } return $form; @@ -72,6 +73,7 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract public function labelSubmitForm($submitLabel, $submitTitle, $cls, $commandName, array $arguments = array()) { $form = $this->simpleForm($commandName, $arguments); + $button = new Zend_Form_Element_Button( array( 'name' => 'btn_submit', @@ -84,10 +86,11 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract ) ); - $button->setDecorators(array('ViewHelper')); - $form->addElement($button); + // Because of implicit added decorators + $form->getElement('btn_submit')->setDecorators(array('ViewHelper')); + return $form; } diff --git a/modules/monitoring/application/views/scripts/show/components/flags.phtml b/modules/monitoring/application/views/scripts/show/components/flags.phtml index 222e23c4e..fe177aeb6 100644 --- a/modules/monitoring/application/views/scripts/show/components/flags.phtml +++ b/modules/monitoring/application/views/scripts/show/components/flags.phtml @@ -1,5 +1,8 @@ object; + + /** @var Zend_View_Helper_CommandForm $cf */ + $cf = $this->getHelper('CommandForm'); ?>
@@ -16,7 +19,9 @@
Passive Checks
passive_checks_enabled === '1') ? 'checked="true"' : '' ?> /> + passive_checks_enabled === '1') ? 'checked="true"' : '' ?> /> +