Module: check_mk
Branch: master
Commit: e9f3bb14b71df52b573ee8672954fb75ac40530e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e9f3bb14b71df5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 19 09:42:46 2014 +0100
Updated bug entries #2275
---
.bugs/2275 | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/.bugs/2275 b/.bugs/2275
index 84fa109..6ba768e 100644
--- a/.bugs/2275
+++ b/.bugs/2275
@@ -1,8 +1,11 @@
Title: Filters are missing after adding a view to a dashboard
Component: multisite
-State: open
+Class: bug
+State: done
Date: 2014-12-09 16:21:48
Targetversion: 1.2.5i1
-Class: bug
After adding a new view to a dashboard, the list of filters in the view are empty.
+
+2014-12-19 09:42:13: changed state open -> done
+Has been fixed.
Module: check_mk
Branch: master
Commit: 508e434b3bff2e331aa333be95fec998155bd9f8
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=508e434b3bff2e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 19 09:41:43 2014 +0100
#1799 FIX Dashboards: Existing views added to dashboards now get a correct title / title_url
---
.werks/1799 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/dashboard.py | 16 ++++++++++++----
web/htdocs/views.py | 2 +-
web/htdocs/visuals.py | 20 ++++++++++++++------
5 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/.werks/1799 b/.werks/1799
new file mode 100644
index 0000000..f7b79ab
--- /dev/null
+++ b/.werks/1799
@@ -0,0 +1,10 @@
+Title: Dashboards: Existing views added to dashboards now get a correct title / title_url
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1418978475
+
+
diff --git a/ChangeLog b/ChangeLog
index 2a97522..b0130c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,7 @@
* 1774 FIX: IE: Always use the latest available rendering enginge of the used browser...
* 1777 FIX: Fixed js error making the "add to visual" link break on pages with context...
* 1798 FIX: Filters are now retained when adding a view to a dashboard...
+ * 1799 FIX: Dashboards: Existing views added to dashboards now get a correct title / title_url
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 2c71a1b..a58367b 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -206,12 +206,21 @@ def transform_builtin_dashboards():
dashboard.setdefault('description', dashboard.get('title', ''))
builtin_dashboards_transformed = True
-def load_view_into_dashlet(dashlet, nr, view_name):
+def load_view_into_dashlet(dashlet, nr, view_name, add_context=None):
import views
views.load_views()
views = views.permitted_views()
if view_name in views:
- dashlet.update(views[view_name])
+ view = copy.deepcopy(views[view_name])
+ dashlet.update(view)
+ if add_context:
+ dashlet['context'].update(add_context)
+
+ # Overwrite the views default title with the context specific title
+ dashlet['title'] = visuals.visual_title('view', view)
+ dashlet['title_url'] = html.makeuri_contextless(
+ [('view_name', view_name)] + visuals.get_singlecontext_vars(view).items(),
+ filename='view.py')
dashlet['type'] = 'view'
dashlet['name'] = 'dashlet_%d' % nr
@@ -1186,8 +1195,7 @@ def popup_add_dashlet(dashboard_name, dashlet_type, context, params):
if dashlet_type == 'view':
# save the original context and override the context provided by the view
context = dashlet['context']
- load_view_into_dashlet(dashlet, len(dashboard['dashlets']), view_name)
- dashlet['context'].update(context)
+ load_view_into_dashlet(dashlet, len(dashboard['dashlets']), view_name, add_context=context)
add_dashlet(dashlet, dashboard)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 6ff18a2..6aa1c7f 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -780,7 +780,7 @@ def page_view():
if not view:
raise MKGeneralException(_("No view defined with the name '%s'.") % html.attrencode(view_name))
- html.set_page_context(dict(visuals.get_singlecontext_html_vars(view)))
+ html.set_page_context(visuals.get_singlecontext_html_vars(view))
show_view(view, True, True, True)
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 6d48598..4972117 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -1118,7 +1118,7 @@ def unpack_context_after_editing(packed_context):
# '----------------------------------------------------------------------'
def verify_single_contexts(what, visual):
- for k, v in get_singlecontext_html_vars(visual):
+ for k, v in get_singlecontext_html_vars(visual).items():
if v == None:
raise MKUserError(k, _('This %s can not be displayed, because the '
'necessary context information "%s" is missing.') %
@@ -1130,7 +1130,7 @@ def visual_title(what, visual):
# Beware: if a single context visual is being visited *without* a context, then
# the value of the context variable(s) is None. In order to avoid exceptions,
# we simply drop these here.
- extra_titles = [ v for k, v in get_singlecontext_html_vars(visual) if v != None ]
+ extra_titles = [ v for k, v in get_singlecontext_html_vars(visual).items() if v != None ]
# FIXME: Is this really only needed for visuals without single infos?
if not visual['single_infos']:
used_filters = [ multisite_filters[fn] for fn in visual["context"].keys() ]
@@ -1176,10 +1176,18 @@ def get_single_info_keys(visual):
keys += info_params(info_key)
return list(set(keys))
+def get_singlecontext_vars(visual):
+ vars = {}
+ for key in get_single_info_keys(visual):
+ vars[key] = visual['context'].get(key)
+ return vars
+
def get_singlecontext_html_vars(visual):
- vars = []
+ vars = get_singlecontext_vars(visual)
for key in get_single_info_keys(visual):
- vars.append((key, html.var_utf8(key, visual['context'].get(key))))
+ val = html.var_utf8(key)
+ if val != None:
+ vars[key] = val
return vars
# Collect all visuals that share a context with visual. For example
@@ -1187,7 +1195,7 @@ def get_singlecontext_html_vars(visual):
def collect_context_links(this_visual, mobile = False, only_types = []):
# compute list of html variables needed for this visual
active_filter_vars = set([])
- for var, val in get_singlecontext_html_vars(this_visual):
+ for var, val in get_singlecontext_html_vars(this_visual).items():
if html.has_var(var):
active_filter_vars.add(var)
@@ -1236,7 +1244,7 @@ def collect_context_links_of(visual_type_name, this_visual, active_filter_vars,
# We can show a button only if all single contexts of the
# target visual are known currently
- needed_vars = get_singlecontext_html_vars(visual)
+ needed_vars = get_singlecontext_html_vars(visual).items()
skip = False
vars_values = []
for var, val in needed_vars:
Module: check_mk
Branch: master
Commit: 9c09bdb700325680c4234fdf127326aa3073be92
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9c09bdb7003256…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 19 09:11:34 2014 +0100
#1798 FIX Filters are now retained when adding a view to a dashboard
Only the context of the URL variables was retained before. The hard coded
context in the view was lost.
---
.werks/1798 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/dashboard.py | 4 ++--
web/htdocs/htmllib.py | 4 ++--
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/.werks/1798 b/.werks/1798
new file mode 100644
index 0000000..65a1e66
--- /dev/null
+++ b/.werks/1798
@@ -0,0 +1,11 @@
+Title: Filters are now retained when adding a view to a dashboard
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1418976614
+
+Only the context of the URL variables was retained before. The hard coded
+context in the view was lost.
diff --git a/ChangeLog b/ChangeLog
index a7b65db..2a97522 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,7 @@
* 1773 FIX: Fixed different exceptions when using localized multisite
* 1774 FIX: IE: Always use the latest available rendering enginge of the used browser...
* 1777 FIX: Fixed js error making the "add to visual" link break on pages with context...
+ * 1798 FIX: Filters are now retained when adding a view to a dashboard...
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 1181048..2c71a1b 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -1173,6 +1173,7 @@ def popup_add_dashlet(dashboard_name, dashlet_type, context, params):
if dashboard_name not in available_dashboards:
return
dashboard = load_dashboard_with_cloning(dashboard_name)
+
dashlet = default_dashlet_definition(dashlet_type)
dashlet["context"] = context
@@ -1181,13 +1182,12 @@ def popup_add_dashlet(dashboard_name, dashlet_type, context, params):
else:
dashlet.update(params)
-
# When a view shal be added to the dashboard, load the view and put it into the dashlet
if dashlet_type == 'view':
# save the original context and override the context provided by the view
context = dashlet['context']
load_view_into_dashlet(dashlet, len(dashboard['dashlets']), view_name)
- dashlet['context'] = context
+ dashlet['context'].update(context)
add_dashlet(dashlet, dashboard)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index e2a5bd8..61bb742 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -901,13 +901,13 @@ class html:
if self.myfile == "view":
mode_name = self.var('mode') == "availability" and "availability" or "view"
- encoded_vars = []
+ encoded_vars = {}
for k, v in self.page_context.items():
if v == None:
v = ''
elif type(v) == unicode:
v = v.encode('utf-8')
- encoded_vars.append((k, v))
+ encoded_vars[k] = v
h += '<div class="visualadd"><a class="visualadd" href="javascript:void(0)" ' \
'onclick="toggle_add_to_visual(event, this, \'%s\', %s, {\'name\': \'%s\'})">' \
Module: check_mk
Branch: master
Commit: ad39b496426a145ee8e821f988706f533832a8f2
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ad39b496426a14…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 19 08:39:47 2014 +0100
#1777 FIX Fixed js error making the "add to visual" link break on pages with context
When opening e.g. the detail page of a host or a view which has hardcoded filters
set, the "add to visual" link might not work because of a syntax error.
---
.werks/1777 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/htmllib.py | 12 ++++++++++--
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/.werks/1777 b/.werks/1777
new file mode 100644
index 0000000..49c70fe
--- /dev/null
+++ b/.werks/1777
@@ -0,0 +1,11 @@
+Title: Fixed js error making the "add to visual" link break on pages with context
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1418974714
+
+When opening e.g. the detail page of a host or a view which has hardcoded filters
+set, the "add to visual" link might not work because of a syntax error.
diff --git a/ChangeLog b/ChangeLog
index 13a677e..a7b65db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -46,6 +46,7 @@
* 1766 FIX: Fixed exceptions in Web GUI when host or service groups used non ascii characters in names...
* 1773 FIX: Fixed different exceptions when using localized multisite
* 1774 FIX: IE: Always use the latest available rendering enginge of the used browser...
+ * 1777 FIX: Fixed js error making the "add to visual" link break on pages with context...
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 9396b47..e2a5bd8 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -900,11 +900,19 @@ class html:
if self.myfile == "view":
mode_name = self.var('mode') == "availability" and "availability" or "view"
- encoded_vars = self.attrencode([ (k, v != None and v or '') for k,v in self.page_context.items() ])
+
+ encoded_vars = []
+ for k, v in self.page_context.items():
+ if v == None:
+ v = ''
+ elif type(v) == unicode:
+ v = v.encode('utf-8')
+ encoded_vars.append((k, v))
+
h += '<div class="visualadd"><a class="visualadd" href="javascript:void(0)" ' \
'onclick="toggle_add_to_visual(event, this, \'%s\', %s, {\'name\': \'%s\'})">' \
'<img class=statusicon src="images/status_add_dashlet.png" title="%s"></a></div>\n' % \
- (mode_name, encoded_vars, self.var('view_name'), _("Add this view to..."))
+ (mode_name, self.attrencode(repr(encoded_vars)), self.var('view_name'), _("Add this view to..."))
for img, tooltip in self.status_icons.items():
if type(tooltip) == tuple: