akf-forum/views/user.ejs

103 lines
2.3 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) {%>
<form id="admin">
<button class="big" type="submit">Give admin permissions!</button>
</form>
2022-03-26 23:28:10 +03:00
2022-08-26 20:36:04 +03:00
<form id="delete">
<button class="big" type="submit">Delete user!</button>
</form>
2022-03-26 23:28:10 +03:00
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-26 20:36:04 +03:00
document.addEventListener("submit", async e => {
e.preventDefault();
2022-08-26 20:36:04 +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>
<form id="undelete">
<button class="big" type="submit">Undelete user!</button>
</form>
<script type="module">
import request from "../../js/request.js";
document.addEventListener("submit", async e => {
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()
});
</script>
<% }; %>
2022-08-26 20:36:04 +03:00
</body>
2022-03-13 16:16:46 +03:00
</html>