# HG changeset patch # User sean # Date 1437564685 -7200 # Node ID c8cb2aa0b72c723138bb32637798d06b36bbc7db # Parent 3acc5164369e922e835a71fb12bbae4cc3b27c25 fixed default condifuration diff -r 3acc5164369e -r c8cb2aa0b72c dash.conf --- a/dash.conf Wed Jul 22 10:47:55 2015 +0200 +++ b/dash.conf Wed Jul 22 13:31:25 2015 +0200 @@ -4,25 +4,46 @@ ### ### Usage: ### define the tiles for the dashboard in sections -### -### options for tiles: -### -### type -### values: mon, d3.js -### -### source (only if type = mon) -### value: IP or FQDN -### status -### -### status (for debug purpose only | only if type = mon) -### values: up, down -### -### example: -### [tile1] -### type=mon -### source=192.168.0.2 -### status=up +# Settings: +# example: +# -------------------- +# [settings] +# show_top_bar=True +# -------------------- +# options: +# show_top_bar (True / False) [optional] +# If True, the dashboard will show the current date and the time on the top +# if False, the dashboard will not show a top-bar +# default: True +# hint: the top-bar has got a height of 5%! + +[settings] +show_top_bar=True + +# Tiles: +# example: +# -------------------- +# [tile1] +# type=mon +# source=192.168.0.2 +# status=up +# -------------------- +# options: +# type (mon / d3js) [required] +# tells the program what kind of tile you need. +# a "mon" tile can be used for IT infrastructure monitoring purposes +# a d3js tile can be used to display a chart +# default: - +# +# source ( or ) [required for mon-types] +# ONLY FOR MON-Type tiles! +# tells the tile which resource to watch +# default: none +# +# status: (up / down) [required] +# ONLY FOR DEBUGGING PURPOSE - WILL BE REMOVED LATER +# simulates up and down events for mon-type-tiles [tile1] type=mon @@ -52,4 +73,4 @@ [tile6] type=mon source=192.168.4.3 -status=up \ No newline at end of file +status=up diff -r 3acc5164369e -r c8cb2aa0b72c dash.py --- a/dash.py Wed Jul 22 10:47:55 2015 +0200 +++ b/dash.py Wed Jul 22 13:31:25 2015 +0200 @@ -11,8 +11,14 @@ CONFIG_FILE = "dash.conf" tiles = [] +settings = {} +default_settings = configparser.ConfigParser() +default_settings['settings'] = {'show_top_bar': True} + +##read the config file. usually "dash.conf" def read_config(): + global settings if os.path.isfile(CONFIG_FILE) == False: write_default_config() @@ -20,55 +26,89 @@ config = configparser.ConfigParser() config.read(CONFIG_FILE) - - - #read the tiles - read_tiles_config(config) - -def read_tiles_config(config): for section in config.items(): if "tile" in section[0]: tiles.append(section[1]) - # print(tiles[0]["type"]) + try: + if config["settings"]: + settings = config["settings"] + else: + settings = default_settings["settings"] + except KeyError: + settings = default_settings["settings"] + +###write the default condfig file if there is none def write_default_config(): file = open("dash.conf", "w") file.write(""" - ### bottledash default configuration ### created by sean engelhardt >sean.engelhardt@intevation.de -### license: GNU GPL >= v2 +### license: GNU GPL >= v2. See LICENSE for details ### ### Usage: ### define the tiles for the dashboard in sections -### -### options for tiles: -### -### type -### values: mon, d3.js -### -### source (only if type = mon) -### value: IP or FQDN -### status -### -### status (for debug purpose only | only if type = mon) -### values: up, down -### -### example: -### [tile1] -### type=mon -### source=192.168.0.2 -### status=up + +# Settings: +# example: +# -------------------- +# [settings] +# show_top_bar=True +# -------------------- +# options: +# show_top_bar (True / False) [optional] +# If True, the dashboard will show the current date and the time on the top +# if False, the dashboard will not show a top-bar +# default: True +# hint: the top-bar has got a height of 5%! + +[settings] +show_top_bar=True + +# Tiles: +# example: +# -------------------- +# [tile1] +# type=mon +# source=192.168.0.2 +# status=up +# -------------------- +# options: +# type (mon / d3js) [required] +# tells the program what kind of tile you need. +# a "mon" tile can be used for IT infrastructure monitoring purposes +# a d3js tile can be used to display a chart +# default: - +# +# source ( or ) [required for mon-types] +# ONLY FOR MON-Type tiles! +# tells the tile which resource to watch +# default: none +# +# status: (up / down) [required] +# ONLY FOR DEBUGGING PURPOSE - WILL BE REMOVED LATER +# simulates up and down events for mon-type-tiles [tile1] type=mon source=192.168.0.2 -status=down +status=up [tile2] type=mon -source=192.168.2.1 +source=192.168.2.3 +status=down + +[tile3] +type=mon +source=192.168.4.3 status=up + +[tile4] +type=mon +source=192.168.4.3 +status=down + """) file.close() @@ -76,7 +116,7 @@ @route('/') @view('hello_template') def call_dashboard(): - return dict(tiles=tiles) + return dict(tiles=tiles, settings=settings) @route('/config') def call_config(): @@ -92,5 +132,5 @@ return 'Nothing here, sorry
404' read_config() -print(tiles) +# print(tiles) run(host='localhost', port=8080, debug=True) diff -r 3acc5164369e -r c8cb2aa0b72c views/hello_template.tpl --- a/views/hello_template.tpl Wed Jul 22 10:47:55 2015 +0200 +++ b/views/hello_template.tpl Wed Jul 22 13:31:25 2015 +0200 @@ -8,6 +8,14 @@ from datetime import date ################# + # settings # + ################# + + + show_top_bar = settings["show_top_bar"] + + + ################# # date and time # ################# @@ -19,19 +27,12 @@ "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember")[today.month-1] - - ################## - # size of tiles # - ################## - number_of_rows = 2 ################# # viewport size # ################# - - vp_size = "12px" - + vp_size = "17px" #if len(tiles) <= 2: # vp_size = "6vw" #elif len(tiles) >2 and len(tiles) <=4 : @@ -123,7 +124,11 @@ #content{ min-width: 100%; - height:95%; + % if show_top_bar == "True": + height: 95%; + % else : + height: 100%; + %end } .tile{ @@ -165,10 +170,11 @@
- + % if show_top_bar == "True" :
{{weekday}} {{today.day}}. {{month_name}}
+ % end