Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "beacon-web",
"private": true,
"version": "2.3.1",
"version": "2.3.2",
"license": "AGPL-3.0-or-later",
"type": "module",
"scripts": {
Expand Down
18 changes: 10 additions & 8 deletions src/components/NodeChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,29 +118,31 @@ const ROLE = {
// Outline chip for a role. Glyph only in the list (named for assistive tech and a tooltip), with the
// word in the panel.
// foreign is a poller this server does not manage: the dashed neutral outline of the Foreign tag, and its info tip on the full chip.
export function RoleChip({ role, glyphOnly = false, foreign = false }: { role: "poller" | "observer"; glyphOnly?: boolean; foreign?: boolean }) {
// local is one in local mode, which follows no server; it takes the same outline with its own name and tip.
export function RoleChip({ role, glyphOnly = false, foreign = false, local = false }: { role: "poller" | "observer"; glyphOnly?: boolean; foreign?: boolean; local?: boolean }) {
const { t } = useTranslation();
const { text, border, labelKey } = ROLE[role];
const label = t(labelKey);
const outside = role !== "poller" ? null : local ? "local" : foreign ? "foreign" : null;
const outsideName = outside === "local" ? t("nodes.localPoller") : t("nodes.foreignPoller");
if (glyphOnly) {
const outside = foreign && role === "poller";
const name = outside ? t("nodes.foreignPoller") : label;
const name = outside ? outsideName : label;
return (
<Tooltip label={name}>
<span data-chip={role} data-foreign={outside || undefined} role="img" aria-label={name} className={`${BASE} px-1 ${text} ${outside ? "border-dashed border-text-muted/60" : border}`}>
<span data-chip={role} data-foreign={outside === "foreign" || undefined} data-local={outside === "local" || undefined} role="img" aria-label={name} className={`${BASE} px-1 ${text} ${outside ? "border-dashed border-text-muted/60" : border}`}>
<Glyph name={role} />
</span>
</Tooltip>
);
}
if (foreign && role === "poller") {
if (outside) {
return (
<span className="inline-flex shrink-0 items-center gap-1">
<span data-chip={role} data-foreign className={`${BASE} px-2 uppercase ${text} border-dashed border-text-muted/60`}>
<span data-chip={role} data-foreign={outside === "foreign" || undefined} data-local={outside === "local" || undefined} className={`${BASE} px-2 uppercase ${text} border-dashed border-text-muted/60`}>
<Glyph name={role} />
{t("nodes.foreignPoller")}
{outsideName}
</span>
<InfoTip text={t("nodeDetail.foreignObserver.info")} />
<InfoTip text={t(outside === "local" ? "nodeDetail.foreignObserver.localInfo" : "nodeDetail.foreignObserver.info")} />
</span>
);
}
Expand Down
10 changes: 6 additions & 4 deletions src/features/atlas/AtlasCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { useAtlasObserver } from "./useAtlasObserver";
import type { CardHandleProps } from "./useCardDrag";
import { ViewTabs } from "./ViewTabs";
import { TelemetrySourceTag } from "../nodes/ForeignObserver";
import { allLocal } from "../nodes/poller-seats";
import { PollerClaimTags } from "../nodes/NodePollerSection";

export type { AtlasView };
Expand Down Expand Up @@ -265,7 +266,7 @@ export function AtlasCard({
if (node) {
tags.push(<TypeChip key="type" typeName={node.nodeTypeName} />);
if (node.isObserver || node.isPoller || node.observerId) tags.push(<RoleChip key="observer" role="observer" />);
if (node.isPoller) tags.push(<RoleChip key="poller" role="poller" foreign={node.isForeignPoller === true} />);
if (node.isPoller) tags.push(<RoleChip key="poller" role="poller" foreign={node.isForeignPoller === true} local={node.isLocalPoller === true} />);
}
if (pin.kind === "observer" && observer?.observerType) tags.push(<Badge key="type" variant="default">{observer.observerType}</Badge>);

Expand Down Expand Up @@ -651,7 +652,7 @@ export function AtlasCard({
)}
{view === "telemetry" && node && (
<div ref={body} className="flex flex-1 flex-col gap-3">
{(tel.foreign === "all" || tel.foreign === "some") && <div data-telemetry-source className="flex"><TelemetrySourceTag foreign={tel.foreign} /></div>}
{(tel.foreign === "all" || tel.foreign === "some") && <div data-telemetry-source className="flex"><TelemetrySourceTag foreign={tel.foreign} local={allLocal(tab.polling?.foreign)} /></div>}
<div className="grid flex-1 grid-cols-2 gap-3">{telemetryTiles.map((id, slot) => <Fragment key={id}>{telemetryTile(id, slot)}</Fragment>)}</div>
{footer(
tab.polling
Expand Down Expand Up @@ -688,13 +689,14 @@ export function AtlasCard({
{poller && <PollerClaimTags data={poller} className="justify-end" />}
<PollerTiles poller={poller} />
{footer(
poller?.claim && lead(poller.claim.live, poller.claim.live ? t("atlas.poller.polling", { count: poller.targets.filter((target) => target.role === "poller").length }) : t("atlas.poller.idle"), null, "bg-[#ffb454]"),
poller?.claim ? lead(poller.claim.live, poller.claim.live ? t("atlas.poller.polling", { count: poller.targets.filter((target) => target.role === "poller").length }) : t("atlas.poller.idle"), null, "bg-[#ffb454]")
: poller && lead(null, t("atlas.poller.localMode"), null),
"",
pollerTab,
[
poller?.claim && `${t("nodeDetail.pollerView.lastClaim")} ${formatAbsolute(poller.claim.receivedAt)}`,
poller?.claim && t("nodeDetail.pollerView.slotsUsedOf", { used: poller.claim.slots.used, max: poller.claim.slots.max }),
t("atlas.poller.help"),
poller && !poller.claim ? t("nodeDetail.pollerView.localNote") : t("atlas.poller.help"),
],
)}
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/features/atlas/PollerTiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ function ClaimAge({ at }: { at: number }) {
}

// The Poller tab's four tiles. They are fixed: slots, repeaters answering, readings and the claim.
// A local-mode radio sends no claim or poll state, so it counts its repeaters instead of the ones answering.
export function PollerTiles({ poller }: { poller: NodePoller | undefined }) {
const { t } = useTranslation();
const claim = poller?.claim;
const dash = "—";
const targets = poller?.targets ?? [];
const tile = { compact: true, accent: POLLER_AMBER };
const local = !!poller && !claim;
return (
<div className="grid flex-1 grid-cols-2 gap-3">
<StatCard
Expand All @@ -59,7 +61,7 @@ export function PollerTiles({ poller }: { poller: NodePoller | undefined }) {
sublabel={claim && t("atlas.poller.split", { own: claim.slots.own, requested: claim.slots.requested })}
visual={claim ? <SlotMeter slots={claim.slots} /> : spacer}
/>
<StatCard
{local ? <StatCard {...tile} label={t("atlas.poller.repeaters")} value={targets.length} visual={spacer} /> : <StatCard
{...tile}
label={t("atlas.poller.answering")}
value={poller ? targets.filter((target) => target.state === "ok").length : dash}
Expand All @@ -69,7 +71,7 @@ export function PollerTiles({ poller }: { poller: NodePoller | undefined }) {
{targets.map((target) => <span key={target.publicKey} data-state={target.state} className={`h-2 w-2 shrink-0 rounded-full ${DOT[target.state] ?? "bg-danger"}`} />)}
</div>
}
/>
/>}
<StatCard {...tile} label={t("atlas.poller.readings")} value={poller ? formatCount(poller.readings24h) : dash} sublabel={t("atlas.ranges.24h")} visual={spacer} />
<StatCard
{...tile}
Expand Down
7 changes: 4 additions & 3 deletions src/features/atlas/useAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ export function useTelemetryTab(nodeId: string | null, nodeTypeName: string | un
}

// Does this node get a Poller tab? The server calls it a poller, polling is on, it is linked to its
// observer and the poller route answers with a claim. One small request per poller card. A 404 or a
// missing claim takes the tab away; a failed read does not, so a card pinned to it can say so.
// observer and the poller route answers with a claim, or with the repeaters of a local-mode radio.
// One small request per poller card. A 404 or an answer with neither takes the tab away; a failed
// read does not, so a card pinned to it can say so.
export function usePollerTab(node: { id: string; isPoller?: boolean } | undefined, observerId: string | null, active: boolean) {
const { polling } = useFeatures();
const featuresLoading = useFeaturesLoading();
Expand All @@ -122,7 +123,7 @@ export function usePollerTab(node: { id: string; isPoller?: boolean } | undefine
const ask = eligible && active && !throttled;
const query = useNodePoller(node?.id, ask, ATLAS_REFRESH_MS);
return {
available: eligible && query.state === "ready",
available: eligible && (query.state === "ready" || (query.state === "noClaim" && (query.data?.targets.length ?? 0) > 0)),
// Still finding out, so a card pinned to the tab does not flash another one first.
settling: !node || featuresLoading || (ask && query.state === "loading"),
poller: eligible ? query.data : undefined,
Expand Down
18 changes: 13 additions & 5 deletions src/features/nodes/ForeignObserver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import type { NodePollingForeign, TelemetryForeign } from "./types";
const TAG = "inline-flex shrink-0 items-center rounded-sm border px-1.5 py-px font-mono text-[10px] font-semibold tracking-wider uppercase";
const OUTSIDE = `${TAG} border-dashed border-text-muted/60 text-text-normal`;

function OutsideTag({ label }: { label: string }) {
// info overrides the foreign note, for a local-mode observer.
function OutsideTag({ label, info, chip = "foreign-observer" }: { label: string; info?: string; chip?: "foreign-observer" | "local-observer" }) {
const { t } = useTranslation();
return (
<span className="inline-flex shrink-0 items-center gap-1">
<span data-chip="foreign-observer" className={OUTSIDE}>{label}</span>
<InfoTip text={t("nodeDetail.foreignObserver.info")} />
<span data-chip={chip} className={OUTSIDE}>{label}</span>
<InfoTip text={info ?? t("nodeDetail.foreignObserver.info")} />
</span>
);
}
Expand All @@ -25,10 +26,17 @@ export function ForeignObserverTag() {
return <OutsideTag label={t("nodeDetail.foreignObserver.tag")} />;
}

// source is for a repeater's reporter, the default for the local-mode observer itself.
export function LocalObserverTag({ source = false }: { source?: boolean }) {
const { t } = useTranslation();
return <OutsideTag chip="local-observer" label={t("nodeDetail.foreignObserver.localTag")} info={t(source ? "nodeDetail.foreignObserver.localSourceInfo" : "nodeDetail.foreignObserver.localInfo")} />;
}

// One tag for a telemetry panel, from the server's count of foreign readings behind it.
export function TelemetrySourceTag({ foreign }: { foreign: TelemetryForeign | undefined }) {
export function TelemetrySourceTag({ foreign, local = false }: { foreign: TelemetryForeign | undefined; local?: boolean }) {
const { t } = useTranslation();
if (foreign !== "all" && foreign !== "some") return null;
if (local) return <OutsideTag chip="local-observer" label={t(foreign === "all" ? "nodeDetail.foreignObserver.localSourceAll" : "nodeDetail.foreignObserver.localSourceSome")} info={t("nodeDetail.foreignObserver.localSourceInfo")} />;
return <OutsideTag label={t(foreign === "all" ? "nodeDetail.foreignObserver.sourceAll" : "nodeDetail.foreignObserver.sourceSome")} />;
}

Expand Down Expand Up @@ -62,7 +70,7 @@ export function AlsoReportedBy({ foreign, onView }: { foreign: NodePollingForeig
) : (
<span className="text-text-normal"><EmojiText text={f.name} /></span>
)}
<ForeignObserverTag />
{f.claimed === false ? <LocalObserverTag source /> : <ForeignObserverTag />}
{f.signed && <SignedChip />}
{f.pollHost && <span className="text-text-dim">{t("nodeDetail.foreignObserver.follows", { host: f.pollHost })}</span>}
{!f.claimed && <span className="text-text-dim">{t("nodeDetail.foreignObserver.readingsOnly")}</span>}
Expand Down
2 changes: 1 addition & 1 deletion src/features/nodes/NodeDetailPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export function NodeDetailPanel({ nodeId, onClose, onViewObserver, onOpenObserve
const chips = node && <>
<TypeChip typeName={node.nodeTypeName} />
{(node.isObserver || node.isPoller) && <RoleChip role="observer" />}
{node.isPoller && <RoleChip role="poller" foreign={node.isForeignPoller === true} />}
{node.isPoller && <RoleChip role="poller" foreign={node.isForeignPoller === true} local={node.isLocalPoller === true} />}
<ForeignNodeBadge possiblyForeign={node.possiblyForeign} />
{node.meshmapper?.carpeater && (
<Tooltip label={t("nodeDetail.carpeaterHint")} focusable>
Expand Down
Loading
Loading