ui grouping

This commit is contained in:
2026-06-29 18:26:25 +00:00
parent 76b23f6478
commit ef9444a766
+148 -3
View File
@@ -493,6 +493,7 @@ class ApiHandler(
).path
if path == "/":
self.send_html(
@@ -504,6 +505,23 @@ class ApiHandler(
group_match = re.fullmatch(
r"/group/([a-zA-Z0-9_-]+)",
path
)
if group_match:
self.send_html(
200,
render_group(
group_match.group(1)
)
)
return
if path == "/health":
self.send_json(
@@ -1388,9 +1406,12 @@ def render_index():
sections.append(
f"""
<div class="group-card">
<a class="group-link"
href="/group/{html.escape(group_name)}">
<div class="group-card">
<div class="group-title">
{html.escape(group_name)}
@@ -1398,15 +1419,18 @@ def render_index():
</div>
<div class="button-grid">
<div class="group-count">
{"".join(buttons)}
{len(commands)} Befehle
</div>
</div>
</a>
"""
)
@@ -1431,6 +1455,96 @@ Keine Befehle verfügbar.
"\n".join(sections)
)
def render_group(group_name):
buttons = []
for command_id, command in CONFIG["commands"].items():
if not command.get(
"web_enabled",
False
):
continue
title = command.get(
"web_title",
command_id
)
current_group = title.split(
" ",
1
)[0]
if current_group != group_name:
continue
buttons.append(
f"""
<form method="post"
action="/web/run/{command_id}">
<input type="hidden"
name="csrf"
value="{WEB_CSRF_TOKEN}">
<button class="action-button"
type="submit">
{html.escape(title)}
</button>
</form>
"""
)
if not buttons:
return render_page(
"Fehler",
"<div class='empty'>Gruppe nicht gefunden.</div>"
)
return render_page(
group_name,
f"""
<a class="back"
href="/">
← Gruppen
</a>
<div class="button-grid">
{"".join(buttons)}
</div>
"""
)
def render_page(
title,
body
@@ -1556,6 +1670,37 @@ h1 {{
}}
.group-link {{
text-decoration:
none;
color:
inherit;
}}
.group-card:hover {{
background:
var(--card-hover);
}}
.group-count {{
color:
var(--secondary);
margin-top:
8px;
}}
.card {{