[update] add possibility to add columns with links to other web pages (e.g. seedlink monitor)
This commit is contained in:
parent
cd6b40688b
commit
4ba9c20d0f
@ -14,6 +14,10 @@ track_changes: True # tracks all changes since GUI startup by text highli
|
|||||||
dt_thresh: [300, 1800] # threshold (s) for timing delay colourisation (yellow/red)
|
dt_thresh: [300, 1800] # threshold (s) for timing delay colourisation (yellow/red)
|
||||||
html_figures: True # Create html figure directory and links
|
html_figures: True # Create html figure directory and links
|
||||||
|
|
||||||
|
# add links to html table with specified key as column and value as relative link, interpretable string parameters:
|
||||||
|
# nw (e.g. 1Y), st (e.g. GR01A), st_id (e.g. 1Y.GR01A)
|
||||||
|
add_links: {} # for example: {'slmon': '{nw}_{st}.html'}
|
||||||
|
|
||||||
POWBOX:
|
POWBOX:
|
||||||
pb_ok: 1 # Voltage for PowBox OK
|
pb_ok: 1 # Voltage for PowBox OK
|
||||||
pb_SOH2: # PowBox channel 2 voltage translations
|
pb_SOH2: # PowBox channel 2 voltage translations
|
||||||
|
48
survBot.py
48
survBot.py
@ -82,6 +82,8 @@ class SurveillanceBot(object):
|
|||||||
self.networks_blacklist = self.parameters.get('networks_blacklist')
|
self.networks_blacklist = self.parameters.get('networks_blacklist')
|
||||||
self.refresh_period = self.parameters.get('interval')
|
self.refresh_period = self.parameters.get('interval')
|
||||||
self.transform_parameters()
|
self.transform_parameters()
|
||||||
|
add_links = self.parameters.get('add_links')
|
||||||
|
self.add_links = add_links if add_links else {}
|
||||||
|
|
||||||
def transform_parameters(self):
|
def transform_parameters(self):
|
||||||
for key in ['networks', 'stations', 'locations', 'channels']:
|
for key in ['networks', 'stations', 'locations', 'channels']:
|
||||||
@ -320,8 +322,12 @@ class SurveillanceBot(object):
|
|||||||
init_html_table(outfile)
|
init_html_table(outfile)
|
||||||
|
|
||||||
# First write header items
|
# First write header items
|
||||||
|
header = self.keys.copy()
|
||||||
|
# add columns for additional links
|
||||||
|
for key in self.add_links:
|
||||||
|
header.insert(-1, key)
|
||||||
header_items = [dict(text='Station', color=default_color)]
|
header_items = [dict(text='Station', color=default_color)]
|
||||||
for check_key in self.keys:
|
for check_key in header:
|
||||||
item = dict(text=check_key, color=default_color)
|
item = dict(text=check_key, color=default_color)
|
||||||
header_items.append(item)
|
header_items.append(item)
|
||||||
write_html_row(outfile, header_items, html_key='th')
|
write_html_row(outfile, header_items, html_key='th')
|
||||||
@ -329,25 +335,35 @@ class SurveillanceBot(object):
|
|||||||
# Write all cells
|
# Write all cells
|
||||||
for st_id in self.station_list:
|
for st_id in self.station_list:
|
||||||
fig_name = self.get_fig_path_rel(st_id)
|
fig_name = self.get_fig_path_rel(st_id)
|
||||||
col_items = [dict(text=st_id.rstrip('.'), color=default_color, image_src=fig_name)]
|
col_items = [dict(text=st_id.rstrip('.'), color=default_color, hyperlink=fig_name)]
|
||||||
for check_key in self.keys:
|
for check_key in header:
|
||||||
status_dict, detailed_dict = self.analysis_results.get(st_id)
|
if check_key in self.keys:
|
||||||
status = status_dict.get(check_key)
|
status_dict, detailed_dict = self.analysis_results.get(st_id)
|
||||||
|
status = status_dict.get(check_key)
|
||||||
|
|
||||||
# get background color
|
# get background color
|
||||||
dt_thresh = [timedelta(seconds=sec) for sec in self.dt_thresh]
|
dt_thresh = [timedelta(seconds=sec) for sec in self.dt_thresh]
|
||||||
bg_color = get_bg_color(check_key, status, dt_thresh, hex=True)
|
bg_color = get_bg_color(check_key, status, dt_thresh, hex=True)
|
||||||
if not bg_color:
|
if not bg_color:
|
||||||
bg_color = default_color
|
bg_color = default_color
|
||||||
|
|
||||||
# add degree sign for temp
|
# add degree sign for temp
|
||||||
if check_key == 'temp':
|
if check_key == 'temp':
|
||||||
if not type(status) in [str]:
|
if not type(status) in [str]:
|
||||||
status = str(status) + deg_str
|
status = str(status) + deg_str
|
||||||
|
|
||||||
item = dict(text=str(status), tooltip=str(detailed_dict.get(check_key)),
|
item = dict(text=str(status), tooltip=str(detailed_dict.get(check_key)),
|
||||||
color=bg_color)
|
color=bg_color)
|
||||||
|
elif check_key in self.add_links:
|
||||||
|
value = self.add_links.get(check_key)
|
||||||
|
if not value:
|
||||||
|
continue
|
||||||
|
nw, st = st_id.split('.')[:2]
|
||||||
|
hyperlink_dict = dict(nw=nw, st=st, st_id=st_id)
|
||||||
|
link = value.format(**hyperlink_dict)
|
||||||
|
item = dict(text='link', tooltip=link, hyperlink=link, color=default_color)
|
||||||
col_items.append(item)
|
col_items.append(item)
|
||||||
|
|
||||||
write_html_row(outfile, col_items)
|
write_html_row(outfile, col_items)
|
||||||
|
|
||||||
finish_html_table(outfile)
|
finish_html_table(outfile)
|
||||||
|
@ -42,8 +42,8 @@ def write_html_row(fobj, items, html_key='td'):
|
|||||||
color = item.get('color')
|
color = item.get('color')
|
||||||
# check for black background of headers (shouldnt happen anymore)
|
# check for black background of headers (shouldnt happen anymore)
|
||||||
color = '#e6e6e6' if color == '#000000' else color
|
color = '#e6e6e6' if color == '#000000' else color
|
||||||
image_src = item.get('image_src')
|
hyperlink = item.get('hyperlink')
|
||||||
image_str = f'<a href="{image_src}">' if image_src else ''
|
image_str = f'<a href="{hyperlink}">' if hyperlink else ''
|
||||||
fobj.write(2 * default_space + f'<{html_key} bgcolor="{color}" title="{tooltip}"> {image_str}'
|
fobj.write(2 * default_space + f'<{html_key} bgcolor="{color}" title="{tooltip}"> {image_str}'
|
||||||
+ text + f'</{html_key}>\n')
|
+ text + f'</{html_key}>\n')
|
||||||
fobj.write(default_space + '</tr>\n')
|
fobj.write(default_space + '</tr>\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user