Fix `Same As Server Timezone` do not save correctly

pull/3135/head
Louis Lam 2 years ago
parent 72c16c3aa2
commit f0beccf6bf

@ -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]) {
@ -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;

@ -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"
@ -419,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) => {

Loading…
Cancel
Save