feat(hosts): a host's health tiles span the card and the gaps match; Add host is a dialog on the list (#5290, #5291)
#5290 "Host page: the health tiles span the card's width; even spacing above Ansible": the four tiles take equal quarters (halves on a phone) and their sparklines stretch across them; the Monitors + Agent row drops the Agent card's own margin, so the gap above Ansible is 1rem like every other. #5291 "Add host opens as a dialog over the Hosts list": a native <dialog> on /hosts/, opened by Add host or /hosts/?add=1. A name clash re-renders the list with it open, the error and what was typed. GET /hosts/new is gone; hosts/form.html is Edit only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,13 @@ async def overview_widget():
|
||||
@hosts_bp.get("/")
|
||||
@require_role(UserRole.viewer)
|
||||
async def list_hosts():
|
||||
# ?add=1 opens the Add host dialog on load (#5291).
|
||||
return await _list_page(add={} if request.args.get("add") else None)
|
||||
|
||||
|
||||
async def _list_page(add: dict | None = None):
|
||||
"""The Hosts list. `add` opens the Add host dialog: {} for an empty form,
|
||||
or {"values": form, "error": msg} when a submit comes back."""
|
||||
async with current_app.db_sessionmaker() as db:
|
||||
result = await db.execute(select(Host).order_by(Host.name))
|
||||
hosts = result.scalars().all()
|
||||
@@ -57,6 +64,7 @@ async def list_hosts():
|
||||
host_status=host_status,
|
||||
uptime=uptime,
|
||||
agent=agent,
|
||||
add=add,
|
||||
)
|
||||
|
||||
|
||||
@@ -93,12 +101,6 @@ async def host_detail(host_id: str):
|
||||
)
|
||||
|
||||
|
||||
@hosts_bp.get("/new")
|
||||
@require_role(UserRole.operator)
|
||||
async def new_host():
|
||||
return await render_template("hosts/form.html", host=None)
|
||||
|
||||
|
||||
@hosts_bp.post("/")
|
||||
@require_role(UserRole.operator)
|
||||
async def create_host():
|
||||
@@ -112,8 +114,7 @@ async def create_host():
|
||||
try:
|
||||
await host_svc.check_name_free(db, host.name)
|
||||
except ValueError as exc:
|
||||
return await render_template("hosts/form.html", host=None, values=form,
|
||||
error=str(exc)), 400
|
||||
return await _list_page(add={"values": form, "error": str(exc)}), 400
|
||||
db.add(host)
|
||||
await log_audit(current_app, session.get("user_id"), session.get("username", ""),
|
||||
"host.created", entity_type="host", entity_id=host.name,
|
||||
|
||||
Reference in New Issue
Block a user