Add scrutiny widget
This commit is contained in:
parent
c8d0b5ac4b
commit
16561bac79
5 changed files with 62 additions and 0 deletions
|
@ -344,5 +344,10 @@
|
|||
"hdhomerun": {
|
||||
"channels": "Channels",
|
||||
"hd": "HD"
|
||||
},
|
||||
"scrutiny": {
|
||||
"passed": "Passed",
|
||||
"failed": "Failed",
|
||||
"unknown": "Unknown"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ const components = {
|
|||
readarr: dynamic(() => import("./readarr/component")),
|
||||
rutorrent: dynamic(() => import("./rutorrent/component")),
|
||||
sabnzbd: dynamic(() => import("./sabnzbd/component")),
|
||||
scrutiny: dynamic(() => import("./scrutiny/component")),
|
||||
sonarr: dynamic(() => import("./sonarr/component")),
|
||||
speedtest: dynamic(() => import("./speedtest/component")),
|
||||
strelaysrv: dynamic(() => import("./strelaysrv/component")),
|
||||
|
|
37
src/widgets/scrutiny/component.jsx
Normal file
37
src/widgets/scrutiny/component.jsx
Normal file
|
@ -0,0 +1,37 @@
|
|||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
const { data: scrutinyData, error: scrutinyError } = useWidgetAPI(widget, "summary");
|
||||
|
||||
if (scrutinyError) {
|
||||
return <Container error={scrutinyError} />;
|
||||
}
|
||||
|
||||
if (!scrutinyData) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="scrutiny.passed" />
|
||||
<Block label="scrutiny.failed" />
|
||||
<Block label="scrutiny.unknown" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
const deviceIds = Object.values(scrutinyData.data.summary);
|
||||
|
||||
const passed = deviceIds.filter(deviceId => deviceId.device.device_status === 0)?.length || 0;
|
||||
const failed = deviceIds.filter(deviceId => deviceId.device.device_status > 0 && deviceId.device.device_status <= 3)?.length || 0;
|
||||
const unknown = deviceIds.length - (passed + failed) || 0;
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="scrutiny.passed" value={passed} />
|
||||
<Block label="scrutiny.failed" value={failed} />
|
||||
<Block label="scrutiny.unknown" value={unknown} />
|
||||
</Container>
|
||||
);
|
||||
}
|
17
src/widgets/scrutiny/widget.js
Normal file
17
src/widgets/scrutiny/widget.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/api/{endpoint}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
|
||||
mappings: {
|
||||
summary: {
|
||||
endpoint: "summary",
|
||||
validate: [
|
||||
"data",
|
||||
]
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default widget;
|
|
@ -29,6 +29,7 @@ import radarr from "./radarr/widget";
|
|||
import readarr from "./readarr/widget";
|
||||
import rutorrent from "./rutorrent/widget";
|
||||
import sabnzbd from "./sabnzbd/widget";
|
||||
import scrutiny from "./scrutiny/widget";
|
||||
import sonarr from "./sonarr/widget";
|
||||
import speedtest from "./speedtest/widget";
|
||||
import strelaysrv from "./strelaysrv/widget";
|
||||
|
@ -73,6 +74,7 @@ const widgets = {
|
|||
readarr,
|
||||
rutorrent,
|
||||
sabnzbd,
|
||||
scrutiny,
|
||||
sonarr,
|
||||
speedtest,
|
||||
strelaysrv,
|
||||
|
|
Loading…
Add table
Reference in a new issue