1<?php
2/*
3** Zabbix
4** Copyright (C) 2001-2021 Zabbix SIA
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19**/
20
21
22/**
23 * @var CView $this
24 */
25
26$this->addJsFile('flickerfreescreen.js');
27$this->addJsFile('gtlc.js');
28$this->addJsFile('class.dashboard.js');
29$this->addJsFile('class.dashboard.page.js');
30$this->addJsFile('class.dashboard.widget.placeholder.js');
31$this->addJsFile('class.widget.js');
32$this->addJsFile('class.widget.iterator.js');
33$this->addJsFile('class.widget.clock.js');
34$this->addJsFile('class.widget.graph.js');
35$this->addJsFile('class.widget.graph-prototype.js');
36$this->addJsFile('class.widget.map.js');
37$this->addJsFile('class.widget.navtree.js');
38$this->addJsFile('class.widget.paste-placeholder.js');
39$this->addJsFile('class.widget.problems.js');
40$this->addJsFile('class.widget.problemsbysv.js');
41$this->addJsFile('class.widget.svggraph.js');
42$this->addJsFile('class.widget.trigerover.js');
43$this->addJsFile('multiselect.js');
44$this->addJsFile('class.sortable.js');
45
46$this->includeJsFile('configuration.dashboard.edit.js.php');
47
48$widget = (new CWidget())
49	->setTitle(_('Dashboards'))
50	->setControls(
51		(new CList())
52			->setId('dashboard-control')
53			->addItem(
54				(new CTag('nav', true, new CList([
55					(new CButton('dashboard-config'))->addClass(ZBX_STYLE_BTN_DASHBOARD_CONF),
56					(new CList())
57						->addClass(ZBX_STYLE_BTN_SPLIT)
58						->addItem((new CButton('dashboard-add-widget',
59							[(new CSpan())->addClass(ZBX_STYLE_PLUS_ICON), _('Add')]
60						))->addClass(ZBX_STYLE_BTN_ALT))
61						->addItem(
62							(new CButton('dashboard-add', '&#8203;'))
63								->addClass(ZBX_STYLE_BTN_ALT)
64								->addClass(ZBX_STYLE_BTN_TOGGLE_CHEVRON)
65						),
66					(new CButton('dashboard-save', _('Save changes'))),
67					(new CLink(_('Cancel'), '#'))->setId('dashboard-cancel'),
68					''
69				])))
70					->setAttribute('aria-label', _('Content controls'))
71					->addClass(ZBX_STYLE_DASHBOARD_EDIT)
72			)
73	)
74	->setNavigation(getHostNavigation('dashboards', $data['dashboard']['templateid']));
75
76$dashboard = (new CDiv())
77	->addClass(ZBX_STYLE_DASHBOARD)
78	->addClass(ZBX_STYLE_DASHBOARD_IS_EDIT_MODE);
79
80if (count($data['dashboard']['pages']) > 1) {
81	$dashboard->addClass(ZBX_STYLE_DASHBOARD_IS_MULTIPAGE);
82}
83
84$dashboard->addItem(
85	(new CDiv())
86		->addClass(ZBX_STYLE_DASHBOARD_NAVIGATION)
87		->addItem((new CDiv())->addClass(ZBX_STYLE_DASHBOARD_NAVIGATION_TABS))
88		->addItem(
89			(new CDiv())
90				->addClass(ZBX_STYLE_DASHBOARD_NAVIGATION_CONTROLS)
91				->addItem([
92					(new CSimpleButton())
93						->addClass(ZBX_STYLE_DASHBOARD_PREVIOUS_PAGE)
94						->addClass('btn-iterator-page-previous')
95						->setEnabled(false),
96					(new CSimpleButton())
97						->addClass(ZBX_STYLE_DASHBOARD_NEXT_PAGE)
98						->addClass('btn-iterator-page-next')
99						->setEnabled(false)
100				])
101		)
102);
103
104$dashboard->addItem((new CDiv())->addClass(ZBX_STYLE_DASHBOARD_GRID));
105
106$widget
107	->addItem($dashboard)
108	->show();
109
110(new CScriptTag('
111	initializeView(
112		'.json_encode($data['dashboard']).',
113		'.json_encode($data['widget_defaults']).',
114		'.json_encode($data['time_period']).',
115		'.json_encode($data['page']).'
116	);
117'))
118	->setOnDocumentReady()
119	->show();
120