Added Admin panel buttons and alert for success

This commit is contained in:
Akif9748 2022-03-13 16:32:02 +03:00
parent a0848f1225
commit 6b483c8d28
6 changed files with 18 additions and 8 deletions

View file

@ -8,5 +8,5 @@ module.exports = (req, res) => {
if (!user.admin) return error(res, 404, "You have not got permissions for view to this page.");
res.render("admin", { user })
res.render("admin", { user, user2: false })
}

View file

@ -16,7 +16,7 @@ module.exports = (req, res) => {
user2.write()
}
res.render("admin", { user })
res.render("admin", { user, user2 })
}

View file

@ -27,15 +27,19 @@
<!-- Navbar end -->
<h1>Welcome to the admin panel of the forum, <%= user.name %>!</h1>
<form action="/admin/" method="POST">
<h2>Write an ID for make admin:</h2>
<h2>Write an ID for make admin:</h2>
<input name="userid"></input>
<hr>
<button class = "buyuk" type="submit">Make admin!</button>
<button class="buyuk" type="submit">Make admin!</button>
</form>
<script>
if (<%= user2.admin %>)
alert("Making admin of '<%= user2.name %>'' is success");
</script>
</body>
</html>

View file

@ -14,6 +14,11 @@
<body>
<%if(user.admin){%>
<button onclick="window.location.href = '/admin'">ADMIN PANEL</button> <hr>
<%};%>
<!-- Navbar: -->
<a href="/"><img class="logo" src="/images/logo.jpg" alt="AKF-FORUM"></a>
<br> <button class="buyuk" onclick="window.location.href = '/threads'">THREADS</button>

View file

@ -16,10 +16,10 @@
<body>
<!-- Navbar: -->
<a href="/"><img class="logo" src="/images/logo.jpg" alt="AKF-FORUM"></a>
<br> <button class="buyuk" onclick="window.location.href = '/threads'">THREADS</button>
<br>
<button class="buyuk" onclick="window.location.href = '/search'">SEARCH</button>
<button class="buyuk" onclick="window.location.href = '/users'">USERS</button>
<button class="buyuk" onclick="window.location.href = '/threads'">THREADS</button>
<h1 style="display:inline; float:right;"><a href=<%=user.getLink() %>> <%= user.name %></a>
<img class="yuvarlak" src=<%=user.avatar %> alt=<%= user.name %>>
</h1>

View file

@ -17,8 +17,9 @@
<!-- Navbar: -->
<a href="/"><img class="logo" src="/images/logo.jpg" alt="AKF-FORUM"></a>
<br>
<button class="buyuk" onclick="window.location.href = '/search'">SEARCH</button>
<button class="buyuk" onclick="window.location.href = '/users'">USERS</button>
<button class="buyuk" onclick="window.location.href = '/search'">SEARCH</button>
<button class="buyuk" onclick="window.location.href = '/createThread/'">OPEN THREAD</button>
<h1 style="display:inline; float:right;"><a href=<%=user.getLink() %>> <%= user.name %></a>
<img class="yuvarlak" src=<%=user.avatar %> alt=<%= user.name %>>