mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-04 22:43:40 +01:00
working romm widget
This commit is contained in:
parent
d3427e1bfc
commit
266cfe7a93
@ -809,5 +809,9 @@
|
|||||||
"totalTemplates": "Total Templates",
|
"totalTemplates": "Total Templates",
|
||||||
"totalSyncs": "Total Syncs",
|
"totalSyncs": "Total Syncs",
|
||||||
"loadedCards": "Loaded Cards"
|
"loadedCards": "Loaded Cards"
|
||||||
|
},
|
||||||
|
"romm": {
|
||||||
|
"platforms": "Platforms",
|
||||||
|
"totalRoms": "Total ROMs"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -87,6 +87,7 @@ const components = {
|
|||||||
qnap: dynamic(() => import("./qnap/component")),
|
qnap: dynamic(() => import("./qnap/component")),
|
||||||
radarr: dynamic(() => import("./radarr/component")),
|
radarr: dynamic(() => import("./radarr/component")),
|
||||||
readarr: dynamic(() => import("./readarr/component")),
|
readarr: dynamic(() => import("./readarr/component")),
|
||||||
|
romm: dynamic(() => import("./romm/component")),
|
||||||
rutorrent: dynamic(() => import("./rutorrent/component")),
|
rutorrent: dynamic(() => import("./rutorrent/component")),
|
||||||
sabnzbd: dynamic(() => import("./sabnzbd/component")),
|
sabnzbd: dynamic(() => import("./sabnzbd/component")),
|
||||||
scrutiny: dynamic(() => import("./scrutiny/component")),
|
scrutiny: dynamic(() => import("./scrutiny/component")),
|
||||||
|
36
src/widgets/romm/component.jsx
Normal file
36
src/widgets/romm/component.jsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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: statistics, error: statisticsStatsError } = useWidgetAPI(widget, "statistics");
|
||||||
|
|
||||||
|
if (statisticsStatsError) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="Error" value={statisticsStatsError.message} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statisticsStatsError) {
|
||||||
|
return <Container service={service} error={statisticsStatsError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statistics) {
|
||||||
|
const platforms = statistics.filter(x => x.n_roms!=0).length
|
||||||
|
const totalRoms = statistics.reduce((total, stat) => total + stat.n_roms, 0);
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="romm.platforms" value={platforms} />
|
||||||
|
<Block label="romm.totalRoms" value={totalRoms} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
14
src/widgets/romm/widget.js
Normal file
14
src/widgets/romm/widget.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/{endpoint}",
|
||||||
|
proxyHandler: genericProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
statistics: {
|
||||||
|
endpoint: "platforms",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -79,6 +79,7 @@ import qbittorrent from "./qbittorrent/widget";
|
|||||||
import qnap from "./qnap/widget";
|
import qnap from "./qnap/widget";
|
||||||
import radarr from "./radarr/widget";
|
import radarr from "./radarr/widget";
|
||||||
import readarr from "./readarr/widget";
|
import readarr from "./readarr/widget";
|
||||||
|
import romm from "./romm/widget";
|
||||||
import rutorrent from "./rutorrent/widget";
|
import rutorrent from "./rutorrent/widget";
|
||||||
import sabnzbd from "./sabnzbd/widget";
|
import sabnzbd from "./sabnzbd/widget";
|
||||||
import scrutiny from "./scrutiny/widget";
|
import scrutiny from "./scrutiny/widget";
|
||||||
@ -188,6 +189,7 @@ const widgets = {
|
|||||||
qnap,
|
qnap,
|
||||||
radarr,
|
radarr,
|
||||||
readarr,
|
readarr,
|
||||||
|
romm,
|
||||||
rutorrent,
|
rutorrent,
|
||||||
sabnzbd,
|
sabnzbd,
|
||||||
scrutiny,
|
scrutiny,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user