add: audit log, reports
add: theme preference setting
This commit is contained in:
parent
b2df2739a7
commit
d3d0c41334
38 changed files with 925 additions and 169 deletions
crates/app/src/public/html
|
@ -15,14 +15,42 @@
|
|||
{{ components::community_avatar(id=community.id,
|
||||
community=community, size="72px") }}
|
||||
<div class="flex flex-col">
|
||||
<!-- prettier-ignore -->
|
||||
<h3 id="title" class="title">
|
||||
{% if community.context.display_name %}
|
||||
{{ community.context.display_name }}
|
||||
{% else %}
|
||||
{{ community.title }}
|
||||
{% endif %}
|
||||
</h3>
|
||||
<div class="flex gap-2 items-center">
|
||||
<h3 id="title" class="title">
|
||||
<!-- prettier-ignore -->
|
||||
{% if community.context.display_name %}
|
||||
{{ community.context.display_name }}
|
||||
{% else %}
|
||||
{{ community.title }}
|
||||
{% endif %}
|
||||
</h3>
|
||||
|
||||
{% if user %} {% if user.id != community.owner
|
||||
%}
|
||||
<div class="dropdown">
|
||||
<button
|
||||
class="camo small"
|
||||
onclick="trigger('atto::hooks::dropdown', [event])"
|
||||
exclude="dropdown"
|
||||
>
|
||||
{{ icon "ellipsis" }}
|
||||
</button>
|
||||
|
||||
<div class="inner left">
|
||||
<button
|
||||
class="red"
|
||||
onclick="trigger('me::report', ['{{ community.id }}', 'community'])"
|
||||
>
|
||||
{{ icon "flag" }}
|
||||
<span
|
||||
>{{ text "general:action.report"
|
||||
}}</span
|
||||
>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %} {% endif %}
|
||||
</div>
|
||||
|
||||
<span class="fade">{{ community.title }}</span>
|
||||
</div>
|
||||
|
|
|
@ -227,66 +227,6 @@
|
|||
document.getElementById("uid").value = uid;
|
||||
}
|
||||
|
||||
globalThis.ban_user = async (uid) => {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you would like to do this?",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(
|
||||
`/api/v1/communities/{{ community.id }}/memberships/${uid}/role`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
role: 33,
|
||||
}),
|
||||
},
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
globalThis.unban_user = async (uid) => {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
"Are you sure you would like to do this?",
|
||||
]))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(
|
||||
`/api/v1/communities/{{ community.id }}/memberships/${uid}/role`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
role: 5,
|
||||
}),
|
||||
},
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
globalThis.update_user_role = async (uid, new_role) => {
|
||||
if (
|
||||
!(await trigger("atto::confirm", [
|
||||
|
@ -356,7 +296,7 @@
|
|||
|
||||
element.innerHTML = `<div class="flex gap-2 flex-wrap" ui_ident="actions">
|
||||
<a target="_blank" class="button" href="/api/v1/auth/profile/find/${e.target.uid.value}">Open user profile</a>
|
||||
${res.payload.role !== 33 ? `<button class="red quaternary" onclick="ban_user('${e.target.uid.value}')">Ban</button>` : `<button class="quaternary" onclick="unban_user('${e.target.uid.value}')">Unban</button>`}
|
||||
${res.payload.role !== 33 ? `<button class="red quaternary" onclick="update_user_role('${e.target.uid.value}', 33)">Ban</button>` : `<button class="quaternary" onclick="update_user_role('${e.target.uid.value}', 5)">Unban</button>`}
|
||||
${res.payload.role !== 65 ? `<button class="red quaternary" onclick="update_user_role('${e.target.uid.value}', 65)">Send to review</button>` : `<button class="green quaternary" onclick="update_user_role('${e.target.uid.value}', 5)">Accept join request</button>`}
|
||||
<button class="red quaternary" onclick="kick_user('${e.target.uid.value}')">Kick</button>
|
||||
</div>`;
|
||||
|
|
|
@ -161,7 +161,7 @@ show_community=true) -%} {% if community and show_community %}
|
|||
{{ icon "external-link" }}
|
||||
</a>
|
||||
|
||||
{% if user %} {% if (user.id == post.owner) or is_helper %}
|
||||
{% if user %}
|
||||
<div class="dropdown">
|
||||
<button
|
||||
class="camo small"
|
||||
|
@ -172,6 +172,17 @@ show_community=true) -%} {% if community and show_community %}
|
|||
</button>
|
||||
|
||||
<div class="inner">
|
||||
{% if user.id != post.owner %}
|
||||
<button
|
||||
class="red"
|
||||
onclick="trigger('me::report', ['{{ post.id }}', 'post'])"
|
||||
>
|
||||
{{ icon "flag" }}
|
||||
<span>{{ text "general:action.report" }}</span>
|
||||
</button>
|
||||
{% endif %} {% if (user.id == post.owner) or is_helper
|
||||
%}
|
||||
<b class="title">{{ text "general:action.manage" }}</b>
|
||||
<button
|
||||
class="red"
|
||||
onclick="trigger('me::remove_post', ['{{ post.id }}'])"
|
||||
|
@ -179,9 +190,10 @@ show_community=true) -%} {% if community and show_community %}
|
|||
{{ icon "trash" }}
|
||||
<span>{{ text "general:action.delete" }}</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %} {% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -75,17 +75,30 @@ show_lhs=true) -%}
|
|||
<span>{{ text "auth:link.settings" }}</span>
|
||||
</a>
|
||||
|
||||
<a href="https://github.com/trisuaso/tetratto">
|
||||
{{ icon "code" }}
|
||||
<span>{{ text "general:link.source_code" }}</span>
|
||||
</a>
|
||||
|
||||
{% if is_helper %}
|
||||
<b class="title">{{ text "general:label.mod" }}</b>
|
||||
|
||||
<a href="/mod_panel/audit_log">
|
||||
{{ icon "scroll-text" }}
|
||||
<span>{{ text "general:link.audit_log" }}</span>
|
||||
</a>
|
||||
|
||||
<a href="/mod_panel/reports">
|
||||
{{ icon "flag" }}
|
||||
<span>{{ text "general:link.reports" }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<div class="title"></div>
|
||||
<button class="red" onclick="trigger('me::logout')">
|
||||
{{ icon "log-out" }}
|
||||
<span>{{ text "auth:action.logout" }}</span>
|
||||
</button>
|
||||
|
||||
<div class="title"></div>
|
||||
<a href="https://github.com/trisuaso/tetratto">
|
||||
{{ icon "code" }}
|
||||
<span>View source</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
|
|
36
crates/app/src/public/html/mod/audit_log.html
Normal file
36
crates/app/src/public/html/mod/audit_log.html
Normal file
|
@ -0,0 +1,36 @@
|
|||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
||||
<title>Audit log - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<main class="flex flex-col gap-2">
|
||||
<div class="card-nest w-full">
|
||||
<div class="card small flex items-center gap-2">
|
||||
{{ icon "scroll" }}
|
||||
<span>{{ text "general:link.audit_log" }}</span>
|
||||
</div>
|
||||
|
||||
<div class="card flex flex-col gap-2">
|
||||
<!-- prettier-ignore -->
|
||||
{% for item in items %}
|
||||
<div class="card-nest">
|
||||
<a
|
||||
class="card small flex items-center gap-2 flush"
|
||||
href="/api/v1/auth/profile/find/{{ item.moderator }}"
|
||||
>
|
||||
<!-- prettier-ignore -->
|
||||
{{ components::avatar(username=item.moderator, selector_type="id") }}
|
||||
<span>{{ item.moderator }}</span>
|
||||
<span class="fade date">{{ item.created }}</span>
|
||||
</a>
|
||||
|
||||
<div class="card secondary">
|
||||
<span>{{ item.content|markdown|safe }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
{{ components::pagination(page=page, items=items|length) }}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
65
crates/app/src/public/html/mod/file_report.html
Normal file
65
crates/app/src/public/html/mod/file_report.html
Normal file
|
@ -0,0 +1,65 @@
|
|||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
||||
<title>File report - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<main class="flex flex-col gap-2">
|
||||
<div class="card-nest w-full">
|
||||
<div class="card small flex items-center gap-2">
|
||||
{{ icon "flag" }}
|
||||
<span>{{ text "general:label.file_report" }}</span>
|
||||
</div>
|
||||
|
||||
<form
|
||||
class="card flex flex-col gap-2"
|
||||
onsubmit="create_report_from_form(event)"
|
||||
>
|
||||
<div class="flex flex-col gap-1">
|
||||
<label for="title"
|
||||
>{{ text "communities:label.content" }}</label
|
||||
>
|
||||
<textarea
|
||||
type="text"
|
||||
name="content"
|
||||
id="content"
|
||||
placeholder="content"
|
||||
required
|
||||
minlength="16"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<button class="primary">
|
||||
{{ text "communities:action.create" }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
function create_report_from_form(e) {
|
||||
e.preventDefault();
|
||||
fetch("/api/v1/reports", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
content: e.target.content.value,
|
||||
asset: "{{ asset }}",
|
||||
asset_type: `{{ asset_type }}`,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
|
||||
if (res.ok) {
|
||||
setTimeout(() => {
|
||||
window.close();
|
||||
}, 150);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
79
crates/app/src/public/html/mod/reports.html
Normal file
79
crates/app/src/public/html/mod/reports.html
Normal file
|
@ -0,0 +1,79 @@
|
|||
{% import "macros.html" as macros %} {% extends "root.html" %} {% block head %}
|
||||
<title>Reports - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav(selected="notifications") }}
|
||||
<main class="flex flex-col gap-2">
|
||||
<div class="card-nest w-full">
|
||||
<div class="card small flex items-center gap-2">
|
||||
{{ icon "flag" }}
|
||||
<span>{{ text "general:link.reports" }}</span>
|
||||
</div>
|
||||
|
||||
<div class="card flex flex-col gap-2">
|
||||
<!-- prettier-ignore -->
|
||||
{% for item in items %}
|
||||
<div class="card-nest">
|
||||
<a
|
||||
class="card small flex items-center gap-2 flush"
|
||||
href="/api/v1/auth/profile/find/{{ item.owner }}"
|
||||
>
|
||||
<!-- prettier-ignore -->
|
||||
{{ components::avatar(username=item.owner, selector_type="id") }}
|
||||
<span>{{ item.owner }}</span>
|
||||
<span class="fade date">{{ item.created }}</span>
|
||||
</a>
|
||||
|
||||
<div class="card secondary flex flex-col gap-2">
|
||||
<span>{{ item.content|markdown|safe }}</span>
|
||||
|
||||
<div class="card w-full flex flex-wrap gap-2">
|
||||
<button
|
||||
onclick="open_reported_content('{{ item.asset }}', '{{ item.asset_type }}')"
|
||||
>
|
||||
{{ icon "external-link" }}
|
||||
<span
|
||||
>{{ text "mod_panel:label.open_reported_content"
|
||||
}}</span
|
||||
>
|
||||
</button>
|
||||
|
||||
<button
|
||||
onclick="remove_report('{{ item.id }}')"
|
||||
class="red quaternary"
|
||||
>
|
||||
{{ icon "trash" }}
|
||||
<span>{{ text "general:action.delete" }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
{{ components::pagination(page=page, items=items|length) }}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
function open_reported_content(asset, asset_type) {
|
||||
if (asset_type === "Post") {
|
||||
window.open(`/post/${asset}`);
|
||||
} else if (asset_type === "Community") {
|
||||
window.open(`/community/${asset}`);
|
||||
}
|
||||
}
|
||||
|
||||
function remove_report(id) {
|
||||
fetch(`/api/v1/reports/${id}`, {
|
||||
method: "DELETE",
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -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>
|
||||
|
|
|
@ -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",
|
||||
]);
|
||||
|
|
|
@ -14,6 +14,15 @@
|
|||
|
||||
<link rel="stylesheet" href="/css/style.css" />
|
||||
|
||||
{% if user %}
|
||||
<script>
|
||||
window.localStorage.setItem(
|
||||
"tetratto:theme",
|
||||
"{{ user.settings.theme_preference }}",
|
||||
);
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
<script src="/js/loader.js"></script>
|
||||
<script defer async src="/js/atto.js"></script>
|
||||
|
||||
|
@ -57,7 +66,28 @@
|
|||
<div id="toast_zone"></div>
|
||||
|
||||
<div id="page" style="display: contents">
|
||||
{% block body %}{% endblock %}
|
||||
<!-- prettier-ignore -->
|
||||
{% if user and user.id == 0 %}
|
||||
<article>
|
||||
<main>
|
||||
<div class="card-nest">
|
||||
<div class="card small flex items-center gap-2 red">
|
||||
{{ icon "frown" }}
|
||||
<span
|
||||
>{{ text "general:label.account_banned" }}</span
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<span
|
||||
>{{ text "general:label.account_banned_body"
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</article>
|
||||
{% else %} {% block body %}{% endblock %} {% endif %}
|
||||
</div>
|
||||
|
||||
<script data-turbo-permanent="true" id="init-script">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue