Module: check_mk
Branch: master
Commit: 8434a1c8cc0d7ca471a2da6568b940fc638045a3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8434a1c8cc0d7c…
Author: Kenneth Okoh <ko(a)mathias-kettner.de>
Date: Fri Oct 26 15:59:38 2018 +0200
Refactored snapin server_time to new snapin API
Change-Id: Id0c87f40741562f484f846cd67de6589dc5f9bee
---
cmk/gui/plugins/sidebar/server_time.py | 39 +++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/cmk/gui/plugins/sidebar/server_time.py
b/cmk/gui/plugins/sidebar/server_time.py
index b4f2559..602c251 100644
--- a/cmk/gui/plugins/sidebar/server_time.py
+++ b/cmk/gui/plugins/sidebar/server_time.py
@@ -28,23 +28,33 @@ import time
from cmk.gui.i18n import _
from cmk.gui.globals import html
+from . import SidebarSnapin, snapin_registry
+from cmk.gui.plugins.sidebar import snapin_width
-from cmk.gui.plugins.sidebar import (
- sidebar_snapins,
- snapin_width,
-)
+(a)snapin_registry.register
+class CurrentTime(SidebarSnapin):
+ @staticmethod
+ def type_name():
+ return "time"
+ @classmethod
+ def title(cls):
+ return _("Server Time")
-def render_current_time():
- html.div(time.strftime("%H:%M"), class_="time")
+ @classmethod
+ def description(cls):
+ return _("A large clock showing the current time of "
+ "the web server"),
-sidebar_snapins["time"] = {
- "title" : _("Server Time"),
- "description" : _("A large clock showing the current time of the web
server"),
- "refresh" : True,
- "render" : render_current_time,
- "allowed" : [ "user", "admin", "guest", ],
- "styles" : """
+ def show(self):
+ html.div(time.strftime("%H:%M"), class_="time")
+
+ @classmethod
+ def allowed_roles(cls):
+ return [ "admin", "user", "guest" ]
+
+ def styles(self):
+ return """
div.time {
text-align: center;
font-size: 18pt;
@@ -56,5 +66,4 @@ div.time {
color: #aff;
width: %dpx;
}
-""" % (snapin_width - 2)
-}
+""" % (snapin_width - 2)