Module: check_mk
Branch: master
Commit: aeebf87cf85d0ce43137331218e6cbb38ccf2807
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aeebf87cf85d0c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Oct 19 13:57:29 2010 +0200
The custom open/close states of custom links are now stored for each user
---
ChangeLog | 5 +++++
web/htdocs/sidebar.js | 13 +++++++------
web/plugins/sidebar/shipped.py | 21 ++++++++++++++++++---
3 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4d2fccf..f2e9ed5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1.1.9i1
+ Multisite:
+ * The custom open/close states of custom links are now stored for each
+ user
+
1.1.8b3:
Core, Setup, etc.:
* Added some Livestatus LQL examples to documentation
diff --git a/web/htdocs/sidebar.js b/web/htdocs/sidebar.js
index b90e7a1..5aaa037 100644
--- a/web/htdocs/sidebar.js
+++ b/web/htdocs/sidebar.js
@@ -639,14 +639,14 @@ function hilite_icon(oImg, onoff) {
}
-function toggle_folder(o) {
+function toggle_folder(o, folderId) {
var par = o.parentNode;
var next = null;
var one_more = false;
var img = null;
for (var i in par.childNodes) {
- var child = par.childNodes[i];
+ var child = par.childNodes[i];
if (one_more && child.nodeName == "DIV") {
next = child;
break;
@@ -665,14 +665,15 @@ function toggle_folder(o) {
if (next) {
if (next.style.display == "none") {
- next.style.display = "";
+ next.style.display = "";
if (img)
img.src = "images/link_folder_open.gif";
- }
- else {
- next.style.display = "none";
+ get_url('customlink_openclose.py?name=' + escape(folderId) +
'&state=on');
+ } else {
+ next.style.display = "none";
if (img)
img.src = "images/link_folder.gif";
+ get_url('customlink_openclose.py?name=' + escape(folderId) +
'&state=off');
}
}
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index 0101c4e..a6ceaec 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -900,6 +900,20 @@ sidebar_snapins["bookmarks"] = {
#
# ------------------------------------------------------------
+def load_customlink_states():
+ return config.load_user_file("customlinks", {})
+
+def save_customlink_states(states):
+ config.save_user_file("customlinks", states)
+
+def ajax_customlink_openclose(h):
+ global html
+ html = h
+
+ states = load_customlink_states()
+ states[html.var("name")] = html.var("state")
+ save_customlink_states(states)
+
def render_custom_links():
links = config.custom_links.get(config.role)
if not links:
@@ -907,19 +921,20 @@ def render_custom_links():
(defaults.default_config_dir + "/multisite.mk"))
def render_list(ids, links):
+ states = load_customlink_states()
n = 0
for entry in links:
n += 1
try:
if type(entry[1]) == type(True):
- if entry[1]: # open
+ idss = ids + [str(n)]
+ if states.get(''.join(idss), entry[1] and 'on' or
'off') == 'on': # open
display = ""
img = "link_folder_open.gif"
else:
display = "none"
img = "link_folder.gif"
- idss = ids + [str(n)]
- html.write('<h3 onclick="toggle_folder(this);"
')
+ html.write('<h3 onclick="toggle_folder(this,
\'%s\');" ' % ''.join(idss))
html.write('onmouseover="this.style.cursor=\'pointer\';" ')
html.write('onmouseout="this.style.cursor=\'auto\';">')
html.write('<img src="images/%s">' % img)