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

@ -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 %}

View 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 %}

View 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 %}