add: profile moderation ui
add: pagination ui
This commit is contained in:
parent
d0c1fbcf9a
commit
9a9b72bdbb
14 changed files with 417 additions and 38 deletions
|
@ -137,7 +137,7 @@
|
|||
});
|
||||
};
|
||||
</script>
|
||||
{% endif %} {% else %}
|
||||
{% endif %} {% endif %} {% if is_owner or is_manager %}
|
||||
<a
|
||||
href="/community/{{ community.title }}/manage"
|
||||
class="button primary"
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
{% for post in feed %}
|
||||
{{ components::post(post=post[0], owner=post[1], secondary=true, show_community=false) }}
|
||||
{% endfor %}
|
||||
|
||||
{{ components::pagination(page=page, items=feed|length) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -47,8 +47,12 @@
|
|||
</div>
|
||||
|
||||
<div class="card flex flex-col gap-4">
|
||||
{% for post in replies %} {{ components::post(post=post[0],
|
||||
owner=post[1], secondary=true, show_community=false) }} {% endfor %}
|
||||
<!-- prettier-ignore -->
|
||||
{% for post in replies %}
|
||||
{{ components::post(post=post[0], owner=post[1], secondary=true, show_community=false) }}
|
||||
{% endfor %}
|
||||
|
||||
{{ components::pagination(page=page, items=replies|length) }}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
|
|
@ -246,4 +246,20 @@ show_community=true) -%} {% if community and show_community %}
|
|||
<span class="fade">{{ user.username }}</span>
|
||||
</div>
|
||||
</a>
|
||||
{%- endmacro %} {% macro pagination(page=0, items=0) -%}
|
||||
<div class="flex justify-between gap-2 w-full">
|
||||
{% if page > 0 %}
|
||||
<a class="button quaternary" href="?page={{ page - 1 }}">
|
||||
{{ icon "arrow-left" }}
|
||||
<span>{{ text "general:link.previous" }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<div></div>
|
||||
{% endif %} {% if items != 0 %}
|
||||
<a class="button quaternary" href="?page={{ page + 1 }}">
|
||||
<span>{{ text "general:link.next" }}</span>
|
||||
{{ icon "arrow-right"}}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
}}
|
||||
<div class="flex flex-col">
|
||||
<!-- prettier-ignore -->
|
||||
<h3 id="username" class="username">
|
||||
<h3 id="username" class="username flex items-center gap-2">
|
||||
{{ components::username(user=profile) }}
|
||||
|
||||
{% if profile.is_verified %}
|
||||
<span title="Verified">
|
||||
<span title="Verified" style="color: var(--color-primary);" class="flex items-center">
|
||||
{{ icon "badge-check" }}
|
||||
</span>
|
||||
{% endif %}
|
||||
|
@ -158,7 +158,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %} {% if not profile.settings.private_communities or
|
||||
is_self %}
|
||||
is_self or is_helper %}
|
||||
<div class="card-nest">
|
||||
<div class="card small flex gap-2 items-center">
|
||||
{{ icon "users-round" }}
|
||||
|
@ -177,7 +177,140 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="rhs w-full">{% block content %}{% endblock %}</div>
|
||||
<div class="rhs w-full flex flex-col gap-4">
|
||||
{% if is_helper %}
|
||||
<div class="card-nest">
|
||||
<div class="card small flex items-center gap-2">
|
||||
{{ icon "shield" }}
|
||||
<span>{{ text "auth:label.moderation" }}</span>
|
||||
</div>
|
||||
|
||||
<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"
|
||||
>
|
||||
{{ icon "settings" }}
|
||||
<span>View settings</span>
|
||||
</a>
|
||||
|
||||
<button
|
||||
class="red quaternary"
|
||||
onclick="delete_account(event)"
|
||||
>
|
||||
{{ icon "trash" }}
|
||||
<span
|
||||
>{{ text "settings:label.delete_account"
|
||||
}}</span
|
||||
>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
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/profile/{{ 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/profile/{{ 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,
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
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,
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
}, 150);
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %} {% block content %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
|
|
@ -11,6 +11,8 @@ content %}
|
|||
{% for post in posts %}
|
||||
{{ components::post(post=post[0], owner=post[1], secondary=true, community=post[2], show_community=true) }}
|
||||
{% endfor %}
|
||||
|
||||
{{ components::pagination(page=page, items=posts|length) }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
<title>Settings - {{ config.name }}</title>
|
||||
{% endblock %} {% block body %} {{ macros::nav() }}
|
||||
<main class="flex flex-col gap-2">
|
||||
{% if profile.id != user.id %}
|
||||
<div class="card w-full red flex gap-2 items-center">
|
||||
{{ icon "skull" }}
|
||||
<b>Editing other user's settings! Please be careful.</b>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="pillmenu">
|
||||
<a data-tab-button="account" class="active" href="#/account">
|
||||
{{ text "settings:tab.account" }}
|
||||
|
@ -95,6 +102,38 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-nest" ui_ident="change_password">
|
||||
<div class="card small flex items-center gap-2 red">
|
||||
{{ icon "skull" }}
|
||||
<b>{{ text "settings:label.delete_account" }}</b>
|
||||
</div>
|
||||
|
||||
<form
|
||||
class="card flex flex-col gap-2"
|
||||
onsubmit="delete_account(event)"
|
||||
>
|
||||
<div class="flex flex-col gap-1">
|
||||
<label for="current_password"
|
||||
>{{ text "settings:label.current_password" }}</label
|
||||
>
|
||||
<input
|
||||
type="password"
|
||||
name="current_password"
|
||||
id="current_password"
|
||||
placeholder="current_password"
|
||||
required
|
||||
minlength="6"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button class="primary">
|
||||
{{ icon "trash" }}
|
||||
<span>{{ text "general:action.delete" }}</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<button onclick="save_settings()" id="save_button">
|
||||
{{ icon "check" }}
|
||||
<span>{{ text "general:action.save" }}</span>
|
||||
|
@ -160,7 +199,7 @@
|
|||
class="card w-full tertiary hidden flex flex-col gap-2"
|
||||
data-tab="sessions"
|
||||
>
|
||||
{% for token in user.tokens %}
|
||||
{% for token in profile.tokens %}
|
||||
<div class="card w-full flex justify-between flex-collapse gap-2">
|
||||
<div class="flex flex-col gap-1">
|
||||
<b
|
||||
|
@ -214,7 +253,7 @@
|
|||
tokens = new_tokens;
|
||||
|
||||
// send request to save
|
||||
fetch("/api/v1/auth/profile/{{ user.id }}/tokens", {
|
||||
fetch("/api/v1/auth/profile/{{ profile.id }}/tokens", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -231,7 +270,7 @@
|
|||
};
|
||||
|
||||
globalThis.save_settings = () => {
|
||||
fetch("/api/v1/auth/profile/{{ user.id }}/settings", {
|
||||
fetch("/api/v1/auth/profile/{{ profile.id }}/settings", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -249,7 +288,7 @@
|
|||
|
||||
globalThis.change_password = (e) => {
|
||||
e.preventDefault();
|
||||
fetch("/api/v1/auth/profile/{{ user.id }}/password", {
|
||||
fetch("/api/v1/auth/profile/{{ profile.id }}/password", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -279,7 +318,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
fetch("/api/v1/auth/profile/{{ user.id }}/username", {
|
||||
fetch("/api/v1/auth/profile/{{ profile.id }}/username", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -297,6 +336,35 @@
|
|||
});
|
||||
};
|
||||
|
||||
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/profile/{{ profile.id }}", {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
password: e.target.current_password.value,
|
||||
}),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
trigger("atto::toast", [
|
||||
res.ok ? "success" : "error",
|
||||
res.message,
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
globalThis.upload_avatar = (e) => {
|
||||
e.preventDefault();
|
||||
e.target.querySelector("button").style.display = "none";
|
||||
|
@ -362,12 +430,12 @@
|
|||
[
|
||||
[
|
||||
["display_name", "Display name"],
|
||||
"{{ user.settings.display_name }}",
|
||||
"{{ profile.settings.display_name }}",
|
||||
"input",
|
||||
],
|
||||
[
|
||||
["biography", "Biography"],
|
||||
"{{ user.settings.biography }}",
|
||||
"{{ profile.settings.biography }}",
|
||||
"textarea",
|
||||
],
|
||||
],
|
||||
|
@ -382,7 +450,7 @@
|
|||
"private_profile",
|
||||
"Only allow users I'm following to view my profile",
|
||||
],
|
||||
"{{ user.settings.private_profile }}",
|
||||
"{{ profile.settings.private_profile }}",
|
||||
"checkbox",
|
||||
],
|
||||
[
|
||||
|
@ -390,7 +458,7 @@
|
|||
"private_communities",
|
||||
"Keep my joined communities private",
|
||||
],
|
||||
"{{ user.settings.private_communities }}",
|
||||
"{{ profile.settings.private_communities }}",
|
||||
"checkbox",
|
||||
],
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue