Started work on permissions list in /adminPanel
This commit is contained in:
parent
1de507b7cb
commit
8c4d9693f5
|
|
@ -24,9 +24,25 @@ const {exceptionHandler} = require("../utils/loggerUtils");
|
|||
//register page functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
//Get DB info
|
||||
const chanGuide = await channelModel.getChannelList(true);
|
||||
const userList = await userModel.getUserList(true);
|
||||
return res.render('adminPanel', {instance: config.instanceName, user: req.session.user, chanGuide: chanGuide, userList: userList, rankEnum: permissionModel.rankEnum});
|
||||
const permList = (await permissionModel.getPerms()).toObject();
|
||||
|
||||
//Clean up perm list :P
|
||||
delete permList._id ;
|
||||
delete permList.__v;
|
||||
|
||||
//Render out the page
|
||||
return res.render('adminPanel', {
|
||||
instance: config.instanceName,
|
||||
user: req.session.user,
|
||||
rankEnum: permissionModel.rankEnum,
|
||||
chanGuide: chanGuide,
|
||||
userList: userList,
|
||||
permList: permList
|
||||
});
|
||||
|
||||
}catch(err){
|
||||
return exceptionHandler(res,err);
|
||||
}
|
||||
|
|
|
|||
31
src/controllers/api/admin/listPermissionsController.js
Normal file
31
src/controllers/api/admin/listPermissionsController.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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/>.*/
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
const permissionModel = require('../../../schemas/permissionSchema.js');
|
||||
|
||||
//api account functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
const perms = await permissionModel.getPerms();
|
||||
|
||||
res.status(200);
|
||||
return res.send(perms);
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,5 +16,5 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
|
||||
//root index functions
|
||||
module.exports.get = async function(req, res){
|
||||
res.render('panels/placeholder', {});
|
||||
res.render('partial/panels/placeholder', {});
|
||||
}
|
||||
|
|
@ -19,5 +19,5 @@ const config = require('../../../config.json');
|
|||
|
||||
//popout panel container functions
|
||||
module.exports.get = async function(req, res){
|
||||
res.render('panels/popoutContainer', {instance: config.instanceName});
|
||||
res.render('popoutContainer', {instance: config.instanceName});
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ const permissionSchema = require("../../schemas/permissionSchema");
|
|||
const listUsersController = require("../../controllers/api/admin/listUsersController");
|
||||
const listChannelsController = require("../../controllers/api/admin/listChannelsController");
|
||||
const changeRankController = require("../../controllers/api/admin/changeRankController");
|
||||
const listPermissionsController = require("../../controllers/api/admin/listPermissionsController");
|
||||
|
||||
//globals
|
||||
const router = Router();
|
||||
|
|
@ -34,6 +35,7 @@ router.use(permissionSchema.reqPermCheck("adminAPI"));
|
|||
//routing functions
|
||||
router.get('/listUsers', listUsersController.get);
|
||||
router.get('/listChannels', listChannelsController.get);
|
||||
router.get('/listPermissions', listPermissionsController.get);
|
||||
router.post('/changeRank', accountValidator.user(), accountValidator.rank(), changeRankController.post);
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
|
|||
<%- include('partial/navbar', {user}); %>
|
||||
<%- include('partial/adminPanel/channelList', {chanGuide}) %>
|
||||
<%- include('partial/adminPanel/userList', {user, userList, rankEnum}) %>
|
||||
<%- include('partial/adminPanel/permList', {permList, rankEnum}) %>
|
||||
</body>
|
||||
<footer>
|
||||
<%- include('partial/scripts', {user}); %>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,22 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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/>.-->
|
||||
<div id="admin-channel-list-div" class="admin-list-div">
|
||||
<h3>Channel List:</h3>
|
||||
<table id="admin-channel-list-table" class="admin-list-table">
|
||||
<tr id="admin-channel-list-entry-title" class="admin-list-entry">
|
||||
<tr id="admin-channel-list-entry-title" class="admin-list-entry-title-row">
|
||||
<td id="admin-channel-list-entry-img-title" class="admin-list-entry admin-list-entry-title admin-list-entry-item admin-list-entry-img-title">
|
||||
<h3>Img</h3>
|
||||
</td>
|
||||
|
|
|
|||
30
src/views/partial/adminPanel/permList.ejs
Normal file
30
src/views/partial/adminPanel/permList.ejs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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/>.-->
|
||||
<div id="admin-perm-list-div" class="admin-list-div">
|
||||
<h3>Permissions:</h3>
|
||||
<field id="admin-perm-list-field" class="admin-list-field">
|
||||
<% Object.keys(permList).forEach((key)=>{ %>
|
||||
<span class="admin-list-field-container">
|
||||
<label id="admin-perm-list-label-<%- key %>" class="admin-list-label admin-perm-list" for="admin-perm-list-rank-select-<%- key %>"><%- key %>: </label>
|
||||
<select id="admin-perm-list-rank-select-<%- key %>" name="admin-perm-list-rank-select-<%- key %>" class="admin-list-select admin-perm-list-rank-select">
|
||||
<%rankEnum.slice().reverse().forEach((rank)=>{ %>
|
||||
<option <%if(permList[key] == rank){%> selected <%}%> value="<%- rank %>"><%- rank %></option>
|
||||
<% }); %>
|
||||
</select>
|
||||
</span>
|
||||
<% }); %>
|
||||
</field>
|
||||
</div>
|
||||
|
|
@ -1,7 +1,22 @@
|
|||
<!--Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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/>.-->
|
||||
<div id="admin-user-list-div" class="admin-list-div">
|
||||
<h3>User List:</h3>
|
||||
<table id="admin-user-list-table" class="admin-list-table">
|
||||
<tr id="admin-user-list-entry-title" class="admin-list-entry">
|
||||
<tr id="admin-user-list-entry-title" class="admin-list-entry-title-row">
|
||||
<td id="admin-user-list-entry-img-title" class="admin-list-entry admin-list-entry-title admin-list-entry-item admin-list-entry-img-title">
|
||||
<h3>Img</h3>
|
||||
</td>
|
||||
|
|
@ -53,7 +68,7 @@
|
|||
<%- curUser.email ? curUser.email : "N/A" %>
|
||||
</td>
|
||||
<td id="admin-user-list-entry-date-<%- curUser.name %>" class="admin-list-entry admin-list-entry-item admin-list-entry-not-first-row">
|
||||
<%- curUser.date %>
|
||||
<%- curUser.date.toUTCString() %>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<%- include('../partial/styles'); %>
|
||||
<%- include('partial/styles'); %>
|
||||
<link rel="stylesheet" type="text/css" href="/css/panel.css">
|
||||
<title><%= instance %> - NULL_POPOUT</title>
|
||||
</head>
|
||||
|
|
@ -50,7 +50,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
|
|||
<% } %>
|
||||
</span>
|
||||
|
||||
<p class="profile-item" id="profile-creation-date">Joined: <%= profile.date %></p>
|
||||
<p class="profile-item" id="profile-creation-date">Joined: <%= profile.date.toUTCString(); %></p>
|
||||
<div class="profile-item" id="profile-badge-shelf">
|
||||
<h3 class="profile-item" id="no-badge-label">Badgeless?</h3>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -14,12 +14,18 @@ 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/>.*/
|
||||
|
||||
.admin-list-div{
|
||||
.admin-list-field, .admin-list-div{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.admin-list-div{
|
||||
margin: 0 30%;
|
||||
}
|
||||
|
||||
.admin-list-field{
|
||||
padding: 1em 15%;
|
||||
}
|
||||
|
||||
.admin-list-table{
|
||||
border-spacing: 0px;
|
||||
|
|
@ -52,3 +58,21 @@ img.admin-list-entry-item{
|
|||
#admin-user-list-entry-id-title{
|
||||
width: 2em;
|
||||
}
|
||||
|
||||
.admin-list-label{
|
||||
margin-top: 0.5em;
|
||||
margin-bottom: 0.1em;
|
||||
}
|
||||
|
||||
.admin-list-select{
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.admin-perm-list-rank-select{
|
||||
width: 5em;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.admin-list-field-container{
|
||||
text-align: center;
|
||||
}
|
||||
|
|
@ -134,17 +134,19 @@ a#account-settings-delete-link{
|
|||
color: var(--accent0-warning);
|
||||
}
|
||||
|
||||
.admin-list-table{
|
||||
.admin-list-field,.admin-list-table{
|
||||
background-color: var(--bg1);
|
||||
color: var(--accent1);
|
||||
box-shadow: 3px 3px 1px var(--bg1-alt0) inset;
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
tr.admin-list-entry{
|
||||
box-shadow: var(--accent1) 0px 1em 1px -1em, var(--accent1) 0px -1em 1px -1em;
|
||||
box-shadow: var(--accent1) 0px 1em 1px -2em, var(--accent1) 0px -1em 1px -1em;
|
||||
}
|
||||
|
||||
td.admin-list-entry-not-first-row{
|
||||
box-shadow: var(--accent1) 1em 0px 1px -1em, var(--accent1) -1em 0px 1px -1em;
|
||||
box-shadow: var(--accent1) 1em 0px 1px -2em, var(--accent1) -1em 0px 1px -1em;
|
||||
}
|
||||
|
||||
a.admin-list-entry-item{
|
||||
|
|
|
|||
|
|
@ -1,190 +0,0 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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/>.*/
|
||||
|
||||
:root{
|
||||
--main-font: "open-sans", sans-serif;
|
||||
--bg0: rgb(158, 158, 158);
|
||||
--bg1: rgb(70, 70, 70);
|
||||
--bg2: rgb(220, 220, 220);
|
||||
--bg1-alt0: rgb(30, 30, 30);
|
||||
--bg2-alt0: rgb(200, 200, 200);
|
||||
--bg2-alt1: rgb(180, 180, 180);
|
||||
|
||||
--accent0: rgb(48, 47, 47);
|
||||
--accent0-alt0: rgb(34, 34, 34);
|
||||
--accent0-warning: firebrick;
|
||||
--accent1: rgb(245, 245, 245);
|
||||
--accent1-alt0: rgb(185, 185, 185);
|
||||
--accent2: var(--accent0-alt0);
|
||||
|
||||
|
||||
--userlist-color0:rgb(122, 199, 135);
|
||||
--userlist-color1:rgb(242, 104, 77);
|
||||
--userlist-color2:rgb(77, 150, 239);
|
||||
--userlist-color3:rgb(247, 241, 212);
|
||||
--userlist-color4:rgb(255, 173, 173);
|
||||
--userlist-color5:rgb(254, 151, 82);
|
||||
--userlist-color6:rgb(209, 167, 246);
|
||||
}
|
||||
|
||||
body{
|
||||
background-color: var(--bg0);
|
||||
font-family: var(--main-font);
|
||||
color: var(--accent0);
|
||||
}
|
||||
|
||||
a{
|
||||
text-decoration: none;
|
||||
color: var(--accent0);
|
||||
}
|
||||
|
||||
a:hover{
|
||||
color: var(--accent0-alt0);
|
||||
}
|
||||
|
||||
#navbar{
|
||||
background-color: var(--bg1);
|
||||
}
|
||||
|
||||
.navbar-item{
|
||||
color: var(--accent1);
|
||||
border: hidden;
|
||||
}
|
||||
|
||||
a:hover.navbar-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
.navbar-item input{
|
||||
background-color: var(--bg1-alt0);
|
||||
}
|
||||
|
||||
.channel-guide-entry{
|
||||
background-color: var(--bg1);
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
div.channel-guide-entry{
|
||||
border-radius: 0.3em;
|
||||
box-shadow: 0.2em 0.2em 0.1em var(--bg1-alt0) inset;
|
||||
}
|
||||
|
||||
a.channel-guide-entry-item{
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
a:hover.channel-guide-entry-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
span.channel-guide-entry-item{
|
||||
background-color: var(--bg1-alt0);
|
||||
box-shadow: 0.2em 0.2em 0.1em black inset;
|
||||
border-radius: 0.3em;
|
||||
margin: 0 0.1em 0 0.1em;
|
||||
}
|
||||
|
||||
|
||||
p.channel-guide-entry-item{
|
||||
background-color: var(--bg1-alt0);
|
||||
}
|
||||
|
||||
a#account-settings-delete-link{
|
||||
color: var(--accent0-warning);
|
||||
}
|
||||
|
||||
#channel-delete{
|
||||
color: var(--accent0-warning);
|
||||
}
|
||||
|
||||
#admin-channel-list-table{
|
||||
background-color: var(--bg1);
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
tr.admin-channel-list-entry{
|
||||
box-shadow: var(--accent1) 0px 1em 1px -1em, var(--accent1) 0px -1em 1px -1em;
|
||||
}
|
||||
|
||||
td.admin-channel-list-entry-name-row{
|
||||
box-shadow: var(--accent1) 1em 0px 1px -1em, var(--accent1) -1em 0px 1px -1em;
|
||||
}
|
||||
|
||||
a.admin-channel-list-entry-item{
|
||||
color: var(--accent1);
|
||||
}
|
||||
|
||||
a:hover.admin-channel-list-entry-item{
|
||||
color: var(--accent1-alt0);
|
||||
}
|
||||
|
||||
#media-panel-div{
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
#chat-panel-buffer-div{
|
||||
background-color: var(--bg2);
|
||||
}
|
||||
|
||||
.chat-entry{
|
||||
display: flex;
|
||||
background-color: var(--bg2);
|
||||
border-bottom: 1px solid var(--bg2-alt1);
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.chat-entry-username{
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.chat-entry-body{
|
||||
margin: 0.2em;
|
||||
}
|
||||
|
||||
.userlist-color0{/*green0*/
|
||||
color: var(--userlist-color0);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color1{/*red0*/
|
||||
color: var(--userlist-color1);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color2{/*blue0*/
|
||||
color: var(--userlist-color2);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color3{/*tan0*/
|
||||
color: var(--userlist-color3);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color4{/*pink0*/
|
||||
color: var(--userlist-color4);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color5{/*orange*/
|
||||
color: var(--userlist-color5);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.userlist-color6{/*violet*/
|
||||
color: var(--userlist-color6);
|
||||
text-shadow: none;
|
||||
}
|
||||
Loading…
Reference in a new issue