Module: check_mk
Branch: master
Commit: acafc73e16fd12fc2cdd4ccc37d1a50447d6ba99
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=acafc73e16fd12…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 23 13:22:18 2018 +0200
Moved ajax_snapin next to other snapin rendering code
CMK-855
Change-Id: Ia3d5e53178269592fce854e45e99740098dd7609
---
cmk/gui/sidebar.py | 47 ++++++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 23 deletions(-)
diff --git a/cmk/gui/sidebar.py b/cmk/gui/sidebar.py
index 584ffe8..c15b82a 100644
--- a/cmk/gui/sidebar.py
+++ b/cmk/gui/sidebar.py
@@ -613,31 +613,10 @@ def render_snapin(name, visibility):
return refresh_url
-(a)cmk.gui.pages.register("sidebar_fold")
-def ajax_fold():
- user_config = UserSidebarConfig(config.user, config.sidebar)
- user_config.folded = html.var("fold") == "yes"
- user_config.save()
-
-
-(a)cmk.gui.pages.register("sidebar_openclose")
-def ajax_openclose():
- snapin_id = html.var("name")
- state = html.var("state")
- if state not in [ SnapinVisibility.OPEN.value, SnapinVisibility.CLOSED.value,
"off" ]:
- raise MKUserError("state", "Invalid state: %s" % state)
-
- user_config = UserSidebarConfig(config.user, config.sidebar)
- if state == "off":
- user_config.remove_snapin(snapin_id)
- else:
- user_config.set_snapin_visibility(snapin_id, SnapinVisibility(state))
- user_config.save()
-
-
@cmk.gui.pages.register("sidebar_snapin")
def ajax_snapin():
- """Update online state of the user (if enabled)"""
+ """Renders and returns the contents of the requested sidebar snapin(s)
in JSON format"""
+ # Update online state of the user (if enabled)
userdb.update_user_access_time(config.user.id)
snapname = html.var("name")
@@ -681,6 +660,28 @@ def ajax_snapin():
html.write(json.dumps(snapin_code))
+(a)cmk.gui.pages.register("sidebar_fold")
+def ajax_fold():
+ user_config = UserSidebarConfig(config.user, config.sidebar)
+ user_config.folded = html.var("fold") == "yes"
+ user_config.save()
+
+
+(a)cmk.gui.pages.register("sidebar_openclose")
+def ajax_openclose():
+ snapin_id = html.var("name")
+ state = html.var("state")
+ if state not in [ SnapinVisibility.OPEN.value, SnapinVisibility.CLOSED.value,
"off" ]:
+ raise MKUserError("state", "Invalid state: %s" % state)
+
+ user_config = UserSidebarConfig(config.user, config.sidebar)
+ if state == "off":
+ user_config.remove_snapin(snapin_id)
+ else:
+ user_config.set_snapin_visibility(snapin_id, SnapinVisibility(state))
+ user_config.save()
+
+
@cmk.gui.pages.register("sidebar_move_snapin")
def move_snapin():
if not config.user.may("general.configure_sidebar"):