From e660b1ec875d60a180aea9d6c94c102835282841 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Tue, 30 Jun 2026 23:59:52 +0100 Subject: [PATCH] Add Showy Homepage dashboard widget Homepage widget with totals, library, and watchlist mappings. Displays total entries, collections, favorites, library breakdown (movies/series), and watchlist breakdown (movies/series). --- .../homepage-widgets/showydashboard/README.md | 66 +++++++++++++++++++ .../showydashboard/component.jsx | 47 +++++++++++++ .../homepage-widgets/showydashboard/widget.js | 36 ++++++++++ 3 files changed, 149 insertions(+) create mode 100644 integrations/homepage-widgets/showydashboard/README.md create mode 100644 integrations/homepage-widgets/showydashboard/component.jsx create mode 100644 integrations/homepage-widgets/showydashboard/widget.js diff --git a/integrations/homepage-widgets/showydashboard/README.md b/integrations/homepage-widgets/showydashboard/README.md new file mode 100644 index 0000000..9ba97ba --- /dev/null +++ b/integrations/homepage-widgets/showydashboard/README.md @@ -0,0 +1,66 @@ +# Showy Dashboard — Homepage Widget + +Displays Showy library stats on your Homepage dashboard. + +## Setup + +### 1. Showy Access Token + +In your Showy settings pages you can generate a token. Copy it and use it in the widget configuration below. + +The endpoint will be available at `GET /homepage-integration?token=your-secret-token-here` + +### 2. Copy widget into your Homepage install + +Copy this folder (`showydashboard/`) into your Homepage's `src/widgets/` directory. + +### 3. Register the widget + +**`src/widgets/widgets.js`** — add: + +```js +import showydashboard from "./showydashboard/widget"; + +const widgets = { + // ... + showydashboard: showydashboard, +}; +``` + +**`src/widgets/components.js`** — add: + +```js +const components = { + // ... + showydashboard: dynamic(() => import("./showydashboard/component")), +}; +``` + +### 4. Add to your Homepage services.yaml + +```yaml +- Showy Library: + icon: /icons/showy.png + description: Movies & TV-Series Tracking library + widget: + type: showydashboard + url: http://YOUR-SHOWY-HOST:4000 + dashboardToken: your-secret-token-here + fields: ["library", "libraryMovies", "librarySeries", "watchlist", "watchlistMovies", "watchlistSeries"] +``` + +### Available fields + +| Field | Description | +|---|---| +| `totalEntries` | All entries in the library | +| `library` | Entries not in watchlist | +| `libraryMovies` | Movies not in watchlist | +| `librarySeries` | TV series not in watchlist | +| `watchlist` | Entries in watchlist | +| `watchlistMovies` | Movies in watchlist | +| `watchlistSeries` | TV series in watchlist | +| `collections` | Total collections | +| `favorits` | Favorite entries | + +Omit `fields` to show all 9. `url` is just the host base — the widget appends `/api/v1/homepage-integration?token=...` automatically. diff --git a/integrations/homepage-widgets/showydashboard/component.jsx b/integrations/homepage-widgets/showydashboard/component.jsx new file mode 100644 index 0000000..2c45578 --- /dev/null +++ b/integrations/homepage-widgets/showydashboard/component.jsx @@ -0,0 +1,47 @@ +import Block from "components/services/widget/block"; +import Container from "components/services/widget/container"; + +import useWidgetAPI from "utils/proxy/use-widget-api"; + +export default function Component({ service }) { + const { widget } = service; + + const { data: showyStats, error: showyStatsError } = useWidgetAPI( + widget, + "stats", + ); + + if (showyStatsError) { + return ; + } + + if (!showyStats) { + return ( + + {/* */} + + {/* + */} + + {/* + + + */} + + ); + } + + return ( + + {/* */} + + {/* */} + {/* */} + + {/* */} + {/* */} + {/* */} + {/* */} + + ); +} diff --git a/integrations/homepage-widgets/showydashboard/widget.js b/integrations/homepage-widgets/showydashboard/widget.js new file mode 100644 index 0000000..b04ab8b --- /dev/null +++ b/integrations/homepage-widgets/showydashboard/widget.js @@ -0,0 +1,36 @@ +import { asJson } from "utils/proxy/api-helpers"; +import genericProxyHandler from "utils/proxy/handlers/generic"; + +const widget = { + api: "{url}/api/v1/{endpoint}?token={dashboardToken}", + proxyHandler: genericProxyHandler, + + mappings: { + totals: { + endpoint: "homepage-integration", + map: (data) => ({ + totalEntries: asJson(data).totalEntries, + collections: asJson(data).collections, + favorits: asJson(data).favorits, + }), + }, + library: { + endpoint: "homepage-integration", + map: (data) => ({ + library: asJson(data).library, + libraryMovies: asJson(data).libraryMovies, + librarySeries: asJson(data).librarySeries, + }), + }, + watchlist: { + endpoint: "homepage-integration", + map: (data) => ({ + watchlist: asJson(data).watchlist, + watchlistMovies: asJson(data).watchlistMovies, + watchlistSeries: asJson(data).watchlistSeries, + }), + }, + }, +}; + +export default widget;