[checkmk-commits] Check_MK Git: check_mk: #1979 Relative timestamps display warnings when they should be in future but are in past

Lars Michelsen lm at mathias-kettner.de
Fri Feb 6 09:35:02 CET 2015


Module: check_mk
Branch: master
Commit: a93209e993ed224351a45d6370bed82fecfc8255
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a93209e993ed224351a45d6370bed82fecfc8255

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Fri Feb  6 09:34:49 2015 +0100

#1979 Relative timestamps display warnings when they should be in future but are in past

---

 .werks/1979                   |   10 ++++++++++
 ChangeLog                     |    1 +
 web/plugins/views/painters.py |   23 +++++++++++++++--------
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/.werks/1979 b/.werks/1979
new file mode 100644
index 0000000..ded13ef
--- /dev/null
+++ b/.werks/1979
@@ -0,0 +1,10 @@
+Title: Relative timestamps display warnings when they should be in future but are in past
+Level: 1
+Component: multisite
+Class: feature
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1423211681
+
+
diff --git a/ChangeLog b/ChangeLog
index 2b75bcf..e19afe6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -158,6 +158,7 @@
     * 1667 Sidebar snapin 'Tree of Folders' and 'WATO folder' filter now available on slave sites...
     * 1815 Dashboard: Sidebar snapins can now be added as dashlets to dashboards...
     * 1973 Added intelligent host and service type icons to default views...
+    * 1979 Relative timestamps display warnings when they should be in future but are in past
     * 1781 FIX: Fix broken grouping by host/service group in availability
     * 1783 FIX: Finish the view "History of Scheduled Downtimes"...
     * 1206 FIX: Hostname not longer shown as column in host views
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 94eb8e8..5165a2d 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -314,7 +314,7 @@ def paint_nagios_link(row):
     return "singleicon", "<a href=\"%s\">%s</a>" % \
         (url, html.render_icon('nagios', _('Show this %s in Nagios') % what))
 
-def paint_age(timestamp, has_been_checked, bold_if_younger_than, mode=None):
+def paint_age(timestamp, has_been_checked, bold_if_younger_than, mode=None, what='past'):
     if not has_been_checked:
         return "age", "-"
 
@@ -325,8 +325,8 @@ def paint_age(timestamp, has_been_checked, bold_if_younger_than, mode=None):
         return "", str(int(timestamp))
 
     if mode == "both":
-        css, h1 = paint_age(timestamp, has_been_checked, bold_if_younger_than, "abs")
-        css, h2 = paint_age(timestamp, has_been_checked, bold_if_younger_than, "rel")
+        css, h1 = paint_age(timestamp, has_been_checked, bold_if_younger_than, "abs", what=what)
+        css, h2 = paint_age(timestamp, has_been_checked, bold_if_younger_than, "rel", what=what)
         return css, "%s - %s" % (h1, h2)
 
     dateformat = get_painter_option("ts_date")
@@ -345,14 +345,21 @@ def paint_age(timestamp, has_been_checked, bold_if_younger_than, mode=None):
         age_class = "age recent"
     else:
         age_class = "age"
-    return age_class, prefix + html.age_text(age)
+
+    warn_txt = ''
+    if what == 'future' and age > 0:
+        warn_txt = ' <b>%s</b>' % _('in the past!')
+    elif what == 'past' and age < 0:
+        warn_txt = ' <b>%s</b>' % _('in the future!')
+
+    return age_class, prefix + html.age_text(age) + warn_txt
 
 
 def paint_future_time(timestamp):
     if timestamp <= 0:
         return "", "-"
     else:
-        return paint_age(timestamp, True, 0)
+        return paint_age(timestamp, True, 0, what='future')
 
 def paint_day(timestamp):
     return "", time.strftime("%A, %Y-%m-%d", time.localtime(timestamp))
@@ -1672,7 +1679,7 @@ multisite_painters["comment_expires"] = {
     "short"   : _("Expires"),
     "columns" : ["comment_expire_time"],
     "options" : [ "ts_format", "ts_date" ],
-    "paint"   : lambda row: paint_age(row["comment_expire_time"], row["comment_expire_time"] != 0, 3600),
+    "paint"   : lambda row: paint_age(row["comment_expire_time"], row["comment_expire_time"] != 0, 3600, what='future'),
 }
 
 def paint_comment_entry_type(row):
@@ -1772,7 +1779,7 @@ multisite_painters["downtime_start_time"] = {
     "short"   : _("Start"),
     "columns" : ["downtime_start_time"],
     "options" : [ "ts_format", "ts_date" ],
-    "paint"   : lambda row: paint_age(row["downtime_start_time"], True, 3600),
+    "paint"   : lambda row: paint_age(row["downtime_start_time"], True, 3600, what=None),
 }
 
 multisite_painters["downtime_end_time"] = {
@@ -1780,7 +1787,7 @@ multisite_painters["downtime_end_time"] = {
     "short"   : _("End"),
     "columns" : ["downtime_end_time"],
     "options" : [ "ts_format", "ts_date" ],
-    "paint"   : lambda row: paint_age(row["downtime_end_time"], True, 3600),
+    "paint"   : lambda row: paint_age(row["downtime_end_time"], True, 3600, what=None),
 }
 
 def paint_downtime_duration(row):



More information about the checkmk-commits mailing list