mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
sysutils/nut: do not crash on this edge case, all I can test
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
<status_boost>UPS is boosting voltage</status_boost>
|
<status_boost>UPS is boosting voltage</status_boost>
|
||||||
<status_fsd>Forced Shutdown</status_fsd>
|
<status_fsd>Forced Shutdown</status_fsd>
|
||||||
<unconfigured>Nut is not started. Click to configure Nut.</unconfigured>
|
<unconfigured>Nut is not started. Click to configure Nut.</unconfigured>
|
||||||
|
<misconfigured>Nut is not returning a status. Click to reconfigure Nut.</misconfigured>
|
||||||
<netclient_unconfigured>This widget only works with the Netclient driver. Click to configure the Netclient driver.</netclient_unconfigured>
|
<netclient_unconfigured>This widget only works with the Netclient driver. Click to configure the Netclient driver.</netclient_unconfigured>
|
||||||
<netclient_remote_server>Remote NUT Server</netclient_remote_server>
|
<netclient_remote_server>Remote NUT Server</netclient_remote_server>
|
||||||
<time_hours>h</time_hours>
|
<time_hours>h</time_hours>
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ export default class NutNetclient extends BaseTableWidget {
|
|||||||
// Fetch the UPS status data from the server.
|
// Fetch the UPS status data from the server.
|
||||||
const { response: nut_ups_status_response } = await this.ajaxCall(`/api/nut/${'diagnostics/upsstatus'}`);
|
const { response: nut_ups_status_response } = await this.ajaxCall(`/api/nut/${'diagnostics/upsstatus'}`);
|
||||||
|
|
||||||
|
if (!nut_ups_status_response) {
|
||||||
|
$('#nut-table').html(`<a href="/ui/nut/index">${this.translations.misconfigured}</a>`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse the UPS status data into a key-value object.
|
// Parse the UPS status data into a key-value object.
|
||||||
const nut_ups_status = nut_ups_status_response.split('\n').reduce((acc, line) => {
|
const nut_ups_status = nut_ups_status_response.split('\n').reduce((acc, line) => {
|
||||||
const [key, value] = line.split(': ');
|
const [key, value] = line.split(': ');
|
||||||
|
|||||||
Reference in New Issue
Block a user