From fd10897988b2e779d929f346ef63417014258894 Mon Sep 17 00:00:00 2001 From: duane Date: Mon, 17 Apr 2023 12:46:52 -0500 Subject: [PATCH 01/38] Adds translation for English Slack channel mention label --- src/lang/en.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lang/en.json b/src/lang/en.json index f33a7de37..3e95a1a36 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -624,6 +624,7 @@ "matrixDesc1": "You can find the internal room ID by looking in the advanced section of the room settings in your Matrix client. It should look like !QMdRCpUIfLwsfjxye6:home.server.", "matrixDesc2": "It is highly recommended you create a new user and do not use your own Matrix user's access token as it will allow full access to your account and all the rooms you joined. Instead, create a new user and only invite it to the room that you want to receive the notification in. You can get the access token by running {0}", "Channel Name": "Channel Name", + "Mention Channel": "Mention Channel", "Uptime Kuma URL": "Uptime Kuma URL", "Icon Emoji": "Icon Emoji", "signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!", From 00f733d35280dab78d124b52abdc4edd7cc0fddc Mon Sep 17 00:00:00 2001 From: duane Date: Mon, 17 Apr 2023 12:49:15 -0500 Subject: [PATCH 02/38] Adds ability to notify channel when Slack webhook triggered - Adds field to toggle channel mentions on/off for Slack integration - Adds special mention for @channel when enabled Reference: [Slack docs](https://api.slack.com/reference/surfaces/formatting#special-mentions) --- server/notification-providers/slack.js | 12 ++++++++---- src/components/notifications/Slack.vue | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index da89f0f7a..f4a72b03e 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -27,10 +27,14 @@ class Slack extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; + const finalMsg = notification.slackchannelmention + ? `${msg} ` + : msg; + try { if (heartbeatJSON == null) { let data = { - "text": msg, + "text": finalMsg, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo, @@ -42,7 +46,7 @@ class Slack extends NotificationProvider { const time = heartbeatJSON["time"]; const textMsg = "Uptime Kuma Alert"; let data = { - "text": `${textMsg}\n${msg}`, + "text": `${textMsg}\n${finalMsg}`, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo, @@ -54,14 +58,14 @@ class Slack extends NotificationProvider { "type": "header", "text": { "type": "plain_text", - "text": "Uptime Kuma Alert", + "text": textMsg, }, }, { "type": "section", "fields": [{ "type": "mrkdwn", - "text": "*Message*\n" + msg, + "text": "*Message*\n" + finalMsg, }, { "type": "mrkdwn", diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue index 6d220caad..34ef5feb8 100644 --- a/src/components/notifications/Slack.vue +++ b/src/components/notifications/Slack.vue @@ -24,5 +24,11 @@ https://www.webfx.com/tools/emoji-cheat-sheet/ + +
+ + +
+ From 9825b33ef35807f7e6c1dba9c6a2ab1c3f8d3e05 Mon Sep 17 00:00:00 2001 From: duane Date: Mon, 17 Apr 2023 13:05:41 -0500 Subject: [PATCH 03/38] Fixes eslint warnings for Slack notification modal --- src/components/notifications/Slack.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue index 34ef5feb8..a9b05e683 100644 --- a/src/components/notifications/Slack.vue +++ b/src/components/notifications/Slack.vue @@ -29,6 +29,5 @@ - From 5200e10aabf562a2080c60a77b111d20842213c1 Mon Sep 17 00:00:00 2001 From: duane Date: Tue, 23 May 2023 10:29:18 -0500 Subject: [PATCH 04/38] Removes ternary operator for Slack channel mention --- server/notification-providers/slack.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index f4a72b03e..27bf259af 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -27,14 +27,15 @@ class Slack extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; - const finalMsg = notification.slackchannelmention - ? `${msg} ` - : msg; + + if (notification.slackchannelmention) { + msg += " "; + } try { if (heartbeatJSON == null) { let data = { - "text": finalMsg, + "text": msg, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo, @@ -46,7 +47,7 @@ class Slack extends NotificationProvider { const time = heartbeatJSON["time"]; const textMsg = "Uptime Kuma Alert"; let data = { - "text": `${textMsg}\n${finalMsg}`, + "text": `${textMsg}\n${msg}`, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo, @@ -65,7 +66,7 @@ class Slack extends NotificationProvider { "type": "section", "fields": [{ "type": "mrkdwn", - "text": "*Message*\n" + finalMsg, + "text": "*Message*\n" + msg, }, { "type": "mrkdwn", From 9a8bea576177bccdc10ea2d70b76610f6aa37e19 Mon Sep 17 00:00:00 2001 From: duane Date: Thu, 1 Jun 2023 08:23:13 -0500 Subject: [PATCH 05/38] Changes 'Mention Channel' -> 'Notify Channel' - Updates variable names - Updates any Slack mention references --- server/notification-providers/slack.js | 2 +- src/components/notifications/Slack.vue | 4 ++-- src/lang/en.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index b3986b00f..41c2bd02c 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -28,7 +28,7 @@ class Slack extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; - if (notification.slackchannelmention) { + if (notification.slackchannelnotify) { msg += " "; } diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue index a9b05e683..e99fc31e3 100644 --- a/src/components/notifications/Slack.vue +++ b/src/components/notifications/Slack.vue @@ -26,8 +26,8 @@
- - + +
diff --git a/src/lang/en.json b/src/lang/en.json index 5ebbef133..10dca0811 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -625,7 +625,7 @@ "matrixDesc1": "You can find the internal room ID by looking in the advanced section of the room settings in your Matrix client. It should look like !QMdRCpUIfLwsfjxye6:home.server.", "matrixDesc2": "It is highly recommended you create a new user and do not use your own Matrix user's access token as it will allow full access to your account and all the rooms you joined. Instead, create a new user and only invite it to the room that you want to receive the notification in. You can get the access token by running {0}", "Channel Name": "Channel Name", - "Mention Channel": "Mention Channel", + "Notify Channel": "Notify Channel", "Uptime Kuma URL": "Uptime Kuma URL", "Icon Emoji": "Icon Emoji", "signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!", From 1fa8c0f9fef5ab94c80fc33e46133910538a0b2d Mon Sep 17 00:00:00 2001 From: duane Date: Thu, 1 Jun 2023 08:40:26 -0500 Subject: [PATCH 06/38] Adds help text for `Notify Channel` option --- src/components/notifications/Slack.vue | 3 +++ src/lang/en.json | 1 + 2 files changed, 4 insertions(+) diff --git a/src/components/notifications/Slack.vue b/src/components/notifications/Slack.vue index e99fc31e3..dead709ce 100644 --- a/src/components/notifications/Slack.vue +++ b/src/components/notifications/Slack.vue @@ -29,5 +29,8 @@ +
+ {{ $t("aboutNotifyChannel") }} +
diff --git a/src/lang/en.json b/src/lang/en.json index 10dca0811..6546f0a02 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -626,6 +626,7 @@ "matrixDesc2": "It is highly recommended you create a new user and do not use your own Matrix user's access token as it will allow full access to your account and all the rooms you joined. Instead, create a new user and only invite it to the room that you want to receive the notification in. You can get the access token by running {0}", "Channel Name": "Channel Name", "Notify Channel": "Notify Channel", + "aboutNotifyChannel": "Notify channel will trigger a desktop or mobile notification for all members of the channel, whether their availability is set to active or away.", "Uptime Kuma URL": "Uptime Kuma URL", "Icon Emoji": "Icon Emoji", "signalImportant": "IMPORTANT: You cannot mix groups and numbers in recipients!", From 7cc97834369627c4889021d174915ca1d8365082 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 26 Jun 2023 13:21:51 +0800 Subject: [PATCH 07/38] Fix: Active needs to return bool instead of 0 --- server/model/monitor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 2dfe2e65f..017e6813f 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -155,7 +155,7 @@ class Monitor extends BeanModel { async isActive() { const parentActive = await Monitor.isParentActive(this.id); - return this.active && parentActive; + return (this.active === 1) && parentActive; } /** From 79b38e0e7bf7247da499e7f1266d3e674bfafd55 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 26 Jun 2023 13:23:06 +0800 Subject: [PATCH 08/38] Feat: Improve monitorList filtering --- src/components/MonitorList.vue | 90 ++++-- src/components/MonitorListFilter.vue | 283 +++++++++++++++++++ src/components/MonitorListFilterDropdown.vue | 131 +++++++++ src/mixins/socket.js | 5 +- 4 files changed, 490 insertions(+), 19 deletions(-) create mode 100644 src/components/MonitorListFilter.vue create mode 100644 src/components/MonitorListFilterDropdown.vue diff --git a/src/components/MonitorList.vue b/src/components/MonitorList.vue index c69169ccf..9ee46e243 100644 --- a/src/components/MonitorList.vue +++ b/src/components/MonitorList.vue @@ -1,17 +1,25 @@ @@ -159,8 +205,6 @@ export default { margin: -10px; margin-bottom: 10px; padding: 10px; - display: flex; - justify-content: space-between; .dark & { background-color: $dark-header-bg; @@ -168,6 +212,17 @@ export default { } } +.header-top { + display: flex; + justify-content: space-between; + align-items: center; +} + +.header-filter { + display: flex; + align-items: center; +} + @media (max-width: 770px) { .list-header { margin: -20px; @@ -216,5 +271,4 @@ export default { padding-left: 67px; margin-top: 5px; } - diff --git a/src/components/MonitorListFilter.vue b/src/components/MonitorListFilter.vue new file mode 100644 index 000000000..022f7d919 --- /dev/null +++ b/src/components/MonitorListFilter.vue @@ -0,0 +1,283 @@ + + + + + diff --git a/src/components/MonitorListFilterDropdown.vue b/src/components/MonitorListFilterDropdown.vue new file mode 100644 index 000000000..adf3d6b35 --- /dev/null +++ b/src/components/MonitorListFilterDropdown.vue @@ -0,0 +1,131 @@ + + + + + diff --git a/src/mixins/socket.js b/src/mixins/socket.js index e2834251a..8e078b100 100644 --- a/src/mixins/socket.js +++ b/src/mixins/socket.js @@ -693,9 +693,11 @@ export default { stats() { let result = { + active: 0, up: 0, down: 0, maintenance: 0, + pending: 0, unknown: 0, pause: 0, }; @@ -707,12 +709,13 @@ export default { if (monitor && ! monitor.active) { result.pause++; } else if (beat) { + result.active++; if (beat.status === UP) { result.up++; } else if (beat.status === DOWN) { result.down++; } else if (beat.status === PENDING) { - result.up++; + result.pending++; } else if (beat.status === MAINTENANCE) { result.maintenance++; } else { From cea894cc6d7dcba0ab599f0b85bf5dccb85d899c Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 26 Jun 2023 13:39:19 +0800 Subject: [PATCH 09/38] Chore: Fix lint --- src/components/MonitorListFilterDropdown.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/MonitorListFilterDropdown.vue b/src/components/MonitorListFilterDropdown.vue index adf3d6b35..01b9678f9 100644 --- a/src/components/MonitorListFilterDropdown.vue +++ b/src/components/MonitorListFilterDropdown.vue @@ -48,14 +48,14 @@ export default { .filter-dropdown-menu { z-index: 100; transition: all 0.2s; - padding: 5px 0px !important; + padding: 5px 0 !important; border-radius: 16px; overflow: hidden; position: absolute; - inset: 0px auto auto 0px; - margin: 0px; - transform: translate(0px, 36px); + inset: 0 auto auto 0; + margin: 0; + transform: translate(0, 36px); box-shadow: 0 15px 70px rgba(0, 0, 0, 0.1); visibility: hidden; list-style: none; From f8c9a20afdaae76b3d2307c296f5631beddde27b Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Mon, 26 Jun 2023 13:42:46 +0800 Subject: [PATCH 10/38] Chore: Disable clear filters button --- src/components/MonitorListFilter.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MonitorListFilter.vue b/src/components/MonitorListFilter.vue index 022f7d919..2dcd062fa 100644 --- a/src/components/MonitorListFilter.vue +++ b/src/components/MonitorListFilter.vue @@ -6,6 +6,7 @@ class="clear-filters-btn btn" :class="{ 'active': numFiltersActive > 0}" tabindex="0" + :disabled="numFiltersActive === 0" @click="clearFilters" > From afcfb7e19c85ab6248b542348804a8e4a5d94cc7 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Thu, 29 Jun 2023 04:17:47 +0800 Subject: [PATCH 11/38] Fix: Incorrect data type for DateTime component --- src/pages/StatusPage.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index ca684a1a0..eeddcf7b1 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -325,7 +325,7 @@

-
{{ $t("Last Updated") }}:
+
{{ $t("Last Updated") }}: {{ lastUpdateTimeDisplay }}
{{ $tc("statusPageRefreshIn", [ updateCountdownText]) }}
@@ -360,7 +360,6 @@ import DOMPurify from "dompurify"; import Confirm from "../components/Confirm.vue"; import PublicGroupList from "../components/PublicGroupList.vue"; import MaintenanceTime from "../components/MaintenanceTime.vue"; -import DateTime from "../components/Datetime.vue"; import { getResBaseURL } from "../util-frontend"; import { STATUS_PAGE_ALL_DOWN, STATUS_PAGE_ALL_UP, STATUS_PAGE_MAINTENANCE, STATUS_PAGE_PARTIAL_DOWN, UP, MAINTENANCE } from "../util.ts"; import Tag from "../components/Tag.vue"; @@ -386,7 +385,6 @@ export default { Confirm, PrismEditor, MaintenanceTime, - DateTime, Tag, VueMultiselect }, @@ -583,6 +581,10 @@ export default { return ""; } }, + + lastUpdateTimeDisplay() { + return this.$root.datetime(this.lastUpdateTime); + } }, watch: { From 0e725569e5c93f0e54b27986ad359d396b5a301b Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Thu, 29 Jun 2023 06:50:55 +0800 Subject: [PATCH 12/38] Feat: Add placeholders for badge generator Chore: Save as dev dep. --- config/vite.config.js | 5 +++ package-lock.json | 29 +++++++++++++++++ package.json | 1 + server/config.js | 3 +- src/components/BadgeGeneratorDialog.vue | 42 ++++++++++++++----------- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/config/vite.config.js b/config/vite.config.js index 6e9ebbde8..f9ca0651e 100644 --- a/config/vite.config.js +++ b/config/vite.config.js @@ -3,6 +3,7 @@ import vue from "@vitejs/plugin-vue"; import { defineConfig } from "vite"; import visualizer from "rollup-plugin-visualizer"; import viteCompression from "vite-plugin-compression"; +import commonjs from "vite-plugin-commonjs"; const postCssScss = require("postcss-scss"); const postcssRTLCSS = require("postcss-rtlcss"); @@ -18,6 +19,7 @@ export default defineConfig({ "FRONTEND_VERSION": JSON.stringify(process.env.npm_package_version), }, plugins: [ + commonjs(), vue(), legacy({ targets: [ "since 2015" ], @@ -42,6 +44,9 @@ export default defineConfig({ } }, build: { + commonjsOptions: { + include: [ /.js$/ ], + }, rollupOptions: { output: { manualChunks(id, { getModuleInfo, getModuleIds }) { diff --git a/package-lock.json b/package-lock.json index f3bc2faec..da1eb5903 100644 --- a/package-lock.json +++ b/package-lock.json @@ -114,6 +114,7 @@ "typescript": "~4.4.4", "v-pagination-3": "~0.1.7", "vite": "~3.2.7", + "vite-plugin-commonjs": "^0.8.0", "vite-plugin-compression": "^0.5.1", "vue": "~3.2.47", "vue-chartjs": "~5.2.0", @@ -8528,6 +8529,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/es-module-lexer": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.3.0.tgz", + "integrity": "sha512-vZK7T0N2CBmBOixhmjdqx2gWVbFZ4DXZ/NyRMZVlJXPa7CyFS+/a4QQsDGDQy9ZfEzxFuNEsMLeQJnKP2p5/JA==", + "dev": true + }, "node_modules/es-set-tostringtag": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", @@ -18687,6 +18694,17 @@ } } }, + "node_modules/vite-plugin-commonjs": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/vite-plugin-commonjs/-/vite-plugin-commonjs-0.8.0.tgz", + "integrity": "sha512-55v9Gjp2MpZ0vaDLNRbztI9hiTXaw/aQ8QnqNhGz4lwH0nnYHGeEOjzRS3kTrRljB8m6GQUrgi59UWu6N9KjVQ==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "fast-glob": "^3.2.12", + "vite-plugin-dynamic-import": "^1.4.0" + } + }, "node_modules/vite-plugin-compression": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/vite-plugin-compression/-/vite-plugin-compression-0.5.1.tgz", @@ -18785,6 +18803,17 @@ "node": ">=8" } }, + "node_modules/vite-plugin-dynamic-import": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.4.1.tgz", + "integrity": "sha512-DdAVMCXFK5/IyHLs/l3vciTVCQa5u+C+6mhLOtx82l7MDAPcBAsk36aPd1SLgqm1bCkc7kAC4S5Nqi0dyrlMnQ==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "es-module-lexer": "^1.2.1", + "fast-glob": "^3.2.12" + } + }, "node_modules/vue": { "version": "3.2.47", "resolved": "https://registry.npmjs.org/vue/-/vue-3.2.47.tgz", diff --git a/package.json b/package.json index 1ca874aff..6113e8b99 100644 --- a/package.json +++ b/package.json @@ -173,6 +173,7 @@ "typescript": "~4.4.4", "v-pagination-3": "~0.1.7", "vite": "~3.2.7", + "vite-plugin-commonjs": "^0.8.0", "vite-plugin-compression": "^0.5.1", "vue": "~3.2.47", "vue-chartjs": "~5.2.0", diff --git a/server/config.js b/server/config.js index 43a40f672..77f9e74b3 100644 --- a/server/config.js +++ b/server/config.js @@ -1,4 +1,5 @@ -const args = require("args-parser")(process.argv); +// Interop with browser +const args = (typeof process !== "undefined") ? require("args-parser")(process.argv) : {}; const demoMode = args["demo"] || false; const badgeConstants = { diff --git a/src/components/BadgeGeneratorDialog.vue b/src/components/BadgeGeneratorDialog.vue index 9e073e39a..d9de7a85b 100644 --- a/src/components/BadgeGeneratorDialog.vue +++ b/src/components/BadgeGeneratorDialog.vue @@ -22,78 +22,78 @@
- - + +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
@@ -109,7 +109,11 @@
- + +
+ +
+ Badge Preview
@@ -131,6 +135,7 @@ diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 7b5e6b6c7..673a84a98 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -4,6 +4,7 @@ import AliyunSMS from "./AliyunSms.vue"; import Apprise from "./Apprise.vue"; import Bark from "./Bark.vue"; import ClickSendSMS from "./ClickSendSMS.vue"; +import SMSC from "./SMSC.vue"; import DingDing from "./DingDing.vue"; import Discord from "./Discord.vue"; import Feishu from "./Feishu.vue"; @@ -61,6 +62,7 @@ const NotificationFormList = { "apprise": Apprise, "Bark": Bark, "clicksendsms": ClickSendSMS, + "smsc": SMSC, "DingDing": DingDing, "discord": Discord, "Feishu": Feishu, From be26bb75d9a54debad31a3914bbf072bc929cc7c Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 14 Jul 2023 18:02:49 +0800 Subject: [PATCH 23/38] Update version handling --- server/client.js | 15 ++++++++++++--- server/server.js | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/client.js b/server/client.js index 3efbe8fdc..2e3bd43b7 100644 --- a/server/client.js +++ b/server/client.js @@ -141,12 +141,21 @@ async function sendAPIKeyList(socket) { /** * Emits the version information to the client. * @param {Socket} socket Socket.io socket instance + * @param {boolean} hideVersion * @returns {Promise} */ -async function sendInfo(socket) { +async function sendInfo(socket, hideVersion = false) { + let version; + let latestVersion; + + if (!hideVersion) { + version = checkVersion.version; + latestVersion = checkVersion.latestVersion; + } + socket.emit("info", { - version: checkVersion.version, - latestVersion: checkVersion.latestVersion, + version, + latestVersion, primaryBaseURL: await setting("primaryBaseURL"), serverTimezone: await server.getTimezone(), serverTimezoneOffset: server.getTimezoneOffset(), diff --git a/server/server.js b/server/server.js index b9d618f51..9e34b4e7e 100644 --- a/server/server.js +++ b/server/server.js @@ -263,7 +263,7 @@ let needSetup = false; log.info("server", "Adding socket handler"); io.on("connection", async (socket) => { - sendInfo(socket); + sendInfo(socket, true); if (needSetup) { log.info("server", "Redirect to setup page"); @@ -1651,6 +1651,7 @@ async function afterLogin(socket, user) { socket.join(user.id); let monitorList = await server.sendMonitorList(socket); + sendInfo(socket); server.sendMaintenanceList(socket); sendNotificationList(socket); sendProxyList(socket); From 5c4180fb455a97a21fcc609d8956e686b5984168 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 15 Jul 2023 01:09:09 +0800 Subject: [PATCH 24/38] Merge conflicts --- package-lock.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/package-lock.json b/package-lock.json index ad26942e2..6b9b937ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -116,6 +116,7 @@ "typescript": "~4.4.4", "v-pagination-3": "~0.1.7", "vite": "~4.4.1", + "vite-plugin-commonjs": "^0.8.0", "vite-plugin-compression": "^0.5.1", "vue": "~3.3.4", "vue-chartjs": "~5.2.0", @@ -8751,6 +8752,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/es-module-lexer": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.3.0.tgz", + "integrity": "sha512-vZK7T0N2CBmBOixhmjdqx2gWVbFZ4DXZ/NyRMZVlJXPa7CyFS+/a4QQsDGDQy9ZfEzxFuNEsMLeQJnKP2p5/JA==", + "dev": true + }, "node_modules/es-set-tostringtag": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", @@ -18020,6 +18027,18 @@ } } }, + "node_modules/vite-plugin-commonjs": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/vite-plugin-commonjs/-/vite-plugin-commonjs-0.8.1.tgz", + "integrity": "sha512-hL2wwqgSiLBcrmCH7z+H468Z9uyBnKXX5OAwoYmWd/i03PBGCqkOBR3rjeojyWOoGmWgDVB7lj6Xn5pVw3Fwyg==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "fast-glob": "^3.2.12", + "magic-string": "^0.30.1", + "vite-plugin-dynamic-import": "^1.5.0" + } + }, "node_modules/vite-plugin-compression": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/vite-plugin-compression/-/vite-plugin-compression-0.5.1.tgz", @@ -18118,6 +18137,18 @@ "node": ">=8" } }, + "node_modules/vite-plugin-dynamic-import": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.5.0.tgz", + "integrity": "sha512-Qp85c+AVJmLa8MLni74U4BDiWpUeFNx7NJqbGZyR2XJOU7mgW0cb7nwlAMucFyM4arEd92Nfxp4j44xPi6Fu7g==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "es-module-lexer": "^1.2.1", + "fast-glob": "^3.2.12", + "magic-string": "^0.30.1" + } + }, "node_modules/vue": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/vue/-/vue-3.3.4.tgz", From 5dd4231e565f245c96673cf4d29529a46b3a7955 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 15 Jul 2023 21:24:33 +0800 Subject: [PATCH 25/38] Fix pr-test image --- docker/dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/dockerfile b/docker/dockerfile index 239a0c95e..1bc90f929 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -72,7 +72,6 @@ RUN git clone https://github.com/louislam/uptime-kuma.git . RUN npm ci EXPOSE 3000 3001 -VOLUME ["/app/data"] HEALTHCHECK --interval=60s --timeout=30s --start-period=180s --retries=5 CMD extra/healthcheck CMD ["npm", "run", "start-pr-test"] From b038d093498a7bed68b53c70e3936ebc71fc76b9 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 15 Jul 2023 21:26:41 +0800 Subject: [PATCH 26/38] Minor --- server/uptime-kuma-server.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index 728b8f158..ccf280cf5 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -301,5 +301,4 @@ module.exports = { }; // Must be at the end -const { MonitorType } = require("./monitor-types/monitor-type"); const { RealBrowserMonitorType } = require("./monitor-types/real-browser-monitor-type"); From 357466cc90589356e143eec7dfb67db7e9105e40 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 15 Jul 2023 21:27:39 +0800 Subject: [PATCH 27/38] Minor --- server/uptime-kuma-server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index ccf280cf5..e48dfec22 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -10,7 +10,7 @@ const util = require("util"); const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent"); const { Settings } = require("./settings"); const dayjs = require("dayjs"); -// DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()` +// DO NOT IMPORT HERE IF THE MODULES USED `UptimeKumaServer.getInstance()`, put at the bottom of this file instead. /** * `module.exports` (alias: `server`) should be inside this class, in order to avoid circular dependency issue. @@ -300,5 +300,5 @@ module.exports = { UptimeKumaServer }; -// Must be at the end +// Must be at the end to avoid circular dependencies const { RealBrowserMonitorType } = require("./monitor-types/real-browser-monitor-type"); From 21d556528f121de48968d3b60cb141fac3c5344d Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 15 Jul 2023 23:23:27 +0800 Subject: [PATCH 28/38] Fix #3420 timezone issue (#3425) --- server/uptime-kuma-server.js | 55 ++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index e48dfec22..da86f3b9e 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -262,13 +262,43 @@ class UptimeKumaServer { * @returns {Promise} */ async getTimezone() { + // From process.env.TZ + try { + if (process.env.TZ) { + this.checkTimezone(process.env.TZ); + return process.env.TZ; + } + } catch (e) { + log.warn("timezone", e.message + " in process.env.TZ"); + } + let timezone = await Settings.get("serverTimezone"); - if (timezone) { - return timezone; - } else if (process.env.TZ) { - return process.env.TZ; - } else { - return dayjs.tz.guess(); + + // From Settings + try { + log.debug("timezone", "Using timezone from settings: " + timezone); + if (timezone) { + this.checkTimezone(timezone); + return timezone; + } + } catch (e) { + log.warn("timezone", e.message + " in settings"); + } + + // Guess + try { + let guess = dayjs.tz.guess(); + log.debug("timezone", "Guessing timezone: " + guess); + if (guess) { + this.checkTimezone(guess); + return guess; + } else { + return "UTC"; + } + } catch (e) { + // Guess failed, fall back to UTC + log.debug("timezone", "Guessed an invalid timezone. Use UTC as fallback"); + return "UTC"; } } @@ -280,11 +310,24 @@ class UptimeKumaServer { return dayjs().format("Z"); } + /** + * Throw an error if the timezone is invalid + * @param timezone + */ + checkTimezone(timezone) { + try { + dayjs.utc("2013-11-18 11:55").tz(timezone).format(); + } catch (e) { + throw new Error("Invalid timezone:" + timezone); + } + } + /** * Set the current server timezone and environment variables * @param {string} timezone */ async setTimezone(timezone) { + this.checkTimezone(timezone); await Settings.set("serverTimezone", timezone, "general"); process.env.TZ = timezone; dayjs.tz.setDefault(timezone); From a0eb733d54d45bfc744fede86880f76f49f113a5 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Sun, 16 Jul 2023 08:10:02 +0800 Subject: [PATCH 29/38] Fix: Hide the Delete button correctly --- src/components/TagEditDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TagEditDialog.vue b/src/components/TagEditDialog.vue index bdfbe1322..e601aa426 100644 --- a/src/components/TagEditDialog.vue +++ b/src/components/TagEditDialog.vue @@ -99,7 +99,7 @@