Module: check_mk
Branch: master
Commit: 93e40f0b1c30bdaa1e8a31ca467af3eda5cd85ce
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=93e40f0b1c30bd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sat Jan 5 16:37:46 2019 +0100
Improved site socket rendering in site table
Change-Id: I62753ca2b7a7eff70c277788b3cf86e9b497d746
---
cmk/gui/valuespec.py | 25 ++++++++++++++++++++++++-
cmk/gui/watolib.py | 1 +
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/cmk/gui/valuespec.py b/cmk/gui/valuespec.py
index a3f4e20..d7f0f8a 100644
--- a/cmk/gui/valuespec.py
+++ b/cmk/gui/valuespec.py
@@ -1860,6 +1860,10 @@ class HostState(DropdownChoice):
# y is the value of the valuespec assigned to that entry.
# choices is a list of triples: [ ( value, title, vs ), ... ]
class CascadingDropdown(ValueSpec):
+ class Render(Enum):
+ normal = "normal"
+ foldable = "foldable"
+
def __init__(self, **kwargs):
ValueSpec.__init__(self, **kwargs)
@@ -1872,6 +1876,7 @@ class CascadingDropdown(ValueSpec):
self._separator = kwargs.get("separator", ", ")
self._sorted = kwargs.get("sorted", True)
self._orientation = kwargs.get("orientation", "vertical") #
or horizontal
+ self._render = kwargs.get("render", CascadingDropdown.Render.normal)
if kwargs.get("encoding", "tuple") == "list":
self._encoding_type = list
else:
@@ -1996,8 +2001,26 @@ class CascadingDropdown(ValueSpec):
(value == val):
if not vs:
return title
+
+ rendered_value = vs.value_to_text(value[1])
+ if not rendered_value:
+ return title
+
+ if self._render == CascadingDropdown.Render.foldable:
+ with html.plugged():
+ html.begin_foldable_container(
+ "foldable_cascading_dropdown",
+ id_=hashlib.sha256(repr(value)).hexdigest(),
+ isopen=False,
+ title=title,
+ indent=False)
+ html.write(vs.value_to_text(value[1]))
+ html.end_foldable_container()
+ return html.drain()
+
return title + self._separator + \
- vs.value_to_text(value[1])
+ vs.value_to_text(value[1])
+
return "" # Nothing selected? Should never happen
def from_html_vars(self, varprefix):
diff --git a/cmk/gui/watolib.py b/cmk/gui/watolib.py
index be5b1bd..fa67d43 100644
--- a/cmk/gui/watolib.py
+++ b/cmk/gui/watolib.py
@@ -4017,6 +4017,7 @@ class SiteManagement(object):
return CascadingDropdown(
orientation="horizontal",
choices=cls._connection_choices(),
+ render=CascadingDropdown.Render.foldable,
)
@classmethod