Module: check_mk
Branch: master
Commit: fcf71f45278af910b599b86fc74e02904c9da0ca
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fcf71f45278af9…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 5 22:29:26 2013 +0100
Timeline now with nice hover code
---
web/htdocs/js/checkmk.js | 22 ++++++++++++++++++++++
web/htdocs/views.css | 8 ++++++--
web/plugins/views/availability.py | 11 +++++------
3 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 0d9b91f..a2f3828 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -1864,3 +1864,25 @@ function view_switch_option(oDiv, viewname, option, choices) {
handleReload('');
}
+
+
+// .-Availability----------------------------------------------------------.
+// | _ _ _ _ _ _ _ _ |
+// | / \__ ____ _(_) | __ _| |__ (_) (_) |_ _ _ |
+// | / _ \ \ / / _` | | |/ _` | '_ \| | | | __| | | | |
+// | / ___ \ V / (_| | | | (_| | |_) | | | | |_| |_| | |
+// | /_/ \_\_/ \__,_|_|_|\__,_|_.__/|_|_|_|\__|\__, | |
+// | |___/ |
+// '-----------------------------------------------------------------------'
+
+function timeline_hover(row_nr, onoff)
+{
+ var table = document.getElementsByClassName("availability")[0];
+ var row = table.children[0].children[row_nr+1];
+ if (onoff)
+ add_class(row, 'hilite');
+ else {
+ remove_class(row, 'hilite');
+ }
+}
+
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index ce32677..eb9b3ed 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -510,6 +510,11 @@ div#avoptions_on {
margin-right: 132px;
}
+table.availability tr.hilite {
+ background-color: #6ab;
+ color: white;
+}
+
table.timeline {
width: 100%;
margin-bottom: 20px;
@@ -520,8 +525,7 @@ table.timeline {
}
table.timeline td {
- display: inline-box;
- height: 30px;
padding: 0px;
border: 1px solid #444;
}
+
diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py
index 7c7ca18..5ccbaed 100644
--- a/web/plugins/views/availability.py
+++ b/web/plugins/views/availability.py
@@ -467,7 +467,7 @@ def render_timeline(timeline_rows, from_time, until_time,
considered_duration, t
min_percentage = min(100.0 / len(timeline_rows), 1)
rest_percentage = 100 - len(timeline_rows) * min_percentage
html.write('<table class=timeline><tr>')
- for row, state_id in timeline_rows:
+ for row_nr, (row, state_id) in enumerate(timeline_rows):
for sid, css, sname, help in availability_columns:
if sid == state_id:
title = _("From %s until %s (%s) %s") % (
@@ -477,13 +477,14 @@ def render_timeline(timeline_rows, from_time, until_time,
considered_duration, t
if row["log_output"]:
title += " - " + row["log_output"]
width = min_percentage + rest_percentage * row["duration"] /
considered_duration
- html.write('<td style="width: %.1f%%"
title="%s" class="%s"></td>' % (width, title, css))
+ html.write('<td onmouseover="timeline_hover(%d, 1);"
onmouseout="timeline_hover(%d, 0);" '
+ 'style="width: %.1f%%" title="%s"
class="%s"></td>' % (
+ row_nr, row_nr, width, title, css))
html.write('</tr></table>')
-
# Render Table
table.begin(_("Detailed list of states"), css="availability")
- for row, state_id in timeline_rows:
+ for row_nr, (row, state_id) in enumerate(timeline_rows):
table.row()
table.cell(_("From"), render_date(row["from"]),
css="nobr narrow")
table.cell(_("Until"), render_date(row["until"]),
css="nobr narrow")
@@ -493,8 +494,6 @@ def render_timeline(timeline_rows, from_time, until_time,
considered_duration, t
table.cell(_("State"), sname, css=css + " state
narrow")
table.cell(_("Plugin output"), row["log_output"])
- # table.cell("TEST")
- # html.write(repr(row))
table.end()