Merge remote-tracking branch 'origin/1.21.X'

# Conflicts:
#	package-lock.json
This commit is contained in:
Louis Lam 2023-05-09 00:42:11 +08:00
commit 7f5d0e5490
6 changed files with 22 additions and 21 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "uptime-kuma", "name": "uptime-kuma",
"version": "1.21.2", "version": "1.21.3",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
@ -39,7 +39,7 @@
"build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain", "build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain",
"build-docker-pr-test": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma:pr-test --target pr-test . --push", "build-docker-pr-test": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma:pr-test --target pr-test . --push",
"upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain", "upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain",
"setup": "git checkout 1.21.2 && npm ci --production && npm run download-dist", "setup": "git checkout 1.21.3 && npm ci --production && npm run download-dist",
"download-dist": "node extra/download-dist.js", "download-dist": "node extra/download-dist.js",
"mark-as-nightly": "node extra/mark-as-nightly.js", "mark-as-nightly": "node extra/mark-as-nightly.js",
"reset-password": "node extra/reset-password.js", "reset-password": "node extra/reset-password.js",
@ -119,8 +119,8 @@
"qs": "~6.10.4", "qs": "~6.10.4",
"redbean-node": "~0.2.0", "redbean-node": "~0.2.0",
"redis": "~4.5.1", "redis": "~4.5.1",
"socket.io": "~4.5.3", "socket.io": "~4.6.1",
"socket.io-client": "~4.5.3", "socket.io-client": "~4.6.1",
"socks-proxy-agent": "6.1.1", "socks-proxy-agent": "6.1.1",
"tar": "~6.1.11", "tar": "~6.1.11",
"tcp-ping": "~0.1.1", "tcp-ping": "~0.1.1",

View File

@ -2,7 +2,6 @@ const fs = require("fs");
const { R } = require("redbean-node"); const { R } = require("redbean-node");
const { setSetting, setting } = require("./util-server"); const { setSetting, setting } = require("./util-server");
const { log, sleep } = require("../src/util"); const { log, sleep } = require("../src/util");
const dayjs = require("dayjs");
const knex = require("knex"); const knex = require("knex");
const { PluginsManager } = require("./plugins-manager"); const { PluginsManager } = require("./plugins-manager");

View File

@ -47,7 +47,8 @@ class Maintenance extends BeanModel {
cron: this.cron, cron: this.cron,
duration: this.duration, duration: this.duration,
durationMinutes: parseInt(this.duration / 60), durationMinutes: parseInt(this.duration / 60),
timezone: await this.getTimezone(), timezone: await this.getTimezone(), // Only valid timezone
timezoneOption: this.timezone, // Mainly for dropdown menu, because there is a option "SAME_AS_SERVER"
timezoneOffset: await this.getTimezoneOffset(), timezoneOffset: await this.getTimezoneOffset(),
status: await this.getStatus(), status: await this.getStatus(),
}; };
@ -153,7 +154,7 @@ class Maintenance extends BeanModel {
bean.description = obj.description; bean.description = obj.description;
bean.strategy = obj.strategy; bean.strategy = obj.strategy;
bean.interval_day = obj.intervalDay; bean.interval_day = obj.intervalDay;
bean.timezone = obj.timezone; bean.timezone = obj.timezoneOption;
bean.active = obj.active; bean.active = obj.active;
if (obj.dateRange[0]) { if (obj.dateRange[0]) {
@ -290,7 +291,7 @@ class Maintenance extends BeanModel {
} }
getRunningTimeslot() { getRunningTimeslot() {
let start = dayjs(this.beanMeta.job.nextRun(dayjs().add(-this.duration, "second").format("YYYY-MM-DD HH:mm:ss"))); let start = dayjs(this.beanMeta.job.nextRun(dayjs().add(-this.duration, "second").toDate()));
let end = start.add(this.duration, "second"); let end = start.add(this.duration, "second");
let current = dayjs(); let current = dayjs();
@ -316,7 +317,7 @@ class Maintenance extends BeanModel {
} }
async getTimezone() { async getTimezone() {
if (!this.timezone) { if (!this.timezone || this.timezone === "SAME_AS_SERVER") {
return await UptimeKumaServer.getInstance().getTimezone(); return await UptimeKumaServer.getInstance().getTimezone();
} }
return this.timezone; return this.timezone;

View File

@ -15,7 +15,7 @@ class Opsgenie extends NotificationProvider {
*/ */
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let opsgenieAlertsUrl; let opsgenieAlertsUrl;
let priority = (notification.opsgeniePriority == "") ? 3 : notification.opsgeniePriority; let priority = (!notification.opsgeniePriority) ? 3 : notification.opsgeniePriority;
const textMsg = "Uptime Kuma Alert"; const textMsg = "Uptime Kuma Alert";
try { try {

View File

@ -25,8 +25,11 @@ class Telegram extends NotificationProvider {
return okMsg; return okMsg;
} catch (error) { } catch (error) {
let msg = (error.response.data.description) ? error.response.data.description : "Error without description"; if (error.response && error.response.data && error.response.data.description) {
throw new Error(msg); throw new Error(error.response.data.description);
} else {
throw new Error(error.message);
}
} }
} }
} }

View File

@ -203,8 +203,8 @@
<label for="timezone" class="form-label"> <label for="timezone" class="form-label">
{{ $t("Timezone") }} {{ $t("Timezone") }}
</label> </label>
<select id="timezone" v-model="maintenance.timezone" class="form-select"> <select id="timezone" v-model="maintenance.timezoneOption" class="form-select">
<option :value="null">{{ $t("sameAsServerTimezone") }}</option> <option value="SAME_AS_SERVER">{{ $t("sameAsServerTimezone") }}</option>
<option value="UTC">UTC</option> <option value="UTC">UTC</option>
<option <option
v-for="(timezone, index) in timezoneList" v-for="(timezone, index) in timezoneList"
@ -218,17 +218,17 @@
<!-- Date Range --> <!-- Date Range -->
<div class="my-3"> <div class="my-3">
<label class="form-label">{{ $t("Effective Date Range") }}</label> <label v-if="maintenance.strategy !== 'single'" class="form-label">{{ $t("Effective Date Range") }}</label>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<div class="mb-2">{{ $t("startDateTime") }}</div> <div class="mb-2">{{ $t("startDateTime") }}</div>
<input v-model="maintenance.dateRange[0]" type="datetime-local" class="form-control"> <input v-model="maintenance.dateRange[0]" type="datetime-local" class="form-control" :required="maintenance.strategy === 'single'">
</div> </div>
<div class="col"> <div class="col">
<div class="mb-2">{{ $t("endDateTime") }}</div> <div class="mb-2">{{ $t("endDateTime") }}</div>
<input v-model="maintenance.dateRange[1]" type="datetime-local" class="form-control"> <input v-model="maintenance.dateRange[1]" type="datetime-local" class="form-control" :required="maintenance.strategy === 'single'">
</div> </div>
</div> </div>
</div> </div>
@ -248,7 +248,6 @@
<script> <script>
import { useToast } from "vue-toastification"; import { useToast } from "vue-toastification";
import VueMultiselect from "vue-multiselect"; import VueMultiselect from "vue-multiselect";
import dayjs from "dayjs";
import Datepicker from "@vuepic/vue-datepicker"; import Datepicker from "@vuepic/vue-datepicker";
import { timezoneList } from "../util-frontend"; import { timezoneList } from "../util-frontend";
import cronstrue from "cronstrue/i18n"; import cronstrue from "cronstrue/i18n";
@ -272,7 +271,6 @@ export default {
selectedStatusPages: [], selectedStatusPages: [],
dark: (this.$root.theme === "dark"), dark: (this.$root.theme === "dark"),
neverEnd: false, neverEnd: false,
minDate: this.$root.date(dayjs()) + " 00:00",
lastDays: [ lastDays: [
{ {
langKey: "lastDay1", langKey: "lastDay1",
@ -411,7 +409,7 @@ export default {
cron: "30 3 * * *", cron: "30 3 * * *",
durationMinutes: 60, durationMinutes: 60,
intervalDay: 1, intervalDay: 1,
dateRange: [ this.minDate ], dateRange: [],
timeRange: [{ timeRange: [{
hours: 2, hours: 2,
minutes: 0, minutes: 0,
@ -421,7 +419,7 @@ export default {
}], }],
weekdays: [], weekdays: [],
daysOfMonth: [], daysOfMonth: [],
timezone: null, timezoneOption: null,
}; };
} else if (this.isEdit) { } else if (this.isEdit) {
this.$root.getSocket().emit("getMaintenance", this.$route.params.id, (res) => { this.$root.getSocket().emit("getMaintenance", this.$route.params.id, (res) => {