diff --git a/server/check-version.js b/server/check-version.js index 0da1e3481..2ab5fe514 100644 --- a/server/check-version.js +++ b/server/check-version.js @@ -1,6 +1,5 @@ const { setSetting } = require("./util-server"); const axios = require("axios"); -const { isDev } = require("../src/util"); exports.version = require("../package.json").version; exports.latestVersion = null; diff --git a/server/client.js b/server/client.js index e83d1f59a..c7b3bc162 100644 --- a/server/client.js +++ b/server/client.js @@ -4,6 +4,8 @@ const { TimeLogger } = require("../src/util"); const { R } = require("redbean-node"); const { io } = require("./server"); +const { setting } = require("./util-server"); +const checkVersion = require("./check-version"); async function sendNotificationList(socket) { const timeLogger = new TimeLogger(); @@ -14,10 +16,10 @@ async function sendNotificationList(socket) { ]); for (let bean of list) { - result.push(bean.export()) + result.push(bean.export()); } - io.to(socket.userID).emit("notificationList", result) + io.to(socket.userID).emit("notificationList", result); timeLogger.print("Send Notification List"); @@ -39,7 +41,7 @@ async function sendHeartbeatList(socket, monitorID, toUser = false, overwrite = LIMIT 100 `, [ monitorID, - ]) + ]); let result = list.reverse(); @@ -69,7 +71,7 @@ async function sendImportantHeartbeatList(socket, monitorID, toUser = false, ove LIMIT 500 `, [ monitorID, - ]) + ]); timeLogger.print(`[Monitor: ${monitorID}] sendImportantHeartbeatList`); @@ -81,8 +83,18 @@ async function sendImportantHeartbeatList(socket, monitorID, toUser = false, ove } +async function sendInfo(socket) { + socket.emit("info", { + version: checkVersion.version, + latestVersion: checkVersion.latestVersion, + primaryBaseURL: await setting("primaryBaseURL") + }); +} + module.exports = { sendNotificationList, sendImportantHeartbeatList, sendHeartbeatList, -} + sendInfo +}; + diff --git a/server/server.js b/server/server.js index 55448a79a..ed6fa6df7 100644 --- a/server/server.js +++ b/server/server.js @@ -90,7 +90,7 @@ const io = new Server(server); module.exports.io = io; // Must be after io instantiation -const { sendNotificationList, sendHeartbeatList, sendImportantHeartbeatList } = require("./client"); +const { sendNotificationList, sendHeartbeatList, sendImportantHeartbeatList, sendInfo } = require("./client"); const { statusPageSocketHandler } = require("./socket-handlers/status-page-socket-handler"); app.use(express.json()); @@ -180,10 +180,7 @@ exports.entryPage = "dashboard"; console.log("Adding socket handler"); io.on("connection", async (socket) => { - socket.emit("info", { - version: checkVersion.version, - latestVersion: checkVersion.latestVersion, - }); + sendInfo(socket); totalClient++; @@ -870,6 +867,8 @@ exports.entryPage = "dashboard"; msg: "Saved" }); + sendInfo(socket); + } catch (e) { callback({ ok: false, diff --git a/src/mixins/public.js b/src/mixins/public.js index ba8457a04..a3e12f460 100644 --- a/src/mixins/public.js +++ b/src/mixins/public.js @@ -38,11 +38,15 @@ export default { }, baseURL() { + if (this.$root.info.primaryBaseURL) { + return this.$root.info.primaryBaseURL; + } + if (env === "development" || localStorage.dev === "dev") { return axios.defaults.baseURL; } else { return location.protocol + "//" + location.host; } - } + }, } }; diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 6a72dc82e..b0b0012f2 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -131,7 +131,7 @@ -