mirror of
https://github.com/Zakkaus/doona.git
synced 2026-12-06 16:01:00 +00:00
Activity becomes a dashboard of ordered sections whose default layout reproduces main's Activity page card for card. Each card keeps a preset size that changes only its own span, and sections pack like masonry: a tall card sits beside a stack of shorter ones and every column ends level with its neighbour, in the live page and the editor alike. Extension cards add node latency (drawn with the Latency tab's dumbbell), source health, connections by outbound and network, DNS answers and policy group nodes, each up to three instances with its own display. Edit mode renders the same cells in a sortable grid with drag, keyboard and touch reordering, move-only drops, a gap-line drop indicator, a size and display inspector, a widget gallery with equal preview frames, reset to the default and a confirmation before discarding a changed draft. The canvas reads cached data without live subscriptions, and a runtime error shows above the cards when the status card is removed. The floating widget panel sits at the bottom inline-end corner, resizes by pointer or keyboard within stored limits, collapses to its header with the current rates, and can be pinned so it stays open across pages. The panel and the editor load on demand to keep the startup shell small.
22 lines
1.2 KiB
TypeScript
22 lines
1.2 KiB
TypeScript
import {available, type WidgetId} from './layout';
|
|
import type {Capabilities, ConnectionList, RuntimeOutbounds} from '../../api/model';
|
|
import {parseU64} from '../../api/u64';
|
|
|
|
export function hasPreviewData(value: unknown): boolean {
|
|
if (value == null) return false;
|
|
if (Array.isArray(value)) return value.length > 0;
|
|
if (typeof value !== 'object') return true;
|
|
const data = value as Record<string, unknown>;
|
|
for (const key of ['records', 'providers', 'samples', 'outbounds']) if (Array.isArray(data[key])) return data[key].length > 0;
|
|
if ('tcp' in data && 'udp' in data) return hasPreviewData(data.tcp) || hasPreviewData(data.udp);
|
|
return Object.keys(data).length > 0;
|
|
}
|
|
export function hasModulePreviewData(name: string, data: unknown, id: WidgetId) {
|
|
if (!hasPreviewData(data)) return false;
|
|
if (name === 'capabilities') return available(id, data as Capabilities);
|
|
if (name === 'connections' && id === 'ranking')
|
|
return [...(data as ConnectionList).tcp, ...(data as ConnectionList).udp].some(row => row.src && (parseU64(row.download_bytes) ?? 0n) > 0n);
|
|
if (name === 'runtimeOutbounds') return (data as RuntimeOutbounds).outbounds.some(row => (parseU64(row.download_bytes) ?? 0n) > 0n);
|
|
return true;
|
|
}
|