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)=>
{
return async (req, res)=>
@ -373,7 +372,7 @@ exports.strikeDashboard = (bot)=>
strikes.push(aux);
}));
// console.log(strikes)
res.render('strikesDashboard.ejs', {strikes, guild, moderator})
res.render('strikesDashboard.ejs', {strikes, guild, moderator, params:req.params})
}
}
exports.updateStrikes = (bot)=>
@ -382,8 +381,27 @@ exports.updateStrikes = (bot)=>
{
const moderator = req.params.userid;
const strike = await STRIKES.findByIdAndUpdate(req.params.strikeid, {validated:true, validatedBy:moderator});
const strikes = await STRIKES.find({guildID:req.params.id})
res.render('strikelist.ejs', {strikes, moderator})
const guild = bot.guilds.cache.get(req.params.id);
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)=>
@ -391,8 +409,27 @@ exports.deleteStrikes = (bot)=>
return async (req,res)=>
{
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;
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%;
justify-content: center;
background-color: #071c24;
overflow-y: auto !important;
}
#userWrapper
@ -39,8 +40,6 @@ body
flex-wrap: wrap;
gap: 1em;
justify-content: center;
margin-top:3vh;
margin-left: 10%;
text-align: center;
align-items: center;
height: 15vh;
@ -55,6 +54,7 @@ body
background-color: ivory;
height: 10vh;
width: 10vh;
top:0 !important;
background-size: 10vh 10vh;
border-radius: 10px;
}
@ -70,24 +70,22 @@ body
}
#userName
{
margin: 0;
position: relative;
font-size: 2.5em;
font-family: 'Lato';
font-weight: bolder;
white-space: pre-wrap;
color: rgb(15, 98, 131);
transform: translateY(0.5em);
}
#maindisplay
{
width: 90%;
margin-top: 2vh;
margin-left: 5%;
margin-top: 3vh;
color:white;
display: flex;
overflow-y: auto;
justify-content: center;
align-items: center;
text-align: center;
@ -107,6 +105,10 @@ body
.strike-info {
flex: 4;
}
.strike-info > h3, .strike-info > h4 {
margin-top: 1em;
margin-bottom: 1em;
}
.strike-info > h3 > span> img, .strike-info > h4 > span> img
{
border: none;
@ -144,6 +146,13 @@ body
margin-right: 1em;
}
.actions > div
{
height: 7vh;
display: flex;
justify-content: center;
flex-direction: column;
}
.actions > div:hover
{
background-color: darkslategray;
@ -164,3 +173,8 @@ body
font-family: 'Lato';
font-weight: bolder;
}
.reload
{
color: rgb(15, 98, 131);
transform: translateY(0.2em);
}

@ -1,11 +1,18 @@
<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"/>
<i hx-get="/dashboard" hx-trigger="click" hx-target="body" id="close_bt" class="close material-symbols-outlined">
cancel
</i>
<div id="avatar" style="background-image: url(https://cdn.discordapp.com/icons/<%= guild.id %>/<%= guild.icon%>.webp)"></div> <!--it works somehow -->
<div class="userNameWrapper">
<p id="userName"><%= guild.name%></p>
<div
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 id="maindisplay">

Loading…
Cancel
Save