diff --git a/tailbone/templates/tempmon/appliances/view.mako b/tailbone/templates/tempmon/appliances/view.mako
index bbaa0e3f..07a524b8 100644
--- a/tailbone/templates/tempmon/appliances/view.mako
+++ b/tailbone/templates/tempmon/appliances/view.mako
@@ -8,5 +8,14 @@
% endif
%def>
+<%def name="modify_this_page_vars()">
+ ${parent.modify_this_page_vars()}
+
+%def>
+
${parent.body()}
diff --git a/tailbone/templates/tempmon/clients/view.mako b/tailbone/templates/tempmon/clients/view.mako
index ab65bac6..2141d977 100644
--- a/tailbone/templates/tempmon/clients/view.mako
+++ b/tailbone/templates/tempmon/clients/view.mako
@@ -40,4 +40,14 @@
% endif
%def>
+<%def name="modify_this_page_vars()">
+ ${parent.modify_this_page_vars()}
+
+%def>
+
+
${parent.body()}
diff --git a/tailbone/templates/tempmon/dashboard.mako b/tailbone/templates/tempmon/dashboard.mako
index 815eb89e..214ff480 100644
--- a/tailbone/templates/tempmon/dashboard.mako
+++ b/tailbone/templates/tempmon/dashboard.mako
@@ -83,6 +83,57 @@
%def>
<%def name="render_this_page()">
+ % if use_buefy:
+
+ ${h.form(request.current_route_url(), ref='applianceForm')}
+ ${h.csrf_token(request)}
+
This probe is not enabled.
+ % endif
+ % endfor
+ % elif appliance:
+
@@ -129,6 +180,67 @@
% else:
This appliance has no probes configured!
% endif
+ % endif
+%def>
+
+<%def name="modify_this_page_vars()">
+ ${parent.modify_this_page_vars()}
+
%def>
diff --git a/tailbone/views/tempmon/appliances.py b/tailbone/views/tempmon/appliances.py
index 6b8ee036..c523ae78 100644
--- a/tailbone/views/tempmon/appliances.py
+++ b/tailbone/views/tempmon/appliances.py
@@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
-# Copyright © 2010-2022 Lance Edgar
+# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@@ -121,6 +121,14 @@ class TempmonApplianceView(MasterView):
elif self.creating or self.editing:
f.remove_field('probes')
+ def template_kwargs_view(self, **kwargs):
+ kwargs = super(TempmonApplianceView, self).template_kwargs_view(**kwargs)
+ appliance = kwargs['instance']
+
+ kwargs['probes_data'] = self.normalize_probes(appliance.probes)
+
+ return kwargs
+
def unique_name(self, node, value):
query = self.Session.query(tempmon.Appliance)\
.filter(tempmon.Appliance.name == value)
diff --git a/tailbone/views/tempmon/clients.py b/tailbone/views/tempmon/clients.py
index a3fdb31b..9edbd2ba 100644
--- a/tailbone/views/tempmon/clients.py
+++ b/tailbone/views/tempmon/clients.py
@@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
-# Copyright © 2010-2022 Lance Edgar
+# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@@ -159,6 +159,14 @@ class TempmonClientView(MasterView):
# archived
f.set_helptext('archived', tempmon.Client.archived.__doc__)
+ def template_kwargs_view(self, **kwargs):
+ kwargs = super(TempmonClientView, self).template_kwargs_view(**kwargs)
+ client = kwargs['instance']
+
+ kwargs['probes_data'] = self.normalize_probes(client.probes)
+
+ return kwargs
+
def objectify(self, form, data=None):
# this is a hack to prevent updates to the 'enabled' timestamp, when
diff --git a/tailbone/views/tempmon/core.py b/tailbone/views/tempmon/core.py
index 6665f50e..3f16860d 100644
--- a/tailbone/views/tempmon/core.py
+++ b/tailbone/views/tempmon/core.py
@@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
-# Copyright © 2010-2020 Lance Edgar
+# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@@ -42,6 +42,28 @@ class MasterView(views.MasterView):
from rattail_tempmon.db import Session
return Session()
+ def normalize_probes(self, probes):
+ data = []
+ for probe in probes:
+ view_url = self.request.route_url('tempmon.probes.view', uuid=probe.uuid)
+ edit_url = self.request.route_url('tempmon.probes.edit', uuid=probe.uuid)
+ data.append({
+ 'uuid': probe.uuid,
+ 'url': view_url,
+ '_action_url_view': view_url,
+ '_action_url_edit': edit_url,
+ 'description': probe.description,
+ 'critical_temp_min': probe.critical_temp_min,
+ 'good_temp_min': probe.good_temp_min,
+ 'good_temp_max': probe.good_temp_max,
+ 'critical_temp_max': probe.critical_temp_max,
+ 'status': self.enum.TEMPMON_PROBE_STATUS[probe.status],
+ 'enabled': "Yes" if probe.enabled else "No",
+ })
+ app = self.get_rattail_app()
+ data = app.json_friendly(data)
+ return data
+
def render_probes(self, obj, field):
"""
This method is used by Appliance and Client views.
@@ -50,6 +72,39 @@ class MasterView(views.MasterView):
return ""
route_prefix = self.get_route_prefix()
+ use_buefy = self.get_use_buefy()
+ if use_buefy:
+
+ actions = [self.make_grid_action_view()]
+ if self.request.has_perm('tempmon.probes.edit'):
+ actions.append(self.make_grid_action_edit())
+
+ factory = self.get_grid_factory()
+ g = factory(
+ key='{}.probes'.format(route_prefix),
+ data=[],
+ columns=[
+ 'description',
+ 'critical_temp_min',
+ 'good_temp_min',
+ 'good_temp_max',
+ 'critical_temp_max',
+ 'status',
+ 'enabled',
+ ],
+ labels={
+ 'critical_temp_min': "Crit. Min",
+ 'good_temp_min': "Good Min",
+ 'good_temp_max': "Good Max",
+ 'critical_temp_max': "Crit. Max",
+ },
+ linked_columns=['description'],
+ main_actions=actions,
+ )
+ return HTML.literal(
+ g.render_buefy_table_element(data_prop='probesData'))
+
+ # not buefy!
view_url = lambda p, i: self.request.route_url('tempmon.probes.view', uuid=p.uuid)
actions = [
grids.GridAction('view', icon='zoomin', url=view_url),
diff --git a/tailbone/views/tempmon/dashboard.py b/tailbone/views/tempmon/dashboard.py
index 954acf94..c2b925a8 100644
--- a/tailbone/views/tempmon/dashboard.py
+++ b/tailbone/views/tempmon/dashboard.py
@@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
-# Copyright © 2010-2022 Lance Edgar
+# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@@ -74,27 +74,31 @@ class TempmonDashboardView(View):
selected_appliance = TempmonSession.query(tempmon.Appliance)\
.get(selected_uuid)
- appliances = TempmonSession.query(tempmon.Appliance)\
- .order_by(tempmon.Appliance.name)\
- .all()
- appliance_options = tags.Options([
- tags.Option(appliance.name, appliance.uuid)
- for appliance in appliances])
-
- if use_buefy:
- appliance_select = None
- raise NotImplementedError
- else:
- appliance_select = tags.select('appliance_uuid', selected_uuid, appliance_options)
-
- return {
+ context = {
'index_url': self.request.route_url('tempmon.appliances'),
'index_title': "TempMon Appliances",
'use_buefy': use_buefy,
- 'appliance_select': appliance_select,
'appliance': selected_appliance,
}
+ appliances = TempmonSession.query(tempmon.Appliance)\
+ .order_by(tempmon.Appliance.name)\
+ .all()
+
+ if use_buefy:
+ context['appliances_data'] = [{'uuid': a.uuid,
+ 'name': a.name}
+ for a in appliances]
+
+ else:
+ appliance_options = tags.Options([
+ tags.Option(appliance.name, appliance.uuid)
+ for appliance in appliances])
+ context['appliance_select'] = tags.select(
+ 'appliance_uuid', selected_uuid, appliance_options)
+
+ return context
+
def readings(self):
# track down the requested appliance