Finished up work on ignored users management popup in profile page
This commit is contained in:
parent
25a61b5809
commit
c2bbf0b6f8
8 changed files with 225 additions and 42 deletions
|
|
@ -142,46 +142,6 @@ class profileUpdateImagePrompt extends profileUpdatePrompt{
|
|||
}
|
||||
}
|
||||
|
||||
class passwordResetPrompt{
|
||||
constructor(){
|
||||
this.oldPassNode = document.querySelector('#account-settings-password-reset-old');
|
||||
this.newPassNode = document.querySelector('#account-settings-password-reset-new');
|
||||
this.confirmPassNode = document.querySelector('#account-settings-password-reset-confirm');
|
||||
|
||||
this.setupInput(this.oldPassNode);
|
||||
this.setupInput(this.newPassNode);
|
||||
this.setupInput(this.confirmPassNode);
|
||||
}
|
||||
|
||||
setupInput(node){
|
||||
if(node != null){
|
||||
node.addEventListener("keydown", this.update.bind(this));
|
||||
}
|
||||
}
|
||||
|
||||
async update(event){
|
||||
var hasVal = (this.oldPassNode.value && this.newPassNode.value && this.confirmPassNode.value);
|
||||
if((!event || event.key == "Enter") && hasVal){
|
||||
if(this.newPassNode.value == this.confirmPassNode.value){
|
||||
const updateObj = {};
|
||||
|
||||
updateObj.passChange = {
|
||||
oldPass: this.oldPassNode.value,
|
||||
newPass: this.newPassNode.value,
|
||||
confirmPass: this.confirmPassNode.value
|
||||
};
|
||||
|
||||
const response = await utils.ajax.updateProfile(updateObj);
|
||||
|
||||
if(response != null){
|
||||
//Return user homepage after good pass change, as we've probably been logged out by the server for security.
|
||||
window.location.pathname = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class tokeList{
|
||||
constructor(){
|
||||
this.tokeList = document.querySelector('#profile-tokes');
|
||||
|
|
@ -288,6 +248,93 @@ class changePasswordPopup{
|
|||
}
|
||||
}
|
||||
|
||||
class ignoredUsersPopup{
|
||||
constructor(){
|
||||
this.popup = new canopyUXUtils.popup("ignoredUsers", true, this.asyncConstructor.bind(this), document, false);
|
||||
}
|
||||
|
||||
asyncConstructor(){
|
||||
this.ignoredUsersListDiv = document.querySelector('#ignored-users-popup-list-div')
|
||||
this.ignorePrompt = document.querySelector('#ignored-users-popup-prompt');
|
||||
this.ignoreButton = document.querySelector('#ignored-users-popup-button');
|
||||
|
||||
//Refresh ignored list
|
||||
this.refreshList();
|
||||
|
||||
this.setupInput();
|
||||
}
|
||||
|
||||
//grabs and re-renders list, good for asynchronous fire-and-forget usage
|
||||
async refreshList(){
|
||||
this.renderUsers(await utils.ajax.getIgnoredUsers());
|
||||
}
|
||||
|
||||
renderUsers(users){
|
||||
//Clear out list div
|
||||
this.ignoredUsersListDiv.innerHTML = '';
|
||||
|
||||
//run through our ignored users
|
||||
for(const user of users){
|
||||
//Create a div about it
|
||||
const userDiv = document.createElement('div');
|
||||
userDiv.classList.add('ignored-users-popup-ignored-user');
|
||||
|
||||
//Create userlabel
|
||||
const userLabel = document.createElement('p');
|
||||
userLabel.classList.add('ignored-users-popup-ignored-user-label');
|
||||
userLabel.textContent = user.user;
|
||||
|
||||
//Create unignore icon
|
||||
const unignoreIcon = document.createElement('i');
|
||||
unignoreIcon.classList.add('bi-emoji-smile-fill', 'ignored-users-popup-unignore-user-icon');
|
||||
unignoreIcon.title = `Unignore ${user.user}`;
|
||||
|
||||
//Make the unignore button actually fuckin' do something for once in its no-good, lazy, yellowbellied, chicken-fucking life
|
||||
unignoreIcon.addEventListener('click', (event)=>{this.unignore(user.user)});
|
||||
|
||||
//ASSEMBLE
|
||||
userDiv.append(userLabel, unignoreIcon);
|
||||
|
||||
//Render out to popup
|
||||
this.ignoredUsersListDiv.appendChild(userDiv);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
setupInput(){
|
||||
this.ignorePrompt.addEventListener('keydown', this.ignore.bind(this));
|
||||
this.ignoreButton.addEventListener('click', this.ignore.bind(this));
|
||||
}
|
||||
|
||||
async ignore(event){
|
||||
//If we clicked or hit enter
|
||||
if(event.key == null || event.key == "Enter"){
|
||||
//Tell server who you wanna ignore and get the new list back
|
||||
const ignoredList = await utils.ajax.ignoreUser(this.ignorePrompt.value);
|
||||
|
||||
//If we received a good list
|
||||
if(ignoredList != null){
|
||||
//Render out received ignored lsit
|
||||
this.renderUsers(ignoredList);
|
||||
}
|
||||
|
||||
//Clear prompt
|
||||
this.ignorePrompt.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
async unignore(user){
|
||||
//Tell server who you wanna unignore and get the new list back
|
||||
const ignoredList = await utils.ajax.unignoreUser(user);
|
||||
|
||||
//If we received a good list
|
||||
if(ignoredList != null){
|
||||
//Render out received ignored lsit
|
||||
this.renderUsers(ignoredList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class deleteAccountPopup{
|
||||
constructor(){
|
||||
this.popup = new canopyUXUtils.popup("nukeUser", true, this.asyncConstructor.bind(this));
|
||||
|
|
@ -318,4 +365,5 @@ const bioPrompt = new profileUpdateTextPrompt('bio', true);
|
|||
const profileTokeList = new tokeList();
|
||||
const accountEmailChange = new accountSettingsButton('update-email', changeEmailPopup);
|
||||
const accountPasswordChange = new accountSettingsButton('change-password', changePasswordPopup);
|
||||
const accountDeleteButton = new accountSettingsButton('delete', deleteAccountPopup);
|
||||
const accountIgnoredUsers = new accountSettingsButton('change-password', changePasswordPopup);
|
||||
const accountDeleteButton = new accountSettingsButton('ignored-users', ignoredUsersPopup);
|
||||
Loading…
Add table
Add a link
Reference in a new issue