Remove all deprecated use_buefy logic

also remove some static files no longer used, etc.
This commit is contained in:
Lance Edgar 2023-02-03 12:05:17 -06:00
parent 01e5eee981
commit 9faaea881d
112 changed files with 2079 additions and 7039 deletions

View file

@ -1,20 +1,6 @@
## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" />
<%def name="extra_javascript()">
${parent.extra_javascript()}
% if not use_buefy:
<script type="text/javascript">
$(function() {
$('#restart-client').click(function() {
disable_button(this);
location.href = '${url('tempmon.clients.restart', uuid=instance.uuid)}';
});
});
</script>
% endif
</%def>
<%def name="context_menu_items()">
${parent.context_menu_items()}
% if request.has_perm('tempmon.appliances.dashboard'):
@ -27,14 +13,10 @@
<div class="object-helper">
<h3>Client Tools</h3>
<div class="object-helper-content">
% if use_buefy:
<once-button tag="a" href="${url('{}.restart'.format(route_prefix), uuid=instance.uuid)}"
type="is-primary"
text="Restart tempmon-client daemon">
</once-button>
% else:
<button type="button" id="restart-client">Restart tempmon-client daemon</button>
% endif
<once-button tag="a" href="${url('{}.restart'.format(route_prefix), uuid=instance.uuid)}"
type="is-primary"
text="Restart tempmon-client daemon">
</once-button>
</div>
</div>
% endif

View file

@ -8,178 +8,54 @@
<%def name="extra_javascript()">
${parent.extra_javascript()}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.min.js"></script>
% if not use_buefy:
<script type="text/javascript">
var contexts = {};
var charts = {};
function fetchReadings(appliance_uuid) {
if (appliance_uuid === undefined) {
appliance_uuid = $('#appliance_uuid').val();
}
$('.form-wrapper').mask("Fetching data");
if (Object.keys(charts).length) {
Object.keys(charts).forEach(function(key) {
charts[key].destroy();
delete charts[key];
});
}
var url = '${url("tempmon.dashboard.readings")}';
var params = {'appliance_uuid': appliance_uuid};
$.get(url, params, function(data) {
if (data.probes) {
data.probes.forEach(function(probe) {
charts[probe.uuid] = new Chart(contexts[probe.uuid], {
type: 'scatter',
data: {
datasets: [{
label: probe.description,
data: probe.readings
}]
},
options: {
scales: {
xAxes: [{
type: 'time',
time: {unit: 'minute'},
position: 'bottom'
}]
}
}
});
});
} else {
// TODO: should improve this
alert(data.error);
}
$('.form-wrapper').unmask();
});
}
$(function() {
% for probe in appliance.probes:
contexts['${probe.uuid}'] = $('#tempchart-${probe.uuid}');
% endfor
$('#appliance_uuid').selectmenu({
change: function(event, ui) {
$('.form-wrapper').mask("Fetching data");
$(this).parents('form').submit();
}
});
fetchReadings();
});
</script>
% endif
</%def>
<%def name="render_this_page()">
% if use_buefy:
${h.form(request.current_route_url(), ref='applianceForm')}
${h.csrf_token(request)}
<div class="level-left">
${h.form(request.current_route_url(), ref='applianceForm')}
${h.csrf_token(request)}
<div class="level-left">
<div class="level-item">
<b-field label="Appliance" horizontal>
<b-select name="appliance_uuid"
v-model="applianceUUID"
@input="$refs.applianceForm.submit()">
<option v-for="appliance in appliances"
:key="appliance.uuid"
:value="appliance.uuid">
{{ appliance.name }}
</option>
</b-select>
</b-field>
</div>
% if appliance:
<div class="level-item">
<a href="${url('tempmon.appliances.view', uuid=appliance.uuid)}">
${h.image(url('tempmon.appliances.thumbnail', uuid=appliance.uuid), "")}
</a>
</div>
% endif
</div>
${h.end_form()}
% if appliance and appliance.probes:
% for probe in appliance.probes:
<h4 class="is-size-4">
Probe:&nbsp; ${h.link_to(probe.description, url('tempmon.probes.graph', uuid=probe.uuid))}
(status: ${enum.TEMPMON_PROBE_STATUS[probe.status]})
</h4>
% if probe.enabled:
<canvas ref="tempchart-${probe.uuid}" width="400" height="60"></canvas>
% else:
<p>This probe is not enabled.</p>
% endif
% endfor
% elif appliance:
<h3>This appliance has no probes configured!</h3>
% else:
<h3>Please choose an appliance.</h3>
% endif
% else:
## not buefy
<div style="display: flex;">
<div class="form-wrapper">
<div class="form">
${h.form(request.current_route_url())}
${h.csrf_token(request)}
% if use_buefy:
<b-field horizontal label="Appliance">
${appliance_select}
</b-field>
% else:
<div class="field-wrapper">
<label>Appliance</label>
<div class="field">
${appliance_select}
</div>
</div>
% endif
${h.end_form()}
</div>
<div class="level-item">
<b-field label="Appliance" horizontal>
<b-select name="appliance_uuid"
v-model="applianceUUID"
@input="$refs.applianceForm.submit()">
<option v-for="appliance in appliances"
:key="appliance.uuid"
:value="appliance.uuid">
{{ appliance.name }}
</option>
</b-select>
</b-field>
</div>
<a href="${url('tempmon.appliances.view', uuid=appliance.uuid)}">
${h.image(url('tempmon.appliances.thumbnail', uuid=appliance.uuid), "")}
</a>
</div>
% if appliance:
<div class="level-item">
<a href="${url('tempmon.appliances.view', uuid=appliance.uuid)}">
${h.image(url('tempmon.appliances.thumbnail', uuid=appliance.uuid), "")}
</a>
</div>
% endif
% if appliance.probes:
</div>
${h.end_form()}
% if appliance and appliance.probes:
% for probe in appliance.probes:
<h3>
<h4 class="is-size-4">
Probe:&nbsp; ${h.link_to(probe.description, url('tempmon.probes.graph', uuid=probe.uuid))}
(status: ${enum.TEMPMON_PROBE_STATUS[probe.status]})
</h3>
</h4>
% if probe.enabled:
% if use_buefy:
<canvas ref="tempchart" width="400" height="150"></canvas>
% else:
<canvas id="tempchart-${probe.uuid}" width="400" height="60"></canvas>
% endif
<canvas ref="tempchart-${probe.uuid}" width="400" height="60"></canvas>
% else:
<p>This probe is not enabled.</p>
% endif
% endfor
% else:
% elif appliance:
<h3>This appliance has no probes configured!</h3>
% endif
% else:
<h3>Please choose an appliance.</h3>
% endif
</%def>

View file

@ -6,71 +6,6 @@
<%def name="extra_javascript()">
${parent.extra_javascript()}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.min.js"></script>
% if not use_buefy:
<script type="text/javascript">
var ctx = null;
var chart = null;
function fetchReadings(timeRange) {
if (timeRange === undefined) {
timeRange = $('#time-range').val();
}
var timeUnit;
if (timeRange == 'last hour') {
timeUnit = 'minute';
} else if (['last 6 hours', 'last day'].includes(timeRange)) {
timeUnit = 'hour';
} else {
timeUnit = 'day';
}
$('.form-wrapper').mask("Fetching data");
if (chart) {
chart.destroy();
}
$.get('${url('{}.graph_readings'.format(route_prefix), uuid=probe.uuid)}', {'time-range': timeRange}, function(data) {
chart = new Chart(ctx, {
type: 'scatter',
data: {
datasets: [{
label: "${probe.description}",
data: data
}]
},
options: {
scales: {
xAxes: [{
type: 'time',
time: {unit: timeUnit},
position: 'bottom'
}]
}
}
});
$('.form-wrapper').unmask();
});
}
$(function() {
ctx = $('#tempchart');
$('#time-range').selectmenu({
change: function(event, ui) {
fetchReadings(ui.item.value);
}
});
fetchReadings();
});
</script>
% endif
</%def>
<%def name="context_menu_items()">
@ -89,50 +24,23 @@
<div class="form-wrapper">
<div class="form">
% if use_buefy:
<b-field horizontal label="Appliance">
<div>
% if probe.appliance:
<a href="${url('tempmon.appliances.view', uuid=probe.appliance.uuid)}">${probe.appliance}</a>
% endif
</div>
</b-field>
% else:
<div class="field-wrapper">
<label>Appliance</label>
<div class="field">
% if probe.appliance:
<a href="${url('tempmon.appliances.view', uuid=probe.appliance.uuid)}">${probe.appliance}</a>
% endif
</div>
</div>
% endif
<b-field horizontal label="Appliance">
<div>
% if probe.appliance:
<a href="${url('tempmon.appliances.view', uuid=probe.appliance.uuid)}">${probe.appliance}</a>
% endif
</div>
</b-field>
% if use_buefy:
<b-field horizontal label="Probe Location">
<div>
${probe.location or ""}
</div>
</b-field>
% else:
<div class="field-wrapper">
<label>Probe Location</label>
<div class="field">${probe.location or ""}</div>
</div>
% endif
<b-field horizontal label="Probe Location">
<div>
${probe.location or ""}
</div>
</b-field>
% if use_buefy:
<b-field horizontal label="Showing">
${time_range}
</b-field>
% else:
<div class="field-wrapper">
<label>Showing</label>
<div class="field">
${time_range}
</div>
</div>
% endif
<b-field horizontal label="Showing">
${time_range}
</b-field>
</div>
</div>
@ -149,11 +57,7 @@
</div>
% if use_buefy:
<canvas ref="tempchart" width="400" height="150"></canvas>
% else:
<canvas id="tempchart" width="400" height="150"></canvas>
% endif
<canvas ref="tempchart" width="400" height="150"></canvas>
</%def>
<%def name="modify_this_page_vars()">

View file

@ -2,86 +2,48 @@
<%inherit file="/master/view.mako" />
<%def name="render_form_complete()">
% if use_buefy:
## ${self.render_form()}
## ${self.render_form()}
<script type="text/x-template" id="form-page-template">
<script type="text/x-template" id="form-page-template">
<div style="display: flex; justify-content: space-between;">
<div style="display: flex; justify-content: space-between;">
<div class="form-wrapper">
<div class="form-wrapper">
<div style="display: flex; flex-direction: column;">
<div style="display: flex; flex-direction: column;">
<nav class="panel" id="probe-main">
<p class="panel-heading">General</p>
<div class="panel-block">
<div>
${self.render_main_fields(form)}
</div>
</div>
</nav>
<div style="display: flex;">
<div class="panel-wrapper">
${self.left_column()}
</div>
<div class="panel-wrapper" style="margin-left: 1em;"> <!-- right column -->
${self.right_column()}
</div>
<nav class="panel" id="probe-main">
<p class="panel-heading">General</p>
<div class="panel-block">
<div>
${self.render_main_fields(form)}
</div>
</div>
</nav>
<div style="display: flex;">
<div class="panel-wrapper">
${self.left_column()}
</div>
<div class="panel-wrapper" style="margin-left: 1em;"> <!-- right column -->
${self.right_column()}
</div>
</div>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
</div>
</script>
<div id="form-page-app">
<form-page></form-page>
</div>
% else:
## legacy / not buefy
<ul id="context-menu">
${self.context_menu_items()}
</ul>
<div style="display: flex; justify-content: space-between;">
</div>
</script>
<div class="form-wrapper">
<div style="display: flex; flex-direction: column;">
<div class="panel" id="probe-main">
<h2>General</h2>
<div class="panel-body">
<div>
${self.render_main_fields(form)}
</div>
</div>
</div>
<div style="display: flex;">
<div class="panel-wrapper">
${self.left_column()}
</div>
<div class="panel-wrapper" style="margin-left: 1em;"> <!-- right column -->
${self.right_column()}
</div>
</div>
</div>
</div>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
</div>
% endif
<div id="form-page-app">
<form-page></form-page>
</div>
</%def>
@ -113,43 +75,25 @@
</%def>
<%def name="left_column()">
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Temperatures</p>
<div class="panel-block">
<div>
${self.render_temperature_fields(form)}
</div>
</div>
</nav>
% else:
<div class="panel">
<h2>Temperatures</h2>
<div class="panel-body">
${self.render_temperature_fields(form)}
<nav class="panel">
<p class="panel-heading">Temperatures</p>
<div class="panel-block">
<div>
${self.render_temperature_fields(form)}
</div>
</div>
</div>
% endif
</nav>
</%def>
<%def name="right_column()">
% if use_buefy:
<nav class="panel">
<p class="panel-heading">Timeouts</p>
<div class="panel-block">
<div>
${self.render_timeout_fields(form)}
</div>
</div>
</nav>
% else:
<div class="panel">
<h2>Timeouts</h2>
<div class="panel-body">
${self.render_timeout_fields(form)}
<nav class="panel">
<p class="panel-heading">Timeouts</p>
<div class="panel-block">
<div>
${self.render_timeout_fields(form)}
</div>
</div>
</div>
% endif
</nav>
</%def>
<%def name="render_temperature_fields(form)">