Module: check_mk
Branch: master
Commit: a653c23821a5117dfd99b90c5a851e25d86ee2ae
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a653c23821a511…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 2 11:41:50 2015 +0100
#1972 FIX Prevent erasing of quicksearch field when sidebar is reloaded (e.g. during
activate changes)
When performing "activate changes" in WATO, the quicksearch field of the sidebar
was cleared
during this process. This lead to user confusions when typing into the quicksearch field
while the activate changes process was completing.
---
.werks/1972 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/htmllib.py | 2 +-
web/htdocs/js/checkmk.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++
web/htdocs/js/wato.js | 6 ++----
5 files changed, 62 insertions(+), 5 deletions(-)
diff --git a/.werks/1972 b/.werks/1972
new file mode 100644
index 0000000..e59c19f
--- /dev/null
+++ b/.werks/1972
@@ -0,0 +1,12 @@
+Title: Prevent erasing of quicksearch field when sidebar is reloaded (e.g. during
activate changes)
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1422873119
+
+When performing "activate changes" in WATO, the quicksearch field of the
sidebar was cleared
+during this process. This lead to user confusions when typing into the quicksearch field
+while the activate changes process was completing.
diff --git a/ChangeLog b/ChangeLog
index c81e3ae..7f022f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -163,6 +163,7 @@
* 1876 FIX: User sorting of views can now be disabled again
* 1884 FIX: Fixed exception in virtual host tree snapin
* 1885 FIX: Fixed filtering by software versions in software package search
+ * 1972 FIX: Prevent erasing of quicksearch field when sidebar is reloaded (e.g.
during activate changes)...
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 88e91a9..5748609 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1123,7 +1123,7 @@ class html:
def reload_sidebar(self):
if not self.has_var("_ajaxid"):
- self.javascript("if(parent && parent.frames[0])
parent.frames[0].location.reload();");
+ self.javascript("reload_sidebar()")
def set_ignore_transids(self):
self.ignore_transids = True
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 5c7a2d1..6df55e0 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2347,3 +2347,49 @@ function add_to_visual(visual_type, visual_name)
if (response)
window.location.href = response;
}
+
+var g_sidebar_reload_timer = null;
+
+function reload_sidebar()
+{
+ if (parent && parent.frames[0]) {
+ // reload sidebar, but preserve eventual quicksearch field value and focus
+ var val = '';
+ var focused = false;
+ var field =
parent.frames[0].document.getElementById('mk_side_search_field');
+ if (field) {
+ val = field.value;
+ focused = parent.frames[0].document.activeElement == field;
+ }
+
+ parent.frames[0].document.reloading = 1;
+ parent.frames[0].document.location.reload();
+
+ if (field) {
+ g_sidebar_reload_timer = setInterval(function (value, has_focus) {
+ return function() {
+ if (!parent.frames[0].document.reloading
+ && parent.frames[0].document.readyState ===
'complete') {
+ var field =
parent.frames[0].document.getElementById('mk_side_search_field');
+ if (field) {
+ field.value = value;
+ if (has_focus) {
+ field.focus();
+
+ // Move caret to end
+ if (field.setSelectionRange !== undefined)
+ field.setSelectionRange(value.length, value.length);
+ }
+ field = null;
+ }
+
+ clearInterval(g_sidebar_reload_timer);
+ g_sidebar_reload_timer = null;
+ }
+ };
+ }(val, focused), 50);
+
+ field = null;
+ }
+ }
+}
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index 6580387..31e002c 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -615,10 +615,8 @@ function wato_replication_result(siteid, code) {
function wato_replication_finish() {
// check if we have a sidebar-main frame setup
if (this.parent && parent && parent.frames[1] == this)
- parent.frames[0].location.reload(); // reload sidebar
+ reload_sidebar();
- // always reload main
- // this.location.reload();
var oDiv = document.getElementById("act_changes_button");
oDiv.style.display = "none";
oDiv = null
@@ -702,7 +700,7 @@ function wato_profile_replication_result(siteid, code) {
function wato_profile_replication_finish() {
// check if we have a sidebar-main frame setup
if (this.parent && parent && parent.frames[1] == this)
- parent.frames[0].location.reload(); // reload sidebar
+ reload_sidebar();
}
// ----------------------------------------------------------------------------