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

@ -10,7 +10,25 @@
<ui-btn type="submit">Save</ui-btn>
</div>
</form>
<div class="w-full h-px bg-white bg-opacity-10 my-6" />
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-semibold">Notifications</h2>
<ui-btn small color="success" class="flex items-center" @click="clickCreate">Create <span class="material-icons text-lg pl-2">add</span></ui-btn>
</div>
<div v-if="!notifications.length" class="flex justify-center text-center">
<p class="text-lg text-gray-200">No notifications</p>
</div>
<template v-for="notification in notifications">
<div :key="notification.id" class="w-full bg-primary rounded-xl p-4">
<p>{{ notification.eventName }}</p>
</div>
</template>
</div>
<modals-notification-edit-modal v-model="showEditModal" :notification="selectedNotification" :notification-data="notificationData" />
</div>
</template>
@ -21,11 +39,18 @@ export default {
loading: false,
appriseApiUrl: null,
notifications: [],
notificationSettings: null
notificationSettings: null,
notificationData: null,
showEditModal: false,
selectedNotification: null
}
},
computed: {},
methods: {
clickCreate() {
this.selectedNotification = null
this.showEditModal = true
},
submitForm() {
if (this.notificationSettings && this.notificationSettings.appriseApiUrl == this.appriseApiUrl) {
return
@ -52,18 +77,20 @@ export default {
},
async init() {
this.loading = true
const notificationSettings = await this.$axios.$get('/api/notifications').catch((error) => {
const notificationResponse = await this.$axios.$get('/api/notifications').catch((error) => {
console.error('Failed to get notification settings', error)
this.$toast.error('Failed to load notification settings')
return null
})
this.loading = false
if (!notificationSettings) {
if (!notificationResponse) {
return
}
this.notificationSettings = notificationSettings
this.appriseApiUrl = notificationSettings.appriseApiUrl
this.notifications = notificationSettings.notifications || []
this.notificationSettings = notificationResponse.settings
this.notificationData = notificationResponse.data
console.log('Notification response', notificationResponse)
this.appriseApiUrl = this.notificationSettings.appriseApiUrl
this.notifications = this.notificationSettings.notifications || []
}
},
mounted() {