Module: check_mk
Branch: master
Commit: 6d601a265a93f7d6c8714b23bd00f07a6f0e5f60
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6d601a265a93f7…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 19 10:42:25 2015 +0100
#2140 Remove PNP Timeranges from range selection, put these ranges directly into the list
The selection of a time range for PNP graphs contained one entry <i>PNP
View</i> and a submenu
for <i>4 Hours</i>, <i>25 Hours</i>, etc. These entries have been
moved directly into the
list and are now also available for the availability and reporting modules.
---
.werks/2140 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/valuespec.py | 37 ++++++++++++++++++-------------------
web/plugins/views/painters.py | 4 ++--
4 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/.werks/2140 b/.werks/2140
new file mode 100644
index 0000000..b7b719e
--- /dev/null
+++ b/.werks/2140
@@ -0,0 +1,11 @@
+Title: Remove PNP Timeranges from range selection, put these ranges directly into the
list
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.7i1
+Date: 1426758052
+Class: feature
+
+The selection of a time range for PNP graphs contained one entry <i>PNP
View</i> and a submenu
+for <i>4 Hours</i>, <i>25 Hours</i>, etc. These entries have been
moved directly into the
+list and are now also available for the availability and reporting modules.
diff --git a/ChangeLog b/ChangeLog
index c1075e7..a324fef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -277,6 +277,7 @@
* 1937 cpu.loads: performance graph now displays number of CPUs
* 2040 Allow commands for setting downtimes and acknowledging on BI aggregates...
* 2042 Services are now sorted in a natural way, this affects services containing
numbers...
+ * 2140 Remove PNP Timeranges from range selection, put these ranges directly into the
list...
* 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/htdocs/valuespec.py b/web/htdocs/valuespec.py
index f992060..37194f8 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -2139,6 +2139,12 @@ class Timerange(CascadingDropdown):
]
kwargs['choices'] += [
+ ( "4h", _("The last 4 hours")),
+ ( "25h", _("The last 25 hours")),
+ ( "7d", _("The last 7 days")),
+ ( "31d", _("The last 31 days")),
+ ( "365d", _("The last 365 days")),
+
( "d0", _("Today") ),
( "d1", _("Yesterday") ),
@@ -2209,6 +2215,18 @@ class Timerange(CascadingDropdown):
midnight = time.mktime(broken)
until_time = now
+ if rangespec[0].isdigit(): # 4h, 365d
+ count = int(rangespec[:-1])
+ s = rangespec[-1]
+ if s == 'd':
+ seconds = count * 86400
+ title = _("Last %d days") % count
+ else:
+ seconds = count * 3600
+ title = _("Last %d hours") % count
+ from_time = now - seconds
+ return (from_time, now), title
+
if rangespec[0] == 'd': # this/last Day
from_time = time.mktime(broken)
titles = _("Today"), _("Yesterday")
@@ -2249,25 +2267,6 @@ class Timerange(CascadingDropdown):
from_broken[0] -= 1
return (time.mktime(from_broken), until_time), titles[1]
-class PNPTimerange(Timerange):
- def __init__(self, **kwargs):
- choosable = [
- ("0", _("4 Hours")), ("1", _("25
Hours")),
- ("2", _("One Week")), ("3", _("One
Month")),
- ("4", _("One Year")),
- ]
-
- if kwargs.get('allow_all', True):
- choosable.append(("", _("All")))
-
- kwargs['choices'] = [
- ('pnp_view', _("PNP View"), DropdownChoice(
- default_value = '1',
- choices = choosable,
- )),
- ]
- Timerange.__init__(self, **kwargs)
-
# A selection of various date formats
def DateFormat(**args):
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 6b66dde..fb049e4 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -75,8 +75,8 @@
import bi # needed for aggregation icon
multisite_painter_options["pnp_timerange"] = {
- 'valuespec' : PNPTimerange(
- title = _("PNP Timerange"),
+ 'valuespec' : Timerange(
+ title = _("Graph Timerange"),
default_value = None,
include_time = True,
)