]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix start time format 59727/head
authorIvo Almeida <ialmeida@redhat.com>
Wed, 11 Sep 2024 09:52:37 +0000 (10:52 +0100)
committerIvo Almeida <ialmeida@redhat.com>
Fri, 13 Sep 2024 10:39:18 +0000 (11:39 +0100)
Fixes: https://tracker.ceph.com/issues/68024
Signed-off-by: Ivo Almeida <ialmeida@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-snapshotschedule-form/cephfs-snapshotschedule-form.component.ts

index 14587ebca9566e14235969cceb3aefec63c770c6..da1a3f355c7375d7f6922ccfbfdd6c0b6f03cb54 100644 (file)
@@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component, Inject, OnInit, Optional } from '@angular
 import { AbstractControl, FormArray, FormControl, FormGroup, Validators } from '@angular/forms';
 import { NgbDateStruct, NgbTimeStruct } from '@ng-bootstrap/ng-bootstrap';
 import { padStart, uniq } from 'lodash';
+import moment from 'moment';
 import { Observable, OperatorFunction, of, timer } from 'rxjs';
 import {
   catchError,
@@ -165,29 +166,26 @@ export class CephfsSnapshotscheduleFormComponent extends CdForm implements OnIni
     this.action = this.actionLabels.EDIT;
     this.snapScheduleService.getSnapshotSchedule(this.path, this.fsName, false).subscribe({
       next: (response: SnapshotSchedule[]) => {
-        const first = response.find((x) => x.path === this.path);
+        const schedule = response.find((x) => x.path === this.path);
+        const offset = moment().utcOffset();
+        const startDate = moment
+          .parseZone(schedule.start)
+          .utc()
+          .utcOffset(offset)
+          .local()
+          .format('YYYY-MM-DD HH:mm:ss');
         this.snapScheduleForm.get('directory').disable();
-        this.snapScheduleForm.get('directory').setValue(first.path);
+        this.snapScheduleForm.get('directory').setValue(schedule.path);
         this.snapScheduleForm.get('startDate').disable();
-        this.snapScheduleForm
-          .get('startDate')
-          .setValue(
-            `${new Date(first.start).getUTCFullYear()}-${
-              new Date(first.start).getUTCMonth() + 1
-            }-${new Date(first.start).getUTCDate()} ${new Date(
-              first.start
-            ).getUTCHours()}:${new Date(first.start).getUTCMinutes()}:${new Date(
-              first.start
-            ).getUTCSeconds()}`
-          );
+        this.snapScheduleForm.get('startDate').setValue(startDate);
         this.snapScheduleForm.get('repeatInterval').disable();
-        this.snapScheduleForm.get('repeatInterval').setValue(first.schedule.split('')?.[0]);
+        this.snapScheduleForm.get('repeatInterval').setValue(schedule.schedule.split('')?.[0]);
         this.snapScheduleForm.get('repeatFrequency').disable();
-        this.snapScheduleForm.get('repeatFrequency').setValue(first.schedule.split('')?.[1]);
+        this.snapScheduleForm.get('repeatFrequency').setValue(schedule.schedule.split('')?.[1]);
 
         // retention policies
-        first.retention &&
-          Object.entries(first.retention).forEach(([frequency, interval], idx) => {
+        schedule.retention &&
+          Object.entries(schedule.retention).forEach(([frequency, interval], idx) => {
             const freqKey = Object.keys(RetentionFrequency)[
               Object.values(RetentionFrequency).indexOf(frequency as any)
             ];