add: small littleweb browser changes
This commit is contained in:
parent
e7febc7c7e
commit
388ccbf58c
9 changed files with 194 additions and 21 deletions
|
@ -50,6 +50,18 @@
|
|||
(span
|
||||
("class" "notification")
|
||||
(text "{{ profile.request_count }}")))
|
||||
(a
|
||||
("href" "/services?id={{ profile.id }}")
|
||||
("class" "button lowered")
|
||||
(icon (text "globe"))
|
||||
(span
|
||||
(text "Sites")))
|
||||
(a
|
||||
("href" "/domains?id={{ profile.id }}")
|
||||
("class" "button lowered")
|
||||
(icon (text "globe"))
|
||||
(span
|
||||
(text "Domains")))
|
||||
(button
|
||||
("class" "red lowered")
|
||||
("onclick" "delete_account(event)")
|
||||
|
@ -155,6 +167,33 @@
|
|||
});
|
||||
};
|
||||
|
||||
globalThis.update_user_secondary_role = async (new_role) => {
|
||||
if (
|
||||
!(await trigger(\"atto::confirm\", [
|
||||
\"Are you sure you would like to do this?\",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`/api/v1/auth/user/{{ profile.id }}/role/2`, {
|
||||
method: \"POST\",
|
||||
headers: {
|
||||
\"Content-Type\": \"application/json\",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
role: Number.parseInt(new_role),
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger(\"atto::toast\", [
|
||||
res.ok ? \"success\" : \"error\",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
ui.refresh_container(element, [\"actions\"]);
|
||||
|
||||
setTimeout(() => {
|
||||
|
@ -178,6 +217,11 @@
|
|||
\"{{ profile.permissions }}\",
|
||||
\"input\",
|
||||
],
|
||||
[
|
||||
[\"secondary_role\", \"Secondary permission level\"],
|
||||
\"{{ profile.secondary_permissions }}\",
|
||||
\"input\",
|
||||
],
|
||||
],
|
||||
null,
|
||||
{
|
||||
|
@ -194,6 +238,9 @@
|
|||
role: (new_role) => {
|
||||
return update_user_role(new_role);
|
||||
},
|
||||
secondary_role: (new_role) => {
|
||||
return update_user_secondary_role(new_role);
|
||||
},
|
||||
},
|
||||
);
|
||||
}, 100);
|
||||
|
@ -244,6 +291,24 @@
|
|||
(div
|
||||
("class" "card lowered flex flex-col gap-2")
|
||||
("id" "permission_builder")))
|
||||
(div
|
||||
("class" "card-nest w-full")
|
||||
(div
|
||||
("class" "card small flex items-center justify-between gap-2")
|
||||
(div
|
||||
("class" "flex items-center gap-2")
|
||||
(text "{{ icon \"blocks\" }}")
|
||||
(span
|
||||
(text "{{ text \"mod_panel:label.permissions_level_builder\" }}")))
|
||||
(button
|
||||
("class" "small lowered")
|
||||
("onclick" "update_user_secondary_role(Number.parseInt(document.getElementById('role').value))")
|
||||
(text "{{ icon \"check\" }}")
|
||||
(span
|
||||
(text "{{ text \"general:action.save\" }}"))))
|
||||
(div
|
||||
("class" "card lowered flex flex-col gap-2")
|
||||
("id" "secondary_permission_builder")))
|
||||
(script
|
||||
(text "setTimeout(async () => {
|
||||
const get_permissions_html = await trigger(
|
||||
|
@ -291,6 +356,30 @@
|
|||
Number.parseInt(\"{{ profile.permissions }}\"),
|
||||
\"permission_builder\",
|
||||
);
|
||||
}, 250);
|
||||
|
||||
setTimeout(async () => {
|
||||
const get_permissions_html = await trigger(
|
||||
\"ui::generate_permissions_ui\",
|
||||
[
|
||||
{
|
||||
// https://trisuaso.github.io/tetratto/tetratto/model/permissions/struct.SecondaryPermission.html
|
||||
DEFAULT: 1 << 0,
|
||||
ADMINISTRATOR: 1 << 1,
|
||||
MANAGE_DOMAINS: 1 << 2,
|
||||
MANAGE_SECONDARY: 1 << 3,
|
||||
},
|
||||
\"secondary_role\",
|
||||
\"add_permission_to_secondary_role\",
|
||||
\"remove_permission_to_secondary_role\",
|
||||
],
|
||||
);
|
||||
|
||||
document.getElementById(\"secondary_permission_builder\").innerHTML =
|
||||
get_permissions_html(
|
||||
Number.parseInt(\"{{ profile.secondary_permissions }}\"),
|
||||
\"secondary_permission_builder\",
|
||||
);
|
||||
}, 250);")))
|
||||
|
||||
(text "{% endblock %}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue