From b9c9f564ec5bbb5b357226ffdc36c30c2df70ce3 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Thu, 12 Feb 2015 15:12:10 +0100 Subject: [PATCH 01/24] Add editable auto_refresh parameter to the user preferences refs #7945 --- application/forms/PreferenceForm.php | 11 +++++++++++ library/Icinga/Web/Controller/ActionController.php | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/application/forms/PreferenceForm.php b/application/forms/PreferenceForm.php index 424f76578..3ee1ebb38 100644 --- a/application/forms/PreferenceForm.php +++ b/application/forms/PreferenceForm.php @@ -185,6 +185,17 @@ class PreferenceForm extends Form ) ); + $this->addElement( + 'checkbox', + 'auto_refresh', + array( + 'required' => false, + 'label' => $this->translate('Enable auto refresh'), + 'description' => $this->translate('This option allows you to enable or to disable the global page content auto refresh'), + 'value' => 1 + ) + ); + if ($this->store) { $this->addElement( 'submit', diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index f7a21c20e..8764e49ee 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -399,6 +399,10 @@ class ActionController extends Zend_Controller_Action $layout->benchmark = $this->renderBenchmark(); } } + + if ((bool) $user->getPreferences()->getValue('icingaweb', 'auto_refresh', true) === false) { + $this->disableAutoRefresh(); + } } if ($req->getParam('format') === 'pdf') { From 9bf8488f68aacbe8ad5937b002fff97ec79c33b5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 13 Feb 2015 09:59:34 +0100 Subject: [PATCH 02/24] js: Remove out-commented function hrefIsHashtag from events.js --- public/js/icinga/events.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 57c365649..528899dcb 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -517,14 +517,6 @@ return $target; }, - /* - 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 () { $.each(self.icinga.behaviors, function (name, behavior) { behavior.unbind($(document)); From cd11cf3469f4317e6b18948b414c0c9b9bb23637 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Fri, 13 Feb 2015 11:45:20 +0100 Subject: [PATCH 03/24] Fix close button: Test the anchor if it belongs to us --- public/js/icinga/events.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 528899dcb..3fbb9cf79 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -415,7 +415,8 @@ event.preventDefault(); // This is an anchor only - if (href.substr(0, 1) === '#' && href.substr(1, 1) !== '!') { + if (href.substr(0, 1) === '#' && href.length > 1 + && href.substr(1, 1) !== '!') { self.handleAnchor(href); return; } From 2112676594f67ddfdee81c6a9615b8a350659321 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 13 Feb 2015 14:34:29 +0100 Subject: [PATCH 04/24] Implement hidden accessible control for auto refresh on the page refs #7945 --- application/forms/AutoRefreshForm.php | 79 +++++++++++++++++++ application/layouts/scripts/body.phtml | 5 ++ .../Web/Controller/ActionController.php | 11 +++ public/css/icinga/menu.less | 19 +++++ 4 files changed, 114 insertions(+) create mode 100644 application/forms/AutoRefreshForm.php diff --git a/application/forms/AutoRefreshForm.php b/application/forms/AutoRefreshForm.php new file mode 100644 index 000000000..85992af27 --- /dev/null +++ b/application/forms/AutoRefreshForm.php @@ -0,0 +1,79 @@ +setName('form_auto_refresh'); + } + + /** + * Adjust preferences and persist them + * + * @see Form::onSuccess() + */ + public function onSuccess() + { + /** @var Preferences $preferences */ + $preferences = $this->getRequest()->getUser()->getPreferences(); + $icingaweb = $preferences->get('icingaweb'); + + if ((bool) $preferences->getValue('icingaweb', 'auto_refresh', true) === false) { + $icingaweb['auto_refresh'] = '1'; + $notification = $this->translate('Auto refresh successfully enabled'); + } else { + $icingaweb['auto_refresh'] = '0'; + $notification = $this->translate('Auto refresh successfully disabled'); + } + $preferences->icingaweb = $icingaweb; + + Session::getSession()->user->setPreferences($preferences); + Notification::success($notification); + + $this->getResponse()->setHeader('X-Icinga-Rerender-Layout', 'yes'); + } + + /** + * @see Form::createElements() + */ + public function createElements(array $formData) + { + $preferences = $this->getRequest()->getUser()->getPreferences(); + + if ((bool) $preferences->getValue('icingaweb', 'auto_refresh', true) === false) { + $value = $this->translate('Enable auto refresh'); + } else { + $value = $this->translate('Disable auto refresh'); + } + + $this->addElements(array( + array( + 'button', + 'btn_submit', + array( + 'ignore' => true, + 'type' => 'submit', + 'value' => $value, + 'decorators' => array('ViewHelper'), + 'escape' => false, + 'class' => 'link-like' + ) + ) + )); + } +} diff --git a/application/layouts/scripts/body.phtml b/application/layouts/scripts/body.phtml index 9f0b78ce9..abf823750 100644 --- a/application/layouts/scripts/body.phtml +++ b/application/layouts/scripts/body.phtml @@ -23,6 +23,11 @@ if (Auth::getInstance()->isAuthenticated()): ?> + +
+ layout()->autoRefreshForm ?> +
+
    layout()->moduleName; diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 8764e49ee..0a1fe8ae4 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -10,6 +10,7 @@ use Icinga\Authentication\Manager; use Icinga\Exception\IcingaException; use Icinga\Exception\ProgrammingError; use Icinga\File\Pdf; +use Icinga\Forms\AutoRefreshForm; use Icinga\Security\SecurityException; use Icinga\Util\Translator; use Icinga\Web\Notification; @@ -379,6 +380,16 @@ class ActionController extends Zend_Controller_Action } } + /** + * @see Zend_Controller_Action::preDispatch() + */ + public function preDispatch() + { + $form = new AutoRefreshForm(); + $form->handleRequest(); + $this->_helper->layout()->autoRefreshForm = $form; + } + /** * Detect whether the current request requires changes in the layout and apply them before rendering * diff --git a/public/css/icinga/menu.less b/public/css/icinga/menu.less index 873e6abb0..53150f498 100644 --- a/public/css/icinga/menu.less +++ b/public/css/icinga/menu.less @@ -300,3 +300,22 @@ a:focus { .skip-links-inline { margin-top: -3.5em; } + +.auto-refresh-trigger { + position: absolute; + form { + button[type="submit"] { + position: absolute; + display: block; + left: -999em; + width: 12em !important; + top: 0.4em; + padding: 0.8em 0.8em !important; + background-color: white !important; + text-align: left !important; + &:focus { + left: 0; + } + } + } +} \ No newline at end of file From 73a03ada83ea5f75a531a8b61827e7abc332b845 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 13 Feb 2015 15:33:39 +0100 Subject: [PATCH 05/24] Move autoRefreshForm to skip-links refs #7945 --- application/layouts/scripts/body.phtml | 7 +++---- public/css/icinga/menu.less | 24 +++--------------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/application/layouts/scripts/body.phtml b/application/layouts/scripts/body.phtml index abf823750..71f83ebd1 100644 --- a/application/layouts/scripts/body.phtml +++ b/application/layouts/scripts/body.phtml @@ -20,14 +20,13 @@ if (Auth::getInstance()->isAuthenticated()): ?>
  • +
  • + layout()->autoRefreshForm ?> +
-
- layout()->autoRefreshForm ?> -
-
    layout()->moduleName; diff --git a/public/css/icinga/menu.less b/public/css/icinga/menu.less index 53150f498..cc5156ebd 100644 --- a/public/css/icinga/menu.less +++ b/public/css/icinga/menu.less @@ -280,11 +280,12 @@ a:focus { display: inline; margin: 0; padding: 0; - a { + a, button[type="submit"] { position: absolute; display: block; left: -999em; - width: 10.4em; + width: 10.8em !important; + text-align: left !important; top: 0.4em; padding: 0.8em; background-color: white; @@ -300,22 +301,3 @@ a:focus { .skip-links-inline { margin-top: -3.5em; } - -.auto-refresh-trigger { - position: absolute; - form { - button[type="submit"] { - position: absolute; - display: block; - left: -999em; - width: 12em !important; - top: 0.4em; - padding: 0.8em 0.8em !important; - background-color: white !important; - text-align: left !important; - &:focus { - left: 0; - } - } - } -} \ No newline at end of file From b375a4f6ccd5e5388eae0184505568cee36c102b Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Fri, 13 Feb 2015 16:21:19 +0100 Subject: [PATCH 06/24] Fix multiple renderLayout parameters in the url refs #7945 --- application/forms/AutoRefreshForm.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/forms/AutoRefreshForm.php b/application/forms/AutoRefreshForm.php index 85992af27..e1e436d34 100644 --- a/application/forms/AutoRefreshForm.php +++ b/application/forms/AutoRefreshForm.php @@ -8,6 +8,7 @@ use Icinga\User\Preferences; use Icinga\Web\Form; use Icinga\Web\Notification; use Icinga\Web\Session; +use Icinga\Web\Url; /** * Form class to adjust user auto refresh preferences @@ -46,6 +47,7 @@ class AutoRefreshForm extends Form Notification::success($notification); $this->getResponse()->setHeader('X-Icinga-Rerender-Layout', 'yes'); + $this->setRedirectUrl(Url::fromRequest()->without('renderLayout')); } /** From 97f5018247027fd0c3894b7114d3f9e251774200 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 16 Feb 2015 10:23:54 +0100 Subject: [PATCH 07/24] WCAG/1.1.1: Fix example for accessible icon fonts to work with NVDA too refs #8358 --- doc/accessibility/ifont.html | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/doc/accessibility/ifont.html b/doc/accessibility/ifont.html index 481cbff71..32f122127 100644 --- a/doc/accessibility/ifont.html +++ b/doc/accessibility/ifont.html @@ -10,22 +10,9 @@ .icon-star:before { content: "★"; } - .sr-only { - border: 0; - clip: rect(0 0 0 0); - height: 1px; - margin: -1px; - overflow: hidden; - padding: 0; - position: absolute; - width: 1px; - } - - - Top rated article - + - + \ No newline at end of file From 243bc6ec0cdcddc6363533a28d2d62055e32740f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 16 Feb 2015 10:26:03 +0100 Subject: [PATCH 08/24] Make the view helpers qlink, img and icon handle aria-tags automatically refs #8358 refs #8360 --- library/Icinga/Web/View/helpers/url.php | 63 +++++++++++++++---------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/library/Icinga/Web/View/helpers/url.php b/library/Icinga/Web/View/helpers/url.php index 1f1450b5e..9fa5d4a69 100644 --- a/library/Icinga/Web/View/helpers/url.php +++ b/library/Icinga/Web/View/helpers/url.php @@ -27,55 +27,68 @@ $this->addHelperFunction('url', function ($path = null, $params = null) { return $url; }); +$this->addHelperFunction('qlink', function ($title, $url, $params = null, $properties = array(), $escape = true) use ($view) { + if (array_key_exists('title', $properties) && !array_key_exists('aria-label', $properties)) { + $properties['aria-label'] = $properties['title']; + } -$this->addHelperFunction('qlink', function ($title, $url, $params = null, $properties = array()) use ($view) { return sprintf( '%s', $view->url($url, $params), $view->propertiesToString($properties), - $view->escape($title) + $escape ? $view->escape($title) : $title ); }); -$this->addHelperFunction('img', function ($url, array $properties = array()) use ($view) { +$this->addHelperFunction('img', function ($url, $params = null, array $properties = array()) use ($view) { if (! array_key_exists('alt', $properties)) { $properties['alt'] = ''; } + if (array_key_exists('title', $properties)) { + if (! array_key_exists('aria-label', $properties)) { + $properties['aria-label'] = $properties['title']; + } + } elseif (! array_key_exists('aria-hidden', $properties)) { + $properties['aria-hidden'] = 'true'; + } + return sprintf( '', - $view->url($url), + $view->url($url, $params), $view->propertiesToString($properties) ); }); $this->addHelperFunction('icon', function ($img, $title = null, array $properties = array()) use ($view) { - $isClass = strpos($img, '.') === false; - $class = null; - - if ($isClass) { - $class = 'icon-' . $img; - } else { - $class = 'icon'; - } - if ($title !== null) { - $properties['alt'] = $title; - $properties['title'] = $title; - } - - if ($class !== null) { - if (isset($props['class'])) { - $properties['class'] .= ' ' . $class; + if (strpos($img, '.') !== false) { + if (array_key_exists('class', $properties)) { + $properties['class'] .= ' icon'; } else { - $properties['class'] = $class; + $properties['class'] = 'icon'; } - } - if ($isClass) { - return sprintf('', $view->propertiesToString($properties)); - } else { return $view->img('img/icons/' . $img, $properties); } + + if ($title !== null) { + $properties['role'] = 'img'; + $properties['title'] = $title; + + if (! array_key_exists('aria-label', $properties)) { + $properties['aria-label'] = $title; + } + } elseif (! array_key_exists('aria-hidden', $properties)) { + $properties['aria-hidden'] = 'true'; + } + + if (isset($properties['class'])) { + $properties['class'] .= ' icon-' . $img; + } else { + $properties['class'] = 'icon-' . $img; + } + + return sprintf('', $view->propertiesToString($properties)); }); $this->addHelperFunction('propertiesToString', function ($properties) use ($view) { From 5321c2f9e5bd7ae23a5b5ea5d8d1492f99662c63 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 16 Feb 2015 10:52:42 +0100 Subject: [PATCH 09/24] Mute icons properly using the new automatic mechanisms of our view helpers refs #8360 --- application/layouts/scripts/pdf.phtml | 2 +- .../views/scripts/authentication/login.phtml | 4 ++-- .../scripts/config/authentication/reorder.phtml | 2 +- application/views/scripts/config/resource.phtml | 2 +- .../Icinga/Web/Form/Decorator/NoScriptApply.php | 2 +- library/Icinga/Web/Widget/FilterEditor.php | 2 +- library/Icinga/Web/Widget/Tab.php | 4 ++-- library/Icinga/Web/Widget/Tabs.php | 2 +- .../views/scripts/alertsummary/index.phtml | 6 +++--- .../application/views/scripts/config/index.phtml | 4 ++-- .../application/views/scripts/hosts/show.phtml | 14 +++++++------- .../views/scripts/list/contactgroups.phtml | 2 +- .../application/views/scripts/list/contacts.phtml | 2 +- .../partials/command/objects-command-form.phtml | 4 ++-- .../application/views/scripts/services/show.phtml | 14 +++++++------- .../scripts/show/components/acknowledgement.phtml | 2 +- .../scripts/show/components/checkstatistics.phtml | 2 +- .../views/scripts/show/components/command.phtml | 2 +- .../views/scripts/show/components/comments.phtml | 2 +- .../views/scripts/show/components/contacts.phtml | 4 ++-- .../views/scripts/show/components/downtime.phtml | 2 +- .../views/scripts/show/components/hostgroups.phtml | 2 +- .../scripts/show/components/servicegroups.phtml | 2 +- .../setup/application/forms/AuthenticationPage.php | 4 ++-- 24 files changed, 44 insertions(+), 44 deletions(-) diff --git a/application/layouts/scripts/pdf.phtml b/application/layouts/scripts/pdf.phtml index 38c9bdc2c..c5b28ecbf 100644 --- a/application/layouts/scripts/pdf.phtml +++ b/application/layouts/scripts/pdf.phtml @@ -31,7 +31,7 @@ if ( isset($pdf) ) } -img('img/logo_icinga_big_dark.png', array('align' => 'right', 'width' => '75')) ?> +img('img/logo_icinga_big_dark.png', null, array('align' => 'right', 'width' => '75')) ?>