akf-forum/views/user.ejs

82 lines
1.8 KiB
Plaintext
Raw Normal View History

2022-03-13 16:16:46 +03:00
<!DOCTYPE html>
<html lang="en">
2022-08-26 20:36:04 +03:00
<%- include("extra/meta", {title: "User list!" }) %>
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>
<img style="width:256px;height:256px;" src=<%=member.avatar %> alt=<%= member.name %>>
</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)
alert("User Deleted");
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) {%>
<h1>This user has been deleted!</h1>
<% }; %>
2022-08-26 20:36:04 +03:00
</body>
2022-03-13 16:16:46 +03:00
</html>