All the strike endpoints return info related to the validator, some styles were improved, added reload button to strike dashboard

master
masterhc 1 year ago
parent b199ca670b
commit 8df9b2861d

@ -345,7 +345,6 @@ exports.updateFeed = (bot)=>
} }
exports.strikeDashboard = (bot)=> exports.strikeDashboard = (bot)=>
{ {
return async (req, res)=> return async (req, res)=>
@ -373,7 +372,7 @@ exports.strikeDashboard = (bot)=>
strikes.push(aux); strikes.push(aux);
})); }));
// console.log(strikes) // console.log(strikes)
res.render('strikesDashboard.ejs', {strikes, guild, moderator}) res.render('strikesDashboard.ejs', {strikes, guild, moderator, params:req.params})
} }
} }
exports.updateStrikes = (bot)=> exports.updateStrikes = (bot)=>
@ -382,8 +381,27 @@ exports.updateStrikes = (bot)=>
{ {
const moderator = req.params.userid; const moderator = req.params.userid;
const strike = await STRIKES.findByIdAndUpdate(req.params.strikeid, {validated:true, validatedBy:moderator}); const strike = await STRIKES.findByIdAndUpdate(req.params.strikeid, {validated:true, validatedBy:moderator});
const strikes = await STRIKES.find({guildID:req.params.id}) const guild = bot.guilds.cache.get(req.params.id);
res.render('strikelist.ejs', {strikes, moderator}) const strikeList = await STRIKES.find({guildID:req.params.id})
var strikes = [];
await Promise.all(strikeList.map(async (strike) => {
var aux = {...strike._doc }
if(strike.validated)
{
if(strike.validatedBy)
{
const user = bot.users.cache.get(strike.validatedBy);
const moderator = {
username:user.username,
avatar:user.avatar,
id:user.id
};
aux = {...aux, moderator};
}
}
strikes.push(aux);
}));
res.render('strikelist.ejs', {strikes, guild, moderator, params:req.params})
} }
} }
exports.deleteStrikes = (bot)=> exports.deleteStrikes = (bot)=>
@ -391,8 +409,27 @@ exports.deleteStrikes = (bot)=>
return async (req,res)=> return async (req,res)=>
{ {
await STRIKES.findByIdAndDelete(req.params.strikeid); await STRIKES.findByIdAndDelete(req.params.strikeid);
const strikes = await STRIKES.find({guildID:req.params.id}) const guild = bot.guilds.cache.get(req.params.id);
const strikeList = await STRIKES.find({guildID:req.params.id})
const moderator = req.params.userid; const moderator = req.params.userid;
res.render('strikelist.ejs', {strikes, moderator}) var strikes = [];
await Promise.all(strikeList.map(async (strike) => {
var aux = {...strike._doc }
if(strike.validated)
{
if(strike.validatedBy)
{
const user = bot.users.cache.get(strike.validatedBy);
const moderator = {
username:user.username,
avatar:user.avatar,
id:user.id
};
aux = {...aux, moderator};
}
}
strikes.push(aux);
}));
res.render('strikelist.ejs', {strikes, guild, moderator, params:req.params})
} }
} }

@ -31,6 +31,7 @@ body
width: 100%; width: 100%;
justify-content: center; justify-content: center;
background-color: #071c24; background-color: #071c24;
overflow-y: auto !important;
} }
#userWrapper #userWrapper
@ -39,8 +40,6 @@ body
flex-wrap: wrap; flex-wrap: wrap;
gap: 1em; gap: 1em;
justify-content: center; justify-content: center;
margin-top:3vh;
margin-left: 10%;
text-align: center; text-align: center;
align-items: center; align-items: center;
height: 15vh; height: 15vh;
@ -55,6 +54,7 @@ body
background-color: ivory; background-color: ivory;
height: 10vh; height: 10vh;
width: 10vh; width: 10vh;
top:0 !important;
background-size: 10vh 10vh; background-size: 10vh 10vh;
border-radius: 10px; border-radius: 10px;
} }
@ -70,24 +70,22 @@ body
} }
#userName #userName
{ {
margin: 0;
position: relative;
font-size: 2.5em; font-size: 2.5em;
font-family: 'Lato'; font-family: 'Lato';
font-weight: bolder; font-weight: bolder;
white-space: pre-wrap; white-space: pre-wrap;
color: rgb(15, 98, 131); color: rgb(15, 98, 131);
transform: translateY(0.5em);
} }
#maindisplay #maindisplay
{ {
width: 90%; width: 90%;
margin-top: 2vh; margin-top: 3vh;
margin-left: 5%;
color:white; color:white;
display: flex; display: flex;
overflow-y: auto;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
text-align: center; text-align: center;
@ -107,6 +105,10 @@ body
.strike-info { .strike-info {
flex: 4; flex: 4;
} }
.strike-info > h3, .strike-info > h4 {
margin-top: 1em;
margin-bottom: 1em;
}
.strike-info > h3 > span> img, .strike-info > h4 > span> img .strike-info > h3 > span> img, .strike-info > h4 > span> img
{ {
border: none; border: none;
@ -144,7 +146,14 @@ body
margin-right: 1em; margin-right: 1em;
} }
.actions >div:hover .actions > div
{
height: 7vh;
display: flex;
justify-content: center;
flex-direction: column;
}
.actions > div:hover
{ {
background-color: darkslategray; background-color: darkslategray;
border:none; border:none;
@ -163,4 +172,9 @@ body
color:rgb(15, 98, 131); color:rgb(15, 98, 131);
font-family: 'Lato'; font-family: 'Lato';
font-weight: bolder; font-weight: bolder;
}
.reload
{
color: rgb(15, 98, 131);
transform: translateY(0.2em);
} }

@ -1,11 +1,18 @@
<div id="userWrapper"> <div id="userWrapper">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
<link rel="stylesheet" type="text/css" href="/css/strikesdashboard.css" id="pagesheet"/> <link rel="stylesheet" type="text/css" href="/css/strikesdashboard.css" id="pagesheet"/>
<i hx-get="/dashboard" hx-trigger="click" hx-target="body" id="close_bt" class="close material-symbols-outlined"> <i hx-get="/dashboard" hx-trigger="click" hx-target="body" id="close_bt" class="close material-symbols-outlined">
cancel cancel
</i> </i>
<div id="avatar" style="background-image: url(https://cdn.discordapp.com/icons/<%= guild.id %>/<%= guild.icon%>.webp)"></div> <!--it works somehow --> <div id="avatar" style="background-image: url(https://cdn.discordapp.com/icons/<%= guild.id %>/<%= guild.icon%>.webp)"></div> <!--it works somehow -->
<div class="userNameWrapper"> <div
<p id="userName"><%= guild.name%></p> hx-get="/strikes/<%=params.id %>/<%=params.userid + (params.strikeid?`/${params.strikeid}`:'')%>"
hx-trigger="click"
hx-target="body"
class="userNameWrapper"
style="cursor: pointer;">
<p id="userName"><%= guild.name%> <span class="material-symbols-outlined reload">frame_reload</span>
</p>
</div> </div>
</div> </div>
<div id="maindisplay"> <div id="maindisplay">

Loading…
Cancel
Save