2026-08-15 13:50:24 +07:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from django.shortcuts import render
|
|
|
|
|
|
2026-08-15 20:03:59 +07:00
|
|
|
from agents.control_room import AgentControlRoomService
|
2026-08-15 13:50:24 +07:00
|
|
|
from control_plane.events.models import Event
|
|
|
|
|
from control_plane.projects.models import Project, TaskStatus
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dashboard(request):
|
|
|
|
|
projects = Project.objects.order_by("name")
|
|
|
|
|
recent_events = Event.objects.select_related("project", "task").order_by("-created_at")[:25]
|
|
|
|
|
summary = {
|
|
|
|
|
"project_count": Project.objects.count(),
|
|
|
|
|
"ready_tasks": sum(project.tasks.filter(status=TaskStatus.READY).count() for project in projects),
|
|
|
|
|
"blocked_tasks": sum(project.tasks.filter(status=TaskStatus.BLOCKED).count() for project in projects),
|
|
|
|
|
}
|
|
|
|
|
return render(request, "projects/dashboard.html", {"projects": projects, "summary": summary, "recent_events": recent_events})
|
2026-08-15 20:03:59 +07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def agent_control_room(request):
|
|
|
|
|
service = AgentControlRoomService()
|
|
|
|
|
agents = service.list_agents()
|
|
|
|
|
for agent in agents:
|
|
|
|
|
champion_id = agent.get("champion_version")
|
|
|
|
|
agent["health"] = service.get_agent_health(champion_id) if champion_id else {"status": "WATCH", "reasons": ["No champion version."]}
|
|
|
|
|
return render(request, "projects/agent_control_room.html", {"agents": agents, "teams": service.list_teams()})
|