Module: check_mk
Branch: master
Commit: 5f28b52c87097c63fb84d063f656729e4a1c1404
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5f28b52c87097c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Apr 8 08:50:07 2016 +0200
3331 FIX Availability: avoid duplication of annotation when changing time while editing
Conflicts:
ChangeLog
web/plugins/views/availability.py
---
.werks/3331 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/availability.py | 5 ++---
web/plugins/views/availability.py | 15 +++++++++------
4 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/.werks/3331 b/.werks/3331
new file mode 100644
index 0000000..6209a8b
--- /dev/null
+++ b/.werks/3331
@@ -0,0 +1,10 @@
+Title: Availability: avoid duplication of annotation when changing time while editing
+Level: 1
+Component: reporting
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1460097833
+
+
diff --git a/ChangeLog b/ChangeLog
index 04251ef..591e254 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -259,6 +259,7 @@
* 3249 FIX: Fix missing filter for non-OK services when report is called via context
button
* 3268 FIX: Availability options were invalid after resetting them...
* 3269 FIX: Fix rendering of floating point values < 1 in graphs (e.g. CPU load)
+ * 3331 FIX: Availability: avoid duplication of annotation when changing time while
editing
Event Console:
* 2999 The contact name is now included in Event Console notifications...
diff --git a/web/htdocs/availability.py b/web/htdocs/availability.py
index 158c706..5e0f654 100644
--- a/web/htdocs/availability.py
+++ b/web/htdocs/availability.py
@@ -972,13 +972,12 @@ def load_annotations(lock = False):
return {}
-def update_annotations(site_host_svc, annotation):
+def update_annotations(site_host_svc, annotation, replace_existing):
annotations = load_annotations(lock = True)
entries = annotations.get(site_host_svc, [])
new_entries = []
for entry in entries:
- if entry["from"] == annotation["from"] \
- and entry["until"] == annotation["until"]:
+ if entry == replace_existing:
continue # Skip existing entries with same identity
new_entries.append(entry)
new_entries.append(annotation)
diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py
index 4f2ca83..91db940 100644
--- a/web/plugins/views/availability.py
+++ b/web/plugins/views/availability.py
@@ -658,14 +658,17 @@ def edit_annotation():
annotations = availability.load_annotations()
annotation = availability.find_annotation(annotations, site_host_svc, fromtime,
untiltime)
if not annotation:
- annotation = {
+ value = {
"from" : fromtime,
"until" : untiltime,
"text" : "",
}
- annotation["host"] = hostname
- annotation["service"] = service
- annotation["site"] = site_id
+ else:
+ value = annotation.copy()
+
+ value["host"] = hostname
+ value["service"] = service
+ value["site"] = site_id
# FIXME: Why use plugging here? Can we clean this up?
html.plug()
@@ -697,7 +700,7 @@ def edit_annotation():
label = _("Reclassify downtime of this period"),
)),
( "text", TextAreaUnicode(title = _("Annotation"),
allow_empty = False) ), ],
- annotation,
+ value,
varprefix = "editanno_",
formname = "editanno",
focus = "text")
@@ -708,7 +711,7 @@ def edit_annotation():
del value["host"]
value["date"] = time.time()
value["author"] = config.user_id
- availability.update_annotations(site_host_svc, value)
+ availability.update_annotations(site_host_svc, value,
replace_existing=annotation)
html.drain() # omit previous HTML code, not needed
html.unplug()
html.del_all_vars(prefix = "editanno_")