Module: check_mk
Branch: master
Commit: a208610496861ac83c7279260a0c71fe05029a2d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a208610496861a…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Sep 17 11:54:34 2014 +0200
fixed werk display
---
.werks/973 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.werks/973 b/.werks/973
index 7d8eaed..7e06f22 100644
--- a/.werks/973
+++ b/.werks/973
@@ -13,7 +13,7 @@ Renaming a host is a complex precedure that will not only rename the host in WAT
but also in:
<ul>
-<li>all rules from <i>Host & Service Parameters</i></li>
+<li>all rules from Host & Service Parameters</li>
<li>cluster's node definitions</li>
<li>a host's parent definitions</li>
<li>Business Intelligence rules</li>
Module: check_mk
Branch: master
Commit: c38a6e78a021c8d27f5339e66889a08489a5a153
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c38a6e78a021c8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Sep 16 11:27:04 2014 +0200
#1401 FIX Display options in views are now again persistent
When you change a "Display Option" in a view - such as the <i>Time stamp format</i>, then
this option was only valid whilst you were visiting that view. This was due to a bug, which
was introduced in Januar 2014. This has been fixed now. If you are visiting a view again
after changing display options, then these will be persisted forever. Note: the persistance
is on a per-user-base and per-view-base.
---
.werks/1401 | 13 +++++++++++++
ChangeLog | 1 +
web/htdocs/htmllib.py | 43 ++++++++++++++++++++++++-------------------
web/htdocs/valuespec.py | 12 ++++++------
web/htdocs/views.py | 35 +++++++++++++++++++++++++----------
5 files changed, 69 insertions(+), 35 deletions(-)
diff --git a/.werks/1401 b/.werks/1401
new file mode 100644
index 0000000..16d7555
--- /dev/null
+++ b/.werks/1401
@@ -0,0 +1,13 @@
+Title: Display options in views are now again persistent
+Level: 2
+Component: multisite
+Compatible: compat
+Version: 1.2.5i6
+Date: 1410859507
+Class: fix
+
+When you change a "Display Option" in a view - such as the <i>Time stamp format</i>, then
+this option was only valid whilst you were visiting that view. This was due to a bug, which
+was introduced in Januar 2014. This has been fixed now. If you are visiting a view again
+after changing display options, then these will be persisted forever. Note: the persistance
+is on a per-user-base and per-view-base.
diff --git a/ChangeLog b/ChangeLog
index 1532aad..c73328e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -103,6 +103,7 @@
* 1067 FIX: Fixed login problem in LDAP connector when no user filter specified...
* 1094 FIX: sidebar snaping 'Tree of folders': fixed exception
* 1154 FIX: Availability: Fixed unwanted redirect to edit annotation page after editing availability options...
+ * 1401 FIX: Display options in views are now again persistent...
WATO:
* 1096 New WATO webservices: manage hosts via webinterface...
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 9486e38..3de2f9f 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -917,7 +917,31 @@ class html:
def set_focus(self, varname):
self.focus_object = (self.form_name, varname)
+ def debug_vars(self, prefix=None, hide_with_mouse=True):
+ if hide_with_mouse:
+ hover = ' onmouseover="this.style.display=\'none\';"'
+ else:
+ hover = ""
+ self.lowlevel_write('<table %s class=debug_vars>' % hover)
+ self.lowlevel_write("<tr><th colspan=2>POST / GET Variables</th></tr>")
+ for name, value in sorted(self.vars.items()):
+ if not prefix or name.startswith(prefix):
+ self.write("<tr><td class=left>%s</td><td class=right>%s</td></tr>\n" %
+ (self.attrencode(name), self.attrencode(value)))
+ self.write("</table>")
+ def var(self, varname, deflt = None):
+ return self.vars.get(varname, deflt)
+
+ def has_var(self, varname):
+ return varname in self.vars
+
+ # Checks if a variable with a given prefix is present
+ def has_var_prefix(self, prefix):
+ for varname in self.vars:
+ if varname.startswith(prefix):
+ return True
+ return False
def var_utf8(self, varname, deflt = None):
val = self.vars.get(varname, deflt)
@@ -1116,25 +1140,6 @@ class html:
self.lowlevel_write("<pre>%s</pre>\n" % pprint.pformat(element))
- def debug_vars(self, prefix=None, hide_with_mouse=True):
- if hide_with_mouse:
- hover = ' onmouseover="this.style.display=\'none\';"'
- else:
- hover = ""
- self.lowlevel_write('<table %s class=debug_vars>' % hover)
- self.lowlevel_write("<tr><th colspan=2>POST / GET Variables</th></tr>")
- for name, value in sorted(self.vars.items()):
- if not prefix or name.startswith(prefix):
- self.write("<tr><td class=left>%s</td><td class=right>%s</td></tr>\n" %
- (self.attrencode(name), self.attrencode(value)))
- self.write("</table>")
-
- def var(self, varname, deflt = None):
- return self.vars.get(varname, deflt)
-
- def has_var(self, varname):
- return varname in self.vars
-
def has_cookie(self, varname):
return varname in self.cookies
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 593f59b..9801552 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -186,12 +186,12 @@ class Age(ValueSpec):
html.write("</div>")
def from_html_vars(self, varprefix):
- return (
- saveint(html.var(varprefix+'_days')) * 3600 * 24
- + saveint(html.var(varprefix+'_hours')) * 3600
- + saveint(html.var(varprefix+'_minutes')) * 60
- + saveint(html.var(varprefix+'_seconds'))
- )
+ return (
+ saveint(html.var(varprefix+'_days')) * 3600 * 24
+ + saveint(html.var(varprefix+'_hours')) * 3600
+ + saveint(html.var(varprefix+'_minutes')) * 60
+ + saveint(html.var(varprefix+'_seconds'))
+ )
def value_to_text(self, value):
days, rest = divmod(value, 60*60*24)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index d4bdb79..8865787 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1302,28 +1302,43 @@ def render_view(view, rows, datasource, group_painters, painters,
if 'H' in display_options:
html.body_end()
+# We should rename this into "painter_options". Also the saved file.
def view_options(viewname):
# Options are stored per view. Get all options for all views
vo = config.load_user_file("viewoptions", {})
+
# Now get options for the view in question
v = vo.get(viewname, {})
must_save = False
+ # Now override the loaded options with new option settings that are
+ # provided by the URL. Our problem: we do not know the URL variables
+ # that a valuespec expects. But we know the common prefix of all
+ # variables for each option.
if config.may("general.painter_options"):
- for on, opt in multisite_painter_options.items():
- vs = opt['valuespec']
- value = vs.from_html_vars('po_' + on)
- if value is None:
- value = vs.default_value()
+ for option_name, opt in multisite_painter_options.items():
+ old_value = v.get(option_name)
+ var_prefix = 'po_' + option_name
- old_value = v.get(on)
+ # Are there settings for this painter option present?
+ if html.has_var_prefix(var_prefix):
- v[on] = value
- opt['value'] = value
+ # Get new value for the option from the value spec
+ vs = opt['valuespec']
+ value = vs.from_html_vars(var_prefix)
- if v[on] != old_value:
- must_save = True
+ v[option_name] = value
+ opt['value'] = value # make globally present for painters
+
+ if v[option_name] != old_value:
+ must_save = True
+
+ else:
+ opt['value'] = old_value # make globally present for painters
+ # If the user has no permission for changing painter options
+ # (or has *lost* his permission) then we need to remove all
+ # of the options. But we do not save.
else:
for on, opt in multisite_painter_options.items():
if on in v: