-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Headscale Service Widget (#4247)
- Loading branch information
Showing
9 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters