automatically select valid prediction period
Message-ID: <55adf6d0.hC0Ddb0AYvlZNkn/%mk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 4d34e2fb443dd6816b26a7b0e0262ca213b39b65
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4d34e2fb443dd6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jul 21 09:37:29 2015 +0200
#2375 FIX prediction preview: automatically select valid prediction period
---
.werks/2375 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/prediction.py | 10 +++++++---
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/.werks/2375 b/.werks/2375
new file mode 100644
index 0000000..4ce6c82
--- /dev/null
+++ b/.werks/2375
@@ -0,0 +1,10 @@
+Title: prediction preview: automatically select valid prediction period
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1437464222
+
+
diff --git a/ChangeLog b/ChangeLog
index d9db870..a4be315 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -85,6 +85,7 @@
* 2459 FIX: Preventing caching of all HTTP requests to dynamic pages (*.py)...
* 2468 FIX: Fixed actions for duplicate host names on different sites...
* 2470 FIX: Fixed exception in logwatch log list in rare cases...
+ * 2375 FIX: prediction preview: automatically select valid prediction period
WATO:
* 2365 Removed old deprecated notification global options for plain emails...
diff --git a/web/htdocs/prediction.py b/web/htdocs/prediction.py
index aa89e21..26a0640 100644
--- a/web/htdocs/prediction.py
+++ b/web/htdocs/prediction.py
@@ -71,24 +71,28 @@ def page_graph():
tg_name = html.var("timegroup")
timegroup = None
timegroups = []
+ now = time.time()
for f in os.listdir(dir):
if f.endswith(".info"):
tg_info = eval(file(dir + "/" + f).read())
tg_info["name"] = f[:-5]
timegroups.append(tg_info)
- if tg_info["name"] == tg_name:
+ if tg_info["name"] == tg_name or \
+ (tg_name == None and now >= tg_info["range"][0] and now
<= tg_info["range"][1]):
timegroup = tg_info
+ tg_name = tg_info["name"]
- timegroups.sort(cmp = lambda a,b: cmp(a["range"], b["range"]))
+ timegroups.sort(cmp = lambda a,b: cmp(a["range"][0],
b["range"][0]))
if not timegroup:
timegroup = timegroups[0]
+ tg_name = choices[0][0]
choices = [ (tg_info["name"], tg_info["name"].title())
for tg_info in timegroups ]
html.begin_form("prediction")
html.write(_("Show prediction for "))
- html.select("timegroup", choices, choices[0][0],
onchange="document.prediction.submit();")
+ html.select("timegroup", choices, tg_name,
onchange="document.prediction.submit();")
html.hidden_fields()
html.end_form()