add: audit log, reports

add: theme preference setting
This commit is contained in:
trisua 2025-04-02 11:39:51 -04:00
parent b2df2739a7
commit d3d0c41334
38 changed files with 925 additions and 169 deletions

View file

@ -209,6 +209,22 @@
}}</span
>
</button>
{% if profile.permissions != 131073 %}
<button
class="red quaternary"
onclick="update_user_role(131073)"
>
Ban
</button>
{% else %}
<button
class="quaternary"
onclick="update_user_role(1)"
>
Unban
</button>
{% endif %}
</div>
</div>
@ -286,25 +302,77 @@
});
};
ui.refresh_container(element, ["actions"]);
ui.generate_settings_ui(
element,
[
[
["is_verified", "Is verified"],
"{{ profile.is_verified }}",
"checkbox",
],
],
null,
{
is_verified: (value) => {
profile_request(false, "verified", {
is_verified: value,
});
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/profile/{{ 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);
</script>
</div>

View file

@ -142,6 +142,37 @@
<div class="w-full hidden flex flex-col gap-2" data-tab="profile">
<div class="card tertiary flex flex-col gap-2" id="profile_settings">
<div class="card-nest" ui_ident="theme_preference">
<div class="card small">
<b>Theme preference</b>
</div>
<div class="card">
<select
onchange="set_setting_field('theme_preference', event.target.selectedOptions[0].value)"
>
<option
value="Auto"
selected="{% if user.settings.theme_preference == 'Auto' %}true{% else %}false{% endif %}"
>
Auto
</option>
<option
value="Light"
selected="{% if user.settings.theme_preference == 'Light' %}true{% else %}false{% endif %}"
>
Light
</option>
<option
value="Dark"
selected="{% if user.settings.theme_preference == 'Dark' %}true{% else %}false{% endif %}"
>
Dark
</option>
</select>
</div>
</div>
<div class="card-nest" ui_ident="change_avatar">
<div class="card small">
<b>{{ text "settings:label.change_avatar" }}</b>
@ -421,6 +452,7 @@
"change_username",
]);
ui.refresh_container(profile_settings, [
"theme_preference",
"change_avatar",
"change_banner",
]);