Skip to content

Commit

Permalink
Bug Fix: Disabled Probes Crash Dashboard on WebUI
Browse files Browse the repository at this point in the history
Fixed a bug with default and basic dashboards when a food probe is disabled, causing the dashboard to crash.
  • Loading branch information
nebhead committed Oct 1, 2024
1 parent 295ad67 commit 7adf25d
Show file tree
Hide file tree
Showing 7 changed files with 280 additions and 250 deletions.
5 changes: 4 additions & 1 deletion static/js/dash_default.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function initProbeCards() {
};

function initProbeGauge(key) {
console.log('Init Probe Gauge: ' + key);
// Create a new Gauge
if (key == primary) {
var maxTemp = maxTempPrimary;
Expand Down Expand Up @@ -334,7 +335,9 @@ function updateTempCard(key, temp) {
//console.log('Update Temp Card: ' + key + ' temp: ' + temp);
var index = dashDataStruct.custom.hidden_cards.indexOf(key); // Index of cardID
if (index == -1) {
if ((temp != null) && $('#card_'+key).is(":hidden")) {
const card = document.getElementById('card_'+key);
const card_enabled = card.getAttribute('data-enabled') === 'true'
if ((temp != null) && $('#card_'+key).is(":hidden") && card_enabled) {
$('#card_'+key).show();
} else if (temp == null) {
$('#card_'+key).hide();
Expand Down
6 changes: 5 additions & 1 deletion templates/_macro_dash_basic.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{% macro render_probe_card(probe_data, settings, control) %}
{% macro render_probe_card(probe_data, settings, control, enabled) %}

<!-- Probe Card -->
<div class="card shadow">
{% if enabled %}
<div class="card-header bg-primary text-white text-center">
{% else %}
<div class="card-header bg-secondary text-white-50 text-center">
{% endif %}
<strong>
{% if probe_data['type'] == 'Primary' %}
<i class="fas fa-tachometer-alt"></i>&nbsp;
Expand Down
6 changes: 5 additions & 1 deletion templates/_macro_dash_default.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{% macro render_probe_card(probe_data, settings, control) %}
{% macro render_probe_card(probe_data, settings, control, enabled) %}

<!-- Probe Card -->
<div class="card shadow">
{% if enabled %}
<div class="card-header bg-primary text-white text-center">
{% else %}
<div class="card-header bg-secondary text-white-50 text-center">
{% endif %}
<strong>
{% if probe_data['type'] == 'Primary' %}
<i class="fas fa-tachometer-alt"></i>&nbsp;
Expand Down
16 changes: 12 additions & 4 deletions templates/dash_basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
<!-- Card Section -->
<div class="row"> <!-- Probe Cards -->
{% for probe in settings['probe_settings']['probe_map']['probe_info'] %}
{% if probe['enabled'] and probe['type'] != 'Aux' %}
{% if probe['type'] != 'Aux' %}
<div id="card_{{ probe['label'] }}" class="col-lg-4 col-md-6 col-sm-12"
{% if probe['label'] in dash_data['custom']['hidden_cards'] %}
{% if probe['label'] in dash_data['custom']['hidden_cards'] or not probe['enabled'] %}
style="display:none"
{% endif %}>
{% endif %}
{% if probe['enabled'] %}
data-enabled="true"
{% else %}
data-enabled="false"
{% endif %}
>
<br>
<!-- Card for Probe Data -->
{{ render_probe_card(probe, settings, control) }}
{{ render_probe_card(probe, settings, control, probe['enabled']) }}
<br>
</div>
{% endif %}
Expand Down Expand Up @@ -153,6 +159,7 @@ <h4 class="modal-title">Dashboard Settings</h4>
<table class="table table-hover table-borderless">
<tbody>
{% for probe in settings['probe_settings']['probe_map']['probe_info'] %}
{% if probe['enabled'] %}
<tr onclick="dashToggleVisible('{{ probe['label'] }}');">
<td>
<span id="visibleStatus_{{ probe['label'] }}">
Expand All @@ -165,6 +172,7 @@ <h4 class="modal-title">Dashboard Settings</h4>
{{ probe['name'] }} Card
</td>
</tr>
{% endif %}
{% endfor %}
<tr onclick="dashToggleVisible('status');">
<td>
Expand Down
42 changes: 25 additions & 17 deletions templates/dash_default.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
<!-- Card Section -->
<div class="row"> <!-- Probe Cards -->
{% for probe in settings['probe_settings']['probe_map']['probe_info'] %}
{% if probe['enabled'] and probe['type'] != 'Aux' %}
{% if probe['type'] != 'Aux' %}
<div id="card_{{ probe['label'] }}" class="col-lg-4 col-md-6 col-sm-12"
{% if probe['label'] in dash_data['custom']['hidden_cards'] %}
style="display:none"
{% endif %}>
{% if probe['label'] in dash_data['custom']['hidden_cards'] or not probe['enabled'] %}
style="display:none"
{% endif %}
{% if probe['enabled'] %}
data-enabled="true"
{% else %}
data-enabled="false"
{% endif %}
>
<br>
<!-- Card for Probe Data -->
{{ render_probe_card(probe, settings, control) }}
{{ render_probe_card(probe, settings, control, probe['enabled']) }}
<br>
</div>
{% endif %}
Expand Down Expand Up @@ -152,18 +158,20 @@ <h4 class="modal-title">Dashboard Settings</h4>
<table class="table table-hover table-borderless">
<tbody>
{% for probe in settings['probe_settings']['probe_map']['probe_info'] %}
<tr onclick="dashToggleVisible('{{ probe['label'] }}');">
<td>
<span id="visibleStatus_{{ probe['label'] }}">
{% if probe['label'] not in dash_data['custom']['hidden_cards'] %}
<i class="fa-solid fa-eye text-success"></i>&nbsp;
{% else %}
<i class="fa-solid fa-eye-slash text-secondary"></i>&nbsp;
{% endif %}
</span>
{{ probe['name'] }} Card
</td>
</tr>
{% if probe['enabled'] %}
<tr onclick="dashToggleVisible('{{ probe['label'] }}');">
<td>
<span id="visibleStatus_{{ probe['label'] }}">
{% if probe['label'] not in dash_data['custom']['hidden_cards'] %}
<i class="fa-solid fa-eye text-success"></i>&nbsp;
{% else %}
<i class="fa-solid fa-eye-slash text-secondary"></i>&nbsp;
{% endif %}
</span>
{{ probe['name'] }} Card
</td>
</tr>
{% endif %}
{% endfor %}
<tr onclick="dashToggleVisible('status');">
<td>
Expand Down
213 changes: 108 additions & 105 deletions updater/post-update-message.html
Original file line number Diff line number Diff line change
@@ -1,105 +1,108 @@
<!-- Post Update Message for v1.8.0 -->
<H1>
<img src="{{ url_for('static', filename='img/launcher-icon-1x.png') }}" width="50" height="50" class="d-inline-block align-top" alt="">
PiFire 1.8.1 Release - September / 2024
</H1>
<div class="row justify-content-center">
<div class="card" style="width:80%">
<div class="card-body">
<p>
This release contains bug fixes and feature updates since the previous version.
</p>

<br>

<p>
<i class="fa-regular fa-star"></i>&nbsp; <u>Here are just some of the <b>NEW</b> features that were added in this update:</u>
</p>

<ul>
<li>
Changed the <a href="/wizard">Configuration Wizard</a> to improve platform selection. Now you can select your PCB Board type (or Custom)
and configure the available settings. The wizard will automatically assign the right GPIO pins as configured for that particular version
of the board. This also removes any extraneous configuration options.
</li>
<li>
Added transient probe configuration types so that probes can be marked as transient(not always available). This means that if probes/probe
ports are not fixed (like in the case of the DS18B20 device), then the control script can return None type for the temperature. This allows
the dashboard to do things like hide the card in the case where this probe isn't present.
</li>
<li>
Default Dashboard gets the ability to set maximum temperature to display for the primary probe and food probes. This can be configured via the gear icon settings.
</li>
<li>
Default and Basic dashboards will notify the user if connection to the server is lost (i.e. when the server is not responding to requests).
</li>
<li>
Added ST7789V (Newer V-variant of the display) display which is currently experimental because of the use of an experimental library.
This will likely change in a future release if the V variant gets added to the original library.
</li>
<li>
Behind the scenes improvements including:
<ul>
<li>
Moved all platform/board/system settings into 'platform' in the settings.json. This neatly group all of these settings in a single
place so that they are not spread out across the settings configuration.
</li>
<li>
Combined the pifire.py and pifire_pwm.py modules into a raspberry_pi_all.py module, which supports both AC and DC Fan configurations
with most flavors of the Raspberry Pi single board computer.
</li>
<li>
Created a board configuration utility that will make specific system configurations easier to perform on different single board
computers. The installation, wizard and update utilities can use this tool to do board configuration as needed for enabling different
features of the platform.
</li>
<li>
Refined the auto-tuning tool to use the last sampled resistance at a given reference temperature to use for calculations. This should
help to improve the accuracy of the tuning data, especially with slower probes.
</li>
<li>
Changed the ETA function to use Linear Regression (SciKit) instead of the Interpolate module (SciPy). This will hopefully improve the
reliability of the ETA function.
</li>
<li>
Added ProtoFlex module for testing new display output system. This will be used to test the new display system and allow for additional
screen sizes to be added for existing displays like ILI9341, etc. Also refactored the FlexObject and BaseFlex system to be more modular
and hopefully more performant. Updated the configuration wizard so that configuration of displays is easier. Other minor bug fixes.
</li>
<li>
Improved resilience of the control script, especially when loading probe devices. If a probe device fails to load, the probes that are
associated with that device will be disabled.
</li>
<li>
Added a critical error flag to the control script. This will be used to detect when a critical error is encountered, which may prevent
further control of the system (i.e. changing modes, etc.)
</li>
</ul>
</li>
</ul>

<p><i class="fa-solid fa-bug-slash"></i>&nbsp; <u>Here are some bug fixes in this update:</u></p>

<ul>
<li>
Fixed a bug where changing units from F to C would (during upgrade) would cause the control script to crash.
</li>
<li>
Fixed a bug where the hopper level was not correctly displayed on startup for the flex displays. Reduced the hopper level check to once every 60
seconds during a work cycle.
</li>
<li>
Fixed a bug on 240x320 and 64x128 displays where if pifire is not connected to the network, an IP QR Code will hang the display.
</li>
<li>
Fixed a bug where trigger_level for relays was being ignored and set to HIGH by default.
</li>
</ul>

</div>
</div>

</div>

<br>
<br>
<!-- Post Update Message for v1.8.0 -->
<H1>
<img src="{{ url_for('static', filename='img/launcher-icon-1x.png') }}" width="50" height="50" class="d-inline-block align-top" alt="">
PiFire 1.8.2 Release - September / 2024
</H1>
<div class="row justify-content-center">
<div class="card" style="width:80%">
<div class="card-body">
<p>
This release contains bug fixes and feature updates since the previous version.
</p>

<br>

<p>
<i class="fa-regular fa-star"></i>&nbsp; <u>Here are just some of the <b>NEW</b> features that were added in this update:</u>
</p>

<ul>
<li>
Changed the <a href="/wizard">Configuration Wizard</a> to improve platform selection. Now you can select your PCB Board type (or Custom)
and configure the available settings. The wizard will automatically assign the right GPIO pins as configured for that particular version
of the board. This also removes any extraneous configuration options.
</li>
<li>
Added transient probe configuration types so that probes can be marked as transient(not always available). This means that if probes/probe
ports are not fixed (like in the case of the DS18B20 device), then the control script can return None type for the temperature. This allows
the dashboard to do things like hide the card in the case where this probe isn't present.
</li>
<li>
Default Dashboard gets the ability to set maximum temperature to display for the primary probe and food probes. This can be configured via the gear icon settings.
</li>
<li>
Default and Basic dashboards will notify the user if connection to the server is lost (i.e. when the server is not responding to requests).
</li>
<li>
Added ST7789V (Newer V-variant of the display) display which is currently experimental because of the use of an experimental library.
This will likely change in a future release if the V variant gets added to the original library.
</li>
<li>
Behind the scenes improvements including:
<ul>
<li>
Moved all platform/board/system settings into 'platform' in the settings.json. This neatly group all of these settings in a single
place so that they are not spread out across the settings configuration.
</li>
<li>
Combined the pifire.py and pifire_pwm.py modules into a raspberry_pi_all.py module, which supports both AC and DC Fan configurations
with most flavors of the Raspberry Pi single board computer.
</li>
<li>
Created a board configuration utility that will make specific system configurations easier to perform on different single board
computers. The installation, wizard and update utilities can use this tool to do board configuration as needed for enabling different
features of the platform.
</li>
<li>
Refined the auto-tuning tool to use the last sampled resistance at a given reference temperature to use for calculations. This should
help to improve the accuracy of the tuning data, especially with slower probes.
</li>
<li>
Changed the ETA function to use Linear Regression (SciKit) instead of the Interpolate module (SciPy). This will hopefully improve the
reliability of the ETA function.
</li>
<li>
Added ProtoFlex module for testing new display output system. This will be used to test the new display system and allow for additional
screen sizes to be added for existing displays like ILI9341, etc. Also refactored the FlexObject and BaseFlex system to be more modular
and hopefully more performant. Updated the configuration wizard so that configuration of displays is easier. Other minor bug fixes.
</li>
<li>
Improved resilience of the control script, especially when loading probe devices. If a probe device fails to load, the probes that are
associated with that device will be disabled.
</li>
<li>
Added a critical error flag to the control script. This will be used to detect when a critical error is encountered, which may prevent
further control of the system (i.e. changing modes, etc.)
</li>
</ul>
</li>
</ul>

<p><i class="fa-solid fa-bug-slash"></i>&nbsp; <u>Here are some bug fixes in this update:</u></p>

<ul>
<li>
Fixed a bug where changing units from F to C would (during upgrade) would cause the control script to crash.
</li>
<li>
Fixed a bug where the hopper level was not correctly displayed on startup for the flex displays. Reduced the hopper level check to once every 60
seconds during a work cycle.
</li>
<li>
Fixed a bug on 240x320 and 64x128 displays where if pifire is not connected to the network, an IP QR Code will hang the display.
</li>
<li>
Fixed a bug where trigger_level for relays was being ignored and set to HIGH by default.
</li>
<li>
Fixed a bug with default and basic dashboards when a food probe is disabled, causing the dashboard to crash.
</li>
</ul>

</div>
</div>

</div>

<br>
<br>
Loading

0 comments on commit 7adf25d

Please sign in to comment.