mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-03 05:53:40 +01:00
fix missing passing condition
This commit is contained in:
parent
3f79a2fdda
commit
cbf72eedab
@ -19,12 +19,6 @@ export default function Component({ service }) {
|
|||||||
both: 3
|
both: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
const thresholdStatusMapping = new Map([
|
|
||||||
[DeviceStatusThreshold.smart, DeviceStatus.failed_smart],
|
|
||||||
[DeviceStatusThreshold.scrutiny, DeviceStatus.failed_scrutiny],
|
|
||||||
[DeviceStatusThreshold.both, DeviceStatus.both]
|
|
||||||
])
|
|
||||||
|
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
const { data: scrutinySettings, error: scrutinySettingsError } = useWidgetAPI(widget, "settings");
|
const { data: scrutinySettings, error: scrutinySettingsError } = useWidgetAPI(widget, "settings");
|
||||||
@ -48,9 +42,9 @@ export default function Component({ service }) {
|
|||||||
const deviceIds = Object.values(scrutinyData.data.summary);
|
const deviceIds = Object.values(scrutinyData.data.summary);
|
||||||
const statusThreshold = scrutinySettings.settings.metrics.status_threshold;
|
const statusThreshold = scrutinySettings.settings.metrics.status_threshold;
|
||||||
|
|
||||||
const failed = deviceIds.filter(deviceId => [thresholdStatusMapping.get(statusThreshold), DeviceStatus.failed_both].includes(deviceId.device.device_status))?.length || 0;
|
const failed = deviceIds.filter(deviceId => (deviceId.device.device_status > 0 && statusThreshold === DeviceStatusThreshold.both) || [statusThreshold, DeviceStatus.failed_both].includes(deviceId.device.device_status))?.length || 0;
|
||||||
const unknown = deviceIds.filter(deviceId => deviceId.device.device_status < DeviceStatus.passed || deviceId.device.device_status > DeviceStatus.failed_both)?.length || 0;
|
const unknown = deviceIds.filter(deviceId => deviceId.device.device_status < DeviceStatus.passed || deviceId.device.device_status > DeviceStatus.failed_both)?.length || 0;
|
||||||
const passed = deviceIds.filter(deviceId => deviceId.device.device_status === 0)?.length || 0;
|
const passed = deviceIds.filter(deviceId => deviceId.device.device_status === 0 || (deviceId.device.device_status > statusThreshold && deviceId.device.device_status < DeviceStatus.failed_both))?.length || 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user