Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/views/js/monitoring.dashboard.view.js.php')
-rw-r--r--ui/app/views/js/monitoring.dashboard.view.js.php48
1 files changed, 33 insertions, 15 deletions
diff --git a/ui/app/views/js/monitoring.dashboard.view.js.php b/ui/app/views/js/monitoring.dashboard.view.js.php
index 9f6dc5cd740..c1a623d43f4 100644
--- a/ui/app/views/js/monitoring.dashboard.view.js.php
+++ b/ui/app/views/js/monitoring.dashboard.view.js.php
@@ -26,18 +26,25 @@
<script>
const view = {
- dashboard: null,
- time_period: null,
- dynamic: null,
- has_time_selector: null,
is_busy: false,
is_busy_saving: false,
- init({dashboard, time_period, dynamic, has_time_selector, widget_defaults, web_layout_mode}) {
+ init({
+ dashboard,
+ widget_defaults,
+ widget_last_type,
+ configuration_hash,
+ has_time_selector,
+ time_period,
+ dynamic,
+ web_layout_mode,
+ clone
+ }) {
this.dashboard = dashboard;
+ this.has_time_selector = has_time_selector;
this.time_period = time_period;
this.dynamic = dynamic;
- this.has_time_selector = has_time_selector;
+ this.clone = clone;
timeControl.refreshPage = false;
@@ -73,20 +80,21 @@
max_rows: <?= DASHBOARD_MAX_ROWS ?>,
widget_min_rows: <?= DASHBOARD_WIDGET_MIN_ROWS ?>,
widget_max_rows: <?= DASHBOARD_WIDGET_MAX_ROWS ?>,
- widget_defaults: widget_defaults,
+ widget_defaults,
+ widget_last_type,
+ configuration_hash,
is_editable: dashboard.can_edit_dashboards && dashboard.editable
&& web_layout_mode != <?= ZBX_LAYOUT_KIOSKMODE ?>,
- is_edit_mode: dashboard.dashboardid === null,
+ is_edit_mode: dashboard.dashboardid === null || clone,
can_edit_dashboards: dashboard.can_edit_dashboards,
is_kiosk_mode: web_layout_mode == <?= ZBX_LAYOUT_KIOSKMODE ?>,
- time_period: time_period,
+ time_period,
dynamic_hostid: dynamic.host ? dynamic.host.id : null
});
for (const page of dashboard.pages) {
for (const widget of page.widgets) {
widget.fields = (typeof widget.fields === 'object') ? widget.fields : {};
- widget.configuration = (typeof widget.configuration === 'object') ? widget.configuration : {};
}
ZABBIX.Dashboard.addDashboardPage(page);
@@ -102,7 +110,7 @@
jQuery('#dynamic_hostid').on('change', this.events.dynamicHostChange);
}
- if (dashboard.dashboardid === null) {
+ if (dashboard.dashboardid === null || clone) {
this.edit();
ZABBIX.Dashboard.editProperties();
}
@@ -116,6 +124,8 @@
}
}
+ ZABBIX.Dashboard.on(DASHBOARD_EVENT_CONFIGURATION_OUTDATED, this.events.configurationOutdated);
+
if (dynamic.has_dynamic_widgets) {
// Perform dynamic host switch when browser back/previous buttons are pressed.
window.addEventListener('popstate', this.events.popState);
@@ -183,6 +193,10 @@
request_data.sharing = this.dashboard.sharing;
+ if (this.clone) {
+ request_data.clone = '1';
+ }
+
const curl = new Curl('zabbix.php');
curl.setArgument('action', 'dashboard.update');
@@ -224,7 +238,7 @@
messages = exception.error.messages;
}
else {
- title = this.dashboard.dashboardid === null
+ title = this.dashboard.dashboardid === null || this.clone
? <?= json_encode(_('Failed to create dashboard')) ?>
: <?= json_encode(_('Failed to update dashboard')) ?>;
}
@@ -311,14 +325,14 @@
clickCallback: () => ZABBIX.Dashboard.pasteWidget(
ZABBIX.Dashboard.getStoredWidgetDataCopy()
),
- disabled: (ZABBIX.Dashboard.getStoredWidgetDataCopy() === null)
+ disabled: ZABBIX.Dashboard.getStoredWidgetDataCopy() === null
},
{
label: <?= json_encode(_('Paste page')) ?>,
clickCallback: () => ZABBIX.Dashboard.pasteDashboardPage(
ZABBIX.Dashboard.getStoredDashboardPageDataCopy()
),
- disabled: (ZABBIX.Dashboard.getStoredDashboardPageDataCopy() === null)
+ disabled: ZABBIX.Dashboard.getStoredDashboardPageDataCopy() === null
}
]
}
@@ -380,10 +394,14 @@
applyProperties() {
const dashboard_data = ZABBIX.Dashboard.getData();
- document.getElementById('<?= ZBX_STYLE_PAGE_TITLE ?>').textContent = dashboard_data.name;
+ document.getElementById('<?= CHtmlPage::PAGE_TITLE_ID ?>').textContent = dashboard_data.name;
document.getElementById('dashboard-direct-link').textContent = dashboard_data.name;
},
+ configurationOutdated() {
+ location.href = location.href;
+ },
+
busy() {
view.is_busy = true;
view.updateBusy();