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).
This commit is contained in:
1 parent
63aca7e7b8
commit
e660b1ec87
3 files changed
+149
No files matched your search
@@ -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.
|
||||||
@@ -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 <Container service={service} error={showyStatsError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!showyStats) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
{/* <Block label="Total Entries" />*/}
|
||||||
|
<Block label="Library" />
|
||||||
|
{/* <Block label="Library Movies" />
|
||||||
|
<Block label="Library Series" />*/}
|
||||||
|
<Block label="Watchlist" />
|
||||||
|
{/* <Block label="Watchlist Movies" />
|
||||||
|
<Block label="Watchlist Series" />
|
||||||
|
<Block label="Collections" />
|
||||||
|
<Block label="Favorites" />*/}
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
{/* <Block label="Total Entries" value={showyStats.totalEntries} />*/}
|
||||||
|
<Block label="Library" value={showyStats.library} />
|
||||||
|
{/* <Block label="Library Movies" value={showyStats.libraryMovies} />*/}
|
||||||
|
{/* <Block label="Library Series" value={showyStats.librarySeries} />*/}
|
||||||
|
<Block label="Watchlist" value={showyStats.watchlist} />
|
||||||
|
{/* <Block label="Watchlist Movies" value={showyStats.watchlistMovies} />*/}
|
||||||
|
{/* <Block label="Watchlist Series" value={showyStats.watchlistSeries} />*/}
|
||||||
|
{/* <Block label="Collections" value={showyStats.collections} />*/}
|
||||||
|
{/* <Block label="Favorites" value={showyStats.favorits} />*/}
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
Reference in new issue
Block a user