reports is now respecing all set filters
Message-ID: <554b78ba.NjMIMiWRRUWyOrr8%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 4fea7878a071df1b1ff68f7c27e77b36eabf7b9a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4fea7878a071df…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu May 7 16:37:25 2015 +0200
#2251 FIX Adding views to dashboards / reports is now respecing all set filters
In previous versions only the filters used by single contexts were used. This
has been cleaned up now to get the exact same context information on the view
which is being added.
---
.werks/2251 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/htmllib.py | 2 +-
web/htdocs/js/checkmk.js | 16 ++--------------
web/htdocs/views.py | 7 ++++++-
web/htdocs/visuals.py | 16 +++++++---------
6 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/.werks/2251 b/.werks/2251
new file mode 100644
index 0000000..ffb8c31
--- /dev/null
+++ b/.werks/2251
@@ -0,0 +1,11 @@
+Title: Adding views to dashboards / reports is now respecing all set filters
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.7i1
+Date: 1431009374
+Class: fix
+
+In previous versions only the filters used by single contexts were used. This
+has been cleaned up now to get the exact same context information on the view
+which is being added.
diff --git a/ChangeLog b/ChangeLog
index c70a930..0f6b50a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -425,6 +425,7 @@
* 1957 FIX: Fixed default value for text input fields in notification plugins...
* 2233 FIX: Fixed WATO folder view and Host Tags search with HTML Entity encoding...
* 2074 FIX: pnptemplate netapp_api_volume: fixed title
+ * 2251 FIX: Adding views to dashboards / reports is now respecing all set filters...
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 5510ec4..64d9ac2 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -984,7 +984,7 @@ class html:
encoded_vars[k] = v
self.popup_trigger(
- '<img class=statusicon src="images/status_add_dashlet.png" title="%s">\n' % _("Add this view to..."),
+ '<img class=statusicon src="images/icon_menu.png" title="%s">\n' % _("Add this view to..."),
'add_visual', 'add_visual', data='[\'%s\', %s, {\'name\': \'%s\'}]' %
(mode_name, self.attrencode(repr(encoded_vars)),
self.var('view_name')))
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index f531836..a0db9da 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2472,23 +2472,11 @@ function add_to_visual(visual_type, visual_name)
{
close_popup();
- var context_txt = [];
- for (var key in popup_data[1]) {
- var ty = typeof(popup_data[1][key]);
- context_txt.push(key+':'+ty+':'+popup_data[1][key]);
- }
-
- var params_txt = [];
- for (var key in popup_data[2]) {
- var ty = typeof(popup_data[2][key]);
- params_txt.push(key+':'+ty+':'+popup_data[2][key]);
- }
-
response = get_url_sync('ajax_add_visual.py?visual_type=' + visual_type
+ '&visual_name=' + visual_name
+ '&type=' + popup_data[0]
- + '&context=' + encodeURIComponent(context_txt.join('|'))
- + '¶ms=' + encodeURIComponent(params_txt.join('|')));
+ + '&context=' + encodeURIComponent(JSON.stringify(popup_data[1]))
+ + '¶ms=' + encodeURIComponent(JSON.stringify(popup_data[2])));
popup_data = null;
// After adding a dashlet, go to the choosen dashboard
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index ee0fcb3..8ab1507 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -786,7 +786,12 @@ def page_view():
if not view:
raise MKGeneralException(_("No view defined with the name '%s'.") % html.attrencode(view_name))
- html.set_page_context(visuals.get_singlecontext_html_vars(view))
+ # Gather the page context which is needed for the "add to visual" popup menu
+ # to add e.g. views to dashboards or reports
+ datasource = multisite_datasources[view['datasource']]
+ context = visuals.get_context_from_uri_vars(datasource['infos'])
+ context.update(visuals.get_singlecontext_html_vars(view))
+ html.set_page_context(context)
show_view(view, True, True, True)
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 60208a2..573c5c9 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -26,6 +26,11 @@
import os, copy
+try:
+ import simplejson as json
+except ImportError:
+ import json
+
from lib import *
from valuespec import *
import config, table
@@ -1366,14 +1371,7 @@ def ajax_add_visual():
extra_data = []
for what in [ 'context', 'params' ]:
value = html.var(what)
- data = {}
- extra_data.append(data)
- if value == '':
- continue
- for entry in value.split('|'):
- key, vartype, value = entry.split(':', 2)
- if vartype == 'number':
- value = int(value)
- data[key] = value
+ if value:
+ extra_data.append(json.loads(value))
handler(visual_name, element_type, *extra_data)
Module: check_mk
Branch: master
Commit: 90ddc1b3b76361162032fa7cdd0919e52e5863cb
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=90ddc1b3b76361…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu May 7 15:50:58 2015 +0200
Fix syntax error in wato.py from a couple of minutes ago
---
web/htdocs/wato.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 932b5a4..8124982 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3753,7 +3753,7 @@ def mode_bulk_inventory(phase):
_("Inventorized host: %d added, %d removed, %d kept, %d total services") %
tuple(counts[hostname]))
- if "inventory_failed" in hostand not hosts.get(".folder", {}).get("_lock_hosts"):
+ if "inventory_failed" in host and not hosts.get(".folder", {}).get("_lock_hosts"):
del host["inventory_failed"]
save_hosts(folder) # Could be optimized, but difficult here
Module: check_mk
Branch: master
Commit: cf3d3130896b5e93cae200ece3cba388fa782ea0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cf3d3130896b5e…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu May 7 14:35:49 2015 +0200
The bulk service discovery raised an exception when some of the hosts failed
during the discovery and the folders of these hosts were locked with the option <tt>_lock</tt>.
This has been fixed.
---
.werks/2263 | 13 +++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 9 +++++----
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/.werks/2263 b/.werks/2263
new file mode 100644
index 0000000..a7a9432
--- /dev/null
+++ b/.werks/2263
@@ -0,0 +1,13 @@
+Title: Bulk service discovery: Fixed error when doing bulk inventory on locked folders
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1431001927
+
+The bulk service discovery raised an exception when some of the hosts failed
+during the discovery and the folders of these hosts were locked with the option <tt>_lock</tt>.
+This has been fixed.
+
diff --git a/ChangeLog b/ChangeLog
index c70a930..a642624 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -480,6 +480,7 @@
* 2178 FIX: Fixed handling of user erros in WATO when using Python < 2.5
* 2203 FIX: Fix sorting of unselected elements in a list choice with two panes
* 2244 FIX: Fixed sorting of host tag topics in dropdown selections
+ * 2263 FIX: Bulk service discovery: Fixed error when doing bulk inventory on locked folders...
Notifications:
* 1662 notification plugin spectrum: finalized script. now able to handle host notications
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 8d50384..932b5a4 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3743,7 +3743,7 @@ def mode_bulk_inventory(phase):
host = folder[".hosts"][hostname]
if hostname in failed_hosts:
result_txt += _("Failed to inventorize %s: %s<br>") % (hostname, failed_hosts[hostname])
- if not host.get("inventory_failed"):
+ if not host.get("inventory_failed") and not hosts.get(".folder", {}).get("_lock_hosts"):
host["inventory_failed"] = True
save_hosts(folder)
else:
@@ -3752,7 +3752,8 @@ def mode_bulk_inventory(phase):
log_pending(AFFECTED, hostname, "bulk-inventory",
_("Inventorized host: %d added, %d removed, %d kept, %d total services") %
tuple(counts[hostname]))
- if "inventory_failed" in host:
+
+ if "inventory_failed" in hostand not hosts.get(".folder", {}).get("_lock_hosts"):
del host["inventory_failed"]
save_hosts(folder) # Could be optimized, but difficult here
@@ -18174,12 +18175,12 @@ class API:
host = all_hosts[hostname]
counts, failed_hosts = check_mk_automation(host[".siteid"], "inventory", [ "@scan", mode ] + [hostname])
if failed_hosts:
- if not host.get("inventory_failed"):
+ if not host.get("inventory_failed") and not host.get(".folder", {}).get(".lock_hosts"):
host["inventory_failed"] = True
save_hosts(host[".folder"])
raise MKUserError(None, _("Failed to inventorize %s: %s") % (hostname, failed_hosts[hostname]))
- if host.get("inventory_failed"):
+ if host.get("inventory_failed") and not host.get(".folder", {}).get(".lock_hosts"):
del host["inventory_failed"]
save_hosts(host[".folder"])