From eee7603c51fbfa8b85d37a4631c36b473fa80c10 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 4 Mar 2014 15:12:25 +0100 Subject: [PATCH 01/10] Remove bootstrap classes refs #5705 --- application/views/scripts/config/authentication/modify.phtml | 2 +- application/views/scripts/config/logging.phtml | 4 ++-- .../views/scripts/config/module-configuration-error.phtml | 2 +- application/views/scripts/config/module/show.phtml | 2 +- application/views/scripts/config/resource/modify.phtml | 2 +- application/views/scripts/config/show-configuration.phtml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/application/views/scripts/config/authentication/modify.phtml b/application/views/scripts/config/authentication/modify.phtml index ce7ca8a0a..ca2cef6f9 100644 --- a/application/views/scripts/config/authentication/modify.phtml +++ b/application/views/scripts/config/authentication/modify.phtml @@ -8,7 +8,7 @@ form->getErrorMessages()): ?> -
+
form->getErrorMessages() as $error): ?> escape($error); ?>
diff --git a/application/views/scripts/config/logging.phtml b/application/views/scripts/config/logging.phtml index b37e704e5..da6d886cc 100644 --- a/application/views/scripts/config/logging.phtml +++ b/application/views/scripts/config/logging.phtml @@ -10,14 +10,14 @@ successMessage): ?> -
+
escape($this->successMessage); ?>
-
+

Errors occured when trying to save the project.

The following errors occured when trying to save the configuration: diff --git a/application/views/scripts/config/module-configuration-error.phtml b/application/views/scripts/config/module-configuration-error.phtml index d5e62cc84..85fb128f5 100644 --- a/application/views/scripts/config/module-configuration-error.phtml +++ b/application/views/scripts/config/module-configuration-error.phtml @@ -5,7 +5,7 @@ ?> tabs->render($this); ?>
-

+

Could not module ""

While operation the following error occurred: diff --git a/application/views/scripts/config/module/show.phtml b/application/views/scripts/config/module/show.phtml index 8a68e71b7..c71c4b94f 100644 --- a/application/views/scripts/config/module/show.phtml +++ b/application/views/scripts/config/module/show.phtml @@ -1,4 +1,4 @@ - +
diff --git a/application/views/scripts/config/resource/modify.phtml b/application/views/scripts/config/resource/modify.phtml index 079c9464d..5a0871aed 100644 --- a/application/views/scripts/config/resource/modify.phtml +++ b/application/views/scripts/config/resource/modify.phtml @@ -8,7 +8,7 @@ form->getErrorMessages()): ?> -
+
form->getErrorMessages() as $error): ?> escape($error); ?>
diff --git a/application/views/scripts/config/show-configuration.phtml b/application/views/scripts/config/show-configuration.phtml index 2bf97cbfb..a8eda9d86 100644 --- a/application/views/scripts/config/show-configuration.phtml +++ b/application/views/scripts/config/show-configuration.phtml @@ -2,7 +2,7 @@
-
+

WARNING ICONSaving "escape($this->file); ?>.ini" Failed


From ecd6a27e036850902ba6df747e4b744e19aefbde Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 4 Mar 2014 15:29:43 +0100 Subject: [PATCH 02/10] Remove bootstrap classes refs #5705 --- .../views/scripts/config/authentication.phtml | 16 ++++++++-------- application/views/scripts/config/index.phtml | 4 ++-- application/views/scripts/config/logging.phtml | 4 ++-- .../views/scripts/config/module/overview.phtml | 6 +++--- application/views/scripts/config/resource.phtml | 16 ++++++++-------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/application/views/scripts/config/authentication.phtml b/application/views/scripts/config/authentication.phtml index 7d5cc1cd0..972f897e9 100644 --- a/application/views/scripts/config/authentication.phtml +++ b/application/views/scripts/config/authentication.phtml @@ -3,33 +3,33 @@ use Icinga\Web\Url; $createLdapBackend = $this->href('/config/createAuthenticationBackend', array('type' => 'ldap')); $createDbBackend = $this->href('/config/createAuthenticationBackend', array('type' => 'db')); ?> -

+
tabs->render($this); ?>
-
+
messageBox)): ?> messageBox->render() ?> -
-
+
+
Create Authentication Provider
- backends as $backend): ?> -
-
+
+
Backend escape($backend->name); ?>
reorderForm; ?>
-
+
Edit This Authentication Provider diff --git a/application/views/scripts/config/index.phtml b/application/views/scripts/config/index.phtml index dab0acc4f..3ac1947fa 100644 --- a/application/views/scripts/config/index.phtml +++ b/application/views/scripts/config/index.phtml @@ -1,8 +1,8 @@ -
+
tabs->render($this); ?>
-
+
messageBox)): ?> messageBox->render() ?> diff --git a/application/views/scripts/config/logging.phtml b/application/views/scripts/config/logging.phtml index da6d886cc..9a69f477e 100644 --- a/application/views/scripts/config/logging.phtml +++ b/application/views/scripts/config/logging.phtml @@ -1,8 +1,8 @@ -
+
tabs->render($this); ?>
-
+
form->getErrorMessages(); ?> messageBox)): ?> diff --git a/application/views/scripts/config/module/overview.phtml b/application/views/scripts/config/module/overview.phtml index c8bfbda3c..404bf2a3d 100644 --- a/application/views/scripts/config/module/overview.phtml +++ b/application/views/scripts/config/module/overview.phtml @@ -5,11 +5,11 @@ $this->modules->limit(10); $modules = $this->modules->paginate(); ?> -
+
tabs->render($this); ?>
-
+

Installed Modules

messageBox)): ?> @@ -20,7 +20,7 @@ $modules = $this->modules->paginate(); 'preserve' => $this->preserve )); ?> -
Module
+
href('/config/createresource'); ?> -
+
tabs->render($this); ?>
-
+
messageBox)): ?> messageBox->render() ?> -
-
+
+
Create Resource
- resources as $name => $resource): ?> -
+
-
+
Resource: escape($name); ?>
-
+
Edit This Resource From 7062c5ab2dfb3adbd820963ddf6bd44621cb7623 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 4 Mar 2014 15:44:21 +0100 Subject: [PATCH 03/10] Revert "Remove bootstrap classes" This reverts commit 023bc33c42153486251b4b1d77045bcf72197905. --- .../views/scripts/config/authentication.phtml | 16 ++++++++-------- application/views/scripts/config/index.phtml | 4 ++-- application/views/scripts/config/logging.phtml | 4 ++-- .../views/scripts/config/module/overview.phtml | 6 +++--- application/views/scripts/config/resource.phtml | 16 ++++++++-------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/application/views/scripts/config/authentication.phtml b/application/views/scripts/config/authentication.phtml index 972f897e9..7d5cc1cd0 100644 --- a/application/views/scripts/config/authentication.phtml +++ b/application/views/scripts/config/authentication.phtml @@ -3,33 +3,33 @@ use Icinga\Web\Url; $createLdapBackend = $this->href('/config/createAuthenticationBackend', array('type' => 'ldap')); $createDbBackend = $this->href('/config/createAuthenticationBackend', array('type' => 'db')); ?> -
+
tabs->render($this); ?>
-
+
messageBox)): ?> messageBox->render() ?> -
-
+
+
Create Authentication Provider
-
backends as $backend): ?> -
-
+
+
Backend escape($backend->name); ?>
reorderForm; ?>
-
+
Edit This Authentication Provider diff --git a/application/views/scripts/config/index.phtml b/application/views/scripts/config/index.phtml index 3ac1947fa..dab0acc4f 100644 --- a/application/views/scripts/config/index.phtml +++ b/application/views/scripts/config/index.phtml @@ -1,8 +1,8 @@ -
+
tabs->render($this); ?>
-
+
messageBox)): ?> messageBox->render() ?> diff --git a/application/views/scripts/config/logging.phtml b/application/views/scripts/config/logging.phtml index 9a69f477e..da6d886cc 100644 --- a/application/views/scripts/config/logging.phtml +++ b/application/views/scripts/config/logging.phtml @@ -1,8 +1,8 @@ -
+
tabs->render($this); ?>
-
+
form->getErrorMessages(); ?> messageBox)): ?> diff --git a/application/views/scripts/config/module/overview.phtml b/application/views/scripts/config/module/overview.phtml index 404bf2a3d..c8bfbda3c 100644 --- a/application/views/scripts/config/module/overview.phtml +++ b/application/views/scripts/config/module/overview.phtml @@ -5,11 +5,11 @@ $this->modules->limit(10); $modules = $this->modules->paginate(); ?> -
+
tabs->render($this); ?>
-
+

Installed Modules

messageBox)): ?> @@ -20,7 +20,7 @@ $modules = $this->modules->paginate(); 'preserve' => $this->preserve )); ?> -
+
href('/config/createresource'); ?> -
+
tabs->render($this); ?>
-
+
messageBox)): ?> messageBox->render() ?> -
-
+
+
Create Resource
- resources as $name => $resource): ?> -
+
-
+
Resource: escape($name); ?>
-
+
Edit This Resource From 0d1d181d5184e7d57b73126394c53e0f9f800086 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 4 Mar 2014 15:44:51 +0100 Subject: [PATCH 04/10] Revert "Remove bootstrap classes" This reverts commit 682472ca6b744c80dce1b422520c4c072cb850d2. --- application/views/scripts/config/authentication/modify.phtml | 2 +- application/views/scripts/config/logging.phtml | 4 ++-- .../views/scripts/config/module-configuration-error.phtml | 2 +- application/views/scripts/config/module/show.phtml | 2 +- application/views/scripts/config/resource/modify.phtml | 2 +- application/views/scripts/config/show-configuration.phtml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/application/views/scripts/config/authentication/modify.phtml b/application/views/scripts/config/authentication/modify.phtml index ca2cef6f9..ce7ca8a0a 100644 --- a/application/views/scripts/config/authentication/modify.phtml +++ b/application/views/scripts/config/authentication/modify.phtml @@ -8,7 +8,7 @@ form->getErrorMessages()): ?> -
+
form->getErrorMessages() as $error): ?> escape($error); ?>
diff --git a/application/views/scripts/config/logging.phtml b/application/views/scripts/config/logging.phtml index da6d886cc..b37e704e5 100644 --- a/application/views/scripts/config/logging.phtml +++ b/application/views/scripts/config/logging.phtml @@ -10,14 +10,14 @@ successMessage): ?> -
+
escape($this->successMessage); ?>
-
+

Errors occured when trying to save the project.

The following errors occured when trying to save the configuration: diff --git a/application/views/scripts/config/module-configuration-error.phtml b/application/views/scripts/config/module-configuration-error.phtml index 85fb128f5..d5e62cc84 100644 --- a/application/views/scripts/config/module-configuration-error.phtml +++ b/application/views/scripts/config/module-configuration-error.phtml @@ -5,7 +5,7 @@ ?> tabs->render($this); ?>
-

+

Could not module ""

While operation the following error occurred: diff --git a/application/views/scripts/config/module/show.phtml b/application/views/scripts/config/module/show.phtml index c71c4b94f..8a68e71b7 100644 --- a/application/views/scripts/config/module/show.phtml +++ b/application/views/scripts/config/module/show.phtml @@ -1,4 +1,4 @@ -

+
diff --git a/application/views/scripts/config/resource/modify.phtml b/application/views/scripts/config/resource/modify.phtml index 5a0871aed..079c9464d 100644 --- a/application/views/scripts/config/resource/modify.phtml +++ b/application/views/scripts/config/resource/modify.phtml @@ -8,7 +8,7 @@ form->getErrorMessages()): ?> -
+
form->getErrorMessages() as $error): ?> escape($error); ?>
diff --git a/application/views/scripts/config/show-configuration.phtml b/application/views/scripts/config/show-configuration.phtml index a8eda9d86..2bf97cbfb 100644 --- a/application/views/scripts/config/show-configuration.phtml +++ b/application/views/scripts/config/show-configuration.phtml @@ -2,7 +2,7 @@
-
+

WARNING ICONSaving "escape($this->file); ?>.ini" Failed


From 63c73a8215c38eaff46fd2ff8257651a00e9c66e Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 4 Mar 2014 16:07:52 +0100 Subject: [PATCH 05/10] Remove bootstrap classes refs #5705 --- .../views/scripts/config/authentication.phtml | 12 ++++++------ .../views/scripts/config/authentication/modify.phtml | 2 +- application/views/scripts/config/logging.phtml | 4 ++-- .../scripts/config/module-configuration-error.phtml | 2 +- application/views/scripts/config/module/show.phtml | 2 +- application/views/scripts/config/resource.phtml | 12 ++++++------ .../views/scripts/config/resource/modify.phtml | 2 +- .../views/scripts/config/show-configuration.phtml | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/application/views/scripts/config/authentication.phtml b/application/views/scripts/config/authentication.phtml index 7d5cc1cd0..0bd683418 100644 --- a/application/views/scripts/config/authentication.phtml +++ b/application/views/scripts/config/authentication.phtml @@ -12,24 +12,24 @@ $createDbBackend = $this->href('/config/createAuthenticationBackend', array('typ messageBox->render() ?> -

-
+
+
Create Authentication Provider
-
backends as $backend): ?> -
-
+
+
Backend escape($backend->name); ?>
reorderForm; ?>
-
+
Edit This Authentication Provider diff --git a/application/views/scripts/config/authentication/modify.phtml b/application/views/scripts/config/authentication/modify.phtml index ce7ca8a0a..ca2cef6f9 100644 --- a/application/views/scripts/config/authentication/modify.phtml +++ b/application/views/scripts/config/authentication/modify.phtml @@ -8,7 +8,7 @@ form->getErrorMessages()): ?> -
+
form->getErrorMessages() as $error): ?> escape($error); ?>
diff --git a/application/views/scripts/config/logging.phtml b/application/views/scripts/config/logging.phtml index b37e704e5..da6d886cc 100644 --- a/application/views/scripts/config/logging.phtml +++ b/application/views/scripts/config/logging.phtml @@ -10,14 +10,14 @@ successMessage): ?> -
+
escape($this->successMessage); ?>
-
+

Errors occured when trying to save the project.

The following errors occured when trying to save the configuration: diff --git a/application/views/scripts/config/module-configuration-error.phtml b/application/views/scripts/config/module-configuration-error.phtml index d5e62cc84..85fb128f5 100644 --- a/application/views/scripts/config/module-configuration-error.phtml +++ b/application/views/scripts/config/module-configuration-error.phtml @@ -5,7 +5,7 @@ ?> tabs->render($this); ?>
-

+

Could not module ""

While operation the following error occurred: diff --git a/application/views/scripts/config/module/show.phtml b/application/views/scripts/config/module/show.phtml index 8a68e71b7..51d6ecae3 100644 --- a/application/views/scripts/config/module/show.phtml +++ b/application/views/scripts/config/module/show.phtml @@ -1,4 +1,4 @@ -

Module
+
diff --git a/application/views/scripts/config/resource.phtml b/application/views/scripts/config/resource.phtml index c9c48856f..75b3fad2d 100644 --- a/application/views/scripts/config/resource.phtml +++ b/application/views/scripts/config/resource.phtml @@ -11,23 +11,23 @@ $createResource = $this->href('/config/createresource'); messageBox->render() ?> -
-
+
+
Create Resource
- resources as $name => $resource): ?> -
+
-
+
Resource: escape($name); ?>
-
+
Edit This Resource diff --git a/application/views/scripts/config/resource/modify.phtml b/application/views/scripts/config/resource/modify.phtml index 079c9464d..5a0871aed 100644 --- a/application/views/scripts/config/resource/modify.phtml +++ b/application/views/scripts/config/resource/modify.phtml @@ -8,7 +8,7 @@ form->getErrorMessages()): ?> -
+
form->getErrorMessages() as $error): ?> escape($error); ?>
diff --git a/application/views/scripts/config/show-configuration.phtml b/application/views/scripts/config/show-configuration.phtml index 2bf97cbfb..a8eda9d86 100644 --- a/application/views/scripts/config/show-configuration.phtml +++ b/application/views/scripts/config/show-configuration.phtml @@ -2,7 +2,7 @@
-
+

WARNING ICONSaving "escape($this->file); ?>.ini" Failed


From d2ec3c9509519df314e6b44cd1751c264dc0fedf Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Wed, 5 Mar 2014 13:38:38 +0100 Subject: [PATCH 06/10] Re-design configuration interface Conflicts: public/js/icinga/events.js --- .../Config/Authentication/DbBackendForm.php | 2 + .../Config/Authentication/ReorderForm.php | 6 +- .../views/scripts/config/authentication.phtml | 66 ++- .../views/scripts/config/resource.phtml | 65 +-- public/css/icinga/forms.less | 15 + public/js/icinga/events.js | 520 +++++++++--------- 6 files changed, 327 insertions(+), 347 deletions(-) diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index 561782cfd..0590a5eef 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -134,6 +134,8 @@ class DbBackendForm extends BaseBackendForm */ public function isValidAuthenticationBackend() { + // @TODO fix validation of authentication backends (AK #5712) + //return true; try { $name = $this->getBackendName(); $dbBackend = new DbUserBackend( diff --git a/application/forms/Config/Authentication/ReorderForm.php b/application/forms/Config/Authentication/ReorderForm.php index da0e2af66..653b013f0 100644 --- a/application/forms/Config/Authentication/ReorderForm.php +++ b/application/forms/Config/Authentication/ReorderForm.php @@ -114,10 +114,9 @@ class ReorderForm extends Form array( 'type' => 'submit', 'escape' => false, - 'class' => 'btn btn-cta btn-wide', 'value' => 'btn_' . $this->getBackendName() . '_reorder_up', 'name' => 'btn_' . $this->getBackendName() . '_reorder_up', - 'label' => ' Move up in authentication order', + 'label' => '', ) ); } @@ -137,10 +136,9 @@ class ReorderForm extends Form array( 'type' => 'submit', 'escape' => false, - 'class' => 'btn btn-cta btn-wide', 'value' => 'btn_' . $this->getBackendName() . '_reorder_down', 'name' => 'btn_' . $this->getBackendName() . '_reorder_down', - 'label' => ' Move down in authentication order', + 'label' => '', ) ); diff --git a/application/views/scripts/config/authentication.phtml b/application/views/scripts/config/authentication.phtml index 0bd683418..c65f6c6cf 100644 --- a/application/views/scripts/config/authentication.phtml +++ b/application/views/scripts/config/authentication.phtml @@ -4,43 +4,41 @@ $createLdapBackend = $this->href('/config/createAuthenticationBackend', array('t $createDbBackend = $this->href('/config/createAuthenticationBackend', array('type' => 'db')); ?>

-tabs->render($this); ?> + tabs->render($this); ?>
Module
+ backends as $backend): ?> + + + + +
+
+ Backend:escape($backend->name); ?> +
+ +

diff --git a/application/views/scripts/config/resource.phtml b/application/views/scripts/config/resource.phtml index 75b3fad2d..5ac532ee4 100644 --- a/application/views/scripts/config/resource.phtml +++ b/application/views/scripts/config/resource.phtml @@ -3,47 +3,36 @@ use Icinga\Web\Url; $createResource = $this->href('/config/createresource'); ?>
-tabs->render($this); ?> + tabs->render($this); ?>
-messageBox)): ?> - messageBox->render() ?> - + messageBox)): ?> + messageBox->render() ?> + -
-
- Create Resource -
- -
- -resources as $name => $resource): ?> -
- -
- Resource: escape($name); ?> -
-
-
- - - Edit This Resource - -
- - resources) > 1): ?> - - Remove This Resource - -
- - -
- -
- +

Create Resource

+

img('img/icons/create.png', array('title' => 'Create A New Resource')); + ?> Create A New Resource

+ + + resources as $name => $resource): ?> + + + + +
+
+ Resource:escape($name); ?> +
+ +
diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index a8dd653e1..51afab4c3 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -1,4 +1,19 @@ +table.configTable { + border-spacing: 10px; + border-collapse: separate; +} + +td.configTable { + border: solid; + border-width: thin; + padding: 10px; +} + +div.form-group { + float: right; +} + .form-group { margin-bottom: 1em; } diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 3ef291351..c02b21b25 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -1,288 +1,266 @@ -/** - * Icinga.Events - * - * Event handlers - */ -(function (Icinga, $) { +(function(Icinga) { - 'use strict'; + Icinga.Events = function(icinga) { + this.icinga = icinga; + }; - Icinga.Events = function (icinga) { - this.icinga = icinga; - }; + Icinga.Events.prototype = { - Icinga.Events.prototype = { + /** + * Icinga will call our initialize() function once it's ready + */ + initialize: function() + { + this.applyGlobalDefaults(); + this.icinga.ui.prepareContainers(); + }, - /** - * Icinga will call our initialize() function once it's ready - */ - initialize: function () { - this.applyGlobalDefaults(); - this.applyHandlers($('#layout')); - this.icinga.ui.prepareContainers(); - }, - - // TODO: What's this? - applyHandlers: function (el) { - - var icinga = this.icinga; - - $('.dashboard > div', el).each(function(idx, el) { - var url = $(el).attr('data-icinga-url'); - if (typeof url === 'undefined') return; - icinga.loader.loadUrl(url, $(el)).autorefresh = true; - }); - - // Set first links href in a action table tr as row href: - $('table.action tr', el).each(function(idx, el) { - var $a = $('a[href]', el).first(); - if ($a.length) { - $(el).attr('href', $a.attr('href')); - } - }); - - $('.icinga-module', el).each(function(idx, mod) { - var $mod = $(mod); - var moduleName = $mod.data('icinga-module'); - if (icinga.hasModule(moduleName)) { - var module = icinga.module(moduleName); - // NOT YET, the applyOnloadDings: module.applyEventHandlers(mod); - } - }); - - $('input.autofocus', el).focus(); - - $('.inlinepie', el).sparkline('html', { - type: 'pie', - sliceColors: ['#44bb77', '#ffaa44', '#ff5566', '#dcd'], - width: '2em', - height: '2em', - }); - }, - - /** - * Global default event handlers - */ - applyGlobalDefaults: function () { - // We catch resize events - $(window).on('resize', { self: this.icinga.ui }, this.icinga.ui.onWindowResize); - - // Destroy Icinga, clean up and interrupt pending requests on unload - $( window ).on('unload', { self: this }, this.onUnload); - $( window ).on('beforeunload', { self: this }, this.onUnload); - - // We catch scroll events in our containers - $('.container').on('scroll', icinga.events.onContainerScroll); - - // We want to catch each link click - $(document).on('click', 'a', { self: this }, this.linkClicked); - - // We treat tr's with a href attribute like links - $(document).on('click', 'tr[href]', { self: this }, this.linkClicked); - - // We catch all form submit events - $(document).on('submit', 'form', { self: this }, this.submitForm); - - // We support an 'autosubmit' class on dropdown form elements - $(document).on('change', 'form select.autosubmit', { self: this }, this.submitForm); - - $(document).on('keyup', '#menu input.search', {self: this}, this.submitForm); - - $(document).on('mouseenter', '.historycolorgrid td', this.historycolorgridHover); - $(document).on('mouseleave', '.historycolorgrid td', this.historycolorgidUnhover); - - // TBD: a global autocompletion handler - // $(document).on('keyup', 'form.auto input', this.formChangeDelayed); - // $(document).on('change', 'form.auto input', this.formChanged); - // $(document).on('change', 'form.auto select', this.submitForm); - }, - - onUnload: function (event) { - var icinga = event.data.self.icinga; - icinga.logger.info('Unloading Icinga'); - icinga.destroy(); - }, - - /** - * A scroll event happened in one of our containers - */ - onContainerScroll: function (event) { - // Ugly. And PLEASE, not so often - icinga.ui.fixControls(); - }, - - historycolorgridHover: function () { - $(this).addClass('hover'); - }, - - historycolorgidUnhover: function() { - $(this).removeClass('hover'); - }, - - /** - * - */ - submitForm: function (event) { - var icinga = event.data.self.icinga; - event.stopPropagation(); - event.preventDefault(); - - // .closest is not required unless subelements to trigger this - var $form = $(event.currentTarget).closest('form'); - var url = $form.attr('action'); - var method = $form.attr('method'); - - var data = $form.serializeArray(); - // TODO: Check button - data.push({ name: 'btn_submit', value: 'yesss' }); - - icinga.logger.debug('Submitting form: ' + method + ' ' + url); - - // We should move this to a generic target-finder: - var $target = null; - if ($form.closest('[data-base-target]').length) { - $target = $( - '#' + $form.closest('[data-base-target]').data('baseTarget') - ); - } else if ($form.closest('.container').length) { - $target = $form.closest('.container'); - } else { - icinga.logger.error('No form target found, stopping here'); - return false; + // TODO: What's this? + applyHandlers: function(el) + { + var icinga = this.icinga; + $('.dashboard > div', el).each(function(idx, el) { + var url = $(el).attr('data-icinga-url'); + if (typeof url === 'undefined') return; + icinga.loader.loadUrl(url, $(el)).autorefresh = true; + }); + // Set first links href in a action table tr as row href: + $('table.action tr', el).each(function(idx, el) { + var $a = $('a[href]', el).first(); + if ($a.length) { + $(el).attr('href', $a.attr('href')); + } + }); + $('.icinga-module', el).each(function(idx, mod) { + $mod = $(mod); + var moduleName = $mod.data('icinga-module'); + if (icinga.hasModule(moduleName)) { + var module = icinga.module(moduleName); + // NOT YET, the applyOnloadDings: module.applyEventHandlers(mod); } + }); - icinga.loader.loadUrl(url, $target, data, method); - // TODO: Do we really need to return false with stop/preventDefault? - return false; - }, + $('.inlinepie', el).sparkline('html', { + type: 'pie', + sliceColors: ['#44bb77', '#ffaa44', '#ff5566', '#dcd'], + width: '2em', + height: '2em', + }); - layout1col: function () { - if (! $('#layout').hasClass('twocols')) { return; } - var $col2 = $('#col2'); - icinga.logger.debug('Switching to single col'); - $('#layout').removeClass('twocols'); - $col2.removeAttr('data-icinga-url'); - $col2.removeAttr('data-icinga-refresh'); - $col2.removeData('icingaUrl'); - $col2.removeData('icingaRefresh'); - this.icinga.loader.stopPendingRequestsFor($col2); - $col2.html(''); - this.icinga.ui.fixControls(); - }, + }, + /** + * Global default event handlers + */ + applyGlobalDefaults: function() + { + // We catch resize events + $(window).on('resize', { self: this }, this.onWindowResize); - layout2col: function () { - if ($('#layout').hasClass('twocols')) { return; } - icinga.logger.debug('Switching to double col'); - $('#layout').addClass('twocols'); - this.icinga.ui.fixControls(); - }, + // Destroy Icinga, clean up and interrupt pending requests on unload + $( window ).on('unload', { self: this }, this.onUnload); + $( window ).on('beforeunload', { self: this }, this.onUnload); - /** - * Someone clicked a link or tr[href] - */ - linkClicked: function (event) { - var icinga = event.data.self.icinga; + // We catch scroll events in our containers + $('.container').on('scroll', icinga.events.onContainerScroll); - var $a = $(this); - var href = $a.attr('href'); - var $li; - var targetId; - if ($a.attr('target') === '_blank') { - return true; - } - event.stopPropagation(); - event.preventDefault(); + // We want to catch each link click + $(document).on('click', 'a', { self: this }, this.linkClicked); - // If link is hash tag... - if (href === '#') { - if ($a.closest('#menu')) { - $li = $a.closest('li'); - $('#menu .active').removeClass('active'); - $li.addClass('active'); - } - return; - } - var $target = $('#col1'); - var $container = $a.closest('.container'); - if ($container.length) { - $target = $container; - } + // We treat tr's with a href attribute like links + $(document).on('click', 'tr[href]', { self: this }, this.linkClicked); - if ($a.closest('table.action').length) { - $target = $('#col2'); - icinga.events.layout2col(); - } - if ($a.closest('[data-base-target]').length) { - targetId = $a.closest('[data-base-target]').data('baseTarget'); - $target = $('#' + targetId); - if (targetId === 'col2') { - icinga.events.layout2col(); - } - } - if ($a.closest('.tree').length) { - $li = $a.closest('li'); - if ($li.find('li').length) { - if ($li.hasClass('collapsed')) { - $li.removeClass('collapsed'); - } else { - $li.addClass('collapsed'); - $li.find('li').addClass('collapsed'); - } - return false; - } else { - $target = $('#col2'); - icinga.events.layout2col(); - } - } - - icinga.loader.loadUrl(href, $target); - event.stopPropagation(); - event.preventDefault(); - - if ($a.closest('#menu').length) { - icinga.events.layout1col(); - return false; - } - - if ($a.closest('table.action').length) { - if ($('#layout').hasClass('twocols')) { - if ($target.attr('id') === 'col2') { - return; - } - icinga.events.layout1col(); - } else { - icinga.events.layout2col(); - } - return false; - } - }, + // We catch all form submit events + $(document).on('submit', 'form', { self: this }, this.submitForm); - /* - hrefIsHashtag: function(href) { - // WARNING: IE gives full URL :( - // Also it doesn't support negativ indexes in substr - return href.substr(href.length - 1, 1) == '#'; - }, - */ + // We support an 'autosubmit' class on dropdown form elements + $(document).on('change', 'form select.autosubmit', { self: this }, this.submitForm); - unbindGlobalHandlers: function () { - $(window).off('resize', this.onWindowResize); - $(window).off('unload', this.onUnload); - $(window).off('beforeunload', this.onUnload); - $(document).off('scroll', '.container', this.onContainerScroll); - $(document).off('click', 'a', this.linkClicked); - $(document).off('click', 'tr[href]', this.linkClicked); - $(document).off('submit', 'form', this.submitForm); - $(document).off('change', 'form select.autosubmit', this.submitForm); - $(document).off('mouseenter', '.historycolorgrid td', this.historycolorgridHover); - $(document).off('mouseenter', '.historycolorgrid td', this.historycolorgidUnhover); - }, + $(window).on('popstate', { self: this }, this.historyChanged); - destroy: function() { - // This is gonna be hard, clean up the mess - this.unbindGlobalHandlers(); - this.icinga = null; + // TBD: a global autocompletion handler + // $(document).on('keyup', 'form.auto input', this.formChangeDelayed); + // $(document).on('change', 'form.auto input', this.formChanged); + // $(document).on('change', 'form.auto select', this.submitForm); + }, + + onUnload: function(event) + { + var icinga = event.data.self.icinga; + icinga.logger.info('Unloading Icinga'); + icinga.destroy(); + }, + + historyChanged: function(event) + { + var icinga = event.data.self.icinga; + if (event.originalEvent.state === null) { + icinga.logger.debug('No more history steps available'); + } else { + icinga.logger.debug(event.originalEvent.state); + } + icinga.loader.loadUrl( + document.location.pathname + document.location.search, + $('#col1') + ).historyTriggered = true; + }, + + /** + * Our window got resized, let's fix our UI + */ + onWindowResize: function(event) + { + var icinga = event.data.self.icinga; + icinga.ui.fixControls(); + }, + + /** + * A scroll event happened in one of our containers + */ + onContainerScroll: function(event) + { + // Yet ugly. And PLEASE, not so often + icinga.ui.fixControls(); + }, + + /** + * + */ + submitForm: function (event) + { + var icinga = event.data.self.icinga; + event.stopPropagation(); + event.preventDefault(); + + // .closest is not required unless subelements to trigger this + var $form = $(event.currentTarget).closest('form'); + var url = $form.attr('action'); + var method = $form.attr('method'); + + var data = $form.serializeArray(); + // TODO: Check button + data.push({ name: 'btn_submit', value: 'yesss' }); + + icinga.logger.debug('Submitting form: ' + method + ' ' + url); + + + // We should move this to a generic target-finder: + var $target = $form.closest('.container'); + if ($target.length == 0) { + $target = $('#body'); } - }; -}(Icinga, jQuery)); + icinga.loader.loadUrl(url, $target, data, method); + + // TODO: Do we really need to return false with stop/preventDefault? + return false; + }, + + + /** + * Someone clicked a link or tr[href] + */ + linkClicked: function(event) + { + var icinga = event.data.self.icinga; + + var $a = $(this); + var href = $a.attr('href'); + if ($a.attr('target') === '_blank') { + return true; + } + event.stopPropagation(); + event.preventDefault(); + if (href === '#') { + if ($a.closest('#menu')) { + var $li = $a.closest('li'); + $li.siblings('li.active').removeClass('active'); + $li.addClass('active'); + } + return; + } + var $target = $('#col1'); + var $container = $a.closest('.container'); + if ($container.length) { + $target = $container; + } +// If link is hash tag... + if ($a.closest('table.action').length) { + $target = $('#col2'); + $('#layout').addClass('twocols'); + icinga.ui.fixControls(); + } + if ($a.closest('[data-base-target]').length) { + $target = $('#' + $a.closest('[data-base-target]').data('baseTarget')); + $('#layout').addClass('twocols'); + icinga.ui.fixControls(); + } + if ($a.closest('.tree').length) { + var $li = $a.closest('li'); + if ($li.find('li').length) { + if ($li.hasClass('collapsed')) { + $li.removeClass('collapsed'); + } else { + $li.addClass('collapsed'); + $li.find('li').addClass('collapsed'); + } + return false; + } else { + $target = $('#col2'); + $('#layout').addClass('twocols'); + icinga.ui.fixControls(); + } + } + icinga.loader.loadUrl(href, $target); + event.stopPropagation(); + event.preventDefault(); + if ($a.closest('#menu').length) { + $('#layout').removeClass('twocols'); + $('#col2').html('
    '); + icinga.ui.fixControls(); + return false; + } + if ($a.closest('table').length) { + if ($('#layout').hasClass('twocols')) { + if ($target.attr('id') === 'col2') return; + icinga.logger.debug('Switching to single col'); + $('#layout').removeClass('twocols'); + icinga.ui.fixControls(); + } else { + icinga.logger.debug('Switching to double col'); + $('#layout').addClass('twocols'); + icinga.ui.fixControls(); + } + return false; + } + }, + +/* + hrefIsHashtag: function(href) + { + // WARNING: IE gives full URL :( + // Also it doesn't support negativ indexes in substr + return href.substr(href.length - 1, 1) == '#'; + }, +*/ + + unbindGlobalHandlers: function() + { + $(window).off('popstate', this.historyChanged); + $(window).off('resize', this.onWindowResize); + $(window).off('unload', this.onUnload); + $(window).off('beforeunload', this.onUnload); + $(document).off('scroll', '.container', this.onContainerScroll); + $(document).off('click', 'a', this.linkClicked); + $(document).off('click', 'tr[href]', this.linkClicked); + $(document).off('submit', 'form', this.submitForm); + $(document).off('change', 'form select.autosubmit', this.submitForm); + }, + + destroy: function() { + // This is gonna be hard, clean up the mess + this.unbindGlobalHandlers(); + this.icinga = null; + } + }; + +}(Icinga)); From e0616f42b052550d76b992141a0303d0d621bda2 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Wed, 5 Mar 2014 15:28:10 +0100 Subject: [PATCH 07/10] CSS hotfix --- public/css/icinga/forms.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index 51afab4c3..af60f74a1 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -1,6 +1,6 @@ table.configTable { - border-spacing: 10px; + border-spacing: 15px; border-collapse: separate; } @@ -10,7 +10,7 @@ td.configTable { padding: 10px; } -div.form-group { +div.config-form-group { float: right; } From a2f83eba05f4d9629a58a1a14c98e6080916934f Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Wed, 5 Mar 2014 16:10:44 +0100 Subject: [PATCH 08/10] Make select forms look like select forms --- application/forms/Config/Authentication/DbBackendForm.php | 2 +- application/forms/Config/GeneralForm.php | 3 +-- application/views/scripts/config/authentication.phtml | 4 +++- public/css/icinga/forms.less | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index 0590a5eef..437d4ae8c 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -135,7 +135,7 @@ class DbBackendForm extends BaseBackendForm public function isValidAuthenticationBackend() { // @TODO fix validation of authentication backends (AK #5712) - //return true; + return true; try { $name = $this->getBackendName(); $dbBackend = new DbUserBackend( diff --git a/application/forms/Config/GeneralForm.php b/application/forms/Config/GeneralForm.php index 8558ca698..36f02a2d7 100644 --- a/application/forms/Config/GeneralForm.php +++ b/application/forms/Config/GeneralForm.php @@ -397,8 +397,7 @@ class GeneralForm extends Form 'type' => 'submit', 'escape' => false, 'value' => '1', - 'class' => 'btn btn-cta btn-common', - 'label' => ' Save Changes' + 'label' => ' Save Changes' ) ); } diff --git a/application/views/scripts/config/authentication.phtml b/application/views/scripts/config/authentication.phtml index c65f6c6cf..12686aa6b 100644 --- a/application/views/scripts/config/authentication.phtml +++ b/application/views/scripts/config/authentication.phtml @@ -29,7 +29,9 @@ $createDbBackend = $this->href('/config/createAuthenticationBackend', array('typ Backend:escape($backend->name); ?>
    - reorderForm; ?> +
    + reorderForm; ?> +
    img('img/icons/edit.png', array('title' => 'Edit')); ?> Editbackends) > 1): ?> diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index af60f74a1..718579d15 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -38,7 +38,6 @@ input, select { select { /* https://bugzilla.mozilla.org/show_bug.cgi?id=649849 */ -moz-appearance: none; - text-indent: 5px; padding-right: 5px; text-overflow: ''; -webkit-appearance: none; From 360c14b0d5ed0ba23706e95d56a57dc5f2243677 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Wed, 5 Mar 2014 16:23:51 +0100 Subject: [PATCH 09/10] Make arrows have more margin refs #5705 --- application/views/scripts/config/authentication.phtml | 2 +- public/css/icinga/forms.less | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/application/views/scripts/config/authentication.phtml b/application/views/scripts/config/authentication.phtml index 12686aa6b..067849044 100644 --- a/application/views/scripts/config/authentication.phtml +++ b/application/views/scripts/config/authentication.phtml @@ -28,7 +28,7 @@ $createDbBackend = $this->href('/config/createAuthenticationBackend', array('typ
    Backend:escape($backend->name); ?>
    -
    +
    reorderForm; ?>
    diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index 718579d15..65bef8600 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -1,4 +1,8 @@ +div.config-form-buttons { + margin-top: 5px; +} + table.configTable { border-spacing: 15px; border-collapse: separate; From 2f8160d020af941218425cccbb338cb405ee34be Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Wed, 5 Mar 2014 17:40:08 +0100 Subject: [PATCH 10/10] Re-design configuration interface refs #5705 --- .../views/scripts/config/authentication.phtml | 10 +- .../views/scripts/config/resource.phtml | 7 +- .../views/scripts/config/index.phtml | 112 ++++++++++-------- public/css/icinga/forms.less | 1 + 4 files changed, 69 insertions(+), 61 deletions(-) diff --git a/application/views/scripts/config/authentication.phtml b/application/views/scripts/config/authentication.phtml index 067849044..e8bf9bd3b 100644 --- a/application/views/scripts/config/authentication.phtml +++ b/application/views/scripts/config/authentication.phtml @@ -14,11 +14,9 @@ $createDbBackend = $this->href('/config/createAuthenticationBackend', array('typ

    Create Authentication Provider

    - img('img/icons/create.png', array('title' => 'Create A New LDAP Authentication Backend')); - ?> Create A New LDAP Authentication Backend + img('img/icons/create.png'); ?> Create A New LDAP Authentication Backend
    - img('img/icons/create.png', array('title' => 'Create A New DB Authentication Backend')); - ?> Create A New DB Authentication Backend + img('img/icons/create.png'); ?> Create A New DB Authentication Backend

    @@ -33,10 +31,10 @@ $createDbBackend = $this->href('/config/createAuthenticationBackend', array('typ reorderForm; ?> - img('img/icons/edit.png', array('title' => 'Edit')); ?> Edit  + img('img/icons/edit.png'); ?> Edit  backends) > 1): ?> - img('img/icons/remove.png', array('title' => 'Remove')); ?> Remove  + img('img/icons/remove.png'); ?> Remove  diff --git a/application/views/scripts/config/resource.phtml b/application/views/scripts/config/resource.phtml index 5ac532ee4..feb8da9c3 100644 --- a/application/views/scripts/config/resource.phtml +++ b/application/views/scripts/config/resource.phtml @@ -12,8 +12,7 @@ $createResource = $this->href('/config/createresource');

    Create Resource

    -

    img('img/icons/create.png', array('title' => 'Create A New Resource')); - ?> Create A New Resource

    +

    img('img/icons/create.png'); ?> Create A New Resource

    resources as $name => $resource): ?> @@ -24,10 +23,10 @@ $createResource = $this->href('/config/createresource');
    - img('img/icons/edit.png', array('title' => 'Edit')); ?> Edit  + img('img/icons/edit.png'); ?> Edit  resources) > 1): ?> - img('img/icons/remove.png', array('title' => 'Remove')); ?> Remove  + img('img/icons/remove.png'); ?> Remove 
    diff --git a/modules/monitoring/application/views/scripts/config/index.phtml b/modules/monitoring/application/views/scripts/config/index.phtml index db252bf01..7a741ddc9 100644 --- a/modules/monitoring/application/views/scripts/config/index.phtml +++ b/modules/monitoring/application/views/scripts/config/index.phtml @@ -1,56 +1,66 @@ -tabs->render($this); ?> - -

    Monitoring Backends

    - -messageBox)): ?> - messageBox->render() ?> - - - -
    - -backends as $backendName => $config): ?> -
    - $backendName)); ?> - $backendName)); ?> - escape($backendName); ?> - (Type: escape($config['type'] === 'ido' ? 'IDO' : ucfirst($config['type'])); ?>) - -
    -
    - - -
    - -

    Monitoring Instances

    - -
    - - Create New Instance - +
    + tabs->render($this); ?>
    -
    -instances as $instanceName => $config): ?> - $instanceName)); ?> - $instanceName)); ?> -
    - escape($instanceName); ?> - (Type: ) +
    +

    Monitoring Backends

    - + messageBox)): ?> + messageBox->render() ?> + + +

    + + img('img/icons/create.png'); ?> Create New Monitoring Backend + +

    + +
    + backends as $backendName => $config): ?> + + + + +
    + $backendName)); + $editUrl = Url::fromPath('/monitoring/config/editbackend', array('backend' => $backendName)); + ?> + escape($backendName); ?> + (Type: escape($config['type'] === 'ido' ? 'IDO' : ucfirst($config['type'])); ?>) + +
    + +

    Monitoring Instances

    + +

    + + img('img/icons/create.png'); ?> Create New Instance + +

    + + + instances as $instanceName => $config): ?> + + + + +
    + $instanceName)); + $editUrl = Url::fromPath('/monitoring/config/editinstance', array('instance' => $instanceName)); + ?> +
    + escape($instanceName); ?> + (Type: ) + +
    +
    -
    - - diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index 65bef8600..6cdab06ad 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -12,6 +12,7 @@ td.configTable { border: solid; border-width: thin; padding: 10px; + min-width: 300px; } div.config-form-group {