@@ -66,7 +66,7 @@
import HeartbeatBar from "../components/HeartbeatBar.vue";
import Uptime from "../components/Uptime.vue";
import Tag from "../components/Tag.vue";
-import {getMaintenanceRelativeURL, getMonitorRelativeURL } from "../util.ts";
+import { getMaintenanceRelativeURL, getMonitorRelativeURL } from "../util.ts";
export default {
components: {
@@ -90,18 +90,17 @@ export default {
let result = Object.values(this.$root.maintenanceList);
result.sort((m1, m2) => {
- const now = Date.now();
- if (Date.parse(m1.end_date) >= now !== Date.parse(m2.end_date) >= now) {
- if (Date.parse(m2.end_date) < now) {
+ if (this.$root.isActiveMaintenance(m1.end_date) !== this.$root.isActiveMaintenance(m2.end_date)) {
+ if (!this.$root.isActiveMaintenance(m2.end_date)) {
return -1;
}
- if (Date.parse(m1.end_date) < now) {
+ if (!this.$root.isActiveMaintenance(m1.end_date)) {
return 1;
}
}
- if (Date.parse(m1.end_date) >= now && Date.parse(m2.end_date) >= now) {
+ if (this.$root.isActiveMaintenance(m1.end_date) && this.$root.isActiveMaintenance(m2.end_date)) {
if (Date.parse(m1.end_date) < Date.parse(m2.end_date)) {
return -1;
}
@@ -111,7 +110,7 @@ export default {
}
}
- if (Date.parse(m1.end_date) < now && Date.parse(m2.end_date) < now) {
+ if (!this.$root.isActiveMaintenance(m1.end_date) && !this.$root.isActiveMaintenance(m2.end_date)) {
if (Date.parse(m1.end_date) < Date.parse(m2.end_date)) {
return 1;
}
diff --git a/src/mixins/datetime.js b/src/mixins/datetime.js
index 08689520f..3f4749af6 100644
--- a/src/mixins/datetime.js
+++ b/src/mixins/datetime.js
@@ -18,6 +18,14 @@ export default {
},
methods: {
+ isActiveMaintenance(endDate) {
+ return (dayjs.utc(endDate).unix() >= dayjs.utc().unix());
+ },
+
+ toUTC(value) {
+ return dayjs.tz(value, this.timezone).utc().format();
+ },
+
datetime(value) {
return this.datetimeFormat(value, "YYYY-MM-DD HH:mm:ss");
},
@@ -26,10 +34,10 @@ export default {
const inputDate = new Date(value);
const now = new Date(Date.now());
- if (inputDate.getFullYear() === now.getFullYear() && inputDate.getMonth() === now.getMonth() && inputDate.getDay() === now.getDay())
- return this.datetimeMaintenanceFormat(value, "HH:mm");
+ if (inputDate.getFullYear() === now.getUTCFullYear() && inputDate.getMonth() === now.getUTCMonth() && inputDate.getDay() === now.getUTCDay())
+ return this.datetimeFormat(value, "HH:mm");
else
- return this.datetimeMaintenanceFormat(value, "YYYY-MM-DD HH:mm");
+ return this.datetimeFormat(value, "YYYY-MM-DD HH:mm");
},
date(value) {
@@ -52,13 +60,6 @@ export default {
}
return "";
},
-
- datetimeMaintenanceFormat(value, format) {
- if (value !== undefined && value !== "") {
- return dayjs(value).format(format);
- }
- return "";
- }
},
computed: {
diff --git a/src/pages/EditMaintenance.vue b/src/pages/EditMaintenance.vue
index 6b6f80577..e50affaad 100644
--- a/src/pages/EditMaintenance.vue
+++ b/src/pages/EditMaintenance.vue
@@ -50,14 +50,14 @@
-
+
-
+
@@ -156,6 +156,8 @@ export default {
} else if (this.isEdit) {
this.$root.getSocket().emit("getMaintenance", this.$route.params.id, (res) => {
if (res.ok) {
+ res.maintenance.start_date = this.$root.datetimeFormat(res.maintenance.start_date, "YYYY-MM-DDTHH:mm");
+ res.maintenance.end_date = this.$root.datetimeFormat(res.maintenance.end_date, "YYYY-MM-DDTHH:mm");
this.maintenance = res.maintenance;
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
@@ -182,9 +184,11 @@ export default {
return this.processing = false;
}
+ this.maintenance.start_date = this.$root.toUTC(this.maintenance.start_date);
+ this.maintenance.end_date = this.$root.toUTC(this.maintenance.end_date);
+
if (this.isAdd) {
this.$root.addMaintenance(this.maintenance, async (res) => {
-
if (res.ok) {
await this.addMonitorMaintenance(res.maintenanceID, () => {
toast.success(res.msg);
@@ -206,8 +210,7 @@ export default {
this.$root.toastRes(res);
this.init();
});
- }
- else {
+ } else {
this.processing = false;
toast.error(res.msg);
}
diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue
index 11716b454..fdddba74a 100644
--- a/src/pages/StatusPage.vue
+++ b/src/pages/StatusPage.vue
@@ -152,7 +152,7 @@
- {{ $t("End") }}: {{ $root.datetimeMaintenance(maintenanceItem.end_date) }} ({{ dateFromNowMaintenance(maintenanceItem.start_date) }})
+ {{ $t("End") }}: {{ $root.datetimeMaintenance(maintenanceItem.end_date) }} ({{ dateFromNow(maintenanceItem.start_date) }})
@@ -620,10 +620,6 @@ export default {
return dayjs.utc(date).fromNow();
},
- dateFromNowMaintenance(date) {
- return dayjs(date).fromNow();
- },
-
}
};