diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 4d1b57743..0d1368a69 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -344,5 +344,10 @@ "hdhomerun": { "channels": "Channels", "hd": "HD" + }, + "scrutiny": { + "passed": "Passed", + "failed": "Failed", + "unknown": "Unknown" } } diff --git a/src/widgets/components.js b/src/widgets/components.js index b781172bf..d645d80d9 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -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")), diff --git a/src/widgets/scrutiny/component.jsx b/src/widgets/scrutiny/component.jsx new file mode 100644 index 000000000..2e44d7788 --- /dev/null +++ b/src/widgets/scrutiny/component.jsx @@ -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 ; + } + + if (!scrutinyData) { + return ( + + + + + + ); + } + + 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 ( + + + + + + ); +} diff --git a/src/widgets/scrutiny/widget.js b/src/widgets/scrutiny/widget.js new file mode 100644 index 000000000..8af7e04e9 --- /dev/null +++ b/src/widgets/scrutiny/widget.js @@ -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; diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index fe4328320..3f1c6e08b 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -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,