diff --git a/controller/api.js b/controller/api.js index 20a87a3..45d2cf3 100644 --- a/controller/api.js +++ b/controller/api.js @@ -154,6 +154,13 @@ exports.getRules = async (req,res)=> .catch(()=>{return null}) return res.json(payload); } +exports.deleteRule = async (req, res)=> +{ + var deleted = await roleRulesM.findByIdAndDelete(req.headers.ruleid) + .then(()=>{return {success:'Done'}}) + .catch(()=>{return {error:'Failed to delete'}}); + res.json(deleted); +} exports.updateRule = (bot)=> { return async (req, res)=> diff --git a/public/css/dashboard.css b/public/css/dashboard.css index a0c79ce..48f2b12 100644 --- a/public/css/dashboard.css +++ b/public/css/dashboard.css @@ -120,6 +120,11 @@ p top:1vh; right:1vh; } +#Feeds +{ + cursor:pointer; +} + #Guilds { /* background-color: ivory; */ @@ -452,6 +457,17 @@ input transform:translateX(-50%); color:ivory; cursor:pointer; + font-weight: bold; + font-family: 'lato'; +} +#change +{ + left:70%; +} +#delete +{ + left:30%; + color: #410303a9; } #emojiImg { diff --git a/public/js/dashboard.js b/public/js/dashboard.js index 1b26248..69929de 100644 --- a/public/js/dashboard.js +++ b/public/js/dashboard.js @@ -183,7 +183,32 @@ async function handleToggleRules(element) ` rulesElement.classList.remove('hidden') } +function handleToggleFeeds(element) +{ +} +function deleteRule(element) +{ + var ruleID = document.getElementById('roleRule').classList[1]; + fetch(`${window.location.origin}/api/deleteRule`, + { + method: "POST", + mode: "cors", + headers: {ruleID}, + }) + .then(result => result.json()) + .then(res => + { + console.log(res); + if(res.success) + { + element.parentNode.classList.add('hidden') + document.getElementById('popup').classList.remove('hidden'); + } + else alert(res.error); + }) + .catch(console.error); +} function addRule(element) { diff --git a/routes/routes.js b/routes/routes.js index a2bfcc6..98186fe 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -11,6 +11,7 @@ module.exports = (io, bot)=> router.route('/api/getRules').get(api.getRules); router.route('/api/getMessage').get(api.getMessage(bot)); router.route('/api/updateRule').post(api.updateRule(bot)); + router.route('/api/deleteRule').post(api.deleteRule); router.route('/dashboard').get(dash.get(io)) .post(dash.post(io)); router.route('/getMessage').get(api.getMessage(bot)) diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 2563bc3..b953bad 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -33,6 +33,7 @@ check_box_outline_blank

Role rules

+

Feeds