Skip to content

Commit 1234ac5

Browse files
authored
Merge pull request ceph#59727 from ivoalmeida/snap-schedule-start-time-fix
mgr/dashboard: fix start time format Reviewed-by: Afreen Misbah <[email protected]>
2 parents fb471bd + 3bb41eb commit 1234ac5

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-snapshotschedule-form/cephfs-snapshotschedule-form.component.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component, Inject, OnInit, Optional } from '@angular
22
import { AbstractControl, FormArray, FormControl, FormGroup, Validators } from '@angular/forms';
33
import { NgbDateStruct, NgbTimeStruct } from '@ng-bootstrap/ng-bootstrap';
44
import { padStart, uniq } from 'lodash';
5+
import moment from 'moment';
56
import { Observable, OperatorFunction, of, timer } from 'rxjs';
67
import {
78
catchError,
@@ -165,29 +166,26 @@ export class CephfsSnapshotscheduleFormComponent extends CdForm implements OnIni
165166
this.action = this.actionLabels.EDIT;
166167
this.snapScheduleService.getSnapshotSchedule(this.path, this.fsName, false).subscribe({
167168
next: (response: SnapshotSchedule[]) => {
168-
const first = response.find((x) => x.path === this.path);
169+
const schedule = response.find((x) => x.path === this.path);
170+
const offset = moment().utcOffset();
171+
const startDate = moment
172+
.parseZone(schedule.start)
173+
.utc()
174+
.utcOffset(offset)
175+
.local()
176+
.format('YYYY-MM-DD HH:mm:ss');
169177
this.snapScheduleForm.get('directory').disable();
170-
this.snapScheduleForm.get('directory').setValue(first.path);
178+
this.snapScheduleForm.get('directory').setValue(schedule.path);
171179
this.snapScheduleForm.get('startDate').disable();
172-
this.snapScheduleForm
173-
.get('startDate')
174-
.setValue(
175-
`${new Date(first.start).getUTCFullYear()}-${
176-
new Date(first.start).getUTCMonth() + 1
177-
}-${new Date(first.start).getUTCDate()} ${new Date(
178-
first.start
179-
).getUTCHours()}:${new Date(first.start).getUTCMinutes()}:${new Date(
180-
first.start
181-
).getUTCSeconds()}`
182-
);
180+
this.snapScheduleForm.get('startDate').setValue(startDate);
183181
this.snapScheduleForm.get('repeatInterval').disable();
184-
this.snapScheduleForm.get('repeatInterval').setValue(first.schedule.split('')?.[0]);
182+
this.snapScheduleForm.get('repeatInterval').setValue(schedule.schedule.split('')?.[0]);
185183
this.snapScheduleForm.get('repeatFrequency').disable();
186-
this.snapScheduleForm.get('repeatFrequency').setValue(first.schedule.split('')?.[1]);
184+
this.snapScheduleForm.get('repeatFrequency').setValue(schedule.schedule.split('')?.[1]);
187185

188186
// retention policies
189-
first.retention &&
190-
Object.entries(first.retention).forEach(([frequency, interval], idx) => {
187+
schedule.retention &&
188+
Object.entries(schedule.retention).forEach(([frequency, interval], idx) => {
191189
const freqKey = Object.keys(RetentionFrequency)[
192190
Object.values(RetentionFrequency).indexOf(frequency as any)
193191
];

0 commit comments

Comments
 (0)