Merge pull request #548 from Tarow/scrutiny-widget

Add scrutiny widget
pull/556/head
shamoon 2 years ago committed by GitHub
commit 3ebfad821c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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")),

@ -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>
);
}

@ -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…
Cancel
Save