Finished up with channel rank/perms frontend.
This commit is contained in:
parent
edb4215929
commit
796bb033a7
22 changed files with 472 additions and 57 deletions
29
src/controllers/api/account/rankEnumController.js
Normal file
29
src/controllers/api/account/rankEnumController.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*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 permissionModel = require('../../../schemas/permissionSchema.js');
|
||||
const {exceptionHandler} = require('../../../utils/loggerUtils.js');
|
||||
|
||||
//api account functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
res.status(200);
|
||||
return res.send(permissionModel.rankEnum);
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ module.exports.get = async function(req, res){
|
|||
|
||||
//Send out the userlist we created
|
||||
res.status(200);
|
||||
res.send(userList);
|
||||
res.send(Object.fromEntries(userList));
|
||||
}else{
|
||||
//If we received bad input, we have only one action: bitch, moan, and complain!
|
||||
res.status(400);
|
||||
|
|
@ -97,10 +97,10 @@ module.exports.post = async function(req, res){
|
|||
}
|
||||
|
||||
//Set rank
|
||||
var rankList = await chanDB.setRank(userDB, data.rank);
|
||||
await chanDB.setRank(userDB, data.rank);
|
||||
|
||||
res.status(200);
|
||||
res.send(rankList);
|
||||
res.send(Object.fromEntries(await chanDB.getRankList()));
|
||||
}else{
|
||||
//If we received bad input, we have only one action: bitch, moan, and complain!
|
||||
res.status(400);
|
||||
|
|
|
|||
|
|
@ -18,20 +18,27 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const config = require('../../config.json');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler} = require('../utils/loggerUtils.js');
|
||||
const {exceptionHandler} = require('../utils/loggerUtils');
|
||||
const channelModel = require('../schemas/channel/channelSchema');
|
||||
const permissionModel = require('../schemas/permissionSchema');
|
||||
|
||||
//root index functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
const chanName = (req.url.slice(1).replace('/settings',''));
|
||||
const channel = await channelModel.findOne({name: chanName});
|
||||
const chanDB = await channelModel.findOne({name: chanName});
|
||||
const reqRank = await chanDB.getChannelRank(req.session.user);
|
||||
|
||||
if(channel == null){
|
||||
await chanDB.populate("rankList.user");
|
||||
|
||||
//Take out the permissions doc id since we don't need it.
|
||||
delete chanDB.permissions._doc._id;
|
||||
|
||||
if(chanDB == null){
|
||||
throw new Error("Channel not found.");
|
||||
}
|
||||
|
||||
return res.render('channelSettings', {instance: config.instanceName, user: req.session.user, channel});
|
||||
return res.render('channelSettings', {instance: config.instanceName, user: req.session.user, channel: chanDB, reqRank, rankEnum: permissionModel.rankEnum});
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue