Add more fields to tailscale widget

hostname is the machine name in the admin console.
name is the MagicDNS name of the device.
clientVersion is the version of the Tailscale client software.
This commit is contained in:
Claes Hallström 2023-10-03 20:14:18 +02:00
parent 7adfe2ffd9
commit 2368b88eb1
3 changed files with 14 additions and 2 deletions

View File

@ -7,7 +7,7 @@ You will need to generate an API access token from the [keys page](https://login
To find your device ID, go to the [machine overview page](https://login.tailscale.com/admin/machines) and select your machine. In the "Machine Details" section, copy your `ID`. It will end with `CNTRL`.
Allowed fields: `["address", "last_seen", "expires"]`.
Allowed fields: `["hostname", "address", "name", "last_seen", "expires", "client_version"]`.
```yaml
widget:

View File

@ -266,7 +266,9 @@
"total": "Total"
},
"tailscale": {
"hostname": "Hostname",
"address": "Address",
"name": "Name",
"expires": "Expires",
"never": "Never",
"last_seen": "Last Seen",
@ -277,7 +279,8 @@
"hours": "{{number}}h",
"minutes": "{{number}}m",
"seconds": "{{number}}s",
"ago": "{{value}} Ago"
"ago": "{{value}} Ago",
"client_version": "Client Version"
},
"tdarr": {
"queue": "Queue",

View File

@ -18,18 +18,24 @@ export default function Component({ service }) {
if (!statsData) {
return (
<Container service={service}>
<Block label="tailscale.hostname" />
<Block label="tailscale.address" />
<Block label="tailscale.name" />
<Block label="tailscale.last_seen" />
<Block label="tailscale.expires" />
<Block label="tailscale.client_version" />
</Container>
);
}
const {
hostname,
addresses: [address],
name,
keyExpiryDisabled,
lastSeen,
expires,
clientVersion,
} = statsData;
const now = new Date();
@ -64,9 +70,12 @@ export default function Component({ service }) {
return (
<Container service={service}>
<Block label="tailscale.hostname" value={hostname} />
<Block label="tailscale.address" value={address} />
<Block label="tailscale.name" value={name} />
<Block label="tailscale.last_seen" value={getLastSeen()} />
<Block label="tailscale.expires" value={getExpiry()} />
<Block label="tailscale.client_version" value={clientVersion} />
</Container>
);
}