mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-26 13:20:41 +03:00
114 lines
2.9 KiB
Text
114 lines
2.9 KiB
Text
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<%- include("extra/meta", {title: member.name }) %>
|
|
|
|
|
|
<body>
|
|
<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">
|
|
<h2 class="box-title">Name:</h2>
|
|
<h2 class="box-value"><%= member.name %></h2>
|
|
</div>
|
|
|
|
<div class="box">
|
|
<h2 class="box-title">Created at:</h2>
|
|
<h2 class="box-value"><%= new Date(member.time).toLocaleString() %></h2>
|
|
</div>
|
|
<div class="box">
|
|
<h2 class="box-title">Is admin?</h2>
|
|
<h2 class="box-value"><%= member.admin ? "Yes" : "No" %></h2>
|
|
</div>
|
|
|
|
<div class="box">
|
|
<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>
|
|
</div>
|
|
<div class="box">
|
|
<h2 class="box-title">About:</h2><br>
|
|
</div>
|
|
<p class="box-value">
|
|
<%= member.about %>
|
|
</p>
|
|
|
|
<a class="btn-outline-primary" id="edit">Change name of the user!</a>
|
|
|
|
<% if (user?.admin && !member.deleted) {%>
|
|
<a class="btn-outline-primary" id="admin">Give admin permissions!</a>
|
|
<a class="btn-outline-primary" id="delete">Delete user!</a>
|
|
|
|
<script type="module">
|
|
|
|
import request from "../../js/request.js";
|
|
document.addEventListener("click", async e => {
|
|
if (e.target.id == "admin") {
|
|
|
|
const response = await request("/api/users/<%= member.id %>/admin");
|
|
|
|
if (response.admin)
|
|
return alert("Making admin of " + response.name + " is success!");
|
|
|
|
}else if (e.target.id == "delete") {
|
|
|
|
const response = await request("/api/users/<%= member.id %>/delete");
|
|
|
|
if (!response.deleted) return
|
|
alert("User is deleted!");
|
|
location.reload()
|
|
|
|
}else if (e.target.id == "edit") {
|
|
|
|
const name = prompt("Enter new username!");
|
|
const res =await request(`/api/users/<%= member.id %>/edit`, "POST", { name });
|
|
if (res.error) return;
|
|
alert(`User updated!`);
|
|
location.reload();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
<% }; %>
|
|
<% if (member.deleted) {%>
|
|
<h1>This user has been deleted!</h1>
|
|
<a onclick="undelete();" class="btn-primary" >Undelete user! </a>
|
|
|
|
|
|
|
|
<script type="module">
|
|
|
|
import request from "../../js/request.js";
|
|
window.undelete= async function undelete(params) {
|
|
|
|
const response = await request("/api/users/<%= member.id %>/undelete");
|
|
|
|
if (response.deleted) return;
|
|
alert("User is undeleted successfully!");
|
|
location.reload()
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
<% }; %>
|
|
|
|
</div>
|
|
</body>
|
|
|
|
</html>
|