mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-19 02:59:50 +00:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
parent
fa50bbad9c
commit
19c25713c4
387 changed files with 4785 additions and 4109 deletions
|
@ -2,7 +2,6 @@ import Container from "components/services/widget/container";
|
|||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
|
||||
// @see https://github.com/AnalogJ/scrutiny/blob/d8d56f77f9e868127c4849dac74d65512db658e8/webapp/frontend/src/app/shared/device-status.pipe.ts
|
||||
const DeviceStatus = {
|
||||
passed: 0,
|
||||
|
@ -10,16 +9,20 @@ const DeviceStatus = {
|
|||
failed_scrutiny: 2,
|
||||
failed_both: 3,
|
||||
|
||||
isFailed(s){ return s > this.passed && s <= this.failed_both},
|
||||
isUnknown(s){ return s < this.passed || s > this.failed_both}
|
||||
}
|
||||
isFailed(s) {
|
||||
return s > this.passed && s <= this.failed_both;
|
||||
},
|
||||
isUnknown(s) {
|
||||
return s < this.passed || s > this.failed_both;
|
||||
},
|
||||
};
|
||||
|
||||
// @see https://github.com/AnalogJ/scrutiny/blob/d8d56f77f9e868127c4849dac74d65512db658e8/webapp/frontend/src/app/core/config/app.config.ts
|
||||
const DeviceStatusThreshold = {
|
||||
smart: 1,
|
||||
scrutiny: 2,
|
||||
both: 3
|
||||
}
|
||||
both: 3,
|
||||
};
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
@ -40,13 +43,18 @@ export default function Component({ service }) {
|
|||
<Block label="scrutiny.unknown" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const deviceIds = Object.values(scrutinyData.data.summary);
|
||||
const statusThreshold = scrutinySettings.settings.metrics.status_threshold;
|
||||
|
||||
const failed = deviceIds.filter(deviceId => (DeviceStatus.isFailed(deviceId.device.device_status) && statusThreshold === DeviceStatusThreshold.both) || [statusThreshold, DeviceStatus.failed_both].includes(deviceId.device.device_status))?.length || 0;
|
||||
const unknown = deviceIds.filter(deviceId => DeviceStatus.isUnknown(deviceId.device.device_status))?.length || 0;
|
||||
const failed =
|
||||
deviceIds.filter(
|
||||
(deviceId) =>
|
||||
(DeviceStatus.isFailed(deviceId.device.device_status) && statusThreshold === DeviceStatusThreshold.both) ||
|
||||
[statusThreshold, DeviceStatus.failed_both].includes(deviceId.device.device_status),
|
||||
)?.length || 0;
|
||||
const unknown = deviceIds.filter((deviceId) => DeviceStatus.isUnknown(deviceId.device.device_status))?.length || 0;
|
||||
const passed = deviceIds.length - (failed + unknown);
|
||||
|
||||
return (
|
||||
|
@ -55,8 +63,5 @@ export default function Component({ service }) {
|
|||
<Block label="scrutiny.failed" value={failed} />
|
||||
<Block label="scrutiny.unknown" value={unknown} />
|
||||
</Container>
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,16 +7,12 @@ const widget = {
|
|||
mappings: {
|
||||
summary: {
|
||||
endpoint: "summary",
|
||||
validate: [
|
||||
"data",
|
||||
]
|
||||
validate: ["data"],
|
||||
},
|
||||
settings: {
|
||||
endpoint: "settings",
|
||||
validate: [
|
||||
"settings",
|
||||
]
|
||||
}
|
||||
validate: ["settings"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue