mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Feature: Headscale Service Widget (#4247)
This commit is contained in:
parent
6fd2b6b6dc
commit
c12a5c01f6
19
docs/widgets/services/headscale.md
Normal file
19
docs/widgets/services/headscale.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: Headscale
|
||||||
|
description: Headscale Widget Configuration
|
||||||
|
---
|
||||||
|
|
||||||
|
Learn more about [Headscale](https://headscale.net/).
|
||||||
|
|
||||||
|
You will need to generate an API access token from the [command line](https://headscale.net/ref/remote-cli/#create-an-api-key) using `headscale apikeys create` command.
|
||||||
|
|
||||||
|
To find your node ID, you can use `headscale nodes list` command.
|
||||||
|
|
||||||
|
Allowed fields: `["name", "address", "last_seen", "status"]`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
widget:
|
||||||
|
type: headscale
|
||||||
|
nodeId: nodeid
|
||||||
|
key: headscaleapiaccesstoken
|
||||||
|
```
|
@ -44,6 +44,7 @@ You can also find a list of all available service widgets in the sidebar navigat
|
|||||||
- [Gotify](gotify.md)
|
- [Gotify](gotify.md)
|
||||||
- [Grafana](grafana.md)
|
- [Grafana](grafana.md)
|
||||||
- [HDHomeRun](hdhomerun.md)
|
- [HDHomeRun](hdhomerun.md)
|
||||||
|
- [Headscale](headscale.md)
|
||||||
- [Healthchecks](healthchecks.md)
|
- [Healthchecks](healthchecks.md)
|
||||||
- [Home Assistant](homeassistant.md)
|
- [Home Assistant](homeassistant.md)
|
||||||
- [HomeBox](homebox.md)
|
- [HomeBox](homebox.md)
|
||||||
|
@ -67,6 +67,7 @@ nav:
|
|||||||
- widgets/services/gotify.md
|
- widgets/services/gotify.md
|
||||||
- widgets/services/grafana.md
|
- widgets/services/grafana.md
|
||||||
- widgets/services/hdhomerun.md
|
- widgets/services/hdhomerun.md
|
||||||
|
- widgets/services/headscale.md
|
||||||
- widgets/services/healthchecks.md
|
- widgets/services/healthchecks.md
|
||||||
- widgets/services/homeassistant.md
|
- widgets/services/homeassistant.md
|
||||||
- widgets/services/homebox.md
|
- widgets/services/homebox.md
|
||||||
|
@ -959,5 +959,13 @@
|
|||||||
"tasks7d": "Tasks Due This Week",
|
"tasks7d": "Tasks Due This Week",
|
||||||
"tasksOverdue": "Overdue Tasks",
|
"tasksOverdue": "Overdue Tasks",
|
||||||
"tasksInProgress": "Tasks In Progress"
|
"tasksInProgress": "Tasks In Progress"
|
||||||
|
},
|
||||||
|
"headscale": {
|
||||||
|
"name": "Name",
|
||||||
|
"address": "Address",
|
||||||
|
"last_seen": "Last Seen",
|
||||||
|
"status": "Status",
|
||||||
|
"online": "Online",
|
||||||
|
"offline": "Offline"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ export default async function credentialedProxyHandler(req, res, map) {
|
|||||||
"authentik",
|
"authentik",
|
||||||
"cloudflared",
|
"cloudflared",
|
||||||
"ghostfolio",
|
"ghostfolio",
|
||||||
|
"headscale",
|
||||||
"linkwarden",
|
"linkwarden",
|
||||||
"mealie",
|
"mealie",
|
||||||
"netalertx",
|
"netalertx",
|
||||||
|
@ -41,6 +41,7 @@ const components = {
|
|||||||
gotify: dynamic(() => import("./gotify/component")),
|
gotify: dynamic(() => import("./gotify/component")),
|
||||||
grafana: dynamic(() => import("./grafana/component")),
|
grafana: dynamic(() => import("./grafana/component")),
|
||||||
hdhomerun: dynamic(() => import("./hdhomerun/component")),
|
hdhomerun: dynamic(() => import("./hdhomerun/component")),
|
||||||
|
headscale: dynamic(() => import("./headscale/component")),
|
||||||
peanut: dynamic(() => import("./peanut/component")),
|
peanut: dynamic(() => import("./peanut/component")),
|
||||||
homeassistant: dynamic(() => import("./homeassistant/component")),
|
homeassistant: dynamic(() => import("./homeassistant/component")),
|
||||||
homebox: dynamic(() => import("./homebox/component")),
|
homebox: dynamic(() => import("./homebox/component")),
|
||||||
|
43
src/widgets/headscale/component.jsx
Normal file
43
src/widgets/headscale/component.jsx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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: nodeData, error: nodeError } = useWidgetAPI(widget, "node");
|
||||||
|
|
||||||
|
if (nodeError) {
|
||||||
|
return <Container service={service} error={nodeError} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nodeData) {
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="headscale.name" />
|
||||||
|
<Block label="headscale.address" />
|
||||||
|
<Block label="headscale.last_seen" />
|
||||||
|
<Block label="headscale.status" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
givenName,
|
||||||
|
ipAddresses: [address],
|
||||||
|
lastSeen,
|
||||||
|
online,
|
||||||
|
} = nodeData.node;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="headscale.name" value={givenName} />
|
||||||
|
<Block label="headscale.address" value={address} />
|
||||||
|
<Block label="headscale.last_seen" value={t("common.relativeDate", { value: lastSeen })} />
|
||||||
|
<Block label="headscale.status" value={t(online ? "headscale.online" : "headscale.offline")} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
14
src/widgets/headscale/widget.js
Normal file
14
src/widgets/headscale/widget.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import credentialedProxyHandler from "utils/proxy/handlers/credentialed";
|
||||||
|
|
||||||
|
const widget = {
|
||||||
|
api: "{url}/api/v1/{endpoint}/{nodeId}",
|
||||||
|
proxyHandler: credentialedProxyHandler,
|
||||||
|
|
||||||
|
mappings: {
|
||||||
|
node: {
|
||||||
|
endpoint: "node",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default widget;
|
@ -35,6 +35,7 @@ import gluetun from "./gluetun/widget";
|
|||||||
import gotify from "./gotify/widget";
|
import gotify from "./gotify/widget";
|
||||||
import grafana from "./grafana/widget";
|
import grafana from "./grafana/widget";
|
||||||
import hdhomerun from "./hdhomerun/widget";
|
import hdhomerun from "./hdhomerun/widget";
|
||||||
|
import headscale from "./headscale/widget";
|
||||||
import homeassistant from "./homeassistant/widget";
|
import homeassistant from "./homeassistant/widget";
|
||||||
import homebox from "./homebox/widget";
|
import homebox from "./homebox/widget";
|
||||||
import homebridge from "./homebridge/widget";
|
import homebridge from "./homebridge/widget";
|
||||||
@ -161,6 +162,7 @@ const widgets = {
|
|||||||
gotify,
|
gotify,
|
||||||
grafana,
|
grafana,
|
||||||
hdhomerun,
|
hdhomerun,
|
||||||
|
headscale,
|
||||||
homeassistant,
|
homeassistant,
|
||||||
homebox,
|
homebox,
|
||||||
homebridge,
|
homebridge,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user