Module: check_mk
Branch: master
Commit: 7c613d33edef76ec76cfd86c735a253fe2f9494f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7c613d33edef76…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Jun 18 14:13:29 2011 +0200
Dashboard: make links of views target main frame
---
web/htdocs/dashboard.py | 2 +-
web/htdocs/htmllib.py | 14 +++++++++++++-
web/htdocs/views.py | 9 ++++++++-
web/plugins/dashboard/builtin.py | 13 +++++++------
4 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 3070810..000c63b 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -41,7 +41,7 @@ builtin_dashboards = {}
# in order to allow the user to customize this.
header_height = 40 # Distance from top of the screen to the lower border of the
heading
-screen_margin = 10 # Distance from the left border of the main-frame to the
dashboard area
+screen_margin = 5 # Distance from the left border of the main-frame to the
dashboard area
dashlet_padding = 8 # Margin between outer border of dashlet and its content
raster = 32, 32 # Raster the dashlet choords are measured in
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index d9c1ad2..430448c 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -159,6 +159,7 @@ class html:
self.header_sent = False
self.output_format = "html"
self.status_icons = {}
+ self.link_target = None
def plugin_stylesheets(self):
global plugin_stylesheets
@@ -179,6 +180,9 @@ class html:
def set_output_format(self, f):
self.output_format = f
+ def set_link_target(self, framename):
+ self.link_target = framename
+
def write(self, text):
if type(text) == unicode:
text = text.encode("utf-8")
@@ -476,6 +480,13 @@ class html:
self.write(title)
self.write('''</title>
<link rel="stylesheet" type="text/css"
href="check_mk.css">''')
+
+ # If the variable _link_target is set, then all links in this page
+ # should be targetted to the HTML frame named by _link_target. This
+ # is e.g. useful in the dash-board
+ link_target = self.var("_link_target")
+ if self.link_target:
+ self.write('<base target="%s">' % link_target)
# Load all style sheets in htdocs/css
for css in self.plugin_stylesheets():
@@ -649,7 +660,8 @@ class html:
self.req.vars[varname] = value
def del_var(self, varname):
- del self.req.vars[varname]
+ if varname in self.req.vars:
+ del self.req.vars[varname]
def javascript(self, code):
self.write("<script
language=\"javascript\">\n%s\n</script>\n" % code)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 4955d45..29b2555 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1006,7 +1006,7 @@ def get_needed_columns(painters):
# Display view with real data. This is *the* function everying
# is about.
def show_view(view, show_heading = False, show_buttons = True, show_footer = True):
- all_display_options = "HTBFCEOZRSIXD"
+ all_display_options = "HTBFCEOZRSIXDM"
# Parse display options and
if html.output_format == "html":
@@ -1023,6 +1023,13 @@ def show_view(view, show_heading = False, show_buttons = True,
show_footer = Tru
display_options += c
html.display_options = display_options
+ # If display option 'M' is set, then all links are targetet to the
'main'
+ # frame. Also the display options are removed since the view in the main
+ # frame should be displayed in standard mode.
+ if 'M' not in display_options:
+ html.set_link_target("main")
+ html.del_var("display_options")
+
# [1] Datasource
datasource = multisite_datasources[view["datasource"]]
tablename = datasource["table"]
diff --git a/web/plugins/dashboard/builtin.py b/web/plugins/dashboard/builtin.py
index 2d20fc7..e54cf74 100644
--- a/web/plugins/dashboard/builtin.py
+++ b/web/plugins/dashboard/builtin.py
@@ -6,19 +6,20 @@ builtin_dashboards = {
"title" : "Host problems",
"content" : "0",
"position" : (1, 1),
- "size" : (4, 4),
+ "size" : (20, 0),
},
{
"title" : "Host problems",
- "content" : "1",
- "position" : (5, 5),
- "size" : (4, 4),
+ # "content" : "1",
+ "content" : '<iframe width="100%"
height="100%"
src="http://localhost/lancom/check_mk/view.py?host=&opthostgroup=&view_name=allhosts&site=&is_summary_host=0&num_columns=1&display_options=SIXH&_link_target=main"></iframe>',
+ "position" : (21, 1),
+ "size" : (0, 0),
},
{
"title" : "Host problems",
"content" : "2x1 @ 4,2",
- "position" : (5, 1),
- "size" : (0, 0),
+ "position" : (1, -1),
+ "size" : (0, 8),
},
# {
# "title" : "Anderer Host",