Module: check_mk
Branch: master
Commit: 5eeb618a3de893595a8353b4f273fd5ef3b12968
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5eeb618a3de893…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 7 15:56:42 2016 +0100
3273 FIX Dashboard: The dashboard is now preserving edit/view state during page reloads
---
.werks/3273 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/js/checkmk.js | 2 +-
web/htdocs/js/dashboard.js | 18 +++++++++++++++++-
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/.werks/3273 b/.werks/3273
new file mode 100644
index 0000000..b6704e5
--- /dev/null
+++ b/.werks/3273
@@ -0,0 +1,10 @@
+Title: Dashboard: The dashboard is now preserving edit/view state during page reloads
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457362576
+
+
diff --git a/ChangeLog b/ChangeLog
index 983fd69..7bfb212 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -72,6 +72,7 @@
* 3251 FIX: Fix sorting of entries in Views sidebar element
* 3230 FIX: Slightly improved popup menu positioning...
* 3264 FIX: Fix display of values in graphs that are < 1.0
+ * 3273 FIX: Dashboard: The dashboard is now preserving edit/view state during page
reloads
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node
selection...
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 7e301ce..d4471ac 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -626,7 +626,7 @@ function makeuri(addvars, url) {
// Add new params
for (var key in addvars) {
- params.push(key + '=' + addvars[key]);
+ params.push(encodeURIComponent(key) + '=' +
encodeURIComponent(addvars[key]));
}
return base + '?' + params.join('&')
diff --git a/web/htdocs/js/dashboard.js b/web/htdocs/js/dashboard.js
index 33f85a9..7cbb14f 100644
--- a/web/htdocs/js/dashboard.js
+++ b/web/htdocs/js/dashboard.js
@@ -437,8 +437,24 @@ function toggle_dashboard_edit() {
// Remove/Add edit=1 parameter from URL to make page reload handling correct
// Only a solution for browsers with history.replaceState support. Sadly
// we have no F5/reload fix for others...
+ //
+ // window.parent is either a reference to the current window (when opened as
dedicated page)
+ // or the whole browser window if opened within a frame. The URL is either directly:
+ //
http://[HOST]/[SITE]/check_mk/dashboard.py?name=main&edit=1
+ // or when opened within a frame it is:
+ //
http://[HOST]/[SITE]/check_mk/index.py?start_url=%2F[SITE]%2Fcheck_mk%2Fdas…
+ // The new URL computation needs to deal with it.
if (window.parent.history.replaceState) {
- new_url = makeuri({'edit': g_editing ? '1' : '0'},
window.parent.location.href);
+ var url = window.parent.location.href;
+ if (url.indexOf("start_url") !== -1) {
+ var frame_url = decodeURIComponent(getUrlParam("start_url", url));
+ frame_url = makeuri({'edit': g_editing ? '1' : '0'},
frame_url);
+ new_url = makeuri({'start_url': frame_url}, url);
+ }
+ else {
+ new_url = makeuri({'edit': g_editing ? '1' : '0'},
url);
+ }
+
window.parent.history.replaceState({}, document.title, new_url);
}