Module: check_mk
Branch: master
Commit: e176c81c00a9192497ea13fd006269d939e00dcc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e176c81c00a919…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 21 11:20:43 2017 +0200
4598 Folder tables in ruleset edit dialog can now be folded
For a more comfortable editing of a large number of rules in a single ruleset
it is now possible to fold the rules based on the folders.
We also added the number of rules per folder to the folder title.
Change-Id: I8676f7b4bc10b90a2c1474a3d1386363d0e4c501
---
.werks/4598 | 13 +++++++++++++
web/htdocs/check_mk.css | 9 ++++++++-
web/htdocs/htmllib.py | 3 +++
web/htdocs/table.py | 19 ++++++++++++++++---
web/htdocs/wato.py | 6 ++++--
5 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/.werks/4598 b/.werks/4598
new file mode 100644
index 0000000..c631411
--- /dev/null
+++ b/.werks/4598
@@ -0,0 +1,13 @@
+Title: Folder tables in ruleset edit dialog can now be folded
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1492766075
+Class: feature
+
+For a more comfortable editing of a large number of rules in a single ruleset
+it is now possible to fold the rules based on the folders.
+
+We also added the number of rules per folder to the folder title.
diff --git a/web/htdocs/check_mk.css b/web/htdocs/check_mk.css
index 1a4c300..2cb1f85 100644
--- a/web/htdocs/check_mk.css
+++ b/web/htdocs/check_mk.css
@@ -347,6 +347,7 @@ img.treeangle {
-webkit-transition: -webkit-transform .2s ease-in-out;
-moz-transition: -moz-transform .2s ease-in-out;
transition: transform .2s ease-in-out;
+ vertical-align: middle;
}
img.treeangle.open {
@@ -358,19 +359,25 @@ img.treeangle.open {
img.treeangle.nform {
margin-left: -5px;
}
+
img.treeangle.title {
width: 16px;
height: 16px;
vertical-align: middle;
margin-right: 5px;
}
+
b.treeangle.title {
font-weight: bold;
color: #ffffff;
cursor: pointer;
}
+
+img.treeangle+.treeangle.title {
+ display: inline-block;
+}
+
ul.treeangle {
- /* border: 1px solid #4060ff; */
padding-left: 20px;
margin: 8px 0px;
position: relative; /* In order for placement of invtablelink */
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index bacd115..1071697 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -2481,6 +2481,8 @@ class html(HTMLGenerator, Encoder, RequestHandler):
self.close_td()
self.close_tr()
else:
+ self.open_div(class_="foldable")
+
if not icon:
self.img(id_="treeimg.%s.%s" % (treename, id),
class_=["treeangle", "open" if isopen else
"closed"],
@@ -2516,6 +2518,7 @@ class html(HTMLGenerator, Encoder, RequestHandler):
def end_foldable_container(self):
if self.folding_indent != "nform":
self.close_ul()
+ self.close_div()
def foldable_container_is_open(self, treename, id, isopen):
diff --git a/web/htdocs/table.py b/web/htdocs/table.py
index a51ce5b..ebdfd42 100644
--- a/web/htdocs/table.py
+++ b/web/htdocs/table.py
@@ -123,6 +123,7 @@ class Table(object):
"omit_headers" : kwargs.get("omit_headers", False),
"searchable" : kwargs.get("searchable", True),
"sortable" : kwargs.get("sortable", True),
+ "foldable" : kwargs.get("foldable", False),
"output_format" : kwargs.get("output_format",
"html"), # possible: html, csv, fetch
}
@@ -206,9 +207,18 @@ class Table(object):
return
if self.title:
- html.open_h3()
- html.write(self.title)
- html.close_h3()
+ if self.options["foldable"]:
+ html.begin_foldable_container(
+ treename="table",
+ id=self.id,
+ isopen=True,
+ indent=False,
+ title=html.render_h3(self.title, class_=["treeangle",
"title"])
+ )
+ else:
+ html.open_h3()
+ html.write(self.title)
+ html.close_h3()
if self.help:
html.help(self.help)
@@ -232,6 +242,9 @@ class Table(object):
# Render header
self._write_table(rows, actions_enabled, actions_visible, search_term)
+ if self.title and self.options["foldable"]:
+ html.end_foldable_container()
+
if limit is not None and num_rows_unlimited > limit:
html.message(_('This table is limited to show only %d of %d rows. '
'Click <a href="%s">here</a> to
disable the limitation.') %
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index c83b7c2..7bef7f9 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -12871,8 +12871,10 @@ class ModeEditRuleset(WatoMode):
last_folder = folder
alias_path = folder.alias_path(show_main = False)
- table.begin("rules", title="%s %s" % (_("Rules
in folder"), alias_path),
- css="ruleset", searchable=False, sortable=False,
limit=None)
+ table_id = "rules_%s_%s" % (self._name, folder.ident())
+ table.begin(table_id, title="%s %s (%d)" % (_("Rules in
folder"), alias_path,
+
ruleset.num_rules_in_folder(folder)),
+ css="ruleset", searchable=False, sortable=False,
limit=None, foldable=True)
else:
if skip_this_folder:
continue