Finished polishing site-wide admin control panel
This commit is contained in:
parent
3c37080cb7
commit
441fb56f37
6 changed files with 136 additions and 12 deletions
|
|
@ -14,6 +14,58 @@ GNU Affero General Public License for more details.
|
|||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
class adminNavButtons{
|
||||
constructor(){
|
||||
this.navList = document.querySelector("#admin-nav-list");
|
||||
this.buttons = new Map();
|
||||
this.options = new Map([
|
||||
["Channels", document.querySelector("#admin-channel-list-div")],
|
||||
["Users", document.querySelector("#admin-user-list-div")],
|
||||
["Global Permissions", document.querySelector("#admin-perm-list-div")],
|
||||
["Global Bans", document.querySelector("#admin-ban-list-div")],
|
||||
["Global Tokes", document.querySelector("#toke-command-list-div")],
|
||||
["Global Emotes", document.querySelector("#emote-list-div")],
|
||||
]);
|
||||
|
||||
//Render out buttons
|
||||
this.renderButtons();
|
||||
//Select the first option in the options map
|
||||
this.displayOption(Array.from(this.options.keys())[0]);
|
||||
}
|
||||
|
||||
renderButtons(){
|
||||
//For erry list in the admin panel
|
||||
for(const option of this.options.keys()){
|
||||
//Create a button for it
|
||||
const button = document.createElement('button');
|
||||
button.innerText = option;
|
||||
|
||||
//Attatch an event listener to handle users clickin' der button
|
||||
button.addEventListener('click',()=>{this.displayOption(option)});
|
||||
|
||||
//Drop button in the buttons map
|
||||
this.buttons.set(option, button);
|
||||
|
||||
//Add that shit
|
||||
this.navList.appendChild(button);
|
||||
}
|
||||
}
|
||||
|
||||
displayOption(selectedOption){
|
||||
//For every option
|
||||
for(const option of this.options.keys()){
|
||||
//If we're on the selected option
|
||||
if(option == selectedOption){
|
||||
this.options.get(option).style.display = 'flex';
|
||||
this.buttons.get(option).classList.add('positive-button');
|
||||
}else{
|
||||
this.options.get(option).style.display = 'none';
|
||||
this.buttons.get(option).classList.remove('positive-button');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class adminUserList{
|
||||
constructor(){
|
||||
this.userNames = document.querySelectorAll(".admin-user-list-name");
|
||||
|
|
@ -500,6 +552,7 @@ class adminEmoteList{
|
|||
}
|
||||
}
|
||||
|
||||
const navButton = new adminNavButtons();
|
||||
const userList = new adminUserList();
|
||||
const permissionList = new adminPermissionList();
|
||||
const userBanList = new adminUserBanList();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue