add: ability to generate invite codes in bulk add: better mark as nsfw

ui
This commit is contained in:
trisua 2025-06-23 13:48:16 -04:00
parent 2a77c61bf2
commit 4843688fcf
13 changed files with 126 additions and 90 deletions

View file

@ -77,7 +77,7 @@
(text "{% if config.security.enable_invite_codes -%}")
(a
("data-tab-button" "account/invites")
("href" "#/account/invites")
("href" "?page=0#/account/invites")
(text "{{ icon \"ticket\" }}")
(span
(text "{{ text \"settings:tab.invites\" }}")))
@ -538,10 +538,12 @@
(text "{{ text \"settings:tab.invites\" }}")))
(div
("class" "card flex flex-col gap-2 secondary")
(pre ("id" "invite_codes_output") ("class" "hidden") (code))
(button
("onclick" "generate_invite_code()")
("onclick" "generate_invite_codes()")
(icon (text "plus"))
(str (text "settings:label.generate_invite")))
(str (text "settings:label.generate_invites")))
(text "{{ components::supporter_ad(body=\"Become a supporter to generate up to 48 invite codes! You can currently have 2 maximum.\") }} {% for code in invites %}")
(div
@ -555,8 +557,10 @@
(b (text "{{ code[1].code }}"))
(text "{%- endif %}"))
(text "{% endfor %}")
(text "{{ components::pagination(page=page, items=invites|length, key=\"#/account/invites\") }}")
(script
(text "globalThis.generate_invite_code = async () => {
(text "globalThis.generate_invite_codes = async () => {
await trigger(\"atto::debounce\", [\"invites::create\"]);
if (
!(await trigger(\"atto::confirm\", [
\"Are you sure you would like to do this? This action is permanent.\",
@ -565,7 +569,16 @@
return;
}
fetch(`/api/v1/invite`, {
const count = Number.parseInt(await trigger(\"atto::prompt\", [\"Count (1-48):\"]));
if (!count) {
return;
}
document.getElementById(\"invite_codes_output\").classList.remove(\"hidden\");
document.getElementById(\"invite_codes_output\").children[0].innerText = \"Working...\";
fetch(`/api/v1/invites/${count}`, {
method: \"POST\",
})
.then((res) => res.json())
@ -576,7 +589,7 @@
]);
if (res.ok) {
alert(res.payload);
document.getElementById(\"invite_codes_output\").children[0].innerText = res.payload;
}
});
};"))))))