Skip to content

Commit f4e8723

Browse files
authored
Updated dashboard.html
1 parent 89f2b6d commit f4e8723

File tree

3 files changed

+323
-79
lines changed

3 files changed

+323
-79
lines changed

local_nexus_controller/routers/api_summary.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,31 @@
1414

1515
@router.get("")
1616
def summary(session: Session = Depends(get_session)) -> dict:
17-
services = list(session.exec(select(Service)))
17+
services = list(session.exec(select(Service).order_by(Service.name)))
1818
dbs = list(session.exec(select(Database)))
1919
keys = list(session.exec(select(KeyRef)))
2020

21-
running = 0
22-
stopped = 0
23-
error = 0
21+
running_services = []
22+
stopped_services = []
23+
error_services = []
2424
alerts: list[dict] = []
2525

2626
for svc in services:
2727
refresh_status(session, svc)
28+
svc_data = {
29+
"id": svc.id,
30+
"name": svc.name,
31+
"port": svc.port,
32+
"status": svc.status,
33+
"has_start_command": bool(svc.start_command),
34+
}
35+
2836
if svc.status == "running":
29-
running += 1
37+
running_services.append(svc_data)
3038
elif svc.status == "error":
31-
error += 1
39+
error_services.append(svc_data)
3240
else:
33-
stopped += 1
41+
stopped_services.append(svc_data)
3442

3543
if svc.port is not None:
3644
in_use = is_port_in_use("127.0.0.1", int(svc.port))
@@ -43,7 +51,7 @@ def summary(session: Session = Depends(get_session)) -> dict:
4351
}
4452
)
4553

46-
if not svc.start_command:
54+
if not svc.start_command and (svc.category or "").lower() not in {"repo", "repos"}:
4755
alerts.append(
4856
{
4957
"type": "missing_start_command",
@@ -52,23 +60,20 @@ def summary(session: Session = Depends(get_session)) -> dict:
5260
}
5361
)
5462

55-
if svc.config_paths is not None and len(svc.config_paths) == 0:
56-
# Not necessarily an error; keep low severity
57-
pass
58-
5963
session.commit()
6064

6165
ports_in_use = len([s for s in services if s.port is not None])
6266

6367
return {
64-
"totals": {
65-
"services": len(services),
66-
"running": running,
67-
"stopped": stopped,
68-
"error": error,
69-
"databases": len(dbs),
70-
"keys": len(keys),
71-
"ports_reserved": ports_in_use,
72-
},
68+
"services": len(services),
69+
"running": len(running_services),
70+
"stopped": len(stopped_services),
71+
"error": len(error_services),
72+
"databases": len(dbs),
73+
"keys": len(keys),
74+
"ports_reserved": ports_in_use,
75+
"running_services": running_services,
76+
"stopped_services": stopped_services[:10],
77+
"error_services": error_services,
7378
"alerts": alerts,
7479
}

local_nexus_controller/routers/ui.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,23 @@
2121

2222
@router.get("/", response_class=HTMLResponse)
2323
def dashboard(request: Request, session: Session = Depends(get_session)) -> HTMLResponse:
24-
services = list(session.exec(select(Service)))
24+
services = list(session.exec(select(Service).order_by(Service.name)))
2525
dbs = list(session.exec(select(Database)))
2626
keys = list(session.exec(select(KeyRef)))
2727

28-
running = 0
29-
stopped = 0
30-
error = 0
28+
running_services = []
29+
stopped_services = []
30+
error_services = []
3131
alerts: list[str] = []
32+
3233
for svc in services:
3334
refresh_status(session, svc)
3435
if svc.status == "running":
35-
running += 1
36+
running_services.append(svc)
3637
elif svc.status == "error":
37-
error += 1
38+
error_services.append(svc)
3839
else:
39-
stopped += 1
40+
stopped_services.append(svc)
4041

4142
if svc.port is not None and is_port_in_use("127.0.0.1", int(svc.port)) and svc.status != "running":
4243
alerts.append(f"Port conflict: {svc.name} reserved {svc.port} but is not running.")
@@ -51,13 +52,16 @@ def dashboard(request: Request, session: Session = Depends(get_session)) -> HTML
5152
{
5253
"totals": {
5354
"services": len(services),
54-
"running": running,
55-
"stopped": stopped,
56-
"error": error,
55+
"running": len(running_services),
56+
"stopped": len(stopped_services),
57+
"error": len(error_services),
5758
"databases": len(dbs),
5859
"keys": len(keys),
5960
"ports_reserved": len([s for s in services if s.port is not None]),
6061
},
62+
"running_services": running_services,
63+
"stopped_services": stopped_services[:10],
64+
"error_services": error_services,
6165
"alerts": alerts[:10],
6266
},
6367
)

0 commit comments

Comments
 (0)