forked from thorrak/fermentrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_manage.html
246 lines (189 loc) · 9.51 KB
/
device_manage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
{% extends "sitewide/flat_ui_template.html" %}
{% load custom_tags %}
{# I'm converting this form so that it can be used in both the initial guided setup as well as when the user clicks #}
{# the "gear" icon in the upper right of the form #}
{% block title %}Device {{ active_device.device_name }} Settings{% endblock %}
{% block content %}
<h1 class="page-header">{{ active_device.device_name }} Configuration</h1>
<h3>Device Logs</h3>
{# I shamelessly borrowed this from site_help.html. It could/should be refactored to make more sense when only #}
{# displaying logs for a single device. #}
<table class="table">
<thead class="thead-inverse">
<tr>
<th>Device Name</th>
<th>Stdout Log</th>
<th>Stderr Log</th>
<th>Status</th>
<td>Board Type</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">{{ active_device.device_name }}</th>
<td><a href="{% url "get_device_log" "text" "brewpi" "stdout" active_device.id %}">{% log_file_path "brewpi" "stdout" active_device.id %}</a></td>
<td><a href="{% url "get_device_log" "text" "brewpi" "stderr" active_device.id %}">{% log_file_path "brewpi" "stderr" active_device.id %}</a></td>
<td>{{ active_device.status }}</td>
<td>{{ active_device.board_type }}</td>
</tr>
</tbody>
</table>
<p><a href="{% url 'device_debug_connection' active_device.id %}" class="btn btn-primary btn-large btn-lg">Debug Device Connection</a></p>
<h3 class="page-header">Update Fermentrack Settings for Device</h3>
<form action="{% url "device_manage" active_device.id %}" class="form-horizontal" method="post">{% csrf_token %}
{# This is primarily to capture modify_not_create #}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
<div id="deviceConstantsSection">
<h4 class="form-header">Device Constants</h4>
{% form_generic form.device_name %}
{% form_generic form.temp_format %}
{% form_generic form.data_point_log_interval %}
{% form_generic form.board_type %}
</div>
<div id="inetSocketSection">
<h4 class="form-header">Connect Interface to Script</h4>
{% form_generic form.useInetSocket %}
<div id="localSocketHidden" style="display: none">{# Although I don't recommend local sockets, some people might want them #}
{% form_generic form.socket_name %}
</div>
<div id="inetSocketHidden" style="display: block">
{% form_generic form.socketHost %}
{% form_generic form.socketPort %}
</div>
</div>
<div id="connectivitySection">
<h4 class="form-header">Connect Script to Device</h4>
{% form_generic form.connection_type %}
<div id="serialSocketSection" style="display: none"> {# The javascript below will show the relevant section (serial or wifi) #}
{% form_generic form.serial_port %}
{% form_generic form.serial_alt_port %}
{% form_generic form.prefer_connecting_via_udev %}
</div>
<div id="wifiSection" style="display: none">
{% form_generic form.wifi_host %}
{% form_generic form.wifi_port %}
</div>
</div>
<input type="submit" value="Submit" class="btn btn-primary" />
</form>
{% if active_device.board_type == "esp32" or active_device.board_type == "esp32s2" or active_device.board_type == "esp32c3" or active_device.board_type == "esp8266" %}
{# TODO - Add some kind of version check or something here #}
<h3 class="page-header">Update Extended Settings on Device</h3>
<form action="{% url "device_extended_settings" active_device.id %}" class="form-horizontal" method="post">{% csrf_token %}
{% for hidden in extended_settings_form.hidden_fields %}
{{ hidden }}
{% endfor %}
<div id="extendedSettingsSection">
{#? <h4 class="form-header">Device Constants</h4>#}
{% form_generic extended_settings_form.invertTFT %}
{# {% form_generic extended_settings_form.glycol %}#}
{# {% form_generic extended_settings_form.lowDelay %}#}
</div>
<input type="submit" value="Submit" class="btn btn-primary" />
</form>
{% endif %}
{# ########### UNINSTALL DEVICE SECTION ############# #}
<h2>Reset EEPROM</h2>
<p>
If you are having trouble configuring the pins/sensors or control constants on your device, it may be due to
inconsistencies in the controller's current configuration. To reset the configuration to the "factory" defaults,
click the button below. Once reset, you will need to reconfigure the device's pin's, sensors, and control
constants.
</p>
<a href="{% url 'device_eeprom_reset' active_device.id %}" class="btn btn-danger btn-large btn-lg">Reset EEPROM</a>
<h2>Reset WiFi Settings</h2>
<p>
If you need to reset the WiFi configuration on your device (for switching to a new network/router, for example)
click the button below to delete the WiFi connection settings on the device. Once the settings have been erased
you will need to physically reset the device to cause it to launch the configuration access point.
</p>
<a href="{% url 'device_wifi_reset' active_device.id %}" class="btn btn-danger btn-large btn-lg">Reset WiFi Settings</a>
<h2>Restart Controller</h2>
<p>
Although it generally shouldn't be necessary, if you need to restart the controller for any reason this can
often be triggered through the script to save you physically having to walk to the controller itself. Click the
button below to send a message to the controller instructing it to restart.
</p>
<a href="{% url 'device_restart' active_device.id %}" class="btn btn-danger btn-large btn-lg">Restart Controller</a>
<h2>Uninstall Device</h2>
<p>
To uninstall a device from Fermentrack, approve the following statements and click the "Uninstall Device" button
below. Removing the device will take effect immediately, and this operation cannot be reversed. Once removed,
the device will need to be set up again from scratch to be used with Fermentrack. Beer logs associated with
removed devices will not be linked from within Fermentrack and may become irrecoverable.
</p>
<p>
Once a device is removed from Fermentrack it will no longer be managed by the app and may not continue to
control temperature as expected. If you are actively controlling a heating/cooling source it is highly
recommended you have your device actively controlled.
</p>
<form action="{% url "device_uninstall" active_device.id %}" class="form-horizontal" method="post">{% csrf_token %}
<div class="row">
<div class="col-xs-1">
<input type="checkbox" data-toggle="switch" data-on-color="danger" data-on-text="Yes" data-off-text="No" name="remove_1" />
</div>
<div class="col-xs-11">
I want to uninstall the device "{{ active_device.device_name }}" from this instance of Fermentrack
</div>
</div>
<div class="row">
<div class="col-xs-1">
<input type="checkbox" data-toggle="switch" data-on-color="danger" data-on-text="Yes" data-off-text="No" name="remove_2" />
</div>
<div class="col-xs-11">
I understand that the device may or may not continue to control temperature as expected once removed
</div>
</div>
<div class="row">
<div class="col-xs-1">
<input type="checkbox" data-toggle="switch" data-on-color="danger" data-on-text="Yes" data-off-text="No" name="remove_3" />
</div>
<div class="col-xs-11">
<p>I understand that all logs associated with this device will be delinked and may be irrecoverable</p>
</div>
</div>
<div class="row">
<div class="row col-xs-12">
<input type="submit" value="Uninstall Device" class="btn btn-danger" />
</div>
</div>
</form>
{% endblock %}
{% block scripts %}
<script>
function InetSocketHide() {
if(document.getElementById('id_useInetSocket').checked) {
document.getElementById('localSocketHidden').style.display = 'none';
document.getElementById('inetSocketHidden').style.display = '';
} else {
document.getElementById('localSocketHidden').style.display = '';
document.getElementById('inetSocketHidden').style.display = 'none';
}
}
function ConnectionTypeHide() {
if(document.getElementById('id_connection_type').options[document.getElementById('id_connection_type').selectedIndex].value == "serial") {
document.getElementById('wifiSection').style.display = 'none';
document.getElementById('serialSocketSection').style.display = '';
} else {
document.getElementById('wifiSection').style.display = '';
document.getElementById('serialSocketSection').style.display = 'none';
}
}
window.onload = function() {
document.getElementById('id_connection_type').onchange = ConnectionTypeHide;
document.getElementById('id_useInetSocket').onchange = InetSocketHide;
{# Above we have the code to handle the toggling as the user completes the form, here we're going to unhide as part of creating the form itself #}
InetSocketHide();
ConnectionTypeHide();
};
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
// Switches
if ($('[data-toggle="switch"]').length) {
$('[data-toggle="switch"]').bootstrapSwitch();
}
</script>
{% endblock %}