From ea43422ccfae82f74dc2a0b1b00895a78d4df6ec Mon Sep 17 00:00:00 2001 From: Zack Elia Date: Sun, 9 Jan 2022 12:05:11 -0500 Subject: [PATCH 01/16] Implement gorush notifications --- server/notification-providers/gorush.js | 42 ++++++++++++++++++++ server/notification.js | 4 +- src/components/notifications/Gorush.vue | 51 +++++++++++++++++++++++++ src/components/notifications/index.js | 4 +- src/languages/en.js | 1 + 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 server/notification-providers/gorush.js create mode 100644 src/components/notifications/Gorush.vue diff --git a/server/notification-providers/gorush.js b/server/notification-providers/gorush.js new file mode 100644 index 00000000..58da5525 --- /dev/null +++ b/server/notification-providers/gorush.js @@ -0,0 +1,42 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class Gorush extends NotificationProvider { + + name = "gorush"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + let platformMapping = { + "ios": 1, + "android": 2, + "huawei": 3, + }; + + try { + let data = { + "notifications": [ + { + "tokens": [notification.gorushDeviceToken], + "platform": platformMapping[notification.gorushPlatform], + "message": msg, + // Optional + "title": notification.gorushTitle, + "priority": notification.gorushPriority, + "retry": parseInt(notification.gorushRetry) || 0, + "topic": notification.gorushTopic, + } + ] + }; + let config = {}; + + await axios.post(`${notification.gorushServerURL}/api/push`, data, config); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Gorush; diff --git a/server/notification.js b/server/notification.js index 4d72c81c..83782830 100644 --- a/server/notification.js +++ b/server/notification.js @@ -27,6 +27,7 @@ const SerwerSMS = require("./notification-providers/serwersms"); const Stackfield = require("./notification-providers/stackfield"); const WeCom = require("./notification-providers/wecom"); const GoogleChat = require("./notification-providers/google-chat"); +const Gorush = require("./notification-providers/gorush"); class Notification { @@ -65,7 +66,8 @@ class Notification { new SerwerSMS(), new Stackfield(), new WeCom(), - new GoogleChat() + new GoogleChat(), + new Gorush() ]; for (let item of list) { diff --git a/src/components/notifications/Gorush.vue b/src/components/notifications/Gorush.vue new file mode 100644 index 00000000..b53be2d2 --- /dev/null +++ b/src/components/notifications/Gorush.vue @@ -0,0 +1,51 @@ + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 03945f90..7883890b 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -26,6 +26,7 @@ import SerwerSMS from "./SerwerSMS.vue"; import Stackfield from './Stackfield.vue'; import WeCom from "./WeCom.vue"; import GoogleChat from "./GoogleChat.vue"; +import Gorush from "./Gorush.vue"; /** * Manage all notification form. @@ -60,7 +61,8 @@ const NotificationFormList = { "serwersms": SerwerSMS, "stackfield": Stackfield, "WeCom": WeCom, - "GoogleChat": GoogleChat + "GoogleChat": GoogleChat, + "gorush": Gorush }; export default NotificationFormList; diff --git a/src/languages/en.js b/src/languages/en.js index 47513466..37e831e6 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -361,4 +361,5 @@ export default { smtpDkimHashAlgo: "Hash Algorithm (Optional)", smtpDkimheaderFieldNames: "Header Keys to sign (Optional)", smtpDkimskipFields: "Header Keys not to sign (Optional)", + gorush: "Gorush", }; From 74c584f544bb84c6f41f3d1f07bc5e6813d13fcf Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Fri, 21 Jan 2022 07:42:03 +0000 Subject: [PATCH 02/16] Add Push by Techulus --- .../notification-providers/techulus-push.js | 23 +++++++++++++++++++ server/notification.js | 3 +++ src/components/notifications/TechulusPush.vue | 20 ++++++++++++++++ src/components/notifications/index.js | 2 ++ src/languages/en.js | 1 + 5 files changed, 49 insertions(+) create mode 100644 server/notification-providers/techulus-push.js create mode 100644 src/components/notifications/TechulusPush.vue diff --git a/server/notification-providers/techulus-push.js b/server/notification-providers/techulus-push.js new file mode 100644 index 00000000..b6919da5 --- /dev/null +++ b/server/notification-providers/techulus-push.js @@ -0,0 +1,23 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class TechulusPush extends NotificationProvider { + + name = "PushByTechulus"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + try { + await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, { + "title": "Uptime-Kuma", + "body": msg + }) + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error) + } + } +} + +module.exports = TechulusPush; diff --git a/server/notification.js b/server/notification.js index 4d72c81c..c66f175d 100644 --- a/server/notification.js +++ b/server/notification.js @@ -12,6 +12,7 @@ const ClickSendSMS = require("./notification-providers/clicksendsms"); const Pushbullet = require("./notification-providers/pushbullet"); const Pushover = require("./notification-providers/pushover"); const Pushy = require("./notification-providers/pushy"); +const TechulusPush = require("./notification-providers/techulus-push"); const RocketChat = require("./notification-providers/rocket-chat"); const Signal = require("./notification-providers/signal"); const Slack = require("./notification-providers/slack"); @@ -55,6 +56,7 @@ class Notification { new Pushbullet(), new Pushover(), new Pushy(), + new TechulusPush(), new RocketChat(), new Signal(), new Slack(), @@ -90,6 +92,7 @@ class Notification { * Throw Error with fail msg */ static async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + console.log("this.providerList[notification.type]", this.providerList[notification.type]) if (this.providerList[notification.type]) { return this.providerList[notification.type].send(notification, msg, monitorJSON, heartbeatJSON); } else { diff --git a/src/components/notifications/TechulusPush.vue b/src/components/notifications/TechulusPush.vue new file mode 100644 index 00000000..918f8be6 --- /dev/null +++ b/src/components/notifications/TechulusPush.vue @@ -0,0 +1,20 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 03945f90..da21ee3f 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -9,6 +9,7 @@ import RocketChat from "./RocketChat.vue"; import Teams from "./Teams.vue"; import Pushover from "./Pushover.vue"; import Pushy from "./Pushy.vue"; +import TechulusPush from "./TechulusPush.vue"; import Octopush from "./Octopush.vue"; import PromoSMS from "./PromoSMS.vue"; import ClickSendSMS from "./ClickSendSMS.vue"; @@ -44,6 +45,7 @@ const NotificationFormList = { "rocket.chat": RocketChat, "pushover": Pushover, "pushy": Pushy, + "PushByTechulus": TechulusPush, "octopush": Octopush, "promosms": PromoSMS, "clicksendsms": ClickSendSMS, diff --git a/src/languages/en.js b/src/languages/en.js index 47513466..4acc59fa 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -238,6 +238,7 @@ export default { "rocket.chat": "Rocket.Chat", pushover: "Pushover", pushy: "Pushy", + PushByTechulus: "Push by Techulus", octopush: "Octopush", promosms: "PromoSMS", clicksendsms: "ClickSend SMS", From 51b7a2badbf14f979b5c7bfa9422e908fea9e1a2 Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Fri, 21 Jan 2022 07:43:14 +0000 Subject: [PATCH 03/16] remove log --- server/notification.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/notification.js b/server/notification.js index c66f175d..69326794 100644 --- a/server/notification.js +++ b/server/notification.js @@ -92,7 +92,6 @@ class Notification { * Throw Error with fail msg */ static async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - console.log("this.providerList[notification.type]", this.providerList[notification.type]) if (this.providerList[notification.type]) { return this.providerList[notification.type].send(notification, msg, monitorJSON, heartbeatJSON); } else { From 23796723dd2b6be3623b925d0f9e74b63cab9262 Mon Sep 17 00:00:00 2001 From: Arjun Komath Date: Fri, 21 Jan 2022 20:42:08 +1100 Subject: [PATCH 04/16] Address code review Add missing comma Co-authored-by: Adam Stachowicz --- server/notification-providers/techulus-push.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/techulus-push.js b/server/notification-providers/techulus-push.js index b6919da5..f844d17c 100644 --- a/server/notification-providers/techulus-push.js +++ b/server/notification-providers/techulus-push.js @@ -11,7 +11,7 @@ class TechulusPush extends NotificationProvider { try { await axios.post(`https://push.techulus.com/api/v1/notify/${notification.pushAPIKey}`, { "title": "Uptime-Kuma", - "body": msg + "body": msg, }) return okMsg; } catch (error) { From eaf370637efcb67f6878414190bfc6ae59d54274 Mon Sep 17 00:00:00 2001 From: Computroniks Date: Thu, 27 Jan 2022 17:40:03 +0000 Subject: [PATCH 05/16] Fixed dark mode checkbox The border colour of the checkbox has been changed to make it more visible to the user when the dark mode is in use. Signed-off-by: Computroniks --- src/assets/app.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/assets/app.scss b/src/assets/app.scss index cec64467..f49ed4f2 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -156,8 +156,13 @@ textarea.form-control { .form-check-input { background-color: $dark-bg2; + border-color: $dark-border-color; } + .form-check-input:checked { + border-color: $primary; // Re-apply bootstrap border + } + .form-switch .form-check-input { background-color: #232f3b; } From cefe43800f521279d9327fd9b67fc561ea10671b Mon Sep 17 00:00:00 2001 From: Alvin Pergens Date: Wed, 26 Jan 2022 15:54:17 +0100 Subject: [PATCH 06/16] add alerta service --- server/notification-providers/alerta.js | 67 +++++++++++++++++++++++++ server/notification.js | 4 +- src/components/notifications/Alerta.vue | 14 ++++++ src/components/notifications/index.js | 4 +- src/languages/en.js | 6 +++ src/languages/fr-FR.js | 5 ++ 6 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 server/notification-providers/alerta.js create mode 100644 src/components/notifications/Alerta.vue diff --git a/server/notification-providers/alerta.js b/server/notification-providers/alerta.js new file mode 100644 index 00000000..d3b1a23c --- /dev/null +++ b/server/notification-providers/alerta.js @@ -0,0 +1,67 @@ +const NotificationProvider = require("./notification-provider"); +const { DOWN, UP } = require("../../src/util"); +const axios = require("axios"); + +class Alerta extends NotificationProvider { + + name = "alerta"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + try { + let alertaUrl = `${notification.alertaApiEndpoint}`; + let config = { + headers: { + "Content-Type": "application/json;charset=UTF-8", + "Authorization": "Key " + notification.alertaapiKey, + } + }; + let data = { + environment: notification.alertaEnvironment, + severity: "critical", + correlate: [], + service: [ "UptimeKuma" ], + value: "Timeout", + tags: [ "uptimekuma" ], + attributes: {}, + origin: "uptimekuma", + type: "exceptionAlert", + }; + + if (heartbeatJSON == null) { + let testdata = Object.assign( { + event: "test", + text: "Testing Successful.", + group: "uptimekuma-test", + resource: "Test", + }, data ); + await axios.post(alertaUrl, testdata, config); + } else { + let datadup = Object.assign( { + correlate: ["service_up", "service_down"], + group: "uptimekuma-" + monitorJSON["type"], + resource: monitorJSON["name"], + }, data ); + + if (heartbeatJSON["status"] == DOWN) { + datadup.severity = notification.alertaAlertState; // critical + datadup.event = "service_state"; + datadup.text = "Service is down."; + await axios.post(alertaUrl, datadup, config); + } else if (heartbeatJSON["status"] == UP) { + datadup.severity = notification.alertaRecoverState; // cleaner + datadup.event = "service_state"; + datadup.text = "Service is up."; + await axios.post(alertaUrl, datadup, config); + } + } + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + + } +} + +module.exports = Alerta; diff --git a/server/notification.js b/server/notification.js index 4d72c81c..dc3ea796 100644 --- a/server/notification.js +++ b/server/notification.js @@ -27,6 +27,7 @@ const SerwerSMS = require("./notification-providers/serwersms"); const Stackfield = require("./notification-providers/stackfield"); const WeCom = require("./notification-providers/wecom"); const GoogleChat = require("./notification-providers/google-chat"); +const Alerta = require("./notification-providers/alerta"); class Notification { @@ -65,7 +66,8 @@ class Notification { new SerwerSMS(), new Stackfield(), new WeCom(), - new GoogleChat() + new GoogleChat(), + new Alerta(), ]; for (let item of list) { diff --git a/src/components/notifications/Alerta.vue b/src/components/notifications/Alerta.vue new file mode 100644 index 00000000..962267fb --- /dev/null +++ b/src/components/notifications/Alerta.vue @@ -0,0 +1,14 @@ + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 03945f90..599ea4db 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -26,6 +26,7 @@ import SerwerSMS from "./SerwerSMS.vue"; import Stackfield from './Stackfield.vue'; import WeCom from "./WeCom.vue"; import GoogleChat from "./GoogleChat.vue"; +import Alerta from "./Alerta.vue"; /** * Manage all notification form. @@ -60,7 +61,8 @@ const NotificationFormList = { "serwersms": SerwerSMS, "stackfield": Stackfield, "WeCom": WeCom, - "GoogleChat": GoogleChat + "GoogleChat": GoogleChat, + "alerta": Alerta, }; export default NotificationFormList; diff --git a/src/languages/en.js b/src/languages/en.js index 47513466..d4fe0a5f 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -361,4 +361,10 @@ export default { smtpDkimHashAlgo: "Hash Algorithm (Optional)", smtpDkimheaderFieldNames: "Header Keys to sign (Optional)", smtpDkimskipFields: "Header Keys not to sign (Optional)", + alerta: 'Alerta', + alertaApiEndpoint: 'API Endpoint', + alertaEnvironment: 'Environment', + alertaApiKey: 'API Key', + alertaAlertState: 'Alert State', + alertaRecoverState: 'Recover State', }; diff --git a/src/languages/fr-FR.js b/src/languages/fr-FR.js index 04dede1b..81d8f2dc 100644 --- a/src/languages/fr-FR.js +++ b/src/languages/fr-FR.js @@ -304,4 +304,9 @@ export default { steamApiKeyDescription: "Pour surveiller un serveur Steam, vous avez besoin d'une clé Steam Web-API. Vous pouvez enregistrer votre clé ici : ", "Current User": "Utilisateur actuel", recent: "Récent", + alertaApiEndpoint: 'API Endpoint', + alertaEnvironment: 'Environement', + alertaApiKey: "Clé de l'API", + alertaAlertState: "État de l'Alerte", + alertaRecoverState: 'État de récupération', }; From 90f24975482068131258d672522047fc3c8ce7d4 Mon Sep 17 00:00:00 2001 From: Alvin Pergens Date: Fri, 28 Jan 2022 15:14:34 +0100 Subject: [PATCH 07/16] change data for Alerta --- server/notification-providers/alerta.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/notification-providers/alerta.js b/server/notification-providers/alerta.js index d3b1a23c..3ee331ac 100644 --- a/server/notification-providers/alerta.js +++ b/server/notification-providers/alerta.js @@ -40,19 +40,18 @@ class Alerta extends NotificationProvider { } else { let datadup = Object.assign( { correlate: ["service_up", "service_down"], + event: monitorJSON["type"], group: "uptimekuma-" + monitorJSON["type"], resource: monitorJSON["name"], }, data ); if (heartbeatJSON["status"] == DOWN) { datadup.severity = notification.alertaAlertState; // critical - datadup.event = "service_state"; - datadup.text = "Service is down."; + datadup.text = "Service " + monitorJSON["type"] + " is down."; await axios.post(alertaUrl, datadup, config); } else if (heartbeatJSON["status"] == UP) { datadup.severity = notification.alertaRecoverState; // cleaner - datadup.event = "service_state"; - datadup.text = "Service is up."; + datadup.text = "Service " + monitorJSON["type"] + " is up."; await axios.post(alertaUrl, datadup, config); } } From 8febff9282e3622b92bd420822ca3f9ec1f80d0e Mon Sep 17 00:00:00 2001 From: Alvin Pergens Date: Fri, 28 Jan 2022 15:35:33 +0100 Subject: [PATCH 08/16] fix comments --- server/notification-providers/alerta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/alerta.js b/server/notification-providers/alerta.js index 3ee331ac..f00d1098 100644 --- a/server/notification-providers/alerta.js +++ b/server/notification-providers/alerta.js @@ -50,7 +50,7 @@ class Alerta extends NotificationProvider { datadup.text = "Service " + monitorJSON["type"] + " is down."; await axios.post(alertaUrl, datadup, config); } else if (heartbeatJSON["status"] == UP) { - datadup.severity = notification.alertaRecoverState; // cleaner + datadup.severity = notification.alertaRecoverState; // cleaned datadup.text = "Service " + monitorJSON["type"] + " is up."; await axios.post(alertaUrl, datadup, config); } From b3a690f3b1b604cc3d6c2a175c6fbfdae42464d7 Mon Sep 17 00:00:00 2001 From: deluxghost Date: Wed, 2 Mar 2022 23:12:30 +0800 Subject: [PATCH 09/16] Update zh-CN.js --- src/languages/zh-CN.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/zh-CN.js b/src/languages/zh-CN.js index d4d37948..9133f5d0 100644 --- a/src/languages/zh-CN.js +++ b/src/languages/zh-CN.js @@ -13,7 +13,7 @@ export default { pauseDashboardHome: "暂停", deleteMonitorMsg: "确定要删除此监控项吗?", deleteNotificationMsg: "确定要为所有监控项删除此通知吗?", - resoverserverDescription: "默认服务器是 Cloudflare。您随时可以修改解析服务器。", + resolverserverDescription: "默认服务器是 Cloudflare。您随时可以修改解析服务器。", rrtypeDescription: "选择要监控的资源记录类型", pauseMonitorMsg: "确定要暂停吗?", enableDefaultNotificationDescription: "新的监控项将默认启用此通知,您仍然为每个监控项单独禁用。", From e0175d0010c83e1783f03fc3f8bbed67494edcd5 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Thu, 3 Mar 2022 10:21:34 +0800 Subject: [PATCH 10/16] Delete stale-bot.yml, no idea why it deleted some feature request --- .github/workflows/stale-bot.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/stale-bot.yml diff --git a/.github/workflows/stale-bot.yml b/.github/workflows/stale-bot.yml deleted file mode 100644 index e4faaa5f..00000000 --- a/.github/workflows/stale-bot.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: 'Automatically close stale issues and PRs' -on: - schedule: - - cron: '0 0 * * *' -#Run once a day at midnight - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v4 - with: - stale-issue-message: 'We are clearing up our old issues and your ticket has been open for 6 months with no activity. Remove stale label or comment or this will be closed in 7 days.' - stale-pr-message: 'We are clearing up our old Pull Requests and yours has been open for 6 months with no activity. Remove stale label or comment or this will be closed in 7 days.' - close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' - close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.' - days-before-stale: 180 - days-before-close: 0 - exempt-issue-labels: 'News,Medium,High,discussion,bug,doc,' - exempt-pr-labels: 'awaiting-approval,work-in-progress,enhancement,feature-request' - exempt-issue-assignees: 'louislam' - exempt-pr-assignees: 'louislam' From 602da565eb096ee2390a0d69797a9e7c86437505 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Thu, 3 Mar 2022 20:49:00 +0800 Subject: [PATCH 11/16] Sort notification types --- src/components/NotificationDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 659f5726..ce5d8057 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -85,7 +85,7 @@ export default { model: null, processing: false, id: null, - notificationTypes: Object.keys(NotificationFormList), + notificationTypes: Object.keys(NotificationFormList).sort(), notification: { name: "", /** @type { null | keyof NotificationFormList } */ From fa490d0bf1fa64ad601d9d6b12ef9410b4d5966b Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 4 Mar 2022 14:13:44 +0800 Subject: [PATCH 12/16] [Alerta] Handle general message --- server/notification-providers/alerta.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/notification-providers/alerta.js b/server/notification-providers/alerta.js index f00d1098..e692b57b 100644 --- a/server/notification-providers/alerta.js +++ b/server/notification-providers/alerta.js @@ -30,13 +30,14 @@ class Alerta extends NotificationProvider { }; if (heartbeatJSON == null) { - let testdata = Object.assign( { - event: "test", - text: "Testing Successful.", - group: "uptimekuma-test", - resource: "Test", - }, data ); - await axios.post(alertaUrl, testdata, config); + let postData = Object.assign({ + event: "msg", + text: msg, + group: "uptimekuma-msg", + resource: "Message", + }, data); + + await axios.post(alertaUrl, postData, config); } else { let datadup = Object.assign( { correlate: ["service_up", "service_down"], From e3a0eaf6af3e038d2d0f295ed770e60100ba9f53 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 4 Mar 2022 21:48:35 +0800 Subject: [PATCH 13/16] Sort notification types in case-insensitive --- src/components/NotificationDialog.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index ce5d8057..034e1149 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -85,7 +85,9 @@ export default { model: null, processing: false, id: null, - notificationTypes: Object.keys(NotificationFormList).sort(), + notificationTypes: Object.keys(NotificationFormList).sort((a, b) => { + return a.toLowerCase().localeCompare(b.toLowerCase()); + }), notification: { name: "", /** @type { null | keyof NotificationFormList } */ From 88c3d952d38605c7b90e0d27f84089e1c2178285 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 4 Mar 2022 23:20:42 +0800 Subject: [PATCH 14/16] Improve settings page's UI/UX on mobile --- src/layouts/Layout.vue | 2 +- src/pages/Settings.vue | 48 +++++++++++++++++++++++++++++++----------- src/router.js | 1 - 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue index 75173e1f..1a769a0d 100644 --- a/src/layouts/Layout.vue +++ b/src/layouts/Layout.vue @@ -157,7 +157,7 @@ export default { overflow: hidden; text-decoration: none; - &.router-link-exact-active { + &.router-link-exact-active, &.active { color: $primary; font-weight: bold; } diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue index 58162f57..1717dd52 100644 --- a/src/pages/Settings.vue +++ b/src/pages/Settings.vue @@ -6,7 +6,7 @@
-
+
-
-
+
+
{{ subMenus[currentPage].title }}
@@ -41,7 +41,6 @@ export default { data() { return { show: true, - settings: {}, settingsLoaded: false, }; @@ -52,11 +51,19 @@ export default { let pathSplit = useRoute().path.split("/"); let pathEnd = pathSplit[pathSplit.length - 1]; if (!pathEnd || pathEnd === "settings") { - return "general"; + return null; } return pathEnd; }, + showSubMenu() { + if (this.$root.isMobile) { + return !this.currentPage; + } else { + return true; + } + }, + subMenus() { return { general: { @@ -84,11 +91,26 @@ export default { }, }, + watch: { + "$root.isMobile"() { + this.loadGeneralPage(); + } + }, + mounted() { this.loadSettings(); + this.loadGeneralPage(); }, methods: { + + // For desktop only, mobile do nothing + loadGeneralPage() { + if (!this.currentPage && !this.$root.isMobile) { + this.$router.push("/settings/general"); + } + }, + loadSettings() { this.$root.getSocket().emit("getSettings", (res) => { this.settings = res.data; @@ -115,7 +137,7 @@ export default { this.loadSettings(); }); }, - }, + } }; @@ -136,9 +158,6 @@ footer { } .settings-menu { - flex: 0 0 auto; - width: 300px; - a { text-decoration: none !important; } @@ -171,9 +190,6 @@ footer { } .settings-content { - flex: 0 0 auto; - width: calc(100% - 300px); - .settings-content-header { width: calc(100% + 20px); border-bottom: 1px solid #dee2e6; @@ -187,6 +203,14 @@ footer { background: $dark-header-bg; border-bottom: 0; } + + .mobile & { + padding: 15px 0 0 0; + + .dark & { + background-color: transparent; + } + } } } diff --git a/src/router.js b/src/router.js index a2414eb6..c881dc97 100644 --- a/src/router.js +++ b/src/router.js @@ -70,7 +70,6 @@ const routes = [ children: [ { path: "general", - alias: "", component: General, }, { From 6a57c443fd3f756dac334a76b22d65a1107eab38 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 7 Mar 2022 15:52:17 +0800 Subject: [PATCH 15/16] Set telegram as the default notification type --- src/components/NotificationDialog.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 034e1149..8c03dbbd 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -145,12 +145,9 @@ export default { this.id = null; this.notification = { name: "", - type: null, + type: "telegram", isDefault: false, }; - - // Set Default value here - this.notification.type = this.notificationTypes[0]; } this.modal.show(); From 1fa4a166635441b2733239cc8175b96d0640e23e Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 7 Mar 2022 16:24:24 +0800 Subject: [PATCH 16/16] Check beta release --- server/check-version.js | 16 +++++++++++++++- src/components/settings/About.vue | 27 ++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/server/check-version.js b/server/check-version.js index a3465ddf..f3b15e84 100644 --- a/server/check-version.js +++ b/server/check-version.js @@ -1,5 +1,6 @@ -const { setSetting } = require("./util-server"); +const { setSetting, setting } = require("./util-server"); const axios = require("axios"); +const compareVersions = require("compare-versions"); exports.version = require("../package.json").version; exports.latestVersion = null; @@ -16,6 +17,19 @@ exports.startInterval = () => { res.data.slow = "1000.0.0"; } + if (!await setting("checkUpdate")) { + return; + } + + let checkBeta = await setting("checkBeta"); + + if (checkBeta && res.data.beta) { + if (compareVersions.compare(res.data.beta, res.data.beta, ">")) { + exports.latestVersion = res.data.beta; + return; + } + } + if (res.data.slow) { exports.latestVersion = res.data.slow; } diff --git a/src/components/settings/About.vue b/src/components/settings/About.vue index baa72f39..ad134094 100644 --- a/src/components/settings/About.vue +++ b/src/components/settings/About.vue @@ -4,14 +4,39 @@
Uptime Kuma
{{ $t("Version") }}: {{ $root.info.version }}
- + + + +
+
+ +
+ +
+ +
+