Module: check_mk
Branch: master
Commit: 787d78542e0c447453a9549e3bafd347a72f5330
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=787d78542e0c44…
Author: Kenneth Okoh <ko(a)mathias-kettner.de>
Date: Thu Nov 22 14:58:19 2018 +0100
Moved dashboards snapin to dedicated module
Change-Id: I721551c5ed6ed8fd1ea1e65e40ce3c6bd489a4ca
---
cmk/gui/plugins/sidebar/dashboards.py | 86 +++++++++++++++++++++++++++++++++++
cmk/gui/plugins/sidebar/shipped.py | 63 -------------------------
2 files changed, 86 insertions(+), 63 deletions(-)
diff --git a/cmk/gui/plugins/sidebar/dashboards.py
b/cmk/gui/plugins/sidebar/dashboards.py
new file mode 100644
index 0000000..b403cbf
--- /dev/null
+++ b/cmk/gui/plugins/sidebar/dashboards.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+import cmk.gui.config as config
+import cmk.gui.dashboard as dashboard
+from cmk.gui.globals import html
+from cmk.gui.i18n import _
+from cmk.gui.plugins.sidebar import (
+ sidebar_snapins,
+ visuals_by_topic,
+ bulletlink,
+ footnotelinks,
+)
+
+
+def render_dashboards():
+ dashboard.load_dashboards()
+
+ def render_topic(topic, s, foldable=True):
+ first = True
+ for t, title, name, _is_view in s:
+ if t == topic:
+ if first:
+ if foldable:
+ html.begin_foldable_container(
+ "dashboards", topic, False, topic, indent=True)
+ else:
+ html.open_ul()
+ first = False
+ bulletlink(
+ title, 'dashboard.py?name=%s' % name, onclick="return
wato_views_clicked(this)")
+
+ if not first: # at least one item rendered
+ if foldable:
+ html.end_foldable_container()
+ else:
+ html.open_ul()
+
+ by_topic = visuals_by_topic(
+ dashboard.permitted_dashboards().items(), default_order=[_('Overview')])
+ topics = [topic for topic, _entry in by_topic]
+
+ if len(topics) < 2:
+ render_topic(by_topic[0][0], by_topic[0][1], foldable=False)
+
+ else:
+ for topic, s in by_topic:
+ render_topic(topic, s)
+
+ links = []
+ if config.user.may("general.edit_dashboards"):
+ if config.debug:
+ links.append((_("Export"), "export_dashboards.py"))
+ links.append((_("Edit"), "edit_dashboards.py"))
+ footnotelinks(links)
+
+
+sidebar_snapins["dashboards"] = {
+ "title": _("Dashboards"),
+ "description": _("Links to all dashboards"),
+ "render": render_dashboards,
+ "allowed": ["user", "admin", "guest"],
+}
diff --git a/cmk/gui/plugins/sidebar/shipped.py b/cmk/gui/plugins/sidebar/shipped.py
index 799a2e1..9ca4b02 100644
--- a/cmk/gui/plugins/sidebar/shipped.py
+++ b/cmk/gui/plugins/sidebar/shipped.py
@@ -34,7 +34,6 @@ import re
import cmk.paths
import cmk.gui.config as config
-import cmk.gui.dashboard as dashboard
import cmk.gui.sites as sites
from cmk.gui.htmllib import HTML
from cmk.gui.i18n import _
@@ -42,75 +41,13 @@ from cmk.gui.globals import html
from cmk.gui.plugins.sidebar import (
sidebar_snapins,
- visuals_by_topic,
bulletlink,
- footnotelinks,
snapin_width,
snapin_site_choice,
simplelink,
)
#.
-# .--Dashboards----------------------------------------------------------.
-# | ____ _ _ _ |
-# | | _ \ __ _ ___| |__ | |__ ___ __ _ _ __ __| |___ |
-# | | | | |/ _` / __| '_ \| '_ \ / _ \ / _` | '__/ _` / __| |
-# | | |_| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| \__ \ |
-# | |____/ \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_|___/ |
-# | |
-# '----------------------------------------------------------------------'
-
-
-def render_dashboards():
- dashboard.load_dashboards()
-
- def render_topic(topic, s, foldable=True):
- first = True
- for t, title, name, _is_view in s:
- if t == topic:
- if first:
- if foldable:
- html.begin_foldable_container(
- "dashboards", topic, False, topic, indent=True)
- else:
- html.open_ul()
- first = False
- bulletlink(
- title, 'dashboard.py?name=%s' % name, onclick="return
wato_views_clicked(this)")
-
- if not first: # at least one item rendered
- if foldable:
- html.end_foldable_container()
- else:
- html.open_ul()
-
- by_topic = visuals_by_topic(
- dashboard.permitted_dashboards().items(), default_order=[_('Overview')])
- topics = [topic for topic, _entry in by_topic]
-
- if len(topics) < 2:
- render_topic(by_topic[0][0], by_topic[0][1], foldable=False)
-
- else:
- for topic, s in by_topic:
- render_topic(topic, s)
-
- links = []
- if config.user.may("general.edit_dashboards"):
- if config.debug:
- links.append((_("Export"), "export_dashboards.py"))
- links.append((_("Edit"), "edit_dashboards.py"))
- footnotelinks(links)
-
-
-sidebar_snapins["dashboards"] = {
- "title": _("Dashboards"),
- "description": _("Links to all dashboards"),
- "render": render_dashboards,
- "allowed": ["user", "admin", "guest"],
-}
-
-#.
# .--Performance---------------------------------------------------------.
# | ____ __ |
# | | _ \ ___ _ __ / _| ___ _ __ _ __ ___ __ _ _ __ ___ ___ |