Delete thread button for threads page

This commit is contained in:
Akif9748 2022-08-31 16:25:35 +03:00
parent 3fef090992
commit c268a5bed8
5 changed files with 19 additions and 15 deletions

View file

@ -45,12 +45,10 @@ Akf-forum has got an API for AJAX, other clients etc. And, you can learn about A
- page for threads - users - page for threads - users
- extra ratelimits - extra ratelimits
- better edits - better edits
- IP BAN fix - IP BAN fix, user -> ips []
- message counts for API - message counts for API
- ZATEN SİLİNDİ BU KİŞİ & MESAJ - ZATEN SİLİNDİ BU KİŞİ & MESAJ
- delete thread for threads area
- delete admin request, moreover, add it to user patch delete 😳 - delete admin request, moreover, add it to user patch delete 😳
- user -> ips []
### API ### API
| To do | Is done? | To do | Is done?

View file

@ -52,7 +52,8 @@ a {
.btn-danger { .btn-danger {
color: #e8e8e8; color: #e8e8e8;
background-color: #ff0000; background-color: #ff0000;
padding: 10px 20px 10px 20px; padding: 0px 10px 0px 10px;
border-radius: 4px; border-radius: 4px;
font-weight: 700; font-weight: 700;
margin: 10px; margin: 10px;
@ -60,7 +61,7 @@ a {
border: 2px solid #ff0000; border: 2px solid #ff0000;
} }
.btn-outline-primary { .btn-outline-primary {
color: #4d18e6; color: #4d18e6;
padding: 10px 20px 10px 20px; padding: 10px 20px 10px 20px;
@ -83,9 +84,10 @@ a {
.btn-outline-primary:hover { .btn-outline-primary:hover {
border: 2px solid #4d18e6; border: 2px solid #4d18e6;
} }
.btn-danger:hover{
background-color: #d01919; .btn-danger:hover {
border: 2px solid #d01919; background-color: #d01919;
border: 2px solid #d01919;
} }
@ -95,6 +97,7 @@ border: 2px solid #d01919;
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
} }
.menu-item { .menu-item {
padding: 10px; padding: 10px;
font-weight: 700; font-weight: 700;
@ -143,7 +146,7 @@ div.avatar {
.box-username { .box-username {
display: flex; display: flex;
align-items:center; align-items: center;
justify-content: center; justify-content: center;
font-size: 18px; font-size: 18px;
font-weight: 700; font-weight: 700;
@ -182,4 +185,4 @@ div.avatar {
width: 100%; width: 100%;
text-align: center; text-align: center;
} }
} }

View file

@ -16,8 +16,8 @@ app.get("/:id", async (req, res) => {
if (member && (user?.admin || !member.deleted)) { if (member && (user?.admin || !member.deleted)) {
const message = await MessageModel.count({ "author.id": id }); const message = await MessageModel.count({ authorID: id });
const thread = await ThreadModel.count({ "author.id": id }); const thread = await ThreadModel.count({ authorID: id });
member.about = member.about.replaceAll("&", "&") member.about = member.about.replaceAll("&", "&")
.replaceAll("<", "&lt;").replaceAll(">", "&gt;") .replaceAll("<", "&lt;").replaceAll(">", "&gt;")
.replaceAll("\"", "&quot;").replaceAll("'", "&#39;") .replaceAll("\"", "&quot;").replaceAll("'", "&#39;")

View file

@ -41,7 +41,7 @@
<div class="message" id="message-<%= message.id %>"> <div class="message" id="message-<%= message.id %>">
<div class="left"> <div class="left">
<img src="<%= message.author.avatar || '/images/guest.png' %>"/> <img src="<%= message.author.avatar || '/images/guest.png' %>"/>
<div class="username"><a href="/users/<%=message.author.id %>"><%=message.author.name %></a></div> <div class="username"><a href="/users/<%=message.authorID %>"><%=message.author.name %></a></div>
<div class="date"> <div class="date">
<%= new Date(message.time).toLocaleDateString() %> <%= new Date(message.time).toLocaleDateString() %>
</div> </div>
@ -52,7 +52,7 @@
<div class="content"><%- message.content %></div> <div class="content"><%- message.content %></div>
<% if(user){ %> <% if(user){ %>
<% if(user.id === message.author.id || user.admin){ %> <% if(user.id === message.authorID || user.admin){ %>
<div class="dots" id="dots-<%=message.id %>" onclick="dots('<%=message.id %>')"> <div class="dots" id="dots-<%=message.id %>" onclick="dots('<%=message.id %>')">
<% if (message.deleted){ %> <% if (message.deleted){ %>

View file

@ -19,8 +19,11 @@
<%= thread.title %> <%= thread.title %>
</div> </div>
<div class="box-username"> <div class="box-username">
<a class="btn-danger"><i class="fa-solid fa-trash-can"></i></a> <% if (user && !thread.deleted){ %>
<a class="btn-danger" onclick="fetch('/api/threads/<%= thread.id %>/',{method:'DELETE'})"><i class="fa-solid fa-trash-can"></i></a>
<% } %>
<%= thread.author.name %> <div class="avatar"><img src="<%=thread.author.avatar %>"> </div> <%= thread.author.name %> <div class="avatar"><img src="<%=thread.author.avatar %>"> </div>
</div> </div>
</div> </div>