1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
<?php
/* Icinga Web 2 | (c) 2018 Icinga Development Team | GPLv2+ */
namespace Icinga\Web;
use Icinga\Application\Logger;
use Icinga\Authentication\Auth;
use Icinga\Web\Navigation\Navigation;
/**
* Main menu for Icinga Web 2
*/
class Menu extends Navigation
{
/**
* Create the main menu
*/
public function __construct()
{
$this->init();
$this->load('menu-item');
}
/**
* Setup the main menu
*/
public function init()
{
$this->addItem('dashboard', [
'label' => t('Dashboard'),
'url' => 'dashboard',
'icon' => 'dashboard',
'priority' => 10
]);
$this->addItem('system', [
'cssClass' => 'system-nav-item',
'label' => t('System'),
'icon' => 'services',
'priority' => 700,
'renderer' => [
'SummaryNavigationItemRenderer',
'state' => 'critical'
],
'children' => [
'about' => [
'icon' => 'info',
'description' => t('Open about page'),
'label' => t('About'),
'url' => 'about',
'priority' => 700
],
'health' => [
'icon' => 'eye',
'description' => t('Open health overview'),
'label' => t('Health'),
'url' => 'health',
'priority' => 710,
'renderer' => 'HealthNavigationRenderer'
],
'announcements' => [
'icon' => 'megaphone',
'description' => t('List announcements'),
'label' => t('Announcements'),
'url' => 'announcements',
'priority' => 720
],
'sessions' => [
'icon' => 'host',
'description' => t('List of users who stay logged in'),
'label' => t('User Sessions'),
'permission' => 'application/sessions',
'url' => 'manage-user-devices',
'priority' => 730
]
]
]);
$this->addItem('configuration', [
'cssClass' => 'configuration-nav-item',
'label' => t('Configuration'),
'icon' => 'wrench',
'permission' => 'config/*',
'priority' => 800,
'children' => [
'application' => [
'icon' => 'wrench',
'description' => t('Open application configuration'),
'label' => t('Application'),
'url' => 'config',
'priority' => 810
],
'authentication' => [
'icon' => 'users',
'description' => t('Open access control configuration'),
'label' => t('Access Control'),
'permission' => 'config/access-control/*',
'priority' => 830,
'url' => 'role'
],
'navigation' => [
'icon' => 'sitemap',
'description' => t('Open shared navigation configuration'),
'label' => t('Shared Navigation'),
'url' => 'navigation/shared',
'permission' => 'config/navigation',
'priority' => 840,
],
'modules' => [
'icon' => 'cubes',
'description' => t('Open module configuration'),
'label' => t('Modules'),
'url' => 'config/modules',
'permission' => 'config/modules',
'priority' => 890
]
]
]);
$this->addItem('user', [
'cssClass' => 'user-nav-item',
'label' => Auth::getInstance()->getUser()->getUsername(),
'icon' => 'user',
'priority' => 900,
'children' => [
'account' => [
'icon' => 'sliders',
'description' => t('Open your account preferences'),
'label' => t('My Account'),
'priority' => 100,
'url' => 'account'
],
'logout' => [
'icon' => 'off',
'description' => t('Log out'),
'label' => t('Logout'),
'priority' => 200,
'attributes' => ['target' => '_self'],
'url' => 'authentication/logout'
]
]
]);
if (Logger::writesToFile()) {
$this->getItem('system')->addChild($this->createItem('application_log', [
'icon' => 'doc-text',
'description' => t('Open Application Log'),
'label' => t('Application Log'),
'url' => 'list/applicationlog',
'permission' => 'application/log',
'priority' => 900
]));
}
}
}
|