akf-forum/views/user.ejs

96 lines
2.1 KiB
Text
Raw Normal View History

2022-03-13 16:16:46 +03:00
<!DOCTYPE html>
<html lang="en">
<%- include("extra/meta", {title: member.name }) %>
2022-03-26 23:28:10 +03:00
2022-08-26 20:36:04 +03:00
<body style="text-align: center;">
<%- include("extra/navbar") %>
2022-03-26 23:28:10 +03:00
2022-08-26 20:36:04 +03:00
<ul>
<li>
<h1 style="color: #4d18e6;">Avatar:</h1>
2022-08-27 10:31:16 +03:00
<img style="width:256px;height:256px;" src="<%=member.avatar %>">
2022-08-26 20:36:04 +03:00
</li>
2022-03-26 23:28:10 +03:00
2022-08-26 20:36:04 +03:00
<li>
<h2 style="color: #606060;">Name: <%= member.name %>
</h2>
</li>
<li>
<h2 style="color: #606060;">Created at:
<%= new Date(member.time).toLocaleString() %>
</h2>
2022-03-26 23:28:10 +03:00
2022-08-26 20:36:04 +03:00
</li>
<li>
<h2 style="color: #606060;">Is admin? <%= member.admin ? "Yes" : "No" %>
</h2>
</li>
2022-03-26 23:28:10 +03:00
2022-08-26 20:36:04 +03:00
<li>
<h2 style="color: #606060;"> Message: <%= counts.message %>
</h2>
</li>
<li>
<h2 style="color: #606060;"> Thread: <%= counts.thread %>
</h2>
</li>
</ul>
2022-03-26 23:28:10 +03:00
2022-08-26 20:36:04 +03:00
<% if (user?.admin && !member.deleted) {%>
2022-08-27 14:08:28 +03:00
<a class="big" id="admin">Give admin permissions!</a>
2022-03-26 23:28:10 +03:00
2022-08-27 14:08:28 +03:00
<a class="big" id="delete">Delete user!</a>
2022-08-26 20:36:04 +03:00
<script type="module">
2022-03-26 23:28:10 +03:00
2022-08-26 20:36:04 +03:00
import request from "../../js/request.js";
2022-08-27 14:08:28 +03:00
document.addEventListener("click", async e => {
2022-08-26 20:36:04 +03:00
e.preventDefault();
2022-08-27 14:08:28 +03:00
if (e.target.id == "admin") {
2022-08-11 03:48:35 +03:00
2022-08-26 20:36:04 +03:00
const response = await request("/api/users/<%= member.id %>/admin");
2022-08-11 03:48:35 +03:00
2022-08-26 20:36:04 +03:00
if (response.admin)
return alert("Making admin of " + response.name + " is success!");
2022-08-11 03:48:35 +03:00
2022-08-26 20:36:04 +03:00
}
2022-08-26 20:36:04 +03:00
const response = await request("/api/users/<%= member.id %>/delete");
if (!response.deleted) return
alert("User is deleted!");
location.reload()
2022-08-11 17:55:48 +03:00
2022-08-26 20:36:04 +03:00
});
2022-08-26 20:36:04 +03:00
</script>
<% }; %>
<% if (member.deleted) {%>
2022-08-26 20:36:04 +03:00
<h1>This user has been deleted!</h1>
2022-08-27 14:08:28 +03:00
<a onclick="undelete();" type="">Undelete user! </a>
<script type="module">
import request from "../../js/request.js";
2022-08-27 14:08:28 +03:00
async function undelete(params) {
const response = await request("/api/users/<%= member.id %>/undelete");
if (response.deleted) return;
alert("User is undeleted successfully!");
2022-08-27 10:31:16 +03:00
location.reload()
2022-08-27 14:08:28 +03:00
}
</script>
<% }; %>
2022-08-26 20:36:04 +03:00
</body>
2022-03-13 16:16:46 +03:00
</html>