diff --git a/src/widgets/components.js b/src/widgets/components.js index f7258a52c..9623c63d1 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -14,6 +14,7 @@ const components = { docker: dynamic(() => import("./docker/component")), kubernetes: dynamic(() => import("./kubernetes/component")), emby: dynamic(() => import("./emby/component")), + fileflows: dynamic(() => import("./fileflows/component")), flood: dynamic(() => import("./flood/component")), gluetun: dynamic(() => import("./gluetun/component")), gotify: dynamic(() => import("./gotify/component")), @@ -70,4 +71,4 @@ const components = { uptimekuma: dynamic(() => import("./uptimekuma/component")), }; -export default components; +export default components; \ No newline at end of file diff --git a/src/widgets/fileflows/component.jsx b/src/widgets/fileflows/component.jsx new file mode 100755 index 000000000..1b0225442 --- /dev/null +++ b/src/widgets/fileflows/component.jsx @@ -0,0 +1,45 @@ +import { useTranslation } from "next-i18next"; + +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 { t } = useTranslation(); + + const { widget } = service; + + const { data: fileflowsData, error: fileflowsError } = useWidgetAPI(widget, "status"); + + if (fileflowsError) { + return ; + } + + if (!fileflowsData) { + return ( + + + + + + + ); + } + + function fromTime(value) { + if (!value) { + fileflowsData.time = "0:00"; + return fileflowsData.time; + } + return fileflowsData.time; + } + + return ( + + + + + + + ); +} diff --git a/src/widgets/fileflows/widget.js b/src/widgets/fileflows/widget.js new file mode 100755 index 000000000..31d20de0e --- /dev/null +++ b/src/widgets/fileflows/widget.js @@ -0,0 +1,14 @@ +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/api/{endpoint}", + proxyHandler: genericProxyHandler, + + mappings: { + "status": { + endpoint: "status", + }, + }, +}; + +export default widget; \ No newline at end of file diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index feae40cdd..ff2a27873 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -9,6 +9,7 @@ import deluge from "./deluge/widget"; import diskstation from "./diskstation/widget"; import downloadstation from "./downloadstation/widget"; import emby from "./emby/widget"; +import fileflows from "./fileflows/widget"; import flood from "./flood/widget"; import gluetun from "./gluetun/widget"; import gotify from "./gotify/widget"; @@ -75,6 +76,7 @@ const widgets = { diskstation, downloadstation, emby, + fileflows, flood, gluetun, gotify, @@ -132,4 +134,4 @@ const widgets = { uptimekuma, }; -export default widgets; +export default widgets; \ No newline at end of file