add: ability to add user to stack through block list ui

This commit is contained in:
trisua 2025-06-22 21:07:35 -04:00
parent 8c969cd56f
commit 2a77c61bf2
10 changed files with 130 additions and 20 deletions

View file

@ -0,0 +1,49 @@
(text "{% extends \"root.html\" %} {% block head %}")
(title
(text "Add user to stack - {{ config.name }}"))
(text "{% endblock %} {% block body %} {{ macros::nav(selected=\"\") }}")
(main
("class" "flex flex-col gap-2")
(div
("class" "card-nest")
(div
("class" "card small flex items-center gap-2")
(text "{{ components::avatar(username=add_user.username, size=\"24px\") }}")
(text "{{ components::full_username(user=add_user) }}"))
(div
("class" "card flex flex-col gap-2")
(span (text "Select a stack to add this user to:"))
(text "{% for stack in stacks %}")
(button
("class" "justify-start lowered w-full")
("onclick" "choose_stack('{{ stack.id }}')")
(icon (text "layers"))
(text "{{ stack.name }}"))
(text "{% endfor %}"))))
(script
(text "function choose_stack(id) {
fetch(`/api/v1/stacks/${id}/users`, {
method: \"POST\",
headers: {
\"Content-Type\": \"application/json\",
},
body: JSON.stringify({
username: \"{{ add_user.username }}\",
}),
})
.then((res) => res.json())
.then((res) => {
trigger(\"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
]);
if (res.ok) {
window.close();
}
});
}"))
(text "{% endblock %}")

View file

@ -173,7 +173,7 @@
return;
}
fetch(`/api/v1/stacks/{{ stack.id }}/users`, {
fetch(\"/api/v1/stacks/{{ stack.id }}/users\", {
method: \"POST\",
headers: {
\"Content-Type\": \"application/json\",