Skip to content

Commit c6770d2

Browse files
authored
Feature: SWAG dashboard widget (#3523)
1 parent 0a75c83 commit c6770d2

File tree

7 files changed

+65
-0
lines changed

7 files changed

+65
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: SWAG Dashboard
3+
description: SWAG Dashboard Widget Configuration
4+
---
5+
6+
Learn more about [SWAG Dashboard](https://github.com/linuxserver/docker-mods/tree/swag-dashboard).
7+
8+
Allowed fields: `["proxied", "auth", "outdated", "banned"]`.
9+
10+
```yaml
11+
widget:
12+
type: swagdashboard
13+
url: http://swagdashboard.host.or.ip:adminport # default port is 81
14+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ nav:
129129
- widgets/services/sonarr.md
130130
- widgets/services/speedtest-tracker.md
131131
- widgets/services/stash.md
132+
- widgets/services/swagdashboard.md
132133
- widgets/services/syncthing-relay-server.md
133134
- widgets/services/tailscale.md
134135
- widgets/services/tandoor.md

public/locales/en/common.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,5 +882,11 @@
882882
"enabled": "Enabled",
883883
"disabled": "Disabled",
884884
"total": "Total"
885+
},
886+
"swagdashboard": {
887+
"proxied": "Proxied",
888+
"auth": "With Auth",
889+
"outdated": "Outdated",
890+
"banned": "Banned"
885891
}
886892
}

src/widgets/components.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const components = {
103103
speedtest: dynamic(() => import("./speedtest/component")),
104104
stash: dynamic(() => import("./stash/component")),
105105
strelaysrv: dynamic(() => import("./strelaysrv/component")),
106+
swagdashboard: dynamic(() => import("./swagdashboard/component")),
106107
tailscale: dynamic(() => import("./tailscale/component")),
107108
tandoor: dynamic(() => import("./tandoor/component")),
108109
tautulli: dynamic(() => import("./tautulli/component")),
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Container from "components/services/widget/container";
2+
import Block from "components/services/widget/block";
3+
import useWidgetAPI from "utils/proxy/use-widget-api";
4+
5+
export default function Component({ service }) {
6+
const { widget } = service;
7+
8+
const { data: swagData, error: swagError } = useWidgetAPI(widget, "overview");
9+
10+
if (swagError) {
11+
return <Container service={service} error={swagError} />;
12+
}
13+
14+
if (!swagData) {
15+
return (
16+
<Container service={service}>
17+
<Block label="swagdashboard.proxied" />
18+
<Block label="swagdashboard.auth" />
19+
<Block label="swagdashboard.outdated" />
20+
<Block label="swagdashboard.banned" />
21+
</Container>
22+
);
23+
}
24+
25+
return (
26+
<Container service={service}>
27+
<Block label="swagdashboard.proxied" value={swagData.proxied} />
28+
<Block label="swagdashboard.auth" value={swagData.auth} />
29+
<Block label="swagdashboard.outdated" value={swagData.outdated} />
30+
<Block label="swagdashboard.banned" value={swagData.banned} />
31+
</Container>
32+
);
33+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import genericProxyHandler from "utils/proxy/handlers/generic";
2+
3+
const widget = {
4+
api: "{url}/?stats=true",
5+
proxyHandler: genericProxyHandler,
6+
};
7+
8+
export default widget;

src/widgets/widgets.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ import sonarr from "./sonarr/widget";
9494
import speedtest from "./speedtest/widget";
9595
import stash from "./stash/widget";
9696
import strelaysrv from "./strelaysrv/widget";
97+
import swagdashboard from "./swagdashboard/widget";
9798
import tailscale from "./tailscale/widget";
9899
import tandoor from "./tandoor/widget";
99100
import tautulli from "./tautulli/widget";
@@ -213,6 +214,7 @@ const widgets = {
213214
speedtest,
214215
stash,
215216
strelaysrv,
217+
swagdashboard,
216218
tailscale,
217219
tandoor,
218220
tautulli,

0 commit comments

Comments
 (0)