Source
1
+
/*
2
+
** Zabbix
3
+
** Copyright (C) 2001-2023 Zabbix SIA
4
+
**
5
+
** This program is free software; you can redistribute it and/or modify
6
+
** it under the terms of the GNU General Public License as published by
7
+
** the Free Software Foundation; either version 2 of the License, or
8
+
** (at your option) any later version.
9
+
**
10
+
** This program is distributed in the hope that it will be useful,
11
+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+
** GNU General Public License for more details.
14
+
**
15
+
** You should have received a copy of the GNU General Public License
16
+
** along with this program; if not, write to the Free Software
17
+
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+
**/
19
+
20
+
1
21
class CDashboardPrint extends CDashboard {
22
+
2
23
activate() {
3
24
if (this._dashboard_pages.size === 0) {
4
25
throw new Error('Cannot activate dashboard without dashboard pages.');
5
26
}
6
27
7
28
this._state = DASHBOARD_STATE_ACTIVE;
8
29
9
-
this._selected_dashboard_page = this._getInitialDashboardPage();
10
-
11
30
for (const dashboard_page of this.getDashboardPages()) {
12
31
this.#activateDashboardPage(dashboard_page);
13
32
}
14
33
}
15
34
16
35
addDashboardPage({dashboard_pageid, name, display_period, widgets}, container) {
17
36
const dashboard_page = new CDashboardPage(container, {
18
37
data: {
19
38
dashboard_pageid,
20
39
name,
40
59
this._dashboard_pages.set(dashboard_page, {});
41
60
42
61
for (const widget_data of widgets) {
43
62
dashboard_page.addWidgetFromData({
44
63
...widget_data,
45
64
is_new: false,
46
65
unique_id: this._createUniqueId()
47
66
});
48
67
}
49
68
50
-
this._target.classList.toggle(ZBX_STYLE_DASHBOARD_IS_MULTIPAGE, this._dashboard_pages.size > 1);
51
-
52
69
return dashboard_page;
53
70
}
54
71
55
72
#activateDashboardPage(dashboard_page) {
56
73
dashboard_page.on(CDashboardPage.EVENT_REQUIRE_DATA_SOURCE, this._events.dashboardPageRequireDataSource);
57
74
58
75
dashboard_page.start();
59
76
dashboard_page.activate();
60
77
}
61
78
}