Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #460.
This commit is contained in:
74
apps/web/src/lib/api/dashboard.ts
Normal file
74
apps/web/src/lib/api/dashboard.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Dashboard API Client
|
||||
* Handles dashboard summary data fetching
|
||||
*/
|
||||
|
||||
import { apiGet } from "./client";
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Type definitions matching backend DashboardSummaryDto */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
export interface DashboardMetrics {
|
||||
activeAgents: number;
|
||||
tasksCompleted: number;
|
||||
totalTasks: number;
|
||||
tasksInProgress: number;
|
||||
activeProjects: number;
|
||||
errorRate: number;
|
||||
}
|
||||
|
||||
export interface RecentActivity {
|
||||
id: string;
|
||||
action: string;
|
||||
entityType: string;
|
||||
entityId: string;
|
||||
details: Record<string, unknown> | null;
|
||||
userId: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface ActiveJobStep {
|
||||
id: string;
|
||||
name: string;
|
||||
status: string;
|
||||
phase: string;
|
||||
}
|
||||
|
||||
export interface ActiveJob {
|
||||
id: string;
|
||||
type: string;
|
||||
status: string;
|
||||
progressPercent: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
steps: ActiveJobStep[];
|
||||
}
|
||||
|
||||
export interface TokenBudgetEntry {
|
||||
model: string;
|
||||
used: number;
|
||||
limit: number;
|
||||
}
|
||||
|
||||
export interface DashboardSummaryResponse {
|
||||
metrics: DashboardMetrics;
|
||||
recentActivity: RecentActivity[];
|
||||
activeJobs: ActiveJob[];
|
||||
tokenBudget: TokenBudgetEntry[];
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* API function */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* Fetch dashboard summary data for the given workspace.
|
||||
*
|
||||
* @param workspaceId - Optional workspace ID sent via X-Workspace-Id header
|
||||
*/
|
||||
export async function fetchDashboardSummary(
|
||||
workspaceId?: string
|
||||
): Promise<DashboardSummaryResponse> {
|
||||
return apiGet<DashboardSummaryResponse>("/api/dashboard/summary", workspaceId ?? undefined);
|
||||
}
|
||||
@@ -13,3 +13,4 @@ export * from "./domains";
|
||||
export * from "./teams";
|
||||
export * from "./personalities";
|
||||
export * from "./telemetry";
|
||||
export * from "./dashboard";
|
||||
|
||||
Reference in New Issue
Block a user