From e9735d239b4605d65ca5c39c15fff993edd938d4 Mon Sep 17 00:00:00 2001 From: zsxeee Date: Fri, 17 Sep 2021 16:07:03 +0800 Subject: [PATCH] Convert notification form to separate component --- src/components/NotificationDialog.vue | 398 +------------------- src/components/notifications/Apprise.vue | 30 ++ src/components/notifications/Discord.vue | 30 ++ src/components/notifications/Gotify.vue | 32 ++ src/components/notifications/Line.vue | 34 ++ src/components/notifications/LunaSea.vue | 19 + src/components/notifications/Mattermost.vue | 42 +++ src/components/notifications/Octopush.vue | 45 +++ src/components/notifications/Pushbullet.vue | 25 ++ src/components/notifications/Pushover.vue | 72 ++++ src/components/notifications/Pushy.vue | 31 ++ src/components/notifications/RocketChat.vue | 39 ++ src/components/notifications/Signal.vue | 42 +++ src/components/notifications/Slack.vue | 39 ++ src/components/notifications/Webhook.vue | 37 ++ src/components/notifications/index.js | 44 +++ src/languages/en.js | 17 + 17 files changed, 594 insertions(+), 382 deletions(-) create mode 100644 src/components/notifications/Apprise.vue create mode 100644 src/components/notifications/Discord.vue create mode 100644 src/components/notifications/Gotify.vue create mode 100644 src/components/notifications/Line.vue create mode 100644 src/components/notifications/LunaSea.vue create mode 100644 src/components/notifications/Mattermost.vue create mode 100644 src/components/notifications/Octopush.vue create mode 100644 src/components/notifications/Pushbullet.vue create mode 100644 src/components/notifications/Pushover.vue create mode 100644 src/components/notifications/Pushy.vue create mode 100644 src/components/notifications/RocketChat.vue create mode 100644 src/components/notifications/Signal.vue create mode 100644 src/components/notifications/Slack.vue create mode 100644 src/components/notifications/Webhook.vue create mode 100644 src/components/notifications/index.js diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 220ff8d71..c26990f89 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -13,23 +13,7 @@
@@ -38,370 +22,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
@@ -454,6 +76,7 @@ import HiddenInput from "./HiddenInput.vue"; import Telegram from "./notifications/Telegram.vue"; import Teams from "./notifications/Teams.vue"; import SMTP from "./notifications/SMTP.vue"; +import NotificationForm from "./notifications" export default { components: { @@ -470,8 +93,10 @@ export default { model: null, processing: false, id: null, + notificationTypes: Object.keys(NotificationForm), notification: { name: "", + /** @type { null | keyof NotificationForm } */ type: null, isDefault: false, // Do not set default value here, please scroll to show() @@ -480,6 +105,15 @@ export default { } }, + computed: { + currentForm() { + if (!this.notification.type) { + return null + } + return NotificationForm[this.notification.type] + } + }, + watch: { "notification.type"(to, from) { let oldName; @@ -528,7 +162,7 @@ export default { } // Set Default value here - this.notification.type = "telegram"; + this.notification.type = this.notificationTypes[0]; this.notification.gotifyPriority = 8; this.notification.smtpSecure = false; } diff --git a/src/components/notifications/Apprise.vue b/src/components/notifications/Apprise.vue new file mode 100644 index 000000000..b9d2a94b5 --- /dev/null +++ b/src/components/notifications/Apprise.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/components/notifications/Discord.vue b/src/components/notifications/Discord.vue new file mode 100644 index 000000000..3d4869edd --- /dev/null +++ b/src/components/notifications/Discord.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/components/notifications/Gotify.vue b/src/components/notifications/Gotify.vue new file mode 100644 index 000000000..600b5e48a --- /dev/null +++ b/src/components/notifications/Gotify.vue @@ -0,0 +1,32 @@ + + + diff --git a/src/components/notifications/Line.vue b/src/components/notifications/Line.vue new file mode 100644 index 000000000..2468875b7 --- /dev/null +++ b/src/components/notifications/Line.vue @@ -0,0 +1,34 @@ + + + diff --git a/src/components/notifications/LunaSea.vue b/src/components/notifications/LunaSea.vue new file mode 100644 index 000000000..efa103fb7 --- /dev/null +++ b/src/components/notifications/LunaSea.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/notifications/Mattermost.vue b/src/components/notifications/Mattermost.vue new file mode 100644 index 000000000..79ff23bb2 --- /dev/null +++ b/src/components/notifications/Mattermost.vue @@ -0,0 +1,42 @@ + + + diff --git a/src/components/notifications/Octopush.vue b/src/components/notifications/Octopush.vue new file mode 100644 index 000000000..94c5783b4 --- /dev/null +++ b/src/components/notifications/Octopush.vue @@ -0,0 +1,45 @@ + + + diff --git a/src/components/notifications/Pushbullet.vue b/src/components/notifications/Pushbullet.vue new file mode 100644 index 000000000..8eddb9fb7 --- /dev/null +++ b/src/components/notifications/Pushbullet.vue @@ -0,0 +1,25 @@ + + + diff --git a/src/components/notifications/Pushover.vue b/src/components/notifications/Pushover.vue new file mode 100644 index 000000000..ff29a4066 --- /dev/null +++ b/src/components/notifications/Pushover.vue @@ -0,0 +1,72 @@ + + + diff --git a/src/components/notifications/Pushy.vue b/src/components/notifications/Pushy.vue new file mode 100644 index 000000000..752f16952 --- /dev/null +++ b/src/components/notifications/Pushy.vue @@ -0,0 +1,31 @@ + + + diff --git a/src/components/notifications/RocketChat.vue b/src/components/notifications/RocketChat.vue new file mode 100644 index 000000000..50c21b20e --- /dev/null +++ b/src/components/notifications/RocketChat.vue @@ -0,0 +1,39 @@ + + + diff --git a/src/components/notifications/Signal.vue b/src/components/notifications/Signal.vue new file mode 100644 index 000000000..f68b6dfed --- /dev/null +++ b/src/components/notifications/Signal.vue @@ -0,0 +1,42 @@ + + + diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue new file mode 100644 index 000000000..c1b4f7c01 --- /dev/null +++ b/src/components/notifications/Slack.vue @@ -0,0 +1,39 @@ + + + diff --git a/src/components/notifications/Webhook.vue b/src/components/notifications/Webhook.vue new file mode 100644 index 000000000..002a2d507 --- /dev/null +++ b/src/components/notifications/Webhook.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js new file mode 100644 index 000000000..50716f14b --- /dev/null +++ b/src/components/notifications/index.js @@ -0,0 +1,44 @@ +import STMP from "./SMTP.vue" +import Telegram from "./Telegram.vue"; +import Discord from "./Discord.vue"; +import Webhook from "./Webhook.vue"; +import Signal from "./Signal.vue"; +import Gotify from "./Gotify.vue"; +import Slack from "./Slack.vue"; +import RocketChat from "./RocketChat.vue"; +import Teams from "./Teams.vue"; +import Pushover from "./Pushover.vue"; +import Pushy from "./Pushy.vue"; +import Octopush from "./Octopush.vue"; +import LunaSea from "./LunaSea.vue"; +import Apprise from "./Apprise.vue"; +import Pushbullet from "./Pushbullet.vue"; +import Line from "./Line.vue"; +import Mattermost from "./Mattermost.vue"; + +/** + * manage all notification form. + * + * @type { Record } + */ +const NotificationForm = { + "telegram": Telegram, + "webhook": Webhook, + "smtp": STMP, + "discord": Discord, + "teams": Teams, + "signal": Signal, + "gotify": Gotify, + "slack": Slack, + "rocket.chat": RocketChat, + "pushover": Pushover, + "pushy": Pushy, + "octopush": Octopush, + "lunasea": LunaSea, + "apprise": Apprise, + "pushbullet": Pushbullet, + "line": Line, + "mattermost": Mattermost +} + +export default NotificationForm diff --git a/src/languages/en.js b/src/languages/en.js index 1971f6f6d..bb0f50b9b 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -167,4 +167,21 @@ export default { Purple: "Purple", Pink: "Pink", "Search...": "Search...", + "telegram": "Telegram", + "webhook": "Webhook", + "smtp": "Email (SMTP)", + "discord": "Discord", + "teams": "Microsoft Teams", + "signal": "Signal", + "gotify": "Gotify", + "slack": "Slack", + "rocket.chat": "Rocket.chat", + "pushover": "Pushover", + "pushy": "Pushy", + "octopush": "Octopush", + "lunasea": "LunaSea", + "apprise": "Apprise (Support 50+ Notification services)", + "pushbullet": "Pushbullet", + "line": "Line Messenger", + "mattermost": "Mattermost", }