Notification create/update events UI

This commit is contained in:
advplyr 2022-09-22 18:12:48 -05:00
parent ff04eb8d5e
commit b08ad8785e
9 changed files with 389 additions and 9 deletions

View file

@ -4,7 +4,10 @@ class NotificationController {
constructor() { }
get(req, res) {
res.json(this.db.notificationSettings)
res.json({
data: this.notificationManager.getData(),
settings: this.db.notificationSettings
})
}
async update(req, res) {
@ -15,6 +18,28 @@ class NotificationController {
res.sendStatus(200)
}
async createEvent(req, res) {
const success = this.db.notificationSettings.addNewEvent(req.body)
if (success) {
await this.db.updateEntity('settings', this.db.notificationSettings)
}
res.sendStatus(200)
}
async updateEvent(req, res) {
const success = this.db.notificationSettings.updateEvent(req.body)
if (success) {
await this.db.updateEntity('settings', this.db.notificationSettings)
}
res.sendStatus(200)
}
getData(req, res) {
res.json(this.notificationManager.getData())
}
middleware(req, res, next) {
if (!req.user.isAdminOrUp) {
return res.sendStatus(404)