diff --git a/src/components/services/widget/block.jsx b/src/components/services/widget/block.jsx index 295330d6..00a50772 100644 --- a/src/components/services/widget/block.jsx +++ b/src/components/services/widget/block.jsx @@ -1,6 +1,9 @@ +import { useTranslation } from "next-i18next"; import classNames from "classnames"; export default function Block({ value, label }) { + const { t } = useTranslation(); + return (
{value === undefined || value === null ? "-" : value}
-
{label}
+
{t(label)}
); } diff --git a/src/components/services/widget/container.jsx b/src/components/services/widget/container.jsx index deb5fdc2..6aa9aad0 100644 --- a/src/components/services/widget/container.jsx +++ b/src/components/services/widget/container.jsx @@ -1,4 +1,4 @@ -export default function Container({ error = false, children }) { +export default function Container({ error = false, children, service }) { if (error) { return (
@@ -7,5 +7,16 @@ export default function Container({ error = false, children }) { ); } - return
{children}
; + let visibleChildren = children; + const fields = service?.widget?.fields; + const type = service?.widget?.type; + if (fields && type) { + visibleChildren = children.filter(child => fields.some(field => `${type}.${field}` === child.props?.label)); + } + + return ( +
+ {visibleChildren} +
+ ); } diff --git a/src/utils/config/service-helpers.js b/src/utils/config/service-helpers.js index f36e0a56..813972b2 100644 --- a/src/utils/config/service-helpers.js +++ b/src/utils/config/service-helpers.js @@ -113,6 +113,7 @@ export function cleanServiceGroups(groups) { // whitelisted set of keys to pass to the frontend const { type, // all widgets + fields, server, // docker widget container, currency, // coinmarketcap widget @@ -121,6 +122,7 @@ export function cleanServiceGroups(groups) { cleanedService.widget = { type, + fields: fields || null, service_name: service.name, service_group: serviceGroup.name, }; diff --git a/src/widgets/adguard/component.jsx b/src/widgets/adguard/component.jsx index dbd67644..0c78113d 100644 --- a/src/widgets/adguard/component.jsx +++ b/src/widgets/adguard/component.jsx @@ -17,11 +17,11 @@ export default function Component({ service }) { if (!adguardData) { return ( - - - - - + + + + + ); } @@ -30,12 +30,12 @@ export default function Component({ service }) { adguardData.num_replaced_safebrowsing + adguardData.num_replaced_safesearch + adguardData.num_replaced_parental; return ( - - - - + + + + diff --git a/src/widgets/authentik/component.jsx b/src/widgets/authentik/component.jsx index 7087c205..31f864d1 100644 --- a/src/widgets/authentik/component.jsx +++ b/src/widgets/authentik/component.jsx @@ -19,10 +19,10 @@ export default function Component({ service }) { if (!usersData || !loginsData || !failedLoginsData) { return ( - - - - + + + + ); } @@ -38,10 +38,10 @@ export default function Component({ service }) { ); return ( - - - - + + + + ); } diff --git a/src/widgets/bazarr/component.jsx b/src/widgets/bazarr/component.jsx index 921529da..24fef1ce 100644 --- a/src/widgets/bazarr/component.jsx +++ b/src/widgets/bazarr/component.jsx @@ -13,22 +13,22 @@ export default function Component({ service }) { const { data: moviesData, error: moviesError } = useWidgetAPI(widget, "movies"); if (episodesError || moviesError) { - return ; + return ; } if (!episodesData || !moviesData) { return ( - - - + + + ); } return ( - - - + + + ); } diff --git a/src/widgets/coinmarketcap/component.jsx b/src/widgets/coinmarketcap/component.jsx index 113eb40e..0b970b31 100644 --- a/src/widgets/coinmarketcap/component.jsx +++ b/src/widgets/coinmarketcap/component.jsx @@ -30,7 +30,7 @@ export default function Component({ service }) { if (!symbols || symbols.length === 0) { return ( - + ); @@ -42,7 +42,7 @@ export default function Component({ service }) { if (!statsData || !dateRange) { return ( - + ); @@ -51,7 +51,7 @@ export default function Component({ service }) { const { data } = statsData; return ( - +
diff --git a/src/widgets/docker/component.jsx b/src/widgets/docker/component.jsx index 015a1f25..10e55fcb 100644 --- a/src/widgets/docker/component.jsx +++ b/src/widgets/docker/component.jsx @@ -31,23 +31,23 @@ export default function Component({ service }) { if (!statsData || !statusData) { return ( - - - - - + + + + + ); } return ( - - - + + + {statsData.stats.networks && ( <> - - + + )} diff --git a/src/widgets/gotify/component.jsx b/src/widgets/gotify/component.jsx index f12b0e11..40f5793b 100644 --- a/src/widgets/gotify/component.jsx +++ b/src/widgets/gotify/component.jsx @@ -17,11 +17,22 @@ export default function Component({ service }) { return ; } + + if (!appsData || !messagesData || !clientsData) { + return ( + + + + + + ); + } + return ( - - - - + + + + ); } diff --git a/src/widgets/jackett/component.jsx b/src/widgets/jackett/component.jsx index 98f9bc46..9629e266 100644 --- a/src/widgets/jackett/component.jsx +++ b/src/widgets/jackett/component.jsx @@ -17,9 +17,9 @@ export default function Component({ service }) { if (!indexersData) { return ( - - - + + + ); } @@ -27,9 +27,9 @@ export default function Component({ service }) { const errored = indexersData.filter((indexer) => indexer.last_error); return ( - - - + + + ); } diff --git a/src/widgets/jellyseerr/component.jsx b/src/widgets/jellyseerr/component.jsx index 9e685f64..217e406e 100644 --- a/src/widgets/jellyseerr/component.jsx +++ b/src/widgets/jellyseerr/component.jsx @@ -17,19 +17,19 @@ export default function Component({ service }) { if (!statsData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/lidarr/component.jsx b/src/widgets/lidarr/component.jsx index 96df170e..343760e7 100644 --- a/src/widgets/lidarr/component.jsx +++ b/src/widgets/lidarr/component.jsx @@ -19,19 +19,19 @@ export default function Component({ service }) { if (!albumsData || !wantedData || !queueData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/mastodon/component.jsx b/src/widgets/mastodon/component.jsx index aa1dad01..ec12fca1 100644 --- a/src/widgets/mastodon/component.jsx +++ b/src/widgets/mastodon/component.jsx @@ -17,19 +17,19 @@ export default function Component({ service }) { if (!statsData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/npm/component.jsx b/src/widgets/npm/component.jsx index 518fc3eb..b35e27c8 100644 --- a/src/widgets/npm/component.jsx +++ b/src/widgets/npm/component.jsx @@ -17,10 +17,10 @@ export default function Component({ service }) { if (!infoData) { return ( - - - - + + + + ); } @@ -30,10 +30,10 @@ export default function Component({ service }) { const total = infoData.length; return ( - - - - + + + + ); } diff --git a/src/widgets/nzbget/component.jsx b/src/widgets/nzbget/component.jsx index f69f4cf0..f9ace707 100644 --- a/src/widgets/nzbget/component.jsx +++ b/src/widgets/nzbget/component.jsx @@ -17,23 +17,23 @@ export default function Component({ service }) { if (!statusData) { return ( - - - - + + + + ); } return ( - - + + diff --git a/src/widgets/ombi/component.jsx b/src/widgets/ombi/component.jsx index e7402721..60128c37 100644 --- a/src/widgets/ombi/component.jsx +++ b/src/widgets/ombi/component.jsx @@ -17,19 +17,19 @@ export default function Component({ service }) { if (!statsData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/overseerr/component.jsx b/src/widgets/overseerr/component.jsx index ad46a27e..47131f6e 100644 --- a/src/widgets/overseerr/component.jsx +++ b/src/widgets/overseerr/component.jsx @@ -17,19 +17,19 @@ export default function Component({ service }) { if (!statsData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/pihole/component.jsx b/src/widgets/pihole/component.jsx index a956594e..17a18627 100644 --- a/src/widgets/pihole/component.jsx +++ b/src/widgets/pihole/component.jsx @@ -17,19 +17,19 @@ export default function Component({ service }) { if (!piholeData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/portainer/component.jsx b/src/widgets/portainer/component.jsx index 140078bc..bd44d77e 100644 --- a/src/widgets/portainer/component.jsx +++ b/src/widgets/portainer/component.jsx @@ -19,10 +19,10 @@ export default function Component({ service }) { if (!containersData) { return ( - - - - + + + + ); } @@ -36,10 +36,10 @@ export default function Component({ service }) { const total = containersData.length; return ( - - - - + + + + ); } diff --git a/src/widgets/prowlarr/component.jsx b/src/widgets/prowlarr/component.jsx index 85c50186..bb082519 100644 --- a/src/widgets/prowlarr/component.jsx +++ b/src/widgets/prowlarr/component.jsx @@ -18,12 +18,12 @@ export default function Component({ service }) { if (!indexersData || !grabsData) { return ( - - - - - - + + + + + + ); } @@ -42,12 +42,12 @@ export default function Component({ service }) { }); return ( - - - - - - + + + + + + ); } diff --git a/src/widgets/qbittorrent/component.jsx b/src/widgets/qbittorrent/component.jsx index 28458312..4d3a3585 100644 --- a/src/widgets/qbittorrent/component.jsx +++ b/src/widgets/qbittorrent/component.jsx @@ -17,11 +17,11 @@ export default function Component({ service }) { if (!torrentData) { return ( - - - - - + + + + + ); } @@ -42,11 +42,11 @@ export default function Component({ service }) { const leech = torrentData.length - completed; return ( - - - - - + + + + + ); } diff --git a/src/widgets/radarr/component.jsx b/src/widgets/radarr/component.jsx index d6df7cf0..4b16f75f 100644 --- a/src/widgets/radarr/component.jsx +++ b/src/widgets/radarr/component.jsx @@ -18,19 +18,19 @@ export default function Component({ service }) { if (!moviesData || !queuedData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/readarr/component.jsx b/src/widgets/readarr/component.jsx index 794a6ab8..1e55d7cd 100644 --- a/src/widgets/readarr/component.jsx +++ b/src/widgets/readarr/component.jsx @@ -19,19 +19,19 @@ export default function Component({ service }) { if (!booksData || !wantedData || !queueData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/rutorrent/component.jsx b/src/widgets/rutorrent/component.jsx index cc0d03f5..279bdf0e 100644 --- a/src/widgets/rutorrent/component.jsx +++ b/src/widgets/rutorrent/component.jsx @@ -17,10 +17,10 @@ export default function Component({ service }) { if (!statusData) { return ( - - - - + + + + ); } @@ -32,10 +32,10 @@ export default function Component({ service }) { const active = statusData.filter((torrent) => torrent["d.get_state"] === "1"); return ( - - - - + + + + ); } diff --git a/src/widgets/sabnzbd/component.jsx b/src/widgets/sabnzbd/component.jsx index b38cb90f..c4e64c9a 100644 --- a/src/widgets/sabnzbd/component.jsx +++ b/src/widgets/sabnzbd/component.jsx @@ -27,19 +27,19 @@ export default function Component({ service }) { if (!queueData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/sonarr/component.jsx b/src/widgets/sonarr/component.jsx index 71aeb69c..8618b512 100644 --- a/src/widgets/sonarr/component.jsx +++ b/src/widgets/sonarr/component.jsx @@ -19,19 +19,19 @@ export default function Component({ service }) { if (!wantedData || !queuedData || !seriesData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/speedtest/component.jsx b/src/widgets/speedtest/component.jsx index edf8c66e..778d31c5 100644 --- a/src/widgets/speedtest/component.jsx +++ b/src/widgets/speedtest/component.jsx @@ -17,26 +17,26 @@ export default function Component({ service }) { if (!speedtestData) { return ( - - - - + + + + ); } return ( - + - - - + + + + ); } return ( - + - + diff --git a/src/widgets/traefik/component.jsx b/src/widgets/traefik/component.jsx index efa0e8fa..d24edb9e 100644 --- a/src/widgets/traefik/component.jsx +++ b/src/widgets/traefik/component.jsx @@ -17,19 +17,19 @@ export default function Component({ service }) { if (!traefikData) { return ( - - - - + + + + ); } return ( - - - - + + + + ); } diff --git a/src/widgets/transmission/component.jsx b/src/widgets/transmission/component.jsx index 5e471666..3c2f38ef 100644 --- a/src/widgets/transmission/component.jsx +++ b/src/widgets/transmission/component.jsx @@ -17,11 +17,11 @@ export default function Component({ service }) { if (!torrentData) { return ( - - - - - + + + + + ); } @@ -34,11 +34,11 @@ export default function Component({ service }) { const leech = torrents.length - completed || 0; return ( - - - - - + + + + + ); }