-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/menu-configuration-3759'
resolves #3759
- Loading branch information
Showing
8 changed files
with
596 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?= $this->sub ? '<ul>' : '<ul class="nav nav-stacked" role="navigation" id="icinganavigation">' ?> | ||
<?php foreach ($this->items as $item): ?> | ||
<?php | ||
$itemClass = ''; | ||
if ($this->sub) { | ||
$itemClass .= 'submenu '; | ||
} | ||
if ($this->href($this->url) === $this->href($item->getUrl())) { | ||
$itemClass .= 'active '; | ||
} | ||
?> | ||
<li <?php if (!empty($itemClass)): ?>class="<?= $itemClass ?>"<?php endif ?>> | ||
<?php if($item->getUrl()): ?> | ||
<a href="<?= $this->href($item->getUrl()); ?>"> | ||
<?php endif; ?> | ||
<?php | ||
if ($icon = $item->getIcon()) { | ||
echo $this->img($icon, array('height' => '16px', 'width' => '16px')); | ||
} | ||
?> | ||
<?php if ($iconClass = $item->getIconClass()): ?> | ||
<i class="<?= $iconClass ?>"></i> | ||
<?php endif ?> | ||
<?= $item->getTitle();?> | ||
<?php if($item->getUrl()): ?> | ||
</a> | ||
<?php endif; ?> | ||
<?php | ||
if($item->hasChildren()) { | ||
echo $this->partial( | ||
'parts/menu.phtml', | ||
array('items' => $item->getChildren(), 'sub' => true, 'url' => $this->url) | ||
); | ||
} | ||
?> | ||
</li> | ||
<?php endforeach ?> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,17 @@ | ||
<?php | ||
// determine current key | ||
$url = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); | ||
$currentKey = isset($this->navkey) ? $this->navkey : $url; | ||
$url = Icinga\Web\Url::fromRequest()->getRelativeUrl(); | ||
$menu = Icinga\Web\Menu::fromConfig(); | ||
|
||
$item = $this->navigation->keys("menu"); | ||
?> | ||
<?php if ($this->auth()->isAuthenticated()): ?> | ||
<ul class="nav nav-stacked" role="navigation" id="icinganavigation"> | ||
<?php | ||
$activeSet = false; | ||
foreach ($item as $itemName) { | ||
if($itemName[0] == "_") { | ||
?> | ||
<li class="section-end"></li> | ||
<?php | ||
continue; | ||
} | ||
if ($this->auth()->isAuthenticated()): | ||
echo $this->partial( | ||
'parts/menu.phtml', | ||
array( | ||
'items' => $menu->getChildren(), | ||
'sub' => false, | ||
'url' => $url | ||
) | ||
); | ||
endif; | ||
|
||
$item = $this->navigation->menu->$itemName; | ||
$active = false; | ||
$url = ""; | ||
$iconClass = ''; | ||
|
||
if (is_string($item)) { | ||
$active = !$activeSet && $this->baseUrl($item) == $currentKey; | ||
$url = $this->baseUrl($item); | ||
} else { | ||
$url = $this->baseUrl(isset($item->route) ? $item->route : ""); | ||
$itemName = isset($item->title) ? $item->title : $itemName; | ||
$active = !$activeSet && (isset($item->key) ? $item->key : $url) === $currentKey; | ||
if (isset($item->iconClass)) { | ||
$iconClass = $item->iconClass; | ||
} | ||
} | ||
$activeSet = $activeSet || $active; | ||
?> | ||
<li class="<?= $active ? "active" : "" ?>"> | ||
<a href="<?= $url ?>"> | ||
<?php if ($iconClass): ?> | ||
<i class="<?= $iconClass; ?>"></i> | ||
<?php endif; ?> | ||
<?= $itemName ?> | ||
</a> | ||
</li> | ||
<?php | ||
$class = ""; | ||
} | ||
?> | ||
</ul> | ||
<? endif ?> | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
[menu] | ||
Dashboard.title = "Dashboard" | ||
Dashboard.route = "/dashboard/index" | ||
Dashboard.iconClass = "icinga-icon-dashboard-petrol" | ||
[Home] | ||
title = "Home" | ||
url = "/index/welcome" | ||
icon = "/img/icons/down_petrol.png" | ||
priority = 1 | ||
|
||
Configuration.title = "Configuration" | ||
Configuration.route = "/config/index" | ||
Configuration.iconClass = "icinga-icon-configuration-petrol" | ||
[Configuration] | ||
title = "Configuration" | ||
url = "/config/index" | ||
icon_class = "icinga-icon-configuration-petrol" | ||
priority = 2 | ||
|
||
[Dashboard] | ||
title = "Dashboard" | ||
url = "/dashboard/index" | ||
icon = "/img/icons/dashboard_petrol.png" | ||
priority = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,43 @@ | ||
[menu] | ||
;Remove component as of #4583 since it's not working | ||
;Issues.title = "Issues" ; Extended version | ||
;Issues.route = "/monitoring/list/services?problems=1&sort=severity" ; Explicit route | ||
;Issues.key = "issues" ; When this key is set in the controller, the item is active | ||
|
||
;Remove component as of #4583 since it's not working | ||
;Changes.title = "Recent Changes" | ||
;Changes.route = "/monitoring/list/services?sort=service_last_state_change" | ||
;_1 = 1 ;Spacer after this section | ||
|
||
Hosts.title = "Hosts" | ||
Hosts.route = "/monitoring/list/hosts" | ||
Hosts.iconClass = "icinga-icon-host-petrol" | ||
|
||
Services.title = "Services" | ||
Services.route = "/monitoring/list/services" | ||
Services.iconClass = "icinga-icon-service-petrol" | ||
|
||
Downtimes.title = "Downtimes" | ||
Downtimes.route = "/monitoring/list/downtimes" | ||
Downtimes.iconClass = "icinga-icon-down-petrol" | ||
|
||
Notifications.title = "Notifications" | ||
Notifications.route = "/monitoring/list/notifications" | ||
Notifications.iconClass = "icinga-icon-notification-petrol" | ||
|
||
Comments.title = "Comments" | ||
Comments.route = "/monitoring/list/comments" | ||
Comments.iconClass = "icinga-icon-comment-petrol" | ||
|
||
;Contacts = "/monitoring/list/contacts" | ||
|
||
;Contact Groups = "/monitoring/list/contactgroups" | ||
|
||
Servicegroups.title = "Servicegroups" | ||
Servicegroups.route = "/monitoring/list/servicegroups" | ||
Servicegroups.iconClass = "icinga-icon-servicegroup-petrol" | ||
|
||
Hostgroups.title = "Hostgroups" | ||
Hostgroups.route = "/monitoring/list/hostgroups" | ||
Hostgroups.iconClass = "icinga-icon-hostgroup-petrol" | ||
|
||
History.title = "History" | ||
History.route = "/monitoring/list/eventhistory" | ||
History.iconClass = "icinga-icon-history-petrol" | ||
|
||
Performance.title = "Performance" | ||
Performance.route ="/monitoring/process/performance" | ||
[Hosts] | ||
title = "Hosts" | ||
url = "/monitoring/list/hosts" | ||
icon_class = "icinga-icon-host-petrol" | ||
|
||
[Services] | ||
title = "Services" | ||
url = "/monitoring/list/services" | ||
icon_class = "icinga-icon-service-petrol" | ||
|
||
[Downtimes] | ||
title = "Downtimes" | ||
url = "/monitoring/list/downtimes" | ||
icon_class = "icinga-icon-down-petrol" | ||
|
||
[Notifications] | ||
title = "Notifications" | ||
url = "/monitoring/list/notifications" | ||
icon_class = "icinga-icon-notification-petrol" | ||
|
||
[Comments] | ||
title = "Comments" | ||
url = "/monitoring/list/comments" | ||
icon_class = "icinga-icon-comment-petrol" | ||
|
||
[Servicegroups] | ||
title = "Servicegroups" | ||
url = "/monitoring/list/servicegroups" | ||
icon_class = "icinga-icon-servicegroup-petrol" | ||
|
||
[Hostgroups] | ||
title = "Hostgroups" | ||
url = "/monitoring/list/hostgroups" | ||
icon_class = "icinga-icon-hostgroup-petrol" | ||
|
||
[History] | ||
title = "History" | ||
url = "/monitoring/list/eventhistory" | ||
icon_class = "icinga-icon-history-petrol" | ||
|
||
[Performance] | ||
title = "Performance" | ||
url = "/monitoring/process/performance" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
[menu] | ||
;Remove component as of #4583 since it's not working | ||
;Issues.title = "Issues" ; Extended version | ||
;Issues.route = "/monitoring/list/services?problems=1&sort=severity" ; Explicit route | ||
;Issues.key = "issues" ; When this key is set in the controller, the item is active | ||
|
||
;Remove component as of #4583 since it's not working | ||
;Changes.title = "Recent Changes" | ||
;Changes.route = "/monitoring/list/services?sort=service_last_state_change" | ||
;_1 = 1 ;Spacer after this section | ||
|
||
Hosts.title = "Hosts" | ||
Hosts.route = "/monitoring/list/hosts" | ||
Hosts.iconClass = "icinga-icon-host-petrol" | ||
|
||
Services.title = "Services" | ||
Services.route = "/monitoring/list/services" | ||
Services.iconClass = "icinga-icon-service-petrol" | ||
|
||
Downtimes.title = "Downtimes" | ||
Downtimes.route = "/monitoring/list/downtimes" | ||
Downtimes.iconClass = "icinga-icon-down-petrol" | ||
|
||
Notifications.title = "Notifications" | ||
Notifications.route = "/monitoring/list/notifications" | ||
Notifications.iconClass = "icinga-icon-notification-petrol" | ||
|
||
Comments.title = "Comments" | ||
Comments.route = "/monitoring/list/comments" | ||
Comments.iconClass = "icinga-icon-comment-petrol" | ||
|
||
;Contacts = "/monitoring/list/contacts" | ||
|
||
;Contact Groups = "/monitoring/list/contactgroups" | ||
|
||
Servicegroups.title = "Servicegroups" | ||
Servicegroups.route = "/monitoring/list/servicegroups" | ||
Servicegroups.iconClass = "icinga-icon-servicegroup-petrol" | ||
|
||
Hostgroups.title = "Hostgroups" | ||
Hostgroups.route = "/monitoring/list/hostgroups" | ||
Hostgroups.iconClass = "icinga-icon-hostgroup-petrol" | ||
|
||
History.title = "History" | ||
History.route = "/monitoring/list/eventhistory" | ||
History.iconClass = "icinga-icon-history-petrol" | ||
|
||
Performance.title = "Performance" | ||
Performance.route ="/monitoring/process/performance" | ||
|
||
|
||
[Hosts] | ||
; New section | ||
; Title property unset means title is "Hosts" | ||
url="#" | ||
iconClass="icon-hosts" | ||
priority=1 | ||
|
||
[Hosts.Problems] | ||
; New section beneath section hosts | ||
title="Problem Hosts" | ||
url="/monitoring/list/hosts?problem=1" | ||
priority=2 | ||
|
||
[Hosts.A Link] | ||
title="Wiki" | ||
url="https://wiki.somewhere.com" | ||
priority=1 | ||
icon="https://wiki.somewhere.com/icon.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
/** | ||
* This file is part of Icinga Web 2. | ||
* | ||
* Icinga Web 2 - Head for multiple monitoring backends. | ||
* Copyright (C) 2013 Icinga Development Team | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* @copyright 2013 Icinga Development Team <info@icinga.org> | ||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 | ||
* @author Icinga Development Team <info@icinga.org> | ||
* | ||
*/ | ||
// {{{ICINGA_LICENSE_HEADER}}} | ||
|
||
namespace Icinga\Web; | ||
|
||
use Icinga\Application\Config; | ||
use Icinga\Application\Icinga; | ||
use Icinga\Web\Menu\Item as MenuItem; | ||
|
||
class Menu extends MenuItem | ||
{ | ||
/** | ||
* Create menu from the application's menu config file plus the config files from all enabled modules | ||
* | ||
* @return Menu | ||
*/ | ||
public static function fromConfig() { | ||
$menu = new static('menu'); | ||
$manager = Icinga::app()->getModuleManager(); | ||
$menuConfigs = array(Config::app('menu')); | ||
foreach ($manager->listEnabledModules() as $moduleName) { | ||
$menuConfigs[] = Config::module($moduleName, 'menu'); | ||
} | ||
return $menu->loadMenuItems($menu->flattenConfigs($menuConfigs)); | ||
} | ||
|
||
/** | ||
* Flatten configs into a key-value array | ||
*/ | ||
public function flattenConfigs(array $configs) | ||
{ | ||
$flattened = array(); | ||
foreach ($configs as $menuConfig) { | ||
foreach ($menuConfig as $section => $itemConfig) { | ||
while (array_key_exists($section, $flattened)) { | ||
$section .= '_dup'; | ||
} | ||
$flattened[$section] = $itemConfig; | ||
} | ||
} | ||
ksort($flattened); | ||
return $flattened; | ||
} | ||
|
||
/** | ||
* Load menu items from a key-value array | ||
*/ | ||
public function loadMenuItems(array $flattened) | ||
{ | ||
foreach ($flattened as $id => $itemConfig) { | ||
$this->addChild($id, $itemConfig); | ||
} | ||
return $this; | ||
} | ||
|
||
} |
Oops, something went wrong.