Skip to content

Commit

Permalink
Fix Same As Server Timezone do not save correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed May 8, 2023
1 parent 72c16c3 commit f0beccf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions server/model/maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class Maintenance extends BeanModel {
cron: this.cron,
duration: this.duration,
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(),
status: await this.getStatus(),
};
Expand Down Expand Up @@ -153,7 +154,7 @@ class Maintenance extends BeanModel {
bean.description = obj.description;
bean.strategy = obj.strategy;
bean.interval_day = obj.intervalDay;
bean.timezone = obj.timezone;
bean.timezone = obj.timezoneOption;
bean.active = obj.active;

if (obj.dateRange[0]) {
Expand Down Expand Up @@ -316,7 +317,7 @@ class Maintenance extends BeanModel {
}

async getTimezone() {
if (!this.timezone) {
if (!this.timezone || this.timezone === "SAME_AS_SERVER") {
return await UptimeKumaServer.getInstance().getTimezone();
}
return this.timezone;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/EditMaintenance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@
<label for="timezone" class="form-label">
{{ $t("Timezone") }}
</label>
<select id="timezone" v-model="maintenance.timezone" class="form-select">
<option :value="null">{{ $t("sameAsServerTimezone") }}</option>
<select id="timezone" v-model="maintenance.timezoneOption" class="form-select">
<option value="SAME_AS_SERVER">{{ $t("sameAsServerTimezone") }}</option>
<option value="UTC">UTC</option>
<option
v-for="(timezone, index) in timezoneList"
Expand Down Expand Up @@ -419,7 +419,7 @@ export default {
}],
weekdays: [],
daysOfMonth: [],
timezone: null,
timezoneOption: null,
};
} else if (this.isEdit) {
this.$root.getSocket().emit("getMaintenance", this.$route.params.id, (res) => {
Expand Down

0 comments on commit f0beccf

Please sign in to comment.