-
-
-
+
+
+
-
+
+
+
+
-
-
-
+
@@ -73,11 +74,11 @@ import {
CategoriesSelection,
CATEGORY_ANDROID_SIGN,
CATEGORY_AUTH,
+ CATEGORY_KUBE_CONFIG,
CATEGORY_SSH_RSA,
- CATEGORY_TOKEN,
- CATEGORY_KUBE_CONFIG
+ CATEGORY_TOKEN
} from '@/util/secrets'
-import { secretAndConfigNameRules } from '@/util/rules'
+import {secretAndConfigNameRules} from '@/util/rules'
export default {
name: 'SettingsSecretNew',
From 39a919d3a6d2a7016d64b3871b285e390a815141 Mon Sep 17 00:00:00 2001
From: gy2006 <32008001@qq.com>
Date: Fri, 5 Nov 2021 17:17:26 +0100
Subject: [PATCH 03/20] list notifications
---
src/store/module/notifications.js | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 src/store/module/notifications.js
diff --git a/src/store/module/notifications.js b/src/store/module/notifications.js
new file mode 100644
index 00000000..e69de29b
From 31338f543429c5399e7baa6075a560cb63849ed5 Mon Sep 17 00:00:00 2001
From: gy2006 <32008001@qq.com>
Date: Fri, 5 Nov 2021 22:10:24 +0100
Subject: [PATCH 04/20] show notification list
---
src/store/actions.js | 9 +++
src/store/index.js | 4 +-
src/store/module/configs.js | 10 ++-
src/store/module/notifications.js | 68 +++++++++++++++++++
src/util/configs.js | 2 +-
src/util/notifications.js | 12 ++++
.../Settings/Notification/EmailSettings.vue | 17 ++++-
src/view/Settings/Notification/Index.vue | 40 ++++++++++-
src/view/Settings/Notification/New.vue | 52 ++++++++++++--
src/view/Settings/Secret/New.vue | 36 ++++------
10 files changed, 213 insertions(+), 37 deletions(-)
diff --git a/src/store/actions.js b/src/store/actions.js
index c8fce549..d095585e 100644
--- a/src/store/actions.js
+++ b/src/store/actions.js
@@ -100,10 +100,19 @@ export default {
saveSmtp: 'configs/saveSmtp',
saveText: 'configs/saveText',
list: 'configs/list',
+ listSmtp: 'configs/listSmtp',
get: 'configs/get',
delete: 'configs/delete'
},
+ notifications: {
+ saveEmail: 'notifications/saveEmail',
+ saveWebhook: 'notifications/saveWebhook',
+ list: 'notifications/list',
+ get: 'notifications/get',
+ delete: 'notifications/delete'
+ },
+
users: {
hasDefault: 'users/hasDefault',
createDefault: 'users/createDefault',
diff --git a/src/store/index.js b/src/store/index.js
index f991b2b1..c4c5b095 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -17,6 +17,7 @@ import { Store as PluginStore } from './module/plugins'
import { Store as ConfigStore } from './module/configs'
import { Store as TtyStore } from './module/tty'
import { Store as SettingStore } from './module/settings'
+import { Store as NotificationStore } from './module/notifications'
Vue.use(Vuex)
@@ -37,7 +38,8 @@ const store = new Vuex.Store({
'plugins': PluginStore,
'configs': ConfigStore,
'tty': TtyStore,
- 'settings': SettingStore
+ 'settings': SettingStore,
+ 'notifications': NotificationStore
}
})
diff --git a/src/store/module/configs.js b/src/store/module/configs.js
index df96c322..bb648a3d 100644
--- a/src/store/module/configs.js
+++ b/src/store/module/configs.js
@@ -29,8 +29,14 @@ const mutations = {
}
const actions = {
- list({commit}) {
- http.get('configs', (list) => {
+ async list({commit}) {
+ await http.get('configs', (list) => {
+ commit('list', list)
+ })
+ },
+
+ async listSmtp({commit}) {
+ await http.get('configs?category=SMTP', (list) => {
commit('list', list)
})
},
diff --git a/src/store/module/notifications.js b/src/store/module/notifications.js
index e69de29b..8b52294b 100644
--- a/src/store/module/notifications.js
+++ b/src/store/module/notifications.js
@@ -0,0 +1,68 @@
+import http from '../http'
+
+const state = {
+ items: [],
+ loaded: {}
+}
+
+const mutations = {
+ add(state, notification) {
+ state.items.push(notification)
+ },
+
+ remove(state, n) {
+ for (let i = 0; i < state.items.length; i++) {
+ if (state.items[i].id === n.id) {
+ state.items.splice(i, 1)
+ return
+ }
+ }
+ },
+
+ loaded(state, n) {
+ state.loaded = n
+ },
+
+ list(state, notifications) {
+ state.items = notifications
+ }
+}
+
+const actions = {
+ async list({commit}) {
+ await http.get('notifications', (list) => {
+ commit('list', list)
+ })
+ },
+
+ async get({commit}, name) {
+ await http.get(`notifications/${name}`, (n) => {
+ commit('loaded', n)
+ })
+ },
+
+ async saveEmail({commit}, payload) {
+ await http.post(`notifications/email`, (n) => {
+ commit('add', n)
+ }, payload)
+ },
+
+ async saveWebhook({commit}, payload) {
+ await http.post(`notifications/webhook`, (n) => {
+ commit('add', n)
+ }, payload)
+ },
+
+ async delete({commit}, name) {
+ await http.delete(`notifications/${name}`, (c) => {
+ commit('remove', c)
+ })
+ },
+}
+
+export const Store = {
+ namespaced: true,
+ state,
+ mutations,
+ actions
+}
diff --git a/src/util/configs.js b/src/util/configs.js
index 2f9561c6..de382a9d 100644
--- a/src/util/configs.js
+++ b/src/util/configs.js
@@ -12,7 +12,7 @@ export const CategoriesSelection = [
export const Categories = {
[CATEGORY_SMTP]: {
- name: 'Smtp',
+ name: 'SMTP',
icon: 'mdi-email-outline'
},
[CATEGORY_TEXT]: {
diff --git a/src/util/notifications.js b/src/util/notifications.js
index 392bde4c..8abb0e00 100644
--- a/src/util/notifications.js
+++ b/src/util/notifications.js
@@ -1,3 +1,4 @@
+import {CATEGORY_SMTP, CATEGORY_TEXT} from "@/util/configs";
export const CATEGORY_EMAIL = 'Email'
export const CATEGORY_WEBHOOK = 'WebHook'
@@ -14,6 +15,17 @@ export const CategorySelection = [
{name: 'WebHook', value: CATEGORY_WEBHOOK, icon: 'mdi-webhook'},
]
+export const Categories = {
+ [CATEGORY_EMAIL]: {
+ name: 'Email',
+ icon: 'mdi-email-outline'
+ },
+ [CATEGORY_WEBHOOK]: {
+ name: 'WebHook',
+ icon: 'mdi-webhook'
+ }
+}
+
export const TriggerSelection = [
{name: 'On Job Finished', value: TRIGGER_ON_JOB_FINISHED, icon: ''}
]
\ No newline at end of file
diff --git a/src/view/Settings/Notification/EmailSettings.vue b/src/view/Settings/Notification/EmailSettings.vue
index 6e3c4180..7d2f46ad 100644
--- a/src/view/Settings/Notification/EmailSettings.vue
+++ b/src/view/Settings/Notification/EmailSettings.vue
@@ -39,7 +39,7 @@
:rules="rules.required('Email to is required')"
>
-
+
diff --git a/src/view/Settings/Notification/New.vue b/src/view/Settings/Notification/New.vue
index 99d6c9cb..c2dd383b 100644
--- a/src/view/Settings/Notification/New.vue
+++ b/src/view/Settings/Notification/New.vue
@@ -24,29 +24,44 @@
-
+
+
+
+ Error: {{ error }}
+
+
+
-
+
+
\ No newline at end of file
diff --git a/src/view/Settings/Notification/EmailSettings.vue b/src/view/Settings/Notification/EmailSettings.vue
index 7d2f46ad..a9e59d98 100644
--- a/src/view/Settings/Notification/EmailSettings.vue
+++ b/src/view/Settings/Notification/EmailSettings.vue
@@ -10,7 +10,7 @@