- Add core proxy API infrastructure (api-node.ts) with remote node communication - Create NodeContext for centralized node state management - Implement useNodeProxy hook for node operations (metrics, events, health) - Implement useRemoteNodeData hook with 10-second polling for live metrics - Implement useRemoteNodeEvents hook for real-time SSE event subscription - Add NodeStatusIndicator component with animated status indicators - Add comprehensive tests for all new hooks and components - Update dashboard styles for node status visualization
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
/**
|
|
* Remote Node API functions for fetching data from remote nodes via the proxy.
|
|
* All functions route through /api/proxy/:nodeId/... when a remote node is targeted.
|
|
*/
|
|
|
|
import type { ProjectInfo } from "./api";
|
|
import type { ProjectHealth, Task } from "@fusion/core";
|
|
import { proxyApi } from "./api";
|
|
|
|
/** Health information for a remote node */
|
|
export interface RemoteNodeHealth {
|
|
status: string;
|
|
version: string;
|
|
nodeId: string;
|
|
}
|
|
|
|
/** Fetch health information from a remote node */
|
|
export async function fetchRemoteNodeHealth(nodeId: string): Promise<RemoteNodeHealth> {
|
|
return proxyApi<RemoteNodeHealth>("/health", { nodeId });
|
|
}
|
|
|
|
/** Fetch all projects from a remote node */
|
|
export async function fetchRemoteNodeProjects(nodeId: string): Promise<ProjectInfo[]> {
|
|
return proxyApi<ProjectInfo[]>("/projects", { nodeId });
|
|
}
|
|
|
|
/** Fetch tasks from a specific project on a remote node */
|
|
export async function fetchRemoteNodeTasks(nodeId: string, projectId: string): Promise<Task[]> {
|
|
return proxyApi<Task[]>(`/tasks?projectId=${encodeURIComponent(projectId)}`, { nodeId });
|
|
}
|
|
|
|
/** Fetch project health from a remote node */
|
|
export async function fetchRemoteNodeProjectHealth(
|
|
nodeId: string,
|
|
projectId: string,
|
|
): Promise<ProjectHealth> {
|
|
return proxyApi<ProjectHealth>(`/project-health?projectId=${encodeURIComponent(projectId)}`, {
|
|
nodeId,
|
|
});
|
|
}
|