2022-03-13 16:16:46 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
|
2022-08-26 21:04:30 +03:00
|
|
|
<%- include("extra/meta", {title: member.name }) %>
|
2022-03-26 23:28:10 +03:00
|
|
|
|
2022-08-28 19:03:32 +03:00
|
|
|
|
|
|
|
<body>
|
2022-08-28 18:10:41 +03:00
|
|
|
<link rel="stylesheet" href="/css/user.css" />
|
|
|
|
|
|
|
|
<%- include("extra/navbar") %>
|
|
|
|
|
|
|
|
<div class="content">
|
|
|
|
<div class="box" style="justify-content:center;">
|
|
|
|
<img style="width:100px;height:100px;border-radius:50%;" src="<%=member.avatar %>">
|
|
|
|
</div>
|
|
|
|
<div class="box">
|
2022-08-28 19:03:32 +03:00
|
|
|
<h2 class="box-title">Name:</h2>
|
2022-08-28 20:32:52 +03:00
|
|
|
<h2 class="box-value"><%= member.name %></h2>
|
2022-08-28 18:10:41 +03:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box">
|
2022-08-28 20:32:52 +03:00
|
|
|
<h2 class="box-title">Created at:</h2>
|
|
|
|
<h2 class="box-value"><%= new Date(member.time).toLocaleString() %></h2>
|
|
|
|
</div>
|
2022-08-28 18:10:41 +03:00
|
|
|
<div class="box">
|
2022-08-28 20:32:52 +03:00
|
|
|
<h2 class="box-title">Is admin?</h2>
|
|
|
|
<h2 class="box-value"><%= member.admin ? "Yes" : "No" %></h2>
|
2022-08-28 18:10:41 +03:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box">
|
2022-08-28 20:32:52 +03:00
|
|
|
<h2 class="box-title"> Message:</h2>
|
|
|
|
<h2 class="box-value"><%= counts.message %></h2>
|
|
|
|
</div>
|
|
|
|
<div class="box">
|
|
|
|
<h2 class="box-title">Thread:</h2>
|
|
|
|
<h2 class="box-value"><%= counts.thread %></h2>
|
2022-08-28 18:10:41 +03:00
|
|
|
</div>
|
2022-08-29 19:31:59 +03:00
|
|
|
<div class="box">
|
2022-08-29 21:32:57 +03:00
|
|
|
<h2 class="box-title">About:</h2>
|
2022-08-29 19:31:59 +03:00
|
|
|
</div>
|
|
|
|
<p class="box-value">
|
|
|
|
<%= member.about %>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<% if (user?.admin && !member.deleted) {%>
|
2022-08-29 21:32:57 +03:00
|
|
|
<a class="btn-outline-primary" id="edit_name">Change name of the user!</a>
|
|
|
|
<a class="btn-outline-primary" id="edit_avatar">Change avatar of the user!</a>
|
|
|
|
<a class="btn-outline-primary" id="edit_about">Change about of the user!</a>
|
2022-08-29 19:31:59 +03:00
|
|
|
<a class="btn-outline-primary" id="admin">Give admin permissions!</a>
|
2022-08-29 21:32:57 +03:00
|
|
|
<a class="btn-outline-primary" id="delete">Delete user!</a>
|
2022-08-28 18:10:41 +03:00
|
|
|
|
|
|
|
<script type="module">
|
|
|
|
|
|
|
|
import request from "../../js/request.js";
|
|
|
|
document.addEventListener("click", async e => {
|
2022-08-29 21:32:57 +03:00
|
|
|
if (e.target.id == "admin") {
|
2022-08-28 18:10:41 +03:00
|
|
|
|
|
|
|
const response = await request("/api/users/<%= member.id %>/admin");
|
|
|
|
|
|
|
|
if (response.admin)
|
|
|
|
return alert("Making admin of " + response.name + " is success!");
|
|
|
|
|
2022-08-29 21:32:57 +03:00
|
|
|
} else if (e.target.id == "delete") {
|
2022-08-28 18:10:41 +03:00
|
|
|
|
2022-08-29 21:32:57 +03:00
|
|
|
const response = await request("/api/users/<%= member.id %>","DELETE");
|
2022-08-28 18:10:41 +03:00
|
|
|
|
2022-08-28 19:03:32 +03:00
|
|
|
if (!response.deleted) return
|
2022-08-28 18:10:41 +03:00
|
|
|
alert("User is deleted!");
|
|
|
|
location.reload()
|
|
|
|
|
2022-08-29 21:32:57 +03:00
|
|
|
} else {
|
|
|
|
|
|
|
|
const body = {};
|
2022-08-29 19:31:59 +03:00
|
|
|
|
2022-08-29 21:32:57 +03:00
|
|
|
if (e.target.id == "edit_name")
|
|
|
|
body.name = prompt("Enter new username!");
|
|
|
|
else if (e.target.id == "edit_avatar")
|
|
|
|
body.avatar = prompt("Enter new avatar URL!");
|
|
|
|
else if (e.target.id == "edit_avatar")
|
|
|
|
body.about = prompt("Enter new about text!");
|
|
|
|
else return;
|
|
|
|
const res = await request(`/api/users/<%= member.id %>`, "PATCH", body);
|
2022-08-29 19:31:59 +03:00
|
|
|
|
2022-08-29 19:34:21 +03:00
|
|
|
if (res.error) return;
|
|
|
|
alert(`User updated!`);
|
|
|
|
location.reload();
|
2022-08-28 19:03:32 +03:00
|
|
|
}
|
|
|
|
|
2022-08-28 18:10:41 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
2022-08-29 21:32:57 +03:00
|
|
|
<% }; %>
|
|
|
|
<% if (member.deleted) {%>
|
|
|
|
<h1>This user has been deleted!</h1>
|
|
|
|
<a onclick="undelete();" class="btn-primary" >Undelete user! </a>
|
2022-08-28 18:10:41 +03:00
|
|
|
|
2022-08-29 21:32:57 +03:00
|
|
|
<script type="module">
|
|
|
|
import request from "../../js/request.js";
|
|
|
|
window.undelete= async function undelete(params) {
|
2022-08-28 18:10:41 +03:00
|
|
|
|
2022-08-29 21:32:57 +03:00
|
|
|
const response = await request("/api/users/<%= member.id %>/undelete");
|
2022-08-28 18:10:41 +03:00
|
|
|
|
2022-08-29 21:32:57 +03:00
|
|
|
if (response.deleted) return;
|
|
|
|
alert("User is undeleted successfully!");
|
|
|
|
location.reload()
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<% }; %>
|
|
|
|
|
|
|
|
</div>
|
2022-08-28 18:10:41 +03:00
|
|
|
</body>
|
2022-03-13 16:16:46 +03:00
|
|
|
|
2022-08-28 18:10:41 +03:00
|
|
|
</html>
|