From 08795e7cf4dd63cca39dc985446b29f30ea56a3e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:33:52 +0100 Subject: [PATCH 01/19] monitoring/security: Expect restriction name in ListController::applyRestriction() Before, the restriction was hard coded to 'monitoring/filter'. This restriction will be removed because we can not use the very same filter for all views. --- .../controllers/ListController.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index a9ccb7ee8..823cb6a4e 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -2,6 +2,7 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; +use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; @@ -216,8 +217,8 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->extraColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); - $this->filterQuery($query); + $this->setupSortControl(array( 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), @@ -661,20 +662,24 @@ class Monitoring_ListController extends Controller if ($sort = $this->params->get('sort')) { $query->order($sort, $this->params->get('dir')); } - $this->applyRestrictions($query); $this->handleFormatRequest($query); return $query; } /** - * Apply current user's `monitoring/filter' restrictions on the given data view + * Apply a restriction on the given data view + * + * @param string $restriction The name of restriction + * @param DataView $view The view to restrict + * + * @return DataView $view */ - protected function applyRestrictions($query) + protected function applyRestriction($restriction, DataView $view) { - foreach ($this->getRestrictions('monitoring/filter') as $restriction) { - // TODO: $query->applyFilter(Filter::fromQueryString()); + foreach ($this->getRestrictions($restriction) as $filter) { + $view->applyFilter(Filter::fromQueryString($filter)); } - return $query; + return $view; } protected function extraColumns() From 405e18a46f23634dd2e8ec77212955ebc7f02528 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:37:28 +0100 Subject: [PATCH 02/19] monitoring: Fix PHPDoc for MonitoringBackend::from() --- .../library/Monitoring/Backend/MonitoringBackend.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php index c8f75f540..d165f1252 100644 --- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php @@ -145,7 +145,7 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface $this->type = lcfirst(substr($class, 0, -7)); } else { throw new ProgrammingError( - '%s is not a valid monitoring backend class name', + '%s is not a valid monitoring backend class name', $class ); } @@ -251,7 +251,7 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface * @param string $name * @param array $columns * - * @return DataView + * @return \Icinga\Module\Monitoring\DataView\DataView */ public function from($name, array $columns = null) { From f8aa9eb05c5693cddd726eac8bb97abb98a29464 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:48:33 +0100 Subject: [PATCH 03/19] monitoring/security: Replace 'monitoring/filter' restrictions with filter for the hosts and the services view --- modules/monitoring/configuration.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/configuration.php b/modules/monitoring/configuration.php index 6b1fe1cda..72df4e73f 100644 --- a/modules/monitoring/configuration.php +++ b/modules/monitoring/configuration.php @@ -56,8 +56,13 @@ $this->providePermission( ); $this->provideRestriction( - 'monitoring/filter', - $this->translate('Restrict views to the hosts and services that match the filter') + 'monitoring/hosts/filter', + $this->translate('Restrict hosts view to the hosts that match the filter') +); + +$this->provideRestriction( + 'monitoring/services/filter', + $this->translate('Restrict services view to the services that match the filter') ); $this->provideConfigTab('backends', array( From c8084dde923bb6e0c66874004307130078c8bc37 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:49:51 +0100 Subject: [PATCH 04/19] monitoring/security: Apply services restriction in the services overview --- modules/monitoring/application/controllers/ListController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 823cb6a4e..bd7c66e1b 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -217,8 +217,11 @@ class Monitoring_ListController extends Controller 'max_check_attempts' => 'service_max_check_attempts' ), $this->extraColumns()); $query = $this->backend->select()->from('serviceStatus', $columns); + $this->filterQuery($query); + $this->applyRestriction('monitoring/services/filter', $query); + $this->setupSortControl(array( 'service_severity' => $this->translate('Service Severity'), 'service_state' => $this->translate('Current Service State'), From f37cd0cb95a28f8b1d5f424c74abf8438e64a853 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 13:51:15 +0100 Subject: [PATCH 05/19] monitoring/security: Apply hosts restriction in the hosts overview --- modules/monitoring/application/controllers/ListController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index bd7c66e1b..cd9e8077a 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -132,6 +132,8 @@ class Monitoring_ListController extends Controller $this->filterQuery($query); + $this->applyRestriction('monitoring/hosts/filter', $query); + $this->setupSortControl(array( 'host_severity' => $this->translate('Severity'), 'host_state' => $this->translate('Current State'), From 3cbafe16f6923cf28550aa52677698951aafd3a3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:22:37 +0100 Subject: [PATCH 06/19] monitoring/security: Move applyRestriction() to the module's base controller --- .../controllers/ListController.php | 17 ---------------- .../library/Monitoring/Controller.php | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index cd9e8077a..faaea713a 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -2,7 +2,6 @@ use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Backend; -use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm; use Icinga\Web\Url; @@ -671,22 +670,6 @@ class Monitoring_ListController extends Controller return $query; } - /** - * Apply a restriction on the given data view - * - * @param string $restriction The name of restriction - * @param DataView $view The view to restrict - * - * @return DataView $view - */ - protected function applyRestriction($restriction, DataView $view) - { - foreach ($this->getRestrictions($restriction) as $filter) { - $view->applyFilter(Filter::fromQueryString($filter)); - } - return $view; - } - protected function extraColumns() { $columns = preg_split( diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index 32bafb8b2..de9ea8161 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -4,9 +4,11 @@ namespace Icinga\Module\Monitoring; +use Icinga\Data\Filter\Filter; +use Icinga\File\Csv; +use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Url; -use Icinga\File\Csv; /** * Base class for all monitoring action controller @@ -60,5 +62,21 @@ class Controller extends ModuleActionController exit; } } + + /** + * Apply a restriction on the given data view + * + * @param string $restriction The name of restriction + * @param DataView $view The view to restrict + * + * @return DataView $view + */ + protected function applyRestriction($restriction, DataView $view) + { + foreach ($this->getRestrictions($restriction) as $filter) { + $view->applyFilter(Filter::fromQueryString($filter)); + } + return $view; + } } From b2f93abb120bf6802edecdd0f02a977d1e27a94a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:24:56 +0100 Subject: [PATCH 07/19] monitoring/security: Require a Filterable instead of a DataView in applyRestriction() --- modules/monitoring/library/Monitoring/Controller.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index de9ea8161..f294e9a2e 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -5,8 +5,8 @@ namespace Icinga\Module\Monitoring; use Icinga\Data\Filter\Filter; +use Icinga\Data\Filterable; use Icinga\File\Csv; -use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Web\Controller\ModuleActionController; use Icinga\Web\Url; @@ -67,11 +67,11 @@ class Controller extends ModuleActionController * Apply a restriction on the given data view * * @param string $restriction The name of restriction - * @param DataView $view The view to restrict + * @param Filterable $filterable The filterable to restrict * - * @return DataView $view + * @return Filterable The filterable */ - protected function applyRestriction($restriction, DataView $view) + protected function applyRestriction($restriction, Filterable $view) { foreach ($this->getRestrictions($restriction) as $filter) { $view->applyFilter(Filter::fromQueryString($filter)); From c53b1d27e9ec6c25b9719a9aa8842cb2b55ae3af Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:33:46 +0100 Subject: [PATCH 08/19] lib: Deprecate Data\Filterable because of ... addFilter and applyFilter do the same in all usages. addFilter could be replaced w/ getFilter()->add(). We must no require classes implementing this interface to implement redundant methods over and over again. The interface must be moved to the namespace Icinga\Data\Filter. It lacks documentation. --- library/Icinga/Data/Filterable.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Icinga/Data/Filterable.php b/library/Icinga/Data/Filterable.php index 73ce5dcb4..25d1fc9f5 100644 --- a/library/Icinga/Data/Filterable.php +++ b/library/Icinga/Data/Filterable.php @@ -8,6 +8,11 @@ use Icinga\Data\Filter\Filter; /** * Interface for filtering a result set + * + * @deprecated(EL): addFilter and applyFilter do the same in all usages. + * addFilter could be replaced w/ getFilter()->add(). We must no require classes implementing this interface to + * implement redundant methods over and over again. This interface must be moved to the namespace Icinga\Data\Filter. + * It lacks documentation. */ interface Filterable { From e086905384837e49e772fc893451ad0c5a3cb0ce Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:52:13 +0100 Subject: [PATCH 09/19] monitoring: Deprecate DataView::addFilter() and DataView::setFilter() The from now on deprecated interface Filterable has proven that it sucks in the DataView. Because of requiring us to implement trillion stupid methods, only DataView::applyFilter() does not forget to handle column validation. Thus only DataView::applyFilter() must be used in order to apply filters. For setFilter() a wrapping Filter::matchAny() for the IdoQuery (or the DbQuery or the SimpleQuery I didn't have a look) is required for the filter to work properly. The deprecation is just for the records. I guess we do not use the other methods. --- .../monitoring/library/Monitoring/DataView/DataView.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 5900df737..da48f31c3 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -355,12 +355,21 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable return $this; } + /** + * @deprecated(EL): Only use DataView::applyFilter() for applying filter because all other functions are missing + * column validation. Filter::matchAny() for the IdoQuery (or the DbQuery or the SimpleQuery I didn't have a look) + * is required for the filter to work properly. + */ public function setFilter(Filter $filter) { $this->query->setFilter($filter); return $this; } + /** + * @deprecated(EL): Only use DataView::applyFilter() for applying filter because all other functions are missing + * column validation. + */ public function addFilter(Filter $filter) { $this->query->addFilter(clone($filter)); From 7bf6bd39e9d2a21e25dfd04efc095ebe6f95eeb3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:54:21 +0100 Subject: [PATCH 10/19] monitoring: Implement Filterable in MonitoredObject --- .../Monitoring/Object/MonitoredObject.php | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 8d3246aab..213cf47b8 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -7,13 +7,15 @@ namespace Icinga\Module\Monitoring\Object; use InvalidArgumentException; use Icinga\Application\Config; use Icinga\Exception\InvalidPropertyException; +use Icinga\Data\Filter\Filter; +use Icinga\Data\Filterable; use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Web\UrlParams; /** * A monitored Icinga object, i.e. host or service */ -abstract class MonitoredObject +abstract class MonitoredObject implements Filterable { /** * Type host @@ -116,6 +118,13 @@ abstract class MonitoredObject */ protected $stats; + /** + * Filter + * + * @type Filter + */ + protected $filter; + /** * Create a monitored object, i.e. host or service * @@ -133,6 +142,35 @@ abstract class MonitoredObject */ abstract protected function getDataView(); + public function applyFilter(Filter $filter) + { + $this->getFilter()->addFilter($filter); + return $this; + } + + public function setFilter(Filter $filter) + { + // Left out on purpose. Interface is deprecated. + } + + public function getFilter() + { + if ($this->filter === null) { + $this->filter = Filter::matchAny(); + } + return $this->filter; + } + + public function addFilter(Filter $filter) + { + // Left out on purpose. Interface is deprecated. + } + + public function where($condition, $value = null) + { + // Left out on purpose. Interface is deprecated. + } + /** * Fetch the object's properties * @@ -140,7 +178,7 @@ abstract class MonitoredObject */ public function fetch() { - $this->properties = $this->getDataView()->getQuery()->fetchRow(); + $this->properties = $this->getDataView()->applyFilter($this->getFilter())->getQuery()->fetchRow(); if ($this->properties === false) { return false; } From 49d4d74dbbefe25434621b716c46c443d292e62d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:57:22 +0100 Subject: [PATCH 11/19] monitoring/security: Apply hosts/filter restriction in the host detail view --- modules/monitoring/application/controllers/HostController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index d01335734..3a5038ad6 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -26,6 +26,9 @@ class Monitoring_HostController extends MonitoredObjectController public function init() { $host = new Host($this->backend, $this->params->get('host')); + + $this->applyRestriction('monitoring/hosts/filter', $host); + if ($host->fetch() === false) { throw new Zend_Controller_Action_Exception($this->translate('Host not found')); } From 49b82af70407c3cfafdc088556237423a3d98223 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 27 Jan 2015 14:57:54 +0100 Subject: [PATCH 12/19] monitoring/security: Apply services/filter restriction in the service detail view --- .../monitoring/application/controllers/ServiceController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index c05683400..fe4795fb1 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -26,6 +26,9 @@ class Monitoring_ServiceController extends MonitoredObjectController public function init() { $service = new Service($this->backend, $this->params->get('host'), $this->params->get('service')); + + $this->applyRestriction('monitoring/services/filter', $service); + if ($service->fetch() === false) { throw new Zend_Controller_Action_Exception($this->translate('Service not found')); } From 6fde4eec30054afa6f8580a864a3bf80ee1a0e44 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 12:50:29 +0100 Subject: [PATCH 13/19] Show all tabs except "Add to Dashboard" when issuing a command refs #8279 --- library/Icinga/Web/Widget/Tabs.php | 19 +++++++++++++++++++ .../controllers/HostController.php | 8 -------- .../controllers/ServiceController.php | 8 -------- .../views/scripts/partials/command-form.phtml | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index 72522282e..c6a4bd31b 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -218,6 +218,25 @@ EOT; return $this; } + /** + * Remove a tab + * + * @param string $name + * + * @return self + */ + public function remove($name) + { + if ($this->has($name)) { + unset($this->tabs[$name]); + if (($dropdownIndex = array_search($name, $this->dropdownTabs)) !== false) { + array_splice($this->dropdownTabs, $dropdownIndex, 2); + } + } + + return $this; + } + /** * Add a tab to the dropdown on the right side of the tab-bar. * diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 3a5038ad6..4eccb8899 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -34,15 +34,7 @@ class Monitoring_HostController extends MonitoredObjectController } $this->object = $host; $this->createTabs(); - } - - /** - * Show a host - */ - public function showAction() - { $this->getTabs()->activate('host'); - parent::showAction(); } /** diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index fe4795fb1..4e4e67402 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -34,15 +34,7 @@ class Monitoring_ServiceController extends MonitoredObjectController } $this->object = $service; $this->createTabs(); - } - - /** - * Show a service - */ - public function showAction() - { $this->getTabs()->activate('service'); - parent::showAction(); } /** diff --git a/modules/monitoring/application/views/scripts/partials/command-form.phtml b/modules/monitoring/application/views/scripts/partials/command-form.phtml index 9832bfe17..380687a00 100644 --- a/modules/monitoring/application/views/scripts/partials/command-form.phtml +++ b/modules/monitoring/application/views/scripts/partials/command-form.phtml @@ -1,5 +1,5 @@
- tabs->showOnlyCloseButton() ?> + tabs->remove('dashboard') ?>

icon('help', $form->getHelp()) ?>

From c19ff289bfcf52cdedc8a97b8fbc1cbc78a5346f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 13:02:37 +0100 Subject: [PATCH 14/19] Open command forms in the same column where their link is located refs #8279 --- .../views/scripts/show/components/acknowledgement.phtml | 2 +- .../views/scripts/show/components/checkstatistics.phtml | 2 +- .../application/views/scripts/show/components/command.phtml | 2 +- .../application/views/scripts/show/components/comments.phtml | 2 +- .../application/views/scripts/show/components/downtime.phtml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml index 339652113..8da35590f 100644 --- a/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml +++ b/modules/monitoring/application/views/scripts/show/components/acknowledgement.phtml @@ -35,7 +35,7 @@ if ($object->acknowledged): ?> ); } ?> - + icon('ok') ?> translate('Acknowledge') ?> getType() === $object::TYPE_HOST) { ); } ?> - + icon('reschedule') ?> translate('Reschedule') ?> diff --git a/modules/monitoring/application/views/scripts/show/components/command.phtml b/modules/monitoring/application/views/scripts/show/components/command.phtml index 5239dad41..a74b5b884 100644 --- a/modules/monitoring/application/views/scripts/show/components/command.phtml +++ b/modules/monitoring/application/views/scripts/show/components/command.phtml @@ -21,7 +21,7 @@ $command = array_shift($parts); array('host' => $object->getHost()->getName(), 'service' => $object->getName()) ); } ?> - + icon('reply') ?> translate('Process check result') ?> diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml index dde42c747..a6503a70b 100644 --- a/modules/monitoring/application/views/scripts/show/components/comments.phtml +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -15,7 +15,7 @@ ); } ?> - + icon('comment') ?> translate('Add comment') ?> diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index 8f42a865e..4aa1e21c1 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -15,7 +15,7 @@ ); } ?> - + icon('plug') ?> translate('Schedule downtime') ?> From 7ef86ddf49cd1adba53c4a4c488b1d9c3ccb638c Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 28 Jan 2015 13:19:49 +0100 Subject: [PATCH 15/19] Navigation: Bypass error-prone hover selector for IE8 refs #6417 --- public/js/icinga/behavior/navigation.js | 39 +++++++++++++++---------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index 53fc5c8af..b8a12064d 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -130,23 +130,26 @@ } setTimeout(function () { - if (! $li.is('li:hover')) { - return; - } - if ($li.hasClass('active')) { - return; - } + try { + if (!$li.is('li:hover')) { + return; + } + if ($li.hasClass('active')) { + return; + } + } catch(e) { /* Bypass because if IE8 */ } $li.siblings().each(function () { var $sibling = $(this); - if ($sibling.is('li:hover')) { - return; - } + try { + if ($sibling.is('li:hover')) { + return; + } + } catch(e) { /* Bypass because if IE8 */ }; if ($sibling.hasClass('hover')) { $sibling.removeClass('hover'); } }); - self.hoverElement($li); }, delay); }; @@ -161,9 +164,11 @@ } setTimeout(function () { - if ($li.is('li:hover') || $sidebar.is('sidebar:hover') ) { - return; - } + try { + if ($li.is('li:hover') || $sidebar.is('sidebar:hover')) { + return; + } + } catch(e) { /* Bypass because if IE8 */ }; $li.removeClass('hover'); $('#layout').removeClass('hoveredmenu'); }, 500); @@ -183,9 +188,11 @@ self = event.data.self; setTimeout(function () { // TODO: make this behave well together with keyboard navigation - if (! $li.is('li:hover') /*&& ! $li.find('a:focus')*/) { - $li.removeClass('hover'); - } + try { + if (!$li.is('li:hover') /*&& ! $li.find('a:focus')*/) { + $li.removeClass('hover'); + } + } catch(e) { /* Bypass because if IE8 */ } }, 300); }; Icinga.Behaviors.Navigation = Navigation; From cf857c42571071ca760f8e66598dc5910de3b991 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 14:15:16 +0100 Subject: [PATCH 16/19] Close forms when switching between the main app's configuration tabs refs #6436 --- application/views/scripts/config/authentication/reorder.phtml | 2 +- application/views/scripts/config/index.phtml | 2 +- application/views/scripts/config/resource.phtml | 2 +- application/views/scripts/roles/index.phtml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/views/scripts/config/authentication/reorder.phtml b/application/views/scripts/config/authentication/reorder.phtml index 688d99f88..807f80efe 100644 --- a/application/views/scripts/config/authentication/reorder.phtml +++ b/application/views/scripts/config/authentication/reorder.phtml @@ -1,4 +1,4 @@ -
+
diff --git a/application/views/scripts/config/index.phtml b/application/views/scripts/config/index.phtml index dab0acc4f..1ffd120b4 100644 --- a/application/views/scripts/config/index.phtml +++ b/application/views/scripts/config/index.phtml @@ -1,4 +1,4 @@ -
+
tabs->render($this); ?>
diff --git a/application/views/scripts/config/resource.phtml b/application/views/scripts/config/resource.phtml index c5d4ca0fc..f93b2af82 100644 --- a/application/views/scripts/config/resource.phtml +++ b/application/views/scripts/config/resource.phtml @@ -1,4 +1,4 @@ -
+
diff --git a/application/views/scripts/roles/index.phtml b/application/views/scripts/roles/index.phtml index 79eda5dac..925cdfa4e 100644 --- a/application/views/scripts/roles/index.phtml +++ b/application/views/scripts/roles/index.phtml @@ -1,4 +1,4 @@ -
+

translate('Roles') ?>

From 618ab4f4b9cdc3975cc096eaabfe04da70244fb0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 14:21:06 +0100 Subject: [PATCH 17/19] Introduce link target "_right" to keep a column with tabs rightmost I'd have liked to get it to work that in case the tab control is not in the rightmost column a "go back" in the history is being simulated causing the preceding leftmost column(s) to be restored and the rightmost one set to the one containing the tab control. But the history api does not seem to support any read operations except for the current state.. refs #6436 --- application/views/scripts/config/module.phtml | 2 +- .../application/views/scripts/config/index.phtml | 2 +- .../application/views/scripts/config/security.phtml | 2 +- public/js/icinga/events.js | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/application/views/scripts/config/module.phtml b/application/views/scripts/config/module.phtml index cd6ad5af8..e26ade195 100644 --- a/application/views/scripts/config/module.phtml +++ b/application/views/scripts/config/module.phtml @@ -1,4 +1,4 @@ -
+
tabs ?>

escape($module->getTitle()) ?>

diff --git a/modules/monitoring/application/views/scripts/config/index.phtml b/modules/monitoring/application/views/scripts/config/index.phtml index b1729f9b1..deca8d468 100644 --- a/modules/monitoring/application/views/scripts/config/index.phtml +++ b/modules/monitoring/application/views/scripts/config/index.phtml @@ -1,4 +1,4 @@ -
+

translate('Monitoring Backends') ?>

diff --git a/modules/monitoring/application/views/scripts/config/security.phtml b/modules/monitoring/application/views/scripts/config/security.phtml index 71f2a341a..2a84b2469 100644 --- a/modules/monitoring/application/views/scripts/config/security.phtml +++ b/modules/monitoring/application/views/scripts/config/security.phtml @@ -1,4 +1,4 @@ -
+
tabs ?>
diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index e7ac3e3f1..b7f2f5cee 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -482,6 +482,16 @@ targetId = 'col1'; $target = $('#' + targetId); self.icinga.ui.layout1col(); + } else if (targetId === '_right') { + // Ensure that the content is displayed in the rightmost column + $target = $el.closest('.container'); + if ($target.attr('id') === 'col1') { + // As it's not possible to detect what's preceding the current state in the + // history stack this just simulates _main in case the respective element + // is not part of the rightmost column + $target = $('#col1'); + self.icinga.ui.layout1col(); + } } else { $target = $('#' + targetId); } From f486dabe6dea7d5b9cd5299889de582996c938ea Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 28 Jan 2015 14:22:42 +0100 Subject: [PATCH 18/19] Drop view script config/logging.phtml as it's not used anywhere --- .../views/scripts/config/logging.phtml | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 application/views/scripts/config/logging.phtml diff --git a/application/views/scripts/config/logging.phtml b/application/views/scripts/config/logging.phtml deleted file mode 100644 index da6d886cc..000000000 --- a/application/views/scripts/config/logging.phtml +++ /dev/null @@ -1,35 +0,0 @@ -
-tabs->render($this); ?> -
- -
-form->getErrorMessages(); ?> - -messageBox)): ?> - messageBox->render() ?> - - -successMessage): ?> -
- - escape($this->successMessage); ?> -
- - - -
-

Errors occured when trying to save the project.

-

- The following errors occured when trying to save the configuration: -

-
    - -
  • escape($error) ?>
  • - -
-
- - -form ?> -
- From 9d051905173e72790b11465009891b3ab36a51fa Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 28 Jan 2015 17:03:23 +0100 Subject: [PATCH 19/19] ifont: Fix empty font glyphs for IE8 The embedded font is included inline in the stylesheets. IE falls back and tries to load one of the other font sources which was not exported by the web server. This fix moves the fontello directory to public and add add a prefix path to the embedded stylesheet. refs #6417 --- library/Icinga/Web/LessCompiler.php | 6 ++++-- library/Icinga/Web/StyleSheet.php | 5 +++-- .../fonts/fontello-ifont/LICENSE.txt | 0 .../fonts/fontello-ifont/README.txt | 0 .../fonts/fontello-ifont/config.json | 0 .../fonts/fontello-ifont/css/animation.css | 0 .../fonts/fontello-ifont/css/ifont-codes.css | 0 .../fonts/fontello-ifont/css/ifont-embedded.less | 6 +++--- .../fonts/fontello-ifont/css/ifont-ie7-codes.css | 0 .../fonts/fontello-ifont/css/ifont-ie7.css | 0 .../fonts/fontello-ifont/css/ifont.css | 0 .../fonts/fontello-ifont/demo.html | 0 .../fonts/fontello-ifont/font/ifont.eot | Bin .../fonts/fontello-ifont/font/ifont.svg | 0 .../fonts/fontello-ifont/font/ifont.ttf | Bin .../fonts/fontello-ifont/font/ifont.woff | Bin public/fonts/fontello-ifont/icingaweb.md | 6 ++++++ 17 files changed, 16 insertions(+), 7 deletions(-) rename {application => public}/fonts/fontello-ifont/LICENSE.txt (100%) rename {application => public}/fonts/fontello-ifont/README.txt (100%) rename {application => public}/fonts/fontello-ifont/config.json (100%) rename {application => public}/fonts/fontello-ifont/css/animation.css (100%) rename {application => public}/fonts/fontello-ifont/css/ifont-codes.css (100%) rename application/fonts/fontello-ifont/css/ifont-embedded.css => public/fonts/fontello-ifont/css/ifont-embedded.less (99%) rename {application => public}/fonts/fontello-ifont/css/ifont-ie7-codes.css (100%) rename {application => public}/fonts/fontello-ifont/css/ifont-ie7.css (100%) rename {application => public}/fonts/fontello-ifont/css/ifont.css (100%) rename {application => public}/fonts/fontello-ifont/demo.html (100%) rename {application => public}/fonts/fontello-ifont/font/ifont.eot (100%) rename {application => public}/fonts/fontello-ifont/font/ifont.svg (100%) rename {application => public}/fonts/fontello-ifont/font/ifont.ttf (100%) rename {application => public}/fonts/fontello-ifont/font/ifont.woff (100%) create mode 100644 public/fonts/fontello-ifont/icingaweb.md diff --git a/library/Icinga/Web/LessCompiler.php b/library/Icinga/Web/LessCompiler.php index 791fdbab0..a5349f1a4 100644 --- a/library/Icinga/Web/LessCompiler.php +++ b/library/Icinga/Web/LessCompiler.php @@ -38,15 +38,17 @@ class LessCompiler /** * Create a new instance + * + * @param string $basePath Provide web base path optional */ - public function __construct() + public function __construct($basePath = null) { require_once 'lessphp/lessc.inc.php'; $this->lessc = new lessc(); $this->lessc->setVariables( array( - 'baseurl' => '\'' . Zend_Controller_Front::getInstance()->getBaseUrl(). '\'' + 'baseurl' => '\'' . $basePath. '\'' ) ); } diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index 719d1c829..52bc4b27b 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -11,7 +11,7 @@ use Icinga\Web\LessCompiler; class StyleSheet { protected static $lessFiles = array( - '../application/fonts/fontello-ifont/css/ifont-embedded.css', + 'fonts/fontello-ifont/css/ifont-embedded.less', 'css/vendor/tipsy.css', 'css/icinga/defaults.less', 'css/icinga/layout-colors.less', @@ -96,7 +96,8 @@ class StyleSheet $cache->send($cacheFile); return; } - $less = new LessCompiler(); + + $less = new LessCompiler(dirname($_SERVER['PHP_SELF'])); foreach ($lessFiles as $file) { $less->addFile($file); } diff --git a/application/fonts/fontello-ifont/LICENSE.txt b/public/fonts/fontello-ifont/LICENSE.txt similarity index 100% rename from application/fonts/fontello-ifont/LICENSE.txt rename to public/fonts/fontello-ifont/LICENSE.txt diff --git a/application/fonts/fontello-ifont/README.txt b/public/fonts/fontello-ifont/README.txt similarity index 100% rename from application/fonts/fontello-ifont/README.txt rename to public/fonts/fontello-ifont/README.txt diff --git a/application/fonts/fontello-ifont/config.json b/public/fonts/fontello-ifont/config.json similarity index 100% rename from application/fonts/fontello-ifont/config.json rename to public/fonts/fontello-ifont/config.json diff --git a/application/fonts/fontello-ifont/css/animation.css b/public/fonts/fontello-ifont/css/animation.css similarity index 100% rename from application/fonts/fontello-ifont/css/animation.css rename to public/fonts/fontello-ifont/css/animation.css diff --git a/application/fonts/fontello-ifont/css/ifont-codes.css b/public/fonts/fontello-ifont/css/ifont-codes.css similarity index 100% rename from application/fonts/fontello-ifont/css/ifont-codes.css rename to public/fonts/fontello-ifont/css/ifont-codes.css diff --git a/application/fonts/fontello-ifont/css/ifont-embedded.css b/public/fonts/fontello-ifont/css/ifont-embedded.less similarity index 99% rename from application/fonts/fontello-ifont/css/ifont-embedded.css rename to public/fonts/fontello-ifont/css/ifont-embedded.less index 92bcfdff9..294c342e3 100644 --- a/application/fonts/fontello-ifont/css/ifont-embedded.css +++ b/public/fonts/fontello-ifont/css/ifont-embedded.less @@ -1,8 +1,8 @@ @font-face { font-family: 'ifont'; - src: url('../font/ifont.eot?75097146'); - src: url('../font/ifont.eot?75097146#iefix') format('embedded-opentype'), - url('../font/ifont.svg?75097146#ifont') format('svg'); + src: url('@{baseurl}/fonts/fontello-ifont/font/ifont.eot?75097146'); + src: url('@{baseurl}/fonts/fontello-ifont/font/ifont.eot?75097146#iefix') format('embedded-opentype'), + url('@{baseurl}/fonts/fontello-ifont/ifont.svg?75097146#ifont') format('svg'); font-weight: normal; font-style: normal; } diff --git a/application/fonts/fontello-ifont/css/ifont-ie7-codes.css b/public/fonts/fontello-ifont/css/ifont-ie7-codes.css similarity index 100% rename from application/fonts/fontello-ifont/css/ifont-ie7-codes.css rename to public/fonts/fontello-ifont/css/ifont-ie7-codes.css diff --git a/application/fonts/fontello-ifont/css/ifont-ie7.css b/public/fonts/fontello-ifont/css/ifont-ie7.css similarity index 100% rename from application/fonts/fontello-ifont/css/ifont-ie7.css rename to public/fonts/fontello-ifont/css/ifont-ie7.css diff --git a/application/fonts/fontello-ifont/css/ifont.css b/public/fonts/fontello-ifont/css/ifont.css similarity index 100% rename from application/fonts/fontello-ifont/css/ifont.css rename to public/fonts/fontello-ifont/css/ifont.css diff --git a/application/fonts/fontello-ifont/demo.html b/public/fonts/fontello-ifont/demo.html similarity index 100% rename from application/fonts/fontello-ifont/demo.html rename to public/fonts/fontello-ifont/demo.html diff --git a/application/fonts/fontello-ifont/font/ifont.eot b/public/fonts/fontello-ifont/font/ifont.eot similarity index 100% rename from application/fonts/fontello-ifont/font/ifont.eot rename to public/fonts/fontello-ifont/font/ifont.eot diff --git a/application/fonts/fontello-ifont/font/ifont.svg b/public/fonts/fontello-ifont/font/ifont.svg similarity index 100% rename from application/fonts/fontello-ifont/font/ifont.svg rename to public/fonts/fontello-ifont/font/ifont.svg diff --git a/application/fonts/fontello-ifont/font/ifont.ttf b/public/fonts/fontello-ifont/font/ifont.ttf similarity index 100% rename from application/fonts/fontello-ifont/font/ifont.ttf rename to public/fonts/fontello-ifont/font/ifont.ttf diff --git a/application/fonts/fontello-ifont/font/ifont.woff b/public/fonts/fontello-ifont/font/ifont.woff similarity index 100% rename from application/fonts/fontello-ifont/font/ifont.woff rename to public/fonts/fontello-ifont/font/ifont.woff diff --git a/public/fonts/fontello-ifont/icingaweb.md b/public/fonts/fontello-ifont/icingaweb.md new file mode 100644 index 000000000..fa0a52c7d --- /dev/null +++ b/public/fonts/fontello-ifont/icingaweb.md @@ -0,0 +1,6 @@ +# fontello-ifont has been moved + +The font directory has been moved to the public structure because of Internet Explorer version 8 compatibility. The +common way for browsers is to include the binary embeded font type in the javascript. IE8 falls back and include one of +the provided font sources. Therefore it is important to have the font files available public and exported by the +HTTP server. \ No newline at end of file