mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
parent
5ff3db8a3c
commit
294f9022f2
@ -3,11 +3,8 @@
|
|||||||
|
|
||||||
namespace Icinga\Controllers;
|
namespace Icinga\Controllers;
|
||||||
|
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Web\Controller\ActionController;
|
use Icinga\Web\Controller\ActionController;
|
||||||
use Icinga\Web\Hook;
|
|
||||||
use Icinga\Web\Menu;
|
|
||||||
use Icinga\Web\MenuRenderer;
|
|
||||||
use Icinga\Web\Url;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create complex layout parts
|
* Create complex layout parts
|
||||||
@ -21,9 +18,6 @@ class LayoutController extends ActionController
|
|||||||
{
|
{
|
||||||
$this->setAutorefreshInterval(15);
|
$this->setAutorefreshInterval(15);
|
||||||
$this->_helper->layout()->disableLayout();
|
$this->_helper->layout()->disableLayout();
|
||||||
|
$this->view->menuRenderer = Icinga::app()->getMenu()->getRenderer();
|
||||||
$url = Url::fromRequest();
|
|
||||||
$menu = new MenuRenderer(Menu::load(), $url->getRelativeUrl());
|
|
||||||
$this->view->menuRenderer = $menu->useCustomRenderer();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Web\Menu;
|
|
||||||
use Icinga\Web\MenuRenderer;
|
|
||||||
|
|
||||||
// Don't render a menu for unauthenticated users unless menu is auth aware
|
// Don't render a menu for unauthenticated users unless menu is auth aware
|
||||||
if (! $this->auth()->isAuthenticated()) {
|
if (! $this->auth()->isAuthenticated()) {
|
||||||
@ -27,10 +25,7 @@ if (! $this->auth()->isAuthenticated()) {
|
|||||||
'layout/menu.phtml',
|
'layout/menu.phtml',
|
||||||
'default',
|
'default',
|
||||||
array(
|
array(
|
||||||
'menuRenderer' => new MenuRenderer(
|
'menuRenderer' => Icinga::app()->getMenu()->getRenderer()
|
||||||
Menu::load(),
|
|
||||||
Url::fromRequest()->without('renderLayout')->getRelativeUrl()
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
) ?>
|
) ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,8 +12,5 @@ if ($searchDashboard->search('dummy')->getPane('search')->hasDashlets()): ?>
|
|||||||
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
<? endif; ?>
|
<?php endif; ?>
|
||||||
<nav>
|
<?= $menuRenderer->setHeading(t('Navigation')); ?>
|
||||||
<h1 id="navigation" class="sr-only"><?= t('Navigation'); ?></h1>
|
|
||||||
<?= $menuRenderer; ?>
|
|
||||||
</nav>
|
|
@ -16,6 +16,7 @@ use Icinga\User;
|
|||||||
use Icinga\Util\TimezoneDetect;
|
use Icinga\Util\TimezoneDetect;
|
||||||
use Icinga\Util\Translator;
|
use Icinga\Util\Translator;
|
||||||
use Icinga\Web\Controller\Dispatcher;
|
use Icinga\Web\Controller\Dispatcher;
|
||||||
|
use Icinga\Web\Navigation\Navigation;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
use Icinga\Web\Session;
|
use Icinga\Web\Session;
|
||||||
use Icinga\Web\Session\Session as BaseSession;
|
use Icinga\Web\Session\Session as BaseSession;
|
||||||
@ -139,6 +140,118 @@ class Web extends EmbeddedWeb
|
|||||||
return $this->viewRenderer;
|
return $this->viewRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the app's menu
|
||||||
|
*
|
||||||
|
* @return Navigation
|
||||||
|
*/
|
||||||
|
public function getMenu()
|
||||||
|
{
|
||||||
|
if ($this->user !== null) {
|
||||||
|
$menu = array(
|
||||||
|
'dashboard' => array(
|
||||||
|
'label' => t('Dashboard'),
|
||||||
|
'url' => 'dashboard',
|
||||||
|
'icon' => 'dashboard',
|
||||||
|
'priority' => 10
|
||||||
|
),
|
||||||
|
'system' => array(
|
||||||
|
'label' => t('System'),
|
||||||
|
'icon' => 'services',
|
||||||
|
'priority' => 700,
|
||||||
|
'renderer' => array(
|
||||||
|
'SummaryNavigationItemRenderer',
|
||||||
|
'state' => 'critical'
|
||||||
|
),
|
||||||
|
'children' => array(
|
||||||
|
'about' => array(
|
||||||
|
'label' => t('About'),
|
||||||
|
'url' => 'about',
|
||||||
|
'priority' => 701
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'configuration' => array(
|
||||||
|
'label' => t('Configuration'),
|
||||||
|
'icon' => 'wrench',
|
||||||
|
'permission' => 'config/*',
|
||||||
|
'priority' => 800,
|
||||||
|
'children' => array(
|
||||||
|
'application' => array(
|
||||||
|
'label' => t('Application'),
|
||||||
|
'url' => 'config/general',
|
||||||
|
'permission' => 'config/application/*',
|
||||||
|
'priority' => 810
|
||||||
|
),
|
||||||
|
'authentication' => array(
|
||||||
|
'label' => t('Authentication'),
|
||||||
|
'url' => 'config/userbackend',
|
||||||
|
'permission' => 'config/authentication/*',
|
||||||
|
'priority' => 820
|
||||||
|
),
|
||||||
|
'roles' => array(
|
||||||
|
'label' => t('Roles'),
|
||||||
|
'url' => 'role/list',
|
||||||
|
'permission' => 'config/authentication/roles/show',
|
||||||
|
'priority' => 830
|
||||||
|
),
|
||||||
|
'users' => array(
|
||||||
|
'label' => t('Users'),
|
||||||
|
'url' => 'user/list',
|
||||||
|
'permission' => 'config/authentication/users/show',
|
||||||
|
'priority' => 840
|
||||||
|
),
|
||||||
|
'groups' => array(
|
||||||
|
'label' => t('Usergroups'),
|
||||||
|
'url' => 'group/list',
|
||||||
|
'permission' => 'config/authentication/groups/show',
|
||||||
|
'priority' => 850
|
||||||
|
),
|
||||||
|
'modules' => array(
|
||||||
|
'label' => t('Modules'),
|
||||||
|
'url' => 'config/modules',
|
||||||
|
'permission' => 'config/modules',
|
||||||
|
'priority' => 890
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'user' => array(
|
||||||
|
'label' => $this->user->getUsername(),
|
||||||
|
'icon' => 'user',
|
||||||
|
'priority' => 900,
|
||||||
|
'children' => array(
|
||||||
|
'preferences' => array(
|
||||||
|
'label' => t('Preferences'),
|
||||||
|
'url' => 'preference',
|
||||||
|
'priority' => 910
|
||||||
|
),
|
||||||
|
'logout' => array(
|
||||||
|
'label' => t('Logout'),
|
||||||
|
'url' => 'authentication/logout',
|
||||||
|
'priority' => 990,
|
||||||
|
'renderer' => array(
|
||||||
|
'NavigationItemRenderer',
|
||||||
|
'target' => '_self'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Logger::writesToFile()) {
|
||||||
|
$menu['system']['children']['application_log'] = array(
|
||||||
|
'label' => t('Application Log'),
|
||||||
|
'url' => 'list/applicationlog',
|
||||||
|
'priority' => 710
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$menu = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Navigation::fromArray($menu);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatch public interface
|
* Dispatch public interface
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user