Fix CRUD pages for tempmon clients, probes
for some reason if helptext had embedded newlines, it would now fail to render the form altogether. guess that is a result of recent change to e.g. `<b-field :message="['foo', 'bar']">` logic, somehow.. anyway hopefully this fixes and no more surprises
This commit is contained in:
parent
3dfab8e42d
commit
b30f6cdf3a
|
@ -755,7 +755,8 @@ class Form(object):
|
|||
"""
|
||||
Set the help text for a given field.
|
||||
"""
|
||||
self.helptext[key] = value
|
||||
# nb. must avoid newlines, they cause some weird "blank page" error?!
|
||||
self.helptext[key] = value.replace('\n', ' ')
|
||||
if value and dynamic:
|
||||
self.dynamic_helptext[key] = True
|
||||
else:
|
||||
|
@ -1009,6 +1010,8 @@ class Form(object):
|
|||
# render the field widget or whatever
|
||||
if self.readonly or fieldname in self.readonly_fields:
|
||||
html = self.render_field_value(fieldname) or HTML.tag('span')
|
||||
if type(html) is str:
|
||||
html = HTML.tag('span', c=[html])
|
||||
elif field:
|
||||
html = field.serialize(**self.get_renderer_kwargs(fieldname))
|
||||
html = HTML.literal(html)
|
||||
|
|
|
@ -1,16 +1,8 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/master/view.mako" />
|
||||
|
||||
<%def name="render_form_complete()">
|
||||
|
||||
## ${self.render_form()}
|
||||
|
||||
<script type="text/x-template" id="form-page-template">
|
||||
|
||||
<div style="display: flex; justify-content: space-between;">
|
||||
|
||||
<%def name="page_content()">
|
||||
<div class="form-wrapper">
|
||||
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
|
||||
<nav class="panel" id="probe-main">
|
||||
|
@ -33,17 +25,6 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="context-menu">
|
||||
${self.context_menu_items()}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<div id="form-page-app">
|
||||
<form-page></form-page>
|
||||
</div>
|
||||
</%def>
|
||||
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
Views for tempmon clients
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import subprocess
|
||||
|
||||
from rattail.config import parse_list
|
||||
|
@ -51,6 +49,7 @@ class TempmonClientView(MasterView):
|
|||
|
||||
has_rows = True
|
||||
model_row_class = tempmon.Reading
|
||||
rows_title = "Readings"
|
||||
|
||||
grid_columns = [
|
||||
'config_key',
|
||||
|
@ -83,7 +82,7 @@ class TempmonClientView(MasterView):
|
|||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(TempmonClientView, self).configure_grid(g)
|
||||
super().configure_grid(g)
|
||||
|
||||
# config_key
|
||||
g.set_label('config_key', "Key")
|
||||
|
@ -116,7 +115,7 @@ class TempmonClientView(MasterView):
|
|||
return "No"
|
||||
|
||||
def configure_form(self, f):
|
||||
super(TempmonClientView, self).configure_form(f)
|
||||
super().configure_form(f)
|
||||
|
||||
# config_key
|
||||
f.set_validator('config_key', self.unique_config_key)
|
||||
|
@ -160,7 +159,7 @@ class TempmonClientView(MasterView):
|
|||
f.set_helptext('archived', tempmon.Client.archived.__doc__)
|
||||
|
||||
def template_kwargs_view(self, **kwargs):
|
||||
kwargs = super(TempmonClientView, self).template_kwargs_view(**kwargs)
|
||||
kwargs = super().template_kwargs_view(**kwargs)
|
||||
client = kwargs['instance']
|
||||
|
||||
kwargs['probes_data'] = self.normalize_probes(client.probes)
|
||||
|
@ -177,7 +176,7 @@ class TempmonClientView(MasterView):
|
|||
if data['enabled'] and form.model_instance.enabled:
|
||||
data['enabled'] = form.model_instance.enabled
|
||||
|
||||
return super(TempmonClientView, self).objectify(form, data=data)
|
||||
return super().objectify(form, data=data)
|
||||
|
||||
def unique_config_key(self, node, value):
|
||||
query = self.Session.query(tempmon.Client)\
|
||||
|
@ -230,7 +229,7 @@ class TempmonClientView(MasterView):
|
|||
return reading.client
|
||||
|
||||
def configure_row_grid(self, g):
|
||||
super(TempmonClientView, self).configure_row_grid(g)
|
||||
super().configure_row_grid(g)
|
||||
|
||||
# probe
|
||||
g.set_filter('probe', tempmon.Probe.description)
|
||||
|
|
|
@ -49,6 +49,7 @@ class TempmonProbeView(MasterView):
|
|||
|
||||
has_rows = True
|
||||
model_row_class = tempmon.Reading
|
||||
rows_title = "Readings"
|
||||
|
||||
labels = {
|
||||
'critical_max_timeout': "Critical High Timeout",
|
||||
|
@ -98,7 +99,7 @@ class TempmonProbeView(MasterView):
|
|||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(TempmonProbeView, self).configure_grid(g)
|
||||
super().configure_grid(g)
|
||||
|
||||
g.joiners['client'] = lambda q: q.join(tempmon.Client)
|
||||
g.sorters['client'] = g.make_sorter(tempmon.Client.config_key)
|
||||
|
@ -121,7 +122,7 @@ class TempmonProbeView(MasterView):
|
|||
return "No"
|
||||
|
||||
def configure_form(self, f):
|
||||
super(TempmonProbeView, self).configure_form(f)
|
||||
super().configure_form(f)
|
||||
|
||||
# config_key
|
||||
f.set_validator('config_key', self.unique_config_key)
|
||||
|
@ -186,7 +187,7 @@ class TempmonProbeView(MasterView):
|
|||
if data['enabled'] and form.model_instance.enabled:
|
||||
data['enabled'] = form.model_instance.enabled
|
||||
|
||||
return super(TempmonProbeView, self).objectify(form, data=data)
|
||||
return super().objectify(form, data=data)
|
||||
|
||||
def unique_config_key(self, node, value):
|
||||
query = self.Session.query(tempmon.Probe)\
|
||||
|
@ -240,7 +241,7 @@ class TempmonProbeView(MasterView):
|
|||
return reading.client
|
||||
|
||||
def configure_row_grid(self, g):
|
||||
super(TempmonProbeView, self).configure_row_grid(g)
|
||||
super().configure_row_grid(g)
|
||||
|
||||
# # probe
|
||||
# g.set_filter('probe', tempmon.Probe.description)
|
||||
|
|
Loading…
Reference in a new issue