Compare commits

...

4 Commits

Author SHA1 Message Date
Louis Lam
0b1fdebe34 Update dependencies 2024-09-28 03:12:28 +08:00
Louis Lam
1185b259c2 Fix dayjs issue on frontend (#4881) 2024-06-25 18:08:02 +08:00
jmolnar-comparative
a81f949f98 chore: fixed a typo for internal, unused part of the file upload icon for status page (#4757) 2024-05-13 19:24:13 +02:00
Nelson Chan
59f10d542b Fix: Show API Keys disabled msg. when disabled Auth (#4723)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2024-04-30 22:11:09 +02:00
8 changed files with 4363 additions and 2336 deletions

6379
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -78,7 +78,7 @@
"start-server-node14-win": "private\\node14\\node.exe server/server.js" "start-server-node14-win": "private\\node14\\node.exe server/server.js"
}, },
"dependencies": { "dependencies": {
"@grpc/grpc-js": "~1.7.3", "@grpc/grpc-js": "~1.8.22",
"@louislam/ping": "~0.4.4-mod.1", "@louislam/ping": "~0.4.4-mod.1",
"@louislam/sqlite3": "15.1.6", "@louislam/sqlite3": "15.1.6",
"args-parser": "~1.3.0", "args-parser": "~1.3.0",
@@ -97,7 +97,7 @@
"croner": "~6.0.5", "croner": "~6.0.5",
"dayjs": "~1.11.5", "dayjs": "~1.11.5",
"dotenv": "~16.0.3", "dotenv": "~16.0.3",
"express": "~4.19.2", "express": "~4.21.0",
"express-basic-auth": "~1.2.1", "express-basic-auth": "~1.2.1",
"express-static-gzip": "~2.1.7", "express-static-gzip": "~2.1.7",
"form-data": "~4.0.0", "form-data": "~4.0.0",
@@ -138,8 +138,8 @@
"redbean-node": "~0.3.0", "redbean-node": "~0.3.0",
"redis": "~4.5.1", "redis": "~4.5.1",
"semver": "~7.5.4", "semver": "~7.5.4",
"socket.io": "~4.6.1", "socket.io": "~4.8.0",
"socket.io-client": "~4.6.1", "socket.io-client": "~4.8.0",
"socks-proxy-agent": "6.1.1", "socks-proxy-agent": "6.1.1",
"tar": "~6.2.1", "tar": "~6.2.1",
"tcp-ping": "~0.1.1", "tcp-ping": "~0.1.1",
@@ -171,7 +171,7 @@
"cypress": "^13.2.0", "cypress": "^13.2.0",
"delay": "^5.0.0", "delay": "^5.0.0",
"dns2": "~2.0.1", "dns2": "~2.0.1",
"dompurify": "~3.0.11", "dompurify": "~3.1.7",
"eslint": "~8.14.0", "eslint": "~8.14.0",
"eslint-plugin-vue": "~8.7.1", "eslint-plugin-vue": "~8.7.1",
"favico.js": "~0.3.10", "favico.js": "~0.3.10",

View File

@@ -147,7 +147,7 @@ module.exports.statusPageSocketHandler = (socket) => {
config.logo = `/upload/${filename}?t=` + Date.now(); config.logo = `/upload/${filename}?t=` + Date.now();
} else { } else {
config.icon = imgDataUrl; config.logo = imgDataUrl;
} }
statusPage.slug = config.slug; statusPage.slug = config.slug;

View File

@@ -1,53 +1,63 @@
<template> <template>
<div> <div>
<div class="add-btn"> <div
<button class="btn btn-primary me-2" type="button" @click="$refs.apiKeyDialog.show()"> v-if="settings.disableAuth"
<font-awesome-icon icon="plus" /> {{ $t("Add API Key") }} class="mt-5 d-flex align-items-center justify-content-center my-3"
</button> >
{{ $t("apiKeysDisabledMsg") }}
</div> </div>
<div v-else>
<div class="add-btn">
<button class="btn btn-primary me-2" type="button" @click="$refs.apiKeyDialog.show()">
<font-awesome-icon icon="plus" /> {{ $t("Add API Key") }}
</button>
</div>
<div> <div>
<span v-if="Object.keys(keyList).length === 0" class="d-flex align-items-center justify-content-center my-3"> <span
{{ $t("No API Keys") }} v-if="Object.keys(keyList).length === 0"
</span> class="d-flex align-items-center justify-content-center my-3"
>
{{ $t("No API Keys") }}
</span>
<div <div
v-for="(item, index) in keyList" v-for="(item, index) in keyList"
:key="index" :key="index"
class="item" class="item"
:class="item.status" :class="item.status"
> >
<div class="left-part"> <div class="left-part">
<div <div class="circle"></div>
class="circle" <div class="info">
></div> <div class="title">{{ item.name }}</div>
<div class="info"> <div class="status">
<div class="title">{{ item.name }}</div> {{ $t("apiKey-" + item.status) }}
<div class="status"> </div>
{{ $t("apiKey-" + item.status) }} <div class="date">
</div> {{ $t("Created") }}: {{ item.createdDate }}
<div class="date"> </div>
{{ $t("Created") }}: {{ item.createdDate }} <div class="date">
</div> {{ $t("Expires") }}:
<div class="date"> {{ item.expires || $t("Never") }}
{{ $t("Expires") }}: {{ item.expires || $t("Never") }} </div>
</div> </div>
</div> </div>
</div>
<div class="buttons"> <div class="buttons">
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button v-if="item.active" class="btn btn-normal" @click="disableDialog(item.id)"> <button v-if="item.active" class="btn btn-normal" @click="disableDialog(item.id)">
<font-awesome-icon icon="pause" /> {{ $t("Disable") }} <font-awesome-icon icon="pause" /> {{ $t("Disable") }}
</button> </button>
<button v-if="!item.active" class="btn btn-primary" @click="enableKey(item.id)"> <button v-if="!item.active" class="btn btn-primary" @click="enableKey(item.id)">
<font-awesome-icon icon="play" /> {{ $t("Enable") }} <font-awesome-icon icon="play" /> {{ $t("Enable") }}
</button> </button>
<button class="btn btn-danger" @click="deleteDialog(item.id)"> <button class="btn btn-danger" @click="deleteDialog(item.id)">
<font-awesome-icon icon="trash" /> {{ $t("Delete") }} <font-awesome-icon icon="trash" /> {{ $t("Delete") }}
</button> </button>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -90,6 +100,9 @@ export default {
let result = Object.values(this.$root.apiKeyList); let result = Object.values(this.$root.apiKeyList);
return result; return result;
}, },
settings() {
return this.$parent.$parent.$parent.settings;
},
}, },
methods: { methods: {
@@ -127,9 +140,11 @@ export default {
* Pause maintenance * Pause maintenance
*/ */
disableKey() { disableKey() {
this.$root.getSocket().emit("disableAPIKey", this.selectedKeyID, (res) => { this.$root
this.$root.toastRes(res); .getSocket()
}); .emit("disableAPIKey", this.selectedKeyID, (res) => {
this.$root.toastRes(res);
});
}, },
/** /**
@@ -145,113 +160,113 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../../assets/vars.scss"; @import "../../assets/vars.scss";
.mobile {
.item {
flex-direction: column;
align-items: flex-start;
margin-bottom: 20px;
}
}
.add-btn {
padding-top: 20px;
padding-bottom: 20px;
}
.mobile {
.item { .item {
display: flex; flex-direction: column;
align-items: center; align-items: flex-start;
gap: 10px; margin-bottom: 20px;
text-decoration: none; }
border-radius: 10px; }
transition: all ease-in-out 0.15s;
justify-content: space-between;
padding: 10px;
min-height: 90px;
margin-bottom: 5px;
&:hover { .add-btn {
background-color: $highlight-white; padding-top: 20px;
padding-bottom: 20px;
}
.item {
display: flex;
align-items: center;
gap: 10px;
text-decoration: none;
border-radius: 10px;
transition: all ease-in-out 0.15s;
justify-content: space-between;
padding: 10px;
min-height: 90px;
margin-bottom: 5px;
&:hover {
background-color: $highlight-white;
}
&.active {
.circle {
background-color: $primary;
} }
}
&.active { &.inactive {
.circle { .circle {
background-color: $primary; background-color: $danger;
}
}
&.inactive {
.circle {
background-color: $danger;
}
}
&.expired {
.left-part {
opacity: 0.3;
}
.circle {
background-color: $dark-font-color;
}
} }
}
&.expired {
.left-part { .left-part {
display: flex; opacity: 0.3;
gap: 12px;
align-items: center;
.circle {
width: 25px;
height: 25px;
border-radius: 50rem;
}
.info {
.title {
font-weight: bold;
font-size: 20px;
}
.status {
font-size: 14px;
}
}
} }
.buttons { .circle {
display: flex; background-color: $dark-font-color;
gap: 8px; }
flex-direction: row-reverse; }
.btn-group { .left-part {
width: 310px; display: flex;
gap: 12px;
align-items: center;
.circle {
width: 25px;
height: 25px;
border-radius: 50rem;
}
.info {
.title {
font-weight: bold;
font-size: 20px;
}
.status {
font-size: 14px;
} }
} }
} }
.date { .buttons {
margin-top: 5px; display: flex;
display: block; gap: 8px;
font-size: 14px; flex-direction: row-reverse;
background-color: rgba(255, 255, 255, 0.5);
border-radius: 20px;
padding: 0 10px;
width: fit-content;
.dark & { .btn-group {
color: white; width: 310px;
background-color: rgba(255, 255, 255, 0.1);
} }
} }
}
.dark { .date {
.item { margin-top: 5px;
&:hover { display: block;
background-color: $dark-bg2; font-size: 14px;
} background-color: rgba(255, 255, 255, 0.5);
border-radius: 20px;
padding: 0 10px;
width: fit-content;
.dark & {
color: white;
background-color: rgba(255, 255, 255, 0.1);
}
}
.dark {
.item {
&:hover {
background-color: $dark-bg2;
} }
} }
}
</style> </style>

View File

@@ -820,5 +820,6 @@
"showCertificateExpiry": "Show Certificate Expiry", "showCertificateExpiry": "Show Certificate Expiry",
"noOrBadCertificate": "No/Bad Certificate", "noOrBadCertificate": "No/Bad Certificate",
"gamedigGuessPort": "Gamedig: Guess Port", "gamedigGuessPort": "Gamedig: Guess Port",
"gamedigGuessPortDescription": "The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server." "gamedigGuessPortDescription": "The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server.",
"apiKeysDisabledMsg": "API keys are disabled because authentication is disabled."
} }

View File

@@ -6,9 +6,12 @@
// //
// Backend uses the compiled file util.js // Backend uses the compiled file util.js
// Frontend uses util.ts // Frontend uses util.ts
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMaintenanceRelativeURL = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.badgeConstants = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0; exports.localToUTC = exports.utcToLocal = exports.utcToISODateTime = exports.isoToUTCDateTime = exports.parseTimeFromTimeObject = exports.parseTimeObject = exports.getMaintenanceRelativeURL = exports.getMonitorRelativeURL = exports.genSecret = exports.getCryptoRandomInt = exports.getRandomInt = exports.getRandomArbitrary = exports.TimeLogger = exports.polyfill = exports.log = exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.badgeConstants = exports.MIN_INTERVAL_SECOND = exports.MAX_INTERVAL_SECOND = exports.SQL_DATETIME_FORMAT_WITHOUT_SECOND = exports.SQL_DATETIME_FORMAT = exports.SQL_DATE_FORMAT = exports.STATUS_PAGE_MAINTENANCE = exports.STATUS_PAGE_PARTIAL_DOWN = exports.STATUS_PAGE_ALL_UP = exports.STATUS_PAGE_ALL_DOWN = exports.MAINTENANCE = exports.PENDING = exports.UP = exports.DOWN = exports.appName = exports.isDev = void 0;
const dayjs = require("dayjs"); const dayjs_1 = __importDefault(require("dayjs"));
exports.isDev = process.env.NODE_ENV === "development"; exports.isDev = process.env.NODE_ENV === "development";
exports.appName = "Uptime Kuma"; exports.appName = "Uptime Kuma";
exports.DOWN = 0; exports.DOWN = 0;
@@ -129,11 +132,11 @@ class Logger {
module = module.toUpperCase(); module = module.toUpperCase();
level = level.toUpperCase(); level = level.toUpperCase();
let now; let now;
if (dayjs.tz) { if (dayjs_1.default.tz) {
now = dayjs.tz(new Date()).format(); now = dayjs_1.default.tz(new Date()).format();
} }
else { else {
now = dayjs().format(); now = (0, dayjs_1.default)().format();
} }
const formattedMessage = (typeof msg === "string") ? `${now} [${module}] ${level}: ${msg}` : msg; const formattedMessage = (typeof msg === "string") ? `${now} [${module}] ${level}: ${msg}` : msg;
if (level === "INFO") { if (level === "INFO") {
@@ -222,7 +225,7 @@ function polyfill() {
exports.polyfill = polyfill; exports.polyfill = polyfill;
class TimeLogger { class TimeLogger {
constructor() { constructor() {
this.startTime = dayjs().valueOf(); this.startTime = (0, dayjs_1.default)().valueOf();
} }
/** /**
* Output time since start of monitor * Output time since start of monitor
@@ -230,7 +233,7 @@ class TimeLogger {
*/ */
print(name) { print(name) {
if (exports.isDev && process.env.TIMELOGGER === "1") { if (exports.isDev && process.env.TIMELOGGER === "1") {
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms"); console.log(name + ": " + ((0, dayjs_1.default)().valueOf() - this.startTime) + "ms");
} }
} }
} }
@@ -394,21 +397,21 @@ exports.parseTimeFromTimeObject = parseTimeFromTimeObject;
* @returns ISO Date time * @returns ISO Date time
*/ */
function isoToUTCDateTime(input) { function isoToUTCDateTime(input) {
return dayjs(input).utc().format(exports.SQL_DATETIME_FORMAT); return (0, dayjs_1.default)(input).utc().format(exports.SQL_DATETIME_FORMAT);
} }
exports.isoToUTCDateTime = isoToUTCDateTime; exports.isoToUTCDateTime = isoToUTCDateTime;
/** /**
* @param input * @param input
*/ */
function utcToISODateTime(input) { function utcToISODateTime(input) {
return dayjs.utc(input).toISOString(); return dayjs_1.default.utc(input).toISOString();
} }
exports.utcToISODateTime = utcToISODateTime; exports.utcToISODateTime = utcToISODateTime;
/** /**
* For SQL_DATETIME_FORMAT * For SQL_DATETIME_FORMAT
*/ */
function utcToLocal(input, format = exports.SQL_DATETIME_FORMAT) { function utcToLocal(input, format = exports.SQL_DATETIME_FORMAT) {
return dayjs.utc(input).local().format(format); return dayjs_1.default.utc(input).local().format(format);
} }
exports.utcToLocal = utcToLocal; exports.utcToLocal = utcToLocal;
/** /**
@@ -418,6 +421,6 @@ exports.utcToLocal = utcToLocal;
* @returns Date in requested format * @returns Date in requested format
*/ */
function localToUTC(input, format = exports.SQL_DATETIME_FORMAT) { function localToUTC(input, format = exports.SQL_DATETIME_FORMAT) {
return dayjs(input).utc().format(format); return (0, dayjs_1.default)(input).utc().format(format);
} }
exports.localToUTC = localToUTC; exports.localToUTC = localToUTC;

View File

@@ -6,7 +6,7 @@
// Backend uses the compiled file util.js // Backend uses the compiled file util.js
// Frontend uses util.ts // Frontend uses util.ts
import * as dayjs from "dayjs"; import dayjs from "dayjs";
import * as timezone from "dayjs/plugin/timezone"; import * as timezone from "dayjs/plugin/timezone";
import * as utc from "dayjs/plugin/utc"; import * as utc from "dayjs/plugin/utc";

View File

@@ -11,7 +11,8 @@
"removeComments": false, "removeComments": false,
"preserveConstEnums": true, "preserveConstEnums": true,
"sourceMap": false, "sourceMap": false,
"strict": true "strict": true,
"esModuleInterop": true
}, },
"files": [ "files": [
"./src/util.ts" "./src/util.ts"