[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)
|
||||
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:
|
||||
pb_ok: 1 # Voltage for PowBox OK
|
||||
pb_SOH2: # PowBox channel 2 voltage translations
|
||||
|
22
survBot.py
22
survBot.py
@ -82,6 +82,8 @@ class SurveillanceBot(object):
|
||||
self.networks_blacklist = self.parameters.get('networks_blacklist')
|
||||
self.refresh_period = self.parameters.get('interval')
|
||||
self.transform_parameters()
|
||||
add_links = self.parameters.get('add_links')
|
||||
self.add_links = add_links if add_links else {}
|
||||
|
||||
def transform_parameters(self):
|
||||
for key in ['networks', 'stations', 'locations', 'channels']:
|
||||
@ -320,8 +322,12 @@ class SurveillanceBot(object):
|
||||
init_html_table(outfile)
|
||||
|
||||
# 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)]
|
||||
for check_key in self.keys:
|
||||
for check_key in header:
|
||||
item = dict(text=check_key, color=default_color)
|
||||
header_items.append(item)
|
||||
write_html_row(outfile, header_items, html_key='th')
|
||||
@ -329,8 +335,9 @@ class SurveillanceBot(object):
|
||||
# Write all cells
|
||||
for st_id in self.station_list:
|
||||
fig_name = self.get_fig_path_rel(st_id)
|
||||
col_items = [dict(text=st_id.rstrip('.'), color=default_color, image_src=fig_name)]
|
||||
for check_key in self.keys:
|
||||
col_items = [dict(text=st_id.rstrip('.'), color=default_color, hyperlink=fig_name)]
|
||||
for check_key in header:
|
||||
if check_key in self.keys:
|
||||
status_dict, detailed_dict = self.analysis_results.get(st_id)
|
||||
status = status_dict.get(check_key)
|
||||
|
||||
@ -347,7 +354,16 @@ class SurveillanceBot(object):
|
||||
|
||||
item = dict(text=str(status), tooltip=str(detailed_dict.get(check_key)),
|
||||
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)
|
||||
|
||||
write_html_row(outfile, col_items)
|
||||
|
||||
finish_html_table(outfile)
|
||||
|
@ -42,8 +42,8 @@ def write_html_row(fobj, items, html_key='td'):
|
||||
color = item.get('color')
|
||||
# check for black background of headers (shouldnt happen anymore)
|
||||
color = '#e6e6e6' if color == '#000000' else color
|
||||
image_src = item.get('image_src')
|
||||
image_str = f'<a href="{image_src}">' if image_src else ''
|
||||
hyperlink = item.get('hyperlink')
|
||||
image_str = f'<a href="{hyperlink}">' if hyperlink else ''
|
||||
fobj.write(2 * default_space + f'<{html_key} bgcolor="{color}" title="{tooltip}"> {image_str}'
|
||||
+ text + f'</{html_key}>\n')
|
||||
fobj.write(default_space + '</tr>\n')
|
||||
|
Loading…
Reference in New Issue
Block a user