diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index 00ba83a6c..e0f6279cc 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -468,8 +468,8 @@ class Monitoring_CommandController extends ActionController } $form->setCommand( - 'STOP_ACCEPTING_PASSIVE_HOST_CHECKS', - 'STOP_ACCEPTING_PASSIVE_SVC_CHECKS' + 'DISABLE_PASSIVE_HOST_CHECKS', + 'DISABLE_PASSIVE_SVC_CHECKS' ); $form->setGlobalCommands( @@ -501,8 +501,8 @@ class Monitoring_CommandController extends ActionController } $form->setCommand( - 'START_ACCEPTING_PASSIVE_HOST_CHECKS', - 'START_ACCEPTING_PASSIVE_SVC_CHECKS' + 'ENABLE_PASSIVE_HOST_CHECKS', + 'ENABLE_PASSIVE_SVC_CHECKS' ); $form->setGlobalCommands( diff --git a/modules/monitoring/application/views/helpers/CommandForm.php b/modules/monitoring/application/views/helpers/CommandForm.php index 14d5194dc..91e4e7c10 100644 --- a/modules/monitoring/application/views/helpers/CommandForm.php +++ b/modules/monitoring/application/views/helpers/CommandForm.php @@ -24,6 +24,7 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract $form = new Form(); $form->setIgnoreChangeDiscarding(true); $form->setAttrib('data-icinga-component', 'app/ajaxPostSubmitForm'); + $form->setAttrib('class', 'inline-form'); $form->setRequest(Zend_Controller_Front::getInstance()->getRequest()); $form->setAction($this->view->href('monitoring/command/' . $commandName)); @@ -94,7 +95,19 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract return $form; } - public function toggleSubmitForm($label, $checkValue, $enabledCommand, $disabledCommand, array $arguments = array()) + /** + * Create a toggle form for switch between commands + * + * @param string $label + * @param string $checkValue + * @param string $enabledCommand + * @param string $disabledCommand + * @param bool $changed + * @param array $arguments + * + * @return string + */ + public function toggleSubmitForm($label, $checkValue, $enabledCommand, $disabledCommand, $changed = false, array $arguments = array()) { if ($checkValue === '1') { $commandName = $disabledCommand; @@ -103,7 +116,6 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract } $form = $this->simpleForm($commandName, $arguments); - $form->setAttrib('class', 'pull-right'); $uniqueName = uniqid('check'); @@ -125,7 +137,29 @@ class Zend_View_Helper_CommandForm extends Zend_View_Helper_Abstract $form->addElement($submit_identifier); $form->getElement('btn_submit')->setDecorators(array('ViewHelper')); - return '' . $form; + $out = '' + . '
'; + + if ($changed === true) { + $out .= '' + . ' (modified)' + . ''; + } + + $formCode = (string) $form; + + $jsLessSubmit = ''; + + $formCode = str_replace('', $jsLessSubmit, $formCode); + + $out .= $formCode + . '
'; + + return $out; } /** diff --git a/modules/monitoring/application/views/scripts/process/performance.phtml b/modules/monitoring/application/views/scripts/process/performance.phtml index 0ed318b44..0eb188d82 100644 --- a/modules/monitoring/application/views/scripts/process/performance.phtml +++ b/modules/monitoring/application/views/scripts/process/performance.phtml @@ -227,6 +227,7 @@ $ps->notifications_enabled, 'enablenotifications', 'disablenotifications', + false, array( 'global' => '1' ) @@ -242,6 +243,7 @@ $ps->active_service_checks_enabled, 'enableactivechecks', 'disableactivechecks', + false, array( 'global' => 'service' ) @@ -257,6 +259,7 @@ $ps->passive_service_checks_enabled, 'startacceptingpassivechecks', 'stopacceptingpassivechecks', + false, array( 'global' => 'service' ) @@ -272,6 +275,7 @@ $ps->active_host_checks_enabled, 'enableactivechecks', 'disableactivechecks', + false, array( 'global' => 'host' ) @@ -287,6 +291,7 @@ $ps->passive_host_checks_enabled, 'startacceptingpassivechecks', 'stopacceptingpassivechecks', + false, array( 'global' => 'host' ) @@ -302,6 +307,7 @@ $ps->event_handlers_enabled, 'enableeventhandler', 'disableeventhandler', + false, array( 'global' => '1' ) @@ -317,6 +323,7 @@ $ps->obsess_over_hosts, 'startobsessing', 'stopobsessing', + false, array( 'global' => 'host' ) @@ -332,6 +339,7 @@ $ps->obsess_over_services, 'startobsessing', 'stopobsessing', + false, array( 'global' => 'service' ) @@ -347,6 +355,7 @@ $ps->flap_detection_enabled, 'enableflapdetection', 'disableflapdetection', + false, array( 'global' => '1' ) @@ -362,6 +371,7 @@ $ps->process_performance_data, 'enableperformancedata', 'disableperformancedata', + false, array( 'global' => '1' ) diff --git a/modules/monitoring/application/views/scripts/show/components/flags.phtml b/modules/monitoring/application/views/scripts/show/components/flags.phtml index fe177aeb6..7e742d155 100644 --- a/modules/monitoring/application/views/scripts/show/components/flags.phtml +++ b/modules/monitoring/application/views/scripts/show/components/flags.phtml @@ -3,6 +3,32 @@ /** @var Zend_View_Helper_CommandForm $cf */ $cf = $this->getHelper('CommandForm'); + + $data = array( + 'host' => $o->host_name, + 'service' => $o->service_description + ); + + $modified_attributes = false; + + if ($o->service_description && $o->service_modified_service_attributes) { + $modified_attributes = true; + } elseif ($o->host_modified_host_attributes) { + $modified_attributes = true; + } + + $test_db_modified = ( + ($o->passive_checks_enabled_changed === '0') + && ($o->active_checks_enabled_changed === '0') + && ($o->obsessing_changed === '0') + && ($o->notifications_enabled_changed === '0') + && ($o->event_handler_enabled_changed === '0') + && ($o->flap_detection_enabled_changed === '0') + ) ? false : true; + + if ($modified_attributes && !$test_db_modified) { + $modified_attributes = false; + } ?>
@@ -14,42 +40,109 @@
- +
- - - - - + + + + + - - - + - - - + - - - - - - - - +
Passive Checks
- passive_checks_enabled === '1') ? 'checked="true"' : '' ?> /> + toggleSubmitForm( + 'Passive Checks enabled', + $o->passive_checks_enabled, + 'startacceptingpassivechecks', + 'stopacceptingpassivechecks', + (($o->passive_checks_enabled_changed === '1') ? true : false), + $data + ); + ?>
Active Checksactive_checks_enabled === '1') ? 'checked="true"' : '' ?> /> + toggleSubmitForm( + 'Active Checks enabled', + $o->active_checks_enabled, + 'enableactivechecks', + 'disableactivechecks', + (($o->active_checks_enabled_changed === '1') ? true : false), + $data + ); + ?> +
+ toggleSubmitForm( + 'Obsessing enabled', + $o->obsessing, + 'startobsessing', + 'stopobsessing', + (($o->obsessing_changed === '1') ? true : false), + $data + ); + ?> +
Obsessingobsessing === '1') ? 'checked="true"' : '' ?> /> + toggleSubmitForm( + 'Notifications enabled', + $o->notifications_enabled, + 'enablenotifications', + 'disablenotifications', + (($o->notifications_enabled_changed === '1') ? true : false), + $data + ); + ?> +
Notificationsnotifications_enabled === '1') ? 'checked="true"' : '' ?> /> + toggleSubmitForm( + 'Eventhandler enabled', + $o->event_handler_enabled, + 'enableeventhandler', + 'disableeventhandler', + (($o->event_handler_enabled_changed === '1') ? true : false), + $data + ); + ?> +
Event Handlerevent_handler_enabled === '1') ? 'checked="true"' : '' ?> />
Flap Detectionflap_detection_enabled === '1') ? 'checked="true"' : '' ?> /> + toggleSubmitForm( + 'Flap Detection enabled', + $o->flap_detection_enabled, + 'enableflapdetection', + 'disableflapdetection', + (($o->flap_detection_enabled_changed === '1') ? true : false), + $data + ); + ?> +
+ + + + labelSubmitForm( + 'Reset modified attributes', + 'Reset configuration to initial values after a system restart', + 'btn-cta', + 'resetattributes', + $data + ); + ?> + +
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php index d5369cea2..280031397 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/StatusQuery.php @@ -38,7 +38,12 @@ class StatusQuery extends IdoQuery 'host_check_execution_time' => 'hs.execution_time', 'host_check_latency' => 'hs.latency', 'host_problem' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END', + 'host_notifications_enabled' => 'hs.notifications_enabled', + + 'host_notifications_enabled_changed' => 'CASE WHEN hs.notifications_enabled=h.notifications_enabled + THEN 0 ELSE 1 END', + 'host_last_time_up' => 'UNIX_TIMESTAMP(hs.last_time_up)', 'host_last_time_down' => 'UNIX_TIMESTAMP(hs.last_time_down)', 'host_last_time_unreachable' => 'UNIX_TIMESTAMP(hs.last_time_unreachable)', @@ -54,15 +59,36 @@ class StatusQuery extends IdoQuery 'host_acknowledgement_type' => 'hs.acknowledgement_type', 'host_current_notification_number' => 'hs.current_notification_number', 'host_passive_checks_enabled' => 'hs.passive_checks_enabled', + + 'host_passive_checks_enabled_changed' => 'CASE WHEN hs.passive_checks_enabled=h.passive_checks_enabled + THEN 0 ELSE 1 END', + 'host_active_checks_enabled' => 'hs.active_checks_enabled', + + 'host_active_checks_enabled_changed' => 'CASE WHEN hs.active_checks_enabled=h.active_checks_enabled + THEN 0 ELSE 1 END', + 'host_event_handler_enabled' => 'hs.event_handler_enabled', + + 'host_event_handler_enabled_changed' => 'CASE WHEN hs.event_handler_enabled=h.event_handler_enabled + THEN 0 ELSE 1 END', + 'host_flap_detection_enabled' => 'hs.flap_detection_enabled', + + 'host_flap_detection_enabled_changed' => 'CASE WHEN hs.flap_detection_enabled=h.flap_detection_enabled + THEN 0 ELSE 1 END', + 'host_is_flapping' => 'hs.is_flapping', 'host_percent_state_change' => 'hs.percent_state_change', 'host_scheduled_downtime_depth' => 'hs.scheduled_downtime_depth', 'host_failure_prediction_enabled' => 'hs.failure_prediction_enabled', 'host_process_performance_data' => 'hs.process_performance_data', + 'host_obsessing' => 'hs.obsess_over_host', + + 'host_obsessing_changed' => 'CASE WHEN hs.obsess_over_host=h.obsess_over_host + THEN 0 ELSE 1 END', + 'host_modified_host_attributes' => 'hs.modified_host_attributes', 'host_event_handler' => 'hs.event_handler', 'host_check_command' => 'hs.check_command', @@ -145,14 +171,37 @@ class StatusQuery extends IdoQuery 'service_last_notification' => 'ss.last_notification', 'service_next_notification' => 'ss.next_notification', 'service_no_more_notifications' => 'ss.no_more_notifications', + 'service_notifications_enabled' => 'ss.notifications_enabled', + + 'service_notifications_enabled_changed' => 'CASE WHEN ss.notifications_enabled=s.notifications_enabled + THEN 0 ELSE 1 END', + 'service_problem_has_been_acknowledged' => 'ss.problem_has_been_acknowledged', 'service_acknowledgement_type' => 'ss.acknowledgement_type', 'service_current_notification_number' => 'ss.current_notification_number', + 'service_passive_checks_enabled' => 'ss.passive_checks_enabled', + + 'service_passive_checks_enabled_changed' => 'CASE WHEN ss.passive_checks_enabled=s.passive_checks_enabled + THEN 0 ELSE 1 END', + 'service_active_checks_enabled' => 'ss.active_checks_enabled', + + 'service_active_checks_enabled_changed' => 'CASE WHEN ss.active_checks_enabled=s.active_checks_enabled + THEN 0 ELSE 1 END', + 'service_event_handler_enabled' => 'ss.event_handler_enabled', + + 'service_event_handler_enabled_changed' => 'CASE WHEN ss.event_handler_enabled=s.event_handler_enabled + THEN 0 ELSE 1 END', + + 'service_flap_detection_enabled' => 'ss.flap_detection_enabled', + + 'service_flap_detection_enabled_changed' => 'CASE WHEN ss.flap_detection_enabled=s.flap_detection_enabled + THEN 0 ELSE 1 END', + 'service_is_flapping' => 'ss.is_flapping', 'service_percent_state_change' => 'ss.percent_state_change', 'service_check_latency' => 'ss.latency', @@ -160,10 +209,14 @@ class StatusQuery extends IdoQuery 'service_scheduled_downtime_depth' => 'ss.scheduled_downtime_depth', 'service_failure_prediction_enabled' => 'ss.failure_prediction_enabled', 'service_process_performance_data' => 'ss.process_performance_data', + 'service_obsessing' => 'ss.obsess_over_service', + + 'service_obsessing_changed' => 'CASE WHEN ss.obsess_over_service=s.obsess_over_service + THEN 0 ELSE 1 END', + 'service_modified_service_attributes' => 'ss.modified_service_attributes', 'service_event_handler' => 'ss.event_handler', - 'service_check_command' => 'ss.check_command', 'service_normal_check_interval' => 'ss.normal_check_interval', 'service_retry_check_interval' => 'ss.retry_check_interval', 'service_check_timeperiod_object_id' => 'ss.check_timeperiod_object_id', diff --git a/modules/monitoring/library/Monitoring/DataView/HostStatus.php b/modules/monitoring/library/Monitoring/DataView/HostStatus.php index afa522448..5f87a7101 100644 --- a/modules/monitoring/library/Monitoring/DataView/HostStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/HostStatus.php @@ -37,11 +37,17 @@ class HostStatus extends DataView 'host_check_command', 'host_perfdata', 'host_passive_checks_enabled', + 'host_passive_checks_enabled_changed', 'host_obsessing', + 'host_obsessing_changed', 'host_notifications_enabled', + 'host_notifications_enabled_changed', 'host_event_handler_enabled', + 'host_event_handler_enabled_changed', 'host_flap_detection_enabled', + 'host_flap_detection_enabled_changed', 'host_active_checks_enabled', + 'host_active_checks_enabled_changed', 'host_current_check_attempt', 'host_max_check_attempts', 'host_last_notification', @@ -51,7 +57,8 @@ class HostStatus extends DataView 'host_last_comment', 'host_action_url', 'host_notes_url', - 'host_percent_state_change' + 'host_percent_state_change', + 'host_modified_host_attributes' ); } diff --git a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php index 558cf12f5..d5cd32adf 100644 --- a/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php +++ b/modules/monitoring/library/Monitoring/DataView/ServiceStatus.php @@ -35,6 +35,7 @@ class ServiceStatus extends DataView 'service_severity', 'service_last_check', 'service_notifications_enabled', + 'service_notifications_enabled_changed', 'service_action_url', 'service_notes_url', 'service_last_comment', @@ -67,11 +68,14 @@ class ServiceStatus extends DataView 'host_last_time_up', 'host_last_time_down', 'host_last_time_unreachable', + 'host_modified_host_attributes', 'service', 'service_hard_state', 'service_perfdata', 'service_active_checks_enabled', + 'service_active_checks_enabled_changed', 'service_passive_checks_enabled', + 'service_passive_checks_enabled_changed', 'service_last_hard_state', 'service_last_hard_state_change', 'service_last_time_ok', @@ -79,7 +83,14 @@ class ServiceStatus extends DataView 'service_last_time_critical', 'service_last_time_unknown', 'service_current_check_attempt', - 'service_max_check_attempts' + 'service_max_check_attempts', + 'service_obsessing', + 'service_obsessing_changed', + 'service_event_handler_enabled', + 'service_event_handler_enabled_changed', + 'service_flap_detection_enabled', + 'service_flap_detection_enabled_changed', + 'service_modified_service_attributes', ); } diff --git a/modules/monitoring/public/css/main.less b/modules/monitoring/public/css/main.less index 83c6eb16d..943179cb4 100644 --- a/modules/monitoring/public/css/main.less +++ b/modules/monitoring/public/css/main.less @@ -52,6 +52,11 @@ display: block; } +.config-changed { + display: inline-block; + margin: 0 10px 0 0; +} + /* ========================================================================== Forms ========================================================================== */ diff --git a/public/css/icinga/main.less b/public/css/icinga/main.less index a8b22774b..9551a4e36 100644 --- a/public/css/icinga/main.less +++ b/public/css/icinga/main.less @@ -89,6 +89,10 @@ p { font-weight: normal; } +.label-configuration { + cursor: pointer; +} + .inline-image { display: inline-block; width: 16px; @@ -103,6 +107,10 @@ p { font-weight: normal; } +.inline-form { + display: inline; +} + .gap { margin-bottom: 15px; } @@ -136,6 +144,7 @@ a.button { a.btn-small { height: 25px; + display: inline-block; } /** diff --git a/public/js/icinga/components/ajaxPostSubmitForm.js b/public/js/icinga/components/ajaxPostSubmitForm.js index c26ae16c2..4a54cedde 100644 --- a/public/js/icinga/components/ajaxPostSubmitForm.js +++ b/public/js/icinga/components/ajaxPostSubmitForm.js @@ -35,18 +35,7 @@ define(['components/app/container', 'jquery'], function(Container, $) { "use strict"; - /** - * Returns owner container - * - * @param {Element} targetElement - * @returns {Container} - */ - var getOwnerContainer = function(targetElement) { - var me = new Container(targetElement); - return new Container(me.findNearestContainer(targetElement)); - }; - - /** + /**; * Handler for ajax post submit * * @param {Event} e @@ -73,8 +62,8 @@ define(['components/app/container', 'jquery'], function(Container, $) { submit.attr('disabled', true); } }).done(function() { - var container = getOwnerContainer(form); - container.setUrl(container.getUrl()); + var c = new Container(form); + c.refresh(); }).error(function() { submit.removeAttr('disabled'); }); diff --git a/public/js/icinga/components/container.js b/public/js/icinga/components/container.js index dccecca0e..efa016e93 100644 --- a/public/js/icinga/components/container.js +++ b/public/js/icinga/components/container.js @@ -134,8 +134,6 @@ define(['jquery', 'logging', 'icinga/componentLoader', 'URIjs/URI', 'URIjs/URITe * @private */ var createDefaultLoadIndicator = function() { - - this.showDetail(); if (this.containerDom.find('div.load-indicator').length === 0) { var content = '
' + '
' + @@ -173,11 +171,11 @@ define(['jquery', 'logging', 'icinga/componentLoader', 'URIjs/URI', 'URIjs/URITe }; this.replaceDomAsync = function(url) { - if (url === '') { - this.containerDom.empty(); + urlMgr.syncWithUrl(); + if (urlMgr.detailUrl === '') { this.hideDetail(); - return; } + if (pendingDetailRequest) { pendingDetailRequest.abort(); } @@ -331,7 +329,15 @@ define(['jquery', 'logging', 'icinga/componentLoader', 'URIjs/URI', 'URIjs/URITe } else { urlMgr.setDetailUrl(url.href()); } - } + }; + + this.refresh = function() { + if (this.containerType === CONTAINER_TYPES.MAIN) { + Container.getMainContainer().replaceDomAsync(urlMgr.mainUrl); + } else { + Container.getDetailContainer().replaceDomAsync(urlMgr.detailUrl); + } + }; this.construct(target); };