Finished up with global user bans.

This commit is contained in:
rainbow napkin 2024-11-29 15:39:53 -05:00
parent 26df91262f
commit 8fc699924e
13 changed files with 180 additions and 37 deletions

View file

@ -283,7 +283,31 @@ class adminUserBanList{
renderBanList(banList){
this.clearBanList();
console.log(banList);
banList.forEach((ban) => {
//Calculate expiration date and expiration days
const expirationDate = new Date(ban.expirationDate);
const expirationDays = ((expirationDate - new Date()) / (1000 * 60 * 60 * 24)).toFixed(1);
var expirationDateString = `${expirationDate.toDateString()} (${expirationDays} day(s) left)`;
var banActionString = ban.permanent ? "Account Deletion" : "Un-Ban";
console.log(ban);
if(ban.user == null){
//Fudge the user object if it's already been deleted
ban.user = {
img: "/img/nuked.png",
id: "-",
user: ban.deletedNames[0] ? ban.deletedNames[0] : "UNKNOWN",
deleted: true
};
//Fake the display string
var signUpDateString = "-"
expirationDateString = "Accounts Nuked"
banActionString = "Accounts Nuked"
}else{
var signUpDateString = new Date(ban.user.date).toDateString()
}
//Create entry row
const entryRow = document.createElement('tr');
entryRow.classList.add("admin-list-entry");
@ -293,10 +317,6 @@ class adminUserBanList{
imgNode.classList.add("admin-list-entry","admin-list-entry-item");
imgNode.src = ban.user.img;
//Calculate expiration date and expiration days
const expirationDate = new Date(ban.expirationDate);
const expirationDays = ((expirationDate - new Date()) / (1000 * 60 * 60 * 24)).toFixed(1);
//Create unban icon
const unbanIcon = document.createElement('i');
unbanIcon.classList.add("bi-emoji-smile-fill","admin-user-list-icon","admin-user-list-unban-icon");
@ -315,11 +335,11 @@ class adminUserBanList{
entryRow.appendChild(newCell(imgNode, true));
entryRow.appendChild(newCell(ban.user.id));
entryRow.appendChild(newCell(ban.user.user));
entryRow.appendChild(newCell(new Date(ban.user.date).toDateString()));
entryRow.appendChild(newCell(signUpDateString));
entryRow.appendChild(newCell(new Date(ban.banDate).toDateString()));
entryRow.appendChild(newCell(`${expirationDate.toDateString()} (${expirationDays} day(s) left)`));
entryRow.appendChild(newCell(ban.permanent ? "Account Deletion" : "Un-Ban"));
entryRow.appendChild(newCell([unbanIcon, nukeAccount]));
entryRow.appendChild(newCell(expirationDateString));
entryRow.appendChild(newCell(banActionString));
entryRow.appendChild(newCell(ban.user.deleted ? unbanIcon : [unbanIcon, nukeAccount]));
//Append row to table
this.table.appendChild(entryRow);

View file

@ -25,10 +25,12 @@ class canopyUXUtils{
constructor(){
}
//Update this and popup class to use nodes
//and display multiple errors in one popup
displayResponseError(body){
const errors = body.errors;
errors.forEach((err)=>{
new canopyUXUtils.popup(`<h3>Server Error:</h3><p><br>Message: ${err.msg}`);
new canopyUXUtils.popup(`<h3>Server Error:</h3><p><br>${err.msg}</p>`);
});
}