akf-forum/views/user.ejs

85 lines
1.9 KiB
Text
Raw Normal View History

2022-03-13 16:16:46 +03:00
<!DOCTYPE html>
<html lang="en">
2022-08-26 16:27:29 +03:00
<%- include("extra/old_header", { title: member.name }) %>
2022-03-26 23:28:10 +03:00
<body>
2022-08-26 16:27:29 +03:00
<%- include("extra/old_navbar", { user }) %>
2022-03-26 23:28:10 +03:00
<ul>
<li>
<h1>Avatar:</h1>
<img style="width:256px;height:256px;" src=<%=member.avatar %> alt=<%= member.name %>>
</li>
<li>
<h2>Name: <%= member.name %>
</h2>
</li>
<li>
<h2>Created at:
<%= new Date(member.time).toLocaleString() %>
</h2>
</li>
<li>
<h2>Is admin? <%= member.admin ? "Yes" : "No" %>
</h2>
</li>
<li>
<h2> Message: <%= counts.message %>
</h2>
</li>
<li>
<h2> Thread: <%= counts.thread %>
</h2>
</li>
</ul>
<% if (user?.admin && !member.deleted) {%>
2022-08-11 03:48:35 +03:00
<form id="admin">
2022-08-11 15:36:28 +03:00
<button class="big" type="submit">Give admin permissions!</button>
2022-03-26 23:28:10 +03:00
</form>
<form id="delete">
2022-08-11 15:36:28 +03:00
<button class="big" type="submit">Delete user!</button>
2022-03-26 23:28:10 +03:00
</form>
<script type="module">
import request from "../../js/request.js";
document.addEventListener("submit", async e => {
e.preventDefault();
2022-08-11 03:48:35 +03:00
if (e.target.id == "admin") {
const response = await request("/api/users/<%= member.id %>/admin");
2022-08-11 17:55:48 +03:00
if (response.admin)
return alert("Making admin of " + response.name + " is success!");
2022-08-11 03:48:35 +03:00
2022-08-11 17:55:48 +03:00
}
2022-08-11 17:55:48 +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
});
</script>
<% }; %>
2022-08-11 17:55:48 +03:00
<% if (member.deleted) {%>
<h1>This user has been deleted!</h1>
<% }; %>
2022-08-26 16:27:29 +03:00
<%- include("extra/old_footer") %>
2022-03-26 23:28:10 +03:00
</body>
2022-03-13 16:16:46 +03:00
</html>