[push type] hide upside down mode, apply primary base url

pull/609/head
LouisLam 3 years ago
parent 3f26327f95
commit fc8d1e78b6

@ -1,6 +1,5 @@
const { setSetting } = require("./util-server"); const { setSetting } = require("./util-server");
const axios = require("axios"); const axios = require("axios");
const { isDev } = require("../src/util");
exports.version = require("../package.json").version; exports.version = require("../package.json").version;
exports.latestVersion = null; exports.latestVersion = null;

@ -4,6 +4,8 @@
const { TimeLogger } = require("../src/util"); const { TimeLogger } = require("../src/util");
const { R } = require("redbean-node"); const { R } = require("redbean-node");
const { io } = require("./server"); const { io } = require("./server");
const { setting } = require("./util-server");
const checkVersion = require("./check-version");
async function sendNotificationList(socket) { async function sendNotificationList(socket) {
const timeLogger = new TimeLogger(); const timeLogger = new TimeLogger();
@ -14,10 +16,10 @@ async function sendNotificationList(socket) {
]); ]);
for (let bean of list) { 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"); timeLogger.print("Send Notification List");
@ -39,7 +41,7 @@ async function sendHeartbeatList(socket, monitorID, toUser = false, overwrite =
LIMIT 100 LIMIT 100
`, [ `, [
monitorID, monitorID,
]) ]);
let result = list.reverse(); let result = list.reverse();
@ -69,7 +71,7 @@ async function sendImportantHeartbeatList(socket, monitorID, toUser = false, ove
LIMIT 500 LIMIT 500
`, [ `, [
monitorID, monitorID,
]) ]);
timeLogger.print(`[Monitor: ${monitorID}] sendImportantHeartbeatList`); 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 = { module.exports = {
sendNotificationList, sendNotificationList,
sendImportantHeartbeatList, sendImportantHeartbeatList,
sendHeartbeatList, sendHeartbeatList,
} sendInfo
};

@ -90,7 +90,7 @@ const io = new Server(server);
module.exports.io = io; module.exports.io = io;
// Must be after io instantiation // 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"); const { statusPageSocketHandler } = require("./socket-handlers/status-page-socket-handler");
app.use(express.json()); app.use(express.json());
@ -180,10 +180,7 @@ exports.entryPage = "dashboard";
console.log("Adding socket handler"); console.log("Adding socket handler");
io.on("connection", async (socket) => { io.on("connection", async (socket) => {
socket.emit("info", { sendInfo(socket);
version: checkVersion.version,
latestVersion: checkVersion.latestVersion,
});
totalClient++; totalClient++;
@ -870,6 +867,8 @@ exports.entryPage = "dashboard";
msg: "Saved" msg: "Saved"
}); });
sendInfo(socket);
} catch (e) { } catch (e) {
callback({ callback({
ok: false, ok: false,

@ -38,11 +38,15 @@ export default {
}, },
baseURL() { baseURL() {
if (this.$root.info.primaryBaseURL) {
return this.$root.info.primaryBaseURL;
}
if (env === "development" || localStorage.dev === "dev") { if (env === "development" || localStorage.dev === "dev") {
return axios.defaults.baseURL; return axios.defaults.baseURL;
} else { } else {
return location.protocol + "//" + location.host; return location.protocol + "//" + location.host;
} }
} },
} }
}; };

@ -131,7 +131,7 @@
<input id="retry-interval" v-model="monitor.retryInterval" type="number" class="form-control" required min="20" step="1"> <input id="retry-interval" v-model="monitor.retryInterval" type="number" class="form-control" required min="20" step="1">
</div> </div>
<h2 class="mt-5 mb-2">{{ $t("Advanced") }}</h2> <h2 v-if="monitor.type !== 'push'" class="mt-5 mb-2">{{ $t("Advanced") }}</h2>
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' " class="my-3 form-check"> <div v-if="monitor.type === 'http' || monitor.type === 'keyword' " class="my-3 form-check">
<input id="ignore-tls" v-model="monitor.ignoreTls" class="form-check-input" type="checkbox" value=""> <input id="ignore-tls" v-model="monitor.ignoreTls" class="form-check-input" type="checkbox" value="">
@ -140,7 +140,7 @@
</label> </label>
</div> </div>
<div class="my-3 form-check"> <div v-if="monitor.type !== 'push'" class="my-3 form-check">
<input id="upside-down" v-model="monitor.upsideDown" class="form-check-input" type="checkbox"> <input id="upside-down" v-model="monitor.upsideDown" class="form-check-input" type="checkbox">
<label class="form-check-label" for="upside-down"> <label class="form-check-label" for="upside-down">
{{ $t("Upside Down Mode") }} {{ $t("Upside Down Mode") }}

Loading…
Cancel
Save