Module: check_mk
Branch: master
Commit: 976abcbe693505156ba5ceb00c63616b26d8808e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=976abcbe693505…
Author: Roland Halbig <rh(a)mathias-kettner.de>
Date: Thu Apr 6 11:02:17 2017 +0200
4051 Timeline highlighting for availability tables works in both directions now.
Change-Id: If425cf30cad92eea90c082ed933110b98cb7047f
---
.werks/4051 | 10 ++++++++++
web/htdocs/js/checkmk.js | 18 ++++++++++++++++--
web/htdocs/table.py | 24 +++++++++++++++---------
web/htdocs/views.css | 9 ++++++++-
web/plugins/views/availability.py | 2 +-
5 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/.werks/4051 b/.werks/4051
new file mode 100644
index 0000000..fa4e8d8
--- /dev/null
+++ b/.werks/4051
@@ -0,0 +1,10 @@
+Title: Timeline highlighting for availability tables works in both directions now.
+Level: 3
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1491468793
+Class: feature
+
+
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 841d1c0..7733b06 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2784,13 +2784,27 @@ function timeline_hover(td, row_nr, onoff)
var timeline_bar_table = td.parentNode.parentNode.parentNode.parentNode;
var events_table = timeline_bar_table.nextElementSibling;
var row = events_table.children[0].children[row_nr+1];
- if (onoff)
+ if (onoff) {
add_class(row, 'hilite');
- else {
+ } else {
remove_class(row, 'hilite');
}
}
+
+function timetable_hover(tr, row_nr, onoff) {
+
+ var timeline_bar_table = tr.parentNode.parentNode.previousElementSibling;
+ var tds = timeline_bar_table.getElementsByTagName("TD");
+ var td = tds[row_nr];
+ if (td && onoff) {
+ add_class(td, 'hilite');
+ } else if (td) {
+ remove_class(td, 'hilite');
+ }
+}
+
+
//#.
//# .-Keybindings--------------------------------------------------------.
//# | _ __ _ _ _ _ |
diff --git a/web/htdocs/table.py b/web/htdocs/table.py
index dd596f2..a51ce5b 100644
--- a/web/htdocs/table.py
+++ b/web/htdocs/table.py
@@ -152,11 +152,11 @@ class Table(object):
self.next_func = None
- def add_row(self, css=None, state=0, collect_headers=True, fixed=False):
+ def add_row(self, css=None, state=0, collect_headers=True, fixed=False, **attrs):
if self.next_header:
- self.rows.append((self.next_header, None, "header", True))
+ self.rows.append((self.next_header, None, "header", True, attrs))
self.next_header = None
- self.rows.append(([], css, state, fixed))
+ self.rows.append(([], css, state, fixed, attrs))
if collect_headers:
if self.options["collect_headers"] == False:
self.options["collect_headers"] = True
@@ -331,7 +331,13 @@ class Table(object):
html.end_form()
html.close_tr()
- for nr, (row, css, state, fixed) in enumerate(rows):
+ for nr, (row, css, state, fixed, attrs) in enumerate(rows):
+
+ if not css and "class_" in attrs:
+ css = attrs.pop("class_")
+ if not css and "class" in attrs:
+ css = attrs.pop("class")
+
# Intermediate header
if state == "header":
# Show the header only, if at least one (non-header) row follows
@@ -347,7 +353,7 @@ class Table(object):
self._render_headers(actions_enabled, actions_visible)
continue
- html.open_tr(class_=["data", "odd%d" % state, css if css
else None])
+ html.open_tr(class_=["data", "odd%d" % state, css if css
else None], **attrs)
for cell_content, css_classes, colspan in row:
html.open_td(class_=css_classes if css_classes else None, colspan=colspan
if colspan else None)
html.write(cell_content)
@@ -380,7 +386,7 @@ class Table(object):
if not omit_headers and self.rows and self.rows[0][2] != "header":
html.write(csv_separator.join([html.strip_tags(header) or "" for
(header, css, help, sortable) in headers]) + "\n")
- for nr, (row, css, state, fixed) in enumerate(rows):
+ for nr, (row, css, state, fixed, attrs) in enumerate(rows):
html.write(csv_separator.join([html.strip_tags(cell_content) for
cell_content, css_classes, colspan in row ]))
html.write("\n")
@@ -448,14 +454,14 @@ class Table(object):
def _filter_rows(rows, search_term):
filtered_rows = []
- for row, css, state, fixed in rows:
+ for row, css, state, fixed, attrs in rows:
if state == "header" or fixed:
- filtered_rows.append((row, css, state, fixed))
+ filtered_rows.append((row, css, state, fixed, attrs))
continue # skip filtering of headers or fixed rows
for cell_content, css_classes, colspan in row:
if search_term in cell_content.lower():
- filtered_rows.append((row, css, state, fixed))
+ filtered_rows.append((row, css, state, fixed, attrs))
break # skip other cells when matched
return filtered_rows
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index 87e49d5..f374863 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -530,10 +530,10 @@ table.data.availability tr.summary td {
padding-top: 1px;
}
+
table.data td.flapping, table.timeline td.flapping, div.avlegend.timeline
div.state.flapping {
background-color: #f0f;
}
-
table.data td.downtime, table.timeline td.downtime, div.avlegend.timeline
div.state.downtime {
background-color: #0af;
}
@@ -609,6 +609,13 @@ table.timeline td {
border-style: none;
}
+table.timeline td.hilite {
+ padding: 0px;
+ border-style: none;
+ background-color: #0091b6;
+ filter: brightness(80%);
+}
+
table.timeline td.chaos {
background-color: #8844ff;
}
diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py
index b41934a..a46f233 100644
--- a/web/plugins/views/availability.py
+++ b/web/plugins/views/availability.py
@@ -329,7 +329,7 @@ def render_availability_timeline(what, av_entry, avoptions):
# Table with detailed events
table.begin("av_timeline", "", css="timelineevents",
sortable=False, searchable=False)
for row_nr, row in enumerate(timeline_layout["table"]):
- table.row()
+ table.row(onmouseover="timetable_hover(this, %d, 1);" % row_nr,
onmouseout="timetable_hover(this, %d, 0);" % row_nr)
table.cell(_("Links"), css="buttons")
if what == "bi":
url = html.makeuri([("timewarp",
str(int(row["from"])))])