initial commit
This commit is contained in:
47
frontend/src/app/services/agent-status.service.ts
Normal file
47
frontend/src/app/services/agent-status.service.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Injectable, signal } from '@angular/core';
|
||||
import { AgentCardData, AgentStatus, AgentStatusUpdate, TaskProgressUpdate } from '../models/agent.model';
|
||||
|
||||
/**
|
||||
* Agent Status Service — stub for future SignalR integration.
|
||||
* Per spec Section 7.4: Connects to /hubs/agent-status for real-time updates.
|
||||
*
|
||||
* TODO: Implement SignalR hub connection when backend is ready.
|
||||
* TODO: Wire up NgRx store or signals for reactive state management.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AgentStatusService {
|
||||
/** Stub: list of agents (will come from SignalR) */
|
||||
private readonly _agents = signal<AgentCardData[]>([]);
|
||||
|
||||
readonly agents = this._agents.asReadonly();
|
||||
|
||||
/** Stub: update an agent's status */
|
||||
updateStatus(update: AgentStatusUpdate): void {
|
||||
this._agents.update(agents =>
|
||||
agents.map(agent =>
|
||||
agent.id === update.agentId
|
||||
? { ...agent, status: update.status }
|
||||
: agent
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/** Stub: update an agent's task progress */
|
||||
updateTaskProgress(progress: TaskProgressUpdate): void {
|
||||
this._agents.update(agents =>
|
||||
agents.map(agent =>
|
||||
agent.id === progress.agentId
|
||||
? {
|
||||
...agent,
|
||||
taskProgress: progress.progress,
|
||||
...(progress.taskName ? { currentTask: progress.taskName } : {}),
|
||||
...(progress.elapsed ? { taskElapsed: progress.elapsed } : {}),
|
||||
}
|
||||
: agent
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: connect() — Initialize SignalR connection
|
||||
// TODO: disconnect() — Clean up SignalR connection
|
||||
}
|
||||
Reference in New Issue
Block a user