[checkmk-commits] Check_MK Git: check_mk: Titles for visuals can now be customized using title plugins

Lars Michelsen lm at mathias-kettner.de
Wed Aug 27 16:06:29 CEST 2014


Module: check_mk
Branch: master
Commit: 000ca4eb96f3f8d98dd407b42990ff6023d8b36f
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=000ca4eb96f3f8d98dd407b42990ff6023d8b36f

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Wed Aug 27 16:05:28 2014 +0200

Titles for visuals can now be customized using title plugins

---

 web/htdocs/dashboard.py |    1 +
 web/htdocs/views.py     |    2 +-
 web/htdocs/visuals.py   |   11 +++++++++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index deb2311..6253536 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -273,6 +273,7 @@ def render_dashboard(name):
 
     elif wato_folder is not None:
         title = wato.get_folder_title(wato_folder) + " - " + title
+    title = visuals.visual_title('dashboard', board, title)
 
     html.header(title, javascripts=["dashboard"], stylesheets=["pages", "dashboard", "status", "views"])
 
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 75e3e98..0d4a3a0 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1418,7 +1418,7 @@ def view_title(view):
         if heading:
             title = heading + " - " + title
 
-    return title
+    return visuals.visual_title('view', view, title)
 
 def view_optiondial(view, option, choices, help):
     vo = view_options(view["name"])
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 08817f8..21316fc 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -57,8 +57,8 @@ def load_plugins():
     if loaded_with_language == current_language:
         return
 
-    global context_types
-    context_types = {}
+    global context_types ; context_types = {}
+    global title_functions ; title_functions = []
 
     load_web_plugins('visuals', globals())
     loaded_with_language = current_language
@@ -629,6 +629,13 @@ def page_edit_visual(what, all_visuals, custom_field_handler = None, create_hand
 #   |                                                                      |
 #   '----------------------------------------------------------------------'
 
+def visual_title(what, visual, title):
+    for func in title_functions:
+        result = func(what, visual, title)
+        if result != None:
+            return result
+    return title
+
 def get_context_html_vars(visual):
     context_type = context_types[visual['context_type']]
     if context_type['single']:



More information about the checkmk-commits mailing list