(text "{% extends \"root.html\" %} {% block head %}") (title (text "Manage profile - {{ config.name }}")) (text "{% endblock %} {% block body %} {{ macros::nav() }}") (main ("class" "flex flex-col gap-2") (div ("class" "card-nest w-full") (div ("class" "card small flex items-center gap-2") (text "{{ icon \"shield\" }}") (span (text "{{ text \"mod_panel:label.manage_profile\" }}"))) (div ("class" "card tertiary") (div ("class" "flex flex-col gap-2") ("id" "mod_options") (div ("class" "card w-full flex flex-wrap gap-2") ("ui_ident" "actions") (a ("href" "/settings?username={{ profile.username }}") ("class" "button quaternary") (text "{{ icon \"settings\" }}") (span (text "View settings"))) (a ("href" "/mod_panel/profile/{{ profile.id }}/warnings") ("class" "button quaternary") (text "{{ icon \"shield-alert\" }}") (span (text "View warnings"))) (a ("href" "/notifs?id={{ profile.id }}") ("class" "button quaternary") (text "{{ icon \"bell\" }}") (span (text "Notifications")) (span ("class" "notification") (text "{{ profile.notification_count }}"))) (a ("href" "/requests?id={{ profile.id }}") ("class" "button quaternary") (text "{{ icon \"inbox\" }}") (span (text "Requests")) (span ("class" "notification") (text "{{ profile.request_count }}"))) (button ("class" "red quaternary") ("onclick" "delete_account(event)") (text "{{ icon \"trash\" }}") (span (text "{{ text \"settings:label.delete_account\" }}"))) (text "{% if profile.permissions != 131073 -%}") (button ("class" "red quaternary") ("onclick" "update_user_role(131073)") (text "Ban")) (text "{% else %}") (button ("class" "quaternary") ("onclick" "update_user_role(1)") (text "Unban")) (text "{%- endif %}"))) (script (text "setTimeout(() => { const ui = ns(\"ui\"); const element = document.getElementById(\"mod_options\"); async function profile_request(do_confirm, path, body) { if (do_confirm) { if ( !(await trigger(\"atto::confirm\", [ \"Are you sure you would like to do this?\", ])) ) { return; } } fetch(`/api/v1/auth/user/{{ profile.id }}/${path}`, { method: \"POST\", headers: { \"Content-Type\": \"application/json\", }, body: JSON.stringify(body), }) .then((res) => res.json()) .then((res) => { trigger(\"atto::toast\", [ res.ok ? \"success\" : \"error\", res.message, ]); }); } globalThis.delete_account = async (e) => { e.preventDefault(); if ( !(await trigger(\"atto::confirm\", [ \"Are you sure you would like to do this?\", ])) ) { return; } fetch(\"/api/v1/auth/user/{{ profile.id }}\", { method: \"DELETE\", headers: { \"Content-Type\": \"application/json\", }, body: JSON.stringify({ password: \"\", }), }) .then((res) => res.json()) .then((res) => { trigger(\"atto::toast\", [ res.ok ? \"success\" : \"error\", res.message, ]); }); }; globalThis.update_user_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`, { 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(() => { ui.refresh_container(element, [\"actions\"]); ui.generate_settings_ui( element, [ [ [\"is_verified\", \"Is verified\"], \"{{ profile.is_verified }}\", \"checkbox\", ], [ [\"role\", \"Permission level\"], \"{{ profile.permissions }}\", \"input\", ], ], null, { is_verified: (value) => { profile_request(false, \"verified\", { is_verified: value, }); }, role: (new_role) => { return update_user_role(new_role); }, }, ); }, 100); }, 150);")))) (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 quaternary") ("onclick" "update_user_role(Number.parseInt(document.getElementById('role').value))") (text "{{ icon \"check\" }}") (span (text "{{ text \"general:action.save\" }}")))) (div ("class" "card tertiary flex flex-col gap-2") ("id" "permission_builder"))) (script (text "setTimeout(() => { const get_permissions_html = trigger( \"ui::generate_permissions_ui\", [ { // https://trisuaso.github.io/tetratto/tetratto/model/permissions/struct.FinePermission.html DEFAULT: 1 << 0, ADMINISTRATOR: 1 << 1, MANAGE_COMMUNITIES: 1 << 2, MANAGE_POSTS: 1 << 3, MANAGE_POST_REPLIES: 1 << 4, MANAGE_USERS: 1 << 5, MANAGE_BANS: 1 << 6, MANAGE_WARNINGS: 1 << 7, MANAGE_NOTIFICATIONS: 1 << 8, VIEW_REPORTS: 1 << 9, VIEW_AUDIT_LOG: 1 << 10, MANAGE_MEMBERSHIPS: 1 << 11, MANAGE_REACTIONS: 1 << 12, MANAGE_FOLLOWS: 1 << 13, MANAGE_VERIFIED: 1 << 14, MANAGE_AUDITLOG: 1 << 15, MANAGE_REPORTS: 1 << 16, BANNED: 1 << 17, INFINITE_COMMUNITIES: 1 << 18, SUPPORTER: 1 << 19, MANAGE_REQUESTS: 1 << 20, MANAGE_QUESTIONS: 1 << 21, MANAGE_CHANNELS: 1 << 22, MANAGE_MESSAGES: 1 << 23, MANAGE_UPLOADS: 1 << 24, MANAGE_EMOJIS: 1 << 25, MANAGE_STACKS: 1 << 26, STAFF_BADGE: 1 << 27, }, ], ); document.getElementById(\"permission_builder\").innerHTML = get_permissions_html( Number.parseInt(\"{{ profile.permissions }}\"), \"permission_builder\", ); }, 250);"))) (text "{% endblock %}")