Module: check_mk
Branch: master
Commit: d2026dec1a141c498f816bd6a2f5cbd9a5805bdf
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d2026dec1a141c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Oct 6 18:22:38 2014 +0200
Fix adding new views to implicity main dashboard
---
web/htdocs/dashboard.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index a3e5477..c60628c 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -181,7 +181,10 @@ def permitted_dashboards():
def page_dashboard():
load_dashboards()
- name = html.var("name", "main")
+ name = html.var("name")
+ if not name:
+ name = "main"
+ html.set_var("name", name) # make sure that URL context is always complete
if name not in available_dashboards:
raise MKGeneralException(_("The requested dashboard can not be found."))
@@ -678,6 +681,7 @@ def page_create_view_dashlet():
import views
url = html.makeuri([], filename = "create_view_dashlet_infos.py")
url += '&datasource=%s' # %s can not be added using html.makeuri()
+ # Note: %s will later be replaced by datasource
views.page_create_view(next_url=url)
else:
Changed wording of single object things a bit
Message-ID: <54329358.UO3bOBl5jMcXi3Ez%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 0bd00f64881553493aa6e0338dc4d4363224a9c5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0bd00f64881553…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Oct 6 15:02:09 2014 +0200
Fixed creating new view dashlets; Changed wording of single object things a bit
---
web/htdocs/dashboard.py | 10 ++++++----
web/htdocs/visuals.py | 8 ++++----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index c2dcd2d..a3e5477 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -676,7 +676,8 @@ def page_create_view_dashlet():
if create:
import views
- url = html.makeuri([('datasource', '%s')], filename = "create_view_dashlet_infos.py")
+ url = html.makeuri([], filename = "create_view_dashlet_infos.py")
+ url += '&datasource=%s' # %s can not be added using html.makeuri()
views.page_create_view(next_url=url)
else:
@@ -684,14 +685,15 @@ def page_create_view_dashlet():
choose_view(name)
def page_create_view_dashlet_infos():
+ import views
ds_name = html.var('datasource')
- if ds_name not in multisite_datasources:
+ if ds_name not in views.multisite_datasources:
raise MKGeneralException(_('The given datasource is not supported'))
# Create a new view by choosing the datasource and the single object types
- visuals.page_create_visual('views', _("View"), multisite_datasources[ds_name]['infos'],
+ visuals.page_create_visual('views', _("View"), views.multisite_datasources[ds_name]['infos'],
next_url = 'edit_dashlet.py?name=%s&type=view&datasource=%s&single_infos=%%s' %
- (html.urlencode(html.var('name'), ds_name)))
+ (html.urlencode(html.var('name')), ds_name))
def choose_view(name):
import views
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 461a9b6..d107439 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -373,7 +373,7 @@ def page_create_visual(what, title, info_keys, next_url = None):
'of <i>multiple</i> services, a list of <i>multiple</i> services of a <i>single</i> host or even '
'a list of services with the same name on <i>multiple</i> hosts. When you just want to '
'create a list of objects, you do not need to make any selection in this dialog. '
- 'If you like to create a view for a specific object of a specific type, select the '
+ 'If you like to create a view for one specific object of a specific type, select the '
'object type below and continue.') % what_s)
html.write('</p>')
@@ -394,7 +394,7 @@ def page_create_visual(what, title, info_keys, next_url = None):
html.begin_form('create_visual')
html.hidden_field('mode', 'create')
- forms.header(_('Select specific objects'))
+ forms.header(_('Select specific object type'))
forms.section(vs_infos.title())
vs_infos.render_input('single_infos', '')
html.help(vs_infos.help())
@@ -564,9 +564,9 @@ def page_edit_visual(what, all_visuals, custom_field_handler = None,
optional_keys = None,
elements = [
('single_infos', FixedValue(single_infos,
- title = _('Show information of single'),
+ title = _('Specific objects'),
totext = single_infos and ', '.join(single_infos) \
- or _('Not showing information for a specific object.'),
+ or _('Showing information of multiple objects.'),
)),
('name', TextAscii(
title = _('Unique ID'),
Module: check_mk
Branch: master
Commit: 42f744532fdc948bb5f70ea0e09625d7e1e013c9
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=42f744532fdc94…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Oct 4 18:43:31 2014 +0200
OptionalDropdownChoice: allow function for choices
This is just like DropdownCoice.
---
web/htdocs/valuespec.py | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 98019b3..aec4ea4 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1548,10 +1548,9 @@ class DualListChoice(ListChoice):
# A type-save dropdown choice with one extra field that
# opens a further value spec for entering an alternative
# Value.
-class OptionalDropdownChoice(ValueSpec):
+class OptionalDropdownChoice(DropdownChoice):
def __init__(self, **kwargs):
- ValueSpec.__init__(self, **kwargs)
- self._choices = kwargs["choices"]
+ DropdownChoice.__init__(self, **kwargs)
self._explicit = kwargs["explicit"]
self._otherlabel = kwargs.get("otherlabel", _("Other"))
@@ -1559,15 +1558,17 @@ class OptionalDropdownChoice(ValueSpec):
return self._explicit.canonical_value()
def value_is_explicit(self, value):
- return value not in [ c[0] for c in self._choices ]
+ return value not in [ c[0] for c in self.choices() ]
def render_input(self, varprefix, value):
defval = "other"
options = []
- for n, (val, title) in enumerate(self._choices):
+ for n, (val, title) in enumerate(self.choices()):
options.append((str(n), title))
if val == value:
defval = str(n)
+ if self._sorted:
+ options.sort(cmp = lambda a,b: cmp(a[1], b[1]))
options.append(("other", self._otherlabel))
html.select(varprefix, options, defval, # attrs={"style":"float:left;"},
onchange="valuespec_toggle_dropdown(this, '%s_ex');" % varprefix )
@@ -1588,20 +1589,21 @@ class OptionalDropdownChoice(ValueSpec):
html.write("</span>")
def value_to_text(self, value):
- for val, title in self._choices:
+ for val, title in self.choices():
if val == value:
return title
return self._explicit.value_to_text(value)
def from_html_vars(self, varprefix):
+ choices = self.choices()
sel = html.var(varprefix)
if sel == "other":
return self._explicit.from_html_vars(varprefix + "_ex")
- for n, (val, title) in enumerate(self._choices):
+ for n, (val, title) in enumerate(choices):
if sel == str(n):
return val
- return self._choices[0][0] # can only happen if user garbled URL
+ return choices[0][0] # can only happen if user garbled URL
def validate_value(self, value, varprefix):
if self.value_is_explicit(value):
@@ -1610,7 +1612,7 @@ class OptionalDropdownChoice(ValueSpec):
ValueSpec.custom_validate(self, value, varprefix)
def validate_datatype(self, value, varprefix):
- for val, title in self._choices:
+ for val, title in self.choices():
if val == value:
return
self._explicit.validate_datatype(value, varprefix + "_ex")