Compare commits

...

29 commits

Author SHA1 Message Date
Mohit Nagaraj
663cae443b
Merge ea97159b75 into 46d8744fa4 2024-10-27 05:22:41 +00:00
Louis Lam
46d8744fa4
Fix: Docker Healthcheck is not happy during migration (#5258)
Some checks are pending
Auto Test / auto-test (18, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (18, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (18, windows-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ARM64) (push) Blocked by required conditions
Auto Test / auto-test (20, macos-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, ubuntu-latest) (push) Blocked by required conditions
Auto Test / auto-test (20, windows-latest) (push) Blocked by required conditions
Auto Test / armv7-simple-test (18, ARMv7) (push) Waiting to run
Auto Test / armv7-simple-test (20, ARMv7) (push) Waiting to run
Auto Test / check-linters (push) Waiting to run
Auto Test / e2e-test (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
json-yaml-validate / json-yaml-validate (push) Waiting to run
json-yaml-validate / check-lang-json (push) Waiting to run
2024-10-27 13:22:23 +08:00
Louis Lam
7d8dc55dbe
Fix: the rootless user put in the wrong place (#5257) 2024-10-27 11:47:30 +08:00
Mohit Nagaraj
ea97159b75
Merge branch 'master' into feature-fix-5120 2024-10-22 19:02:10 +05:30
mohit-nagaraj
4c588336d5
Merge branch 'master' of https://github.com/mohit-nagaraj/uptime-kuma into feature-fix-5120 2024-10-20 22:00:48 +05:30
Mohit Nagaraj
6e93ed1392
Merge branch 'master' into master 2024-10-20 21:55:06 +05:30
Mohit Nagaraj
6d25d6d772
Merge branch 'master' into feature-fix-5120 2024-10-18 08:08:29 +05:30
mohit-nagaraj
f65e5e5848
Update NextPingTimer.vue 2024-10-12 13:16:30 +05:30
mohit-nagaraj
a4ab9caa43
FIx 1 2024-10-12 08:50:36 +05:30
mohit-nagaraj
5ce3f0615f
Component breakdown 2024-10-12 08:42:45 +05:30
mohit-nagaraj
d7f9a9b471
lint fixes 2024-10-12 01:11:07 +05:30
mohit-nagaraj
e90965a212
better formatting 2024-10-12 01:08:36 +05:30
mohit-nagaraj
f010d7f874
feat(app): #5120 Upcoming heartbeat timer 2024-10-12 00:54:37 +05:30
mohit-nagaraj
9684d34ad0
Revert "refactor: fix check for empty string"
This reverts commit 949198d09e.
2024-10-11 15:11:13 +05:30
mohit-nagaraj
dcb675a343
update 2024-10-11 14:23:35 +05:30
Mohit Nagaraj
e868ebb68e
Merge branch 'louislam:master' into master 2024-10-11 14:02:19 +05:30
Mohit Nagaraj
adb5cbe425
Merge pull request #1 from mohit-nagaraj/deepsource-autofix-1bba350f
refactor: fix check for empty string
2024-10-11 14:01:58 +05:30
deepsource-autofix[bot]
949198d09e
refactor: fix check for empty string
It is not recommended to use `len` for empty string test.
2024-10-11 08:31:13 +00:00
deepsource-io[bot]
87f3c2ef94
ci: update .deepsource.toml 2024-10-11 07:59:07 +00:00
deepsource-io[bot]
498786eb39
ci: add .deepsource.toml 2024-10-11 07:51:20 +00:00
mohit-nagaraj
95a9e0a096
remove duplicate code 2024-10-08 19:09:21 +05:30
mohit-nagaraj
0d2b380f44
Update NotificationDialog.vue
i hadnt saved this T_T
2024-10-08 09:31:05 +05:30
mohit-nagaraj
56b3cf412b
warnings fix :) 2024-10-08 09:10:36 +05:30
mohit-nagaraj
72849de1b4
fix lint 2024-10-08 08:43:30 +05:30
mohit-nagaraj
e2ce0e38a6
update 2024-10-08 08:23:07 +05:30
mohit-nagaraj
da831893de
fix scroll in notfication 2024-10-08 07:37:35 +05:30
mohit-nagaraj
45b6c8a91d
Fix scroll lock
when the modal is opened, its sets overflow hidden, remove this style so as to unfreeze it
2024-10-08 07:33:18 +05:30
mohit-nagaraj
1dceb96c7c
fix(app): notification modal fix 2024-10-08 07:17:31 +05:30
mohit-nagaraj
401710c3bd
fix(app): Fix proxy modal test 2024-10-08 07:01:49 +05:30
11 changed files with 263 additions and 12 deletions

View file

@ -27,7 +27,6 @@ RUN mkdir ./data
# ⭐ Main Image
############################################
FROM $BASE_IMAGE AS release
USER node
WORKDIR /app
LABEL org.opencontainers.image.source="https://github.com/louislam/uptime-kuma"
@ -46,6 +45,7 @@ CMD ["node", "server/server.js"]
# Rootless Image
############################################
FROM release AS rootless
USER node
############################################
# Mark as Nightly

View file

@ -9,6 +9,7 @@ const mysql = require("mysql2/promise");
const { Settings } = require("./settings");
const { UptimeCalculator } = require("./uptime-calculator");
const dayjs = require("dayjs");
const { SimpleMigrationServer } = require("./utils/simple-migration-server");
/**
* Database & App Data Folder
@ -382,9 +383,11 @@ class Database {
/**
* Patch the database
* @param {number} port Start the migration server for aggregate tables on this port if provided
* @param {string} hostname Start the migration server for aggregate tables on this hostname if provided
* @returns {Promise<void>}
*/
static async patch() {
static async patch(port = undefined, hostname = undefined) {
// Still need to keep this for old versions of Uptime Kuma
if (Database.dbConfig.type === "sqlite") {
await this.patchSqlite();
@ -409,7 +412,7 @@ class Database {
await R.exec("PRAGMA foreign_keys = ON");
}
await this.migrateAggregateTable();
await this.migrateAggregateTable(port, hostname);
} catch (e) {
// Allow missing patch files for downgrade or testing pr.
@ -735,9 +738,11 @@ class Database {
* Normally, it should be in transaction, but UptimeCalculator wasn't designed to be in transaction before that.
* I don't want to heavily modify the UptimeCalculator, so it is not in transaction.
* Run `npm run reset-migrate-aggregate-table-state` to reset, in case the migration is interrupted.
* @param {number} port Start the migration server on this port if provided
* @param {string} hostname Start the migration server on this hostname if provided
* @returns {Promise<void>}
*/
static async migrateAggregateTable() {
static async migrateAggregateTable(port, hostname = undefined) {
log.debug("db", "Enter Migrate Aggregate Table function");
// Add a setting for 2.0.0-dev users to skip this migration
@ -758,6 +763,18 @@ class Database {
throw new Error("Aggregate table migration is already in progress");
}
/**
* Start migration server for displaying the migration status
* @type {SimpleMigrationServer}
*/
let migrationServer;
let msg;
if (port) {
migrationServer = new SimpleMigrationServer();
await migrationServer.start(port, hostname);
}
await Settings.set("migrateAggregateTableState", "migrating");
log.info("db", "Migrating Aggregate Table");
@ -777,6 +794,7 @@ class Database {
let count = countResult.count;
if (count > 0) {
log.warn("db", `Aggregate table ${table} is not empty, migration will not be started (Maybe you were using 2.0.0-dev?)`);
await migrationServer?.stop();
return;
}
}
@ -811,7 +829,9 @@ class Database {
`, [ monitor.monitor_id, date.date ]);
if (heartbeats.length > 0) {
log.info("db", `[DON'T STOP] Migrating monitor data ${monitor.monitor_id} - ${date.date} [${progressPercent.toFixed(2)}%][${i}/${monitors.length}]`);
msg = `[DON'T STOP] Migrating monitor data ${monitor.monitor_id} - ${date.date} [${progressPercent.toFixed(2)}%][${i}/${monitors.length}]`;
log.info("db", msg);
migrationServer?.update(msg);
}
for (let heartbeat of heartbeats) {
@ -829,9 +849,13 @@ class Database {
i++;
}
await Database.clearHeartbeatData(true);
msg = "Clearing non-important heartbeats";
log.info("db", msg);
migrationServer?.update(msg);
await Database.clearHeartbeatData(true);
await Settings.set("migrateAggregateTableState", "migrated");
await migrationServer?.stop();
if (monitors.length > 0) {
log.info("db", "Aggregate Table Migration Completed");

View file

@ -1716,7 +1716,7 @@ async function initDatabase(testMode = false) {
log.info("server", "Connected to the database");
// Patch the database
await Database.patch();
await Database.patch(port, hostname);
let jwtSecretBean = await R.findOne("setting", " `key` = ? ", [
"jwtSecret",

View file

@ -0,0 +1,84 @@
const express = require("express");
const http = require("node:http");
const { log } = require("../../src/util");
/**
* SimpleMigrationServer
* For displaying the migration status of the server
* Also, it is used to let Docker healthcheck know the status of the server, as the main server is not started yet, healthcheck will think the server is down incorrectly.
*/
class SimpleMigrationServer {
/**
* Express app instance
* @type {?Express}
*/
app;
/**
* Server instance
* @type {?Server}
*/
server;
/**
* Response object
* @type {?Response}
*/
response;
/**
* Start the server
* @param {number} port Port
* @param {string} hostname Hostname
* @returns {Promise<void>}
*/
start(port, hostname) {
this.app = express();
this.server = http.createServer(this.app);
this.app.get("/", (req, res) => {
res.set("Content-Type", "text/plain");
res.write("Migration is in progress, listening message...\n");
if (this.response) {
this.response.write("Disconnected\n");
this.response.end();
}
this.response = res;
// never ending response
});
return new Promise((resolve) => {
this.server.listen(port, hostname, () => {
if (hostname) {
log.info("migration", `Migration server is running on http://${hostname}:${port}`);
} else {
log.info("migration", `Migration server is running on http://localhost:${port}`);
}
resolve();
});
});
}
/**
* Update the message
* @param {string} msg Message to update
* @returns {void}
*/
update(msg) {
this.response?.write(msg + "\n");
}
/**
* Stop the server
* @returns {Promise<void>}
*/
async stop() {
this.response?.write("Finished, please refresh this page.\n");
this.response?.end();
await this.server?.close();
}
}
module.exports = {
SimpleMigrationServer,
};

View file

@ -42,6 +42,9 @@ export default {
mounted() {
this.modal = new Modal(this.$refs.modal);
},
beforeUnmount() {
this.cleanupModal();
},
methods: {
/**
* Show the confirm dialog
@ -58,6 +61,19 @@ export default {
this.$emit("added", this.groupName);
this.modal.hide();
},
/**
* Clean up modal and restore scroll behavior
* @returns {void}
*/
cleanupModal() {
if (this.modal) {
try {
this.modal.hide();
} catch (e) {
console.warn("Modal hide failed:", e);
}
}
}
},
};
</script>

View file

@ -0,0 +1,54 @@
<template>
<span class="word">&nbsp;({{ $t("nextCheckIn") }}: {{ formattedTime }})</span>
</template>
<script>
export default {
props: {
/** Time remaining in seconds */
timeRemaining: {
type: Number,
required: true,
},
},
computed: {
/**
* Formatted time remaining
* @returns {string} Formatted time
*/
formattedTime() {
const days = Math.floor(this.timeRemaining / 86400);
const hours = Math.floor((this.timeRemaining % 86400) / 3600);
const minutes = Math.floor((this.timeRemaining % 3600) / 60);
const seconds = this.timeRemaining % 60;
let formattedTime = "";
if (seconds >= 0) {
formattedTime = seconds > 1 ? `${seconds}secs` : `${seconds}sec`;
}
if (minutes > 0) {
formattedTime = minutes > 1 ? `~ ${minutes}mins` : `~ ${minutes}min`;
}
if (hours > 0) {
formattedTime = hours > 1 ? `~ ${hours}hrs` : `~ ${hours}hr`;
}
if (days > 0) {
formattedTime = days > 1 ? `~ ${days}days` : `~ ${days}day`;
}
return formattedTime.trim();
},
},
};
</script>
<style lang="scss" scoped>
@import "../assets/vars.scss";
.word {
color: $secondary-text;
font-size: 12px;
}
</style>

View file

@ -232,6 +232,9 @@ export default {
mounted() {
this.modal = new Modal(this.$refs.modal);
},
beforeUnmount() {
this.cleanupModal();
},
methods: {
/**
@ -336,6 +339,20 @@ export default {
});
} while (this.$root.notificationList.find(it => it.name === name));
return name;
},
/**
* Clean up modal and restore scroll behavior
* @returns {void}
*/
cleanupModal() {
if (this.modal) {
try {
this.modal.hide();
} catch (e) {
console.warn("Modal hide failed:", e);
}
}
}
},
};

View file

@ -125,11 +125,12 @@ export default {
}
};
},
mounted() {
this.modal = new Modal(this.$refs.modal);
},
beforeUnmount() {
this.cleanupModal();
},
methods: {
/**
* Show dialog to confirm deletion
@ -209,6 +210,20 @@ export default {
}
});
},
/**
* Clean up modal and restore scroll behavior
* @returns {void}
*/
cleanupModal() {
if (this.modal) {
try {
this.modal.hide();
} catch (e) {
console.warn("Modal hide failed:", e);
}
}
}
},
};
</script>

View file

@ -248,6 +248,9 @@ export default {
this.modal = new Modal(this.$refs.modal);
this.getExistingTags();
},
beforeUnmount() {
this.cleanupModal();
},
methods: {
/**
* Show the add tag dialog
@ -459,6 +462,19 @@ export default {
this.newTags = [];
this.deleteTags = [];
this.processing = false;
},
/**
* Clean up modal and restore scroll behavior
* @returns {void}
*/
cleanupModal() {
if (this.modal) {
try {
this.modal.hide();
} catch (e) {
console.warn("Modal hide failed:", e);
}
}
}
},
};

View file

@ -1059,6 +1059,7 @@
"RabbitMQ Username": "RabbitMQ Username",
"RabbitMQ Password": "RabbitMQ Password",
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
"nextCheckIn": "Next in ",
"SendGrid API Key": "SendGrid API Key",
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas"
}

View file

@ -76,7 +76,10 @@
<div class="row">
<div class="col-md-8">
<HeartbeatBar :monitor-id="monitor.id" />
<div>
<span class="word">{{ $t("checkEverySecond", [ monitor.interval ]) }}</span>
<span class="word"><NextPingTimer :timeRemaining="timeRemaining" /></span>
</div>
</div>
<div class="col-md-4 text-center">
<span class="badge rounded-pill" :class=" 'bg-' + status.color " style="font-size: 30px;" data-testid="monitor-status">{{ status.text }}</span>
@ -275,6 +278,7 @@ import { useToast } from "vue-toastification";
const toast = useToast();
import Confirm from "../components/Confirm.vue";
import HeartbeatBar from "../components/HeartbeatBar.vue";
import NextPingTimer from "../components/NextPingTimer.vue";
import Status from "../components/Status.vue";
import Datetime from "../components/Datetime.vue";
import CountUp from "../components/CountUp.vue";
@ -293,6 +297,7 @@ import "prismjs/components/prism-css";
import { PrismEditor } from "vue-prism-editor";
import "vue-prism-editor/dist/prismeditor.min.css";
import ScreenshotDialog from "../components/ScreenshotDialog.vue";
import dayjs from "dayjs";
export default {
components: {
@ -300,6 +305,7 @@ export default {
CountUp,
Datetime,
HeartbeatBar,
NextPingTimer,
Confirm,
Status,
Pagination,
@ -313,6 +319,7 @@ export default {
return {
page: 1,
perPage: 25,
timeRemaining: 0,
heartBeatList: [],
toggleCertInfoBox: false,
showPingChartBox: true,
@ -340,6 +347,8 @@ export default {
// Also trigger screenshot refresh here
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.cacheTime = Date.now();
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.timeRemaining = this.monitor.interval;
if (this.monitor.id in this.$root.lastHeartbeatList && this.$root.lastHeartbeatList[this.monitor.id]) {
return this.$root.lastHeartbeatList[this.monitor.id];
@ -399,7 +408,7 @@ export default {
screenshotURL() {
return getResBaseURL() + this.monitor.screenshot + "?time=" + this.cacheTime;
}
},
},
watch: {
@ -419,7 +428,14 @@ export default {
this.loadPushExample();
},
},
created() {
if (this.lastHeartBeat.end_time) {
const lastpingtime = dayjs().utc().diff(dayjs.utc(this.lastHeartBeat.end_time), "seconds");
this.timeRemaining = this.monitor.interval - lastpingtime;
} else {
this.timeRemaining = this.monitor.interval;
}
},
mounted() {
this.getImportantHeartbeatListLength();
@ -431,10 +447,17 @@ export default {
}
this.loadPushExample();
}
this.interval = setInterval(() => {
if (this.timeRemaining > 1) {
this.timeRemaining--;
}
}, 1000);
},
beforeUnmount() {
this.$root.emitter.off("newImportantHeartbeat", this.onNewImportantHeartbeat);
clearInterval(this.interval);
},
methods: {
@ -464,6 +487,7 @@ export default {
this.$root.getSocket().emit("resumeMonitor", this.monitor.id, (res) => {
this.$root.toastRes(res);
});
this.timeRemaining = this.monitor.interval;
},
/**