feat: status dots show whether a link's address answers

With STATUS_CHECKS=true the server requests the address of every link of
the open dashboard once a minute and the tile shows a green dot or a red
ring. Off by default: users choose the addresses, so a user could find
out which hosts and ports the server reaches.
This commit is contained in:
Niklas Haiden
2026-11-21 19:19:44 +01:00
parent cba6eddc56
commit b6e5d81dc0
7 changed files with 192 additions and 10 deletions
+18 -1
View File
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from "react"
import { createContext, useContext, useEffect, useRef, useState } from "react"
import { useDndContext } from "@dnd-kit/core"
import { useSortable } from "@dnd-kit/sortable"
import { CSS } from "@dnd-kit/utilities"
@@ -16,6 +16,9 @@ export type HomeLink = {
lightIcon: string | null
}
/** Per link id: does its address answer? No entry: not checked (yet). */
export const StatusContext = createContext<Partial<Record<string, boolean>>>({})
type IconProps = { link: HomeLink; className?: string }
/** Starts the fallback chain again when the link changes. */
@@ -98,6 +101,7 @@ export function LinkTile({
transition,
isDragging,
} = useSortable({ id: link.id, disabled: { droppable: cardDragged } })
const up = useContext(StatusContext)[link.id]
return (
<div
ref={setNodeRef}
@@ -115,6 +119,19 @@ export function LinkTile({
className="block touch-manipulation rounded-2xl transition-colors outline-none select-none [-webkit-touch-callout:none] hover:bg-white/10 focus-visible:bg-white/10 focus-visible:ring-2 focus-visible:ring-white/60"
>
<TileFace link={link} />
{up !== undefined && (
// at the lower right corner of the icon. Filled green or a red ring:
// the shape differs too, not only the color.
<span
title={up ? "Reachable" : "Not reachable"}
className={cn(
"absolute top-[58px] right-[18px] size-3 rounded-full border-2",
up ? "border-black/70 bg-success" : "border-danger bg-black/80"
)}
>
{!up && <span className="sr-only">, not reachable</span>}
</span>
)}
</a>
<button
type="button"