From 545db945da06b7c6444ef1d44c816437517fcab3 Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Mon, 8 Sep 2014 15:21:14 +0200 Subject: [PATCH] Auto refresh menu Put the navigation into a container and reload it once every 15 seconds from a distinct menu action. Include the current path into an URL param to still be able to mark the current menu item as active. fixes #6955 --- application/controllers/LayoutController.php | 7 ++++--- .../layouts/scripts/parts/navigation.phtml | 17 +++++++++++----- application/views/scripts/layout/menu.phtml | 14 ++++++++++++- public/js/icinga/events.js | 20 +++++++++++++++---- 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/application/controllers/LayoutController.php b/application/controllers/LayoutController.php index 6c1355fc1..7d2ea9ae5 100644 --- a/application/controllers/LayoutController.php +++ b/application/controllers/LayoutController.php @@ -18,10 +18,11 @@ class LayoutController extends ActionController */ public function menuAction() { + $this->setAutorefreshInterval(15); $this->_helper->layout()->disableLayout(); - $this->view->menuRenderer = new MenuRenderer( - Menu::load(), Url::fromRequest()->without('renderLayout')->getRelativeUrl() - ); + + $url = Url::fromPath($this->getParam('url')); + $this->view->menuRenderer = new MenuRenderer(Menu::load(), $url->getRelativeUrl()); } /** diff --git a/application/layouts/scripts/parts/navigation.phtml b/application/layouts/scripts/parts/navigation.phtml index 5dedc75aa..5de8f3e40 100644 --- a/application/layouts/scripts/parts/navigation.phtml +++ b/application/layouts/scripts/parts/navigation.phtml @@ -9,13 +9,20 @@ use Icinga\Web\Widget\SearchDashboard; if (! $this->auth()->isAuthenticated()) { return; } +$dataIcingaUrl = $this->href( + 'layout/menu', + array('url' => Url::fromRequest()->without('renderLayout')->getAbsoluteUrl()) +); ?> -