]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/blob
c24710113ea6c79ee9718d2256c0545102907214
[ceph.git] /
1 import { Component, OnInit, inject } from '@angular/core';
2 import { Step } from 'carbon-components-angular';
3 import { Router } from '@angular/router';
4 import {
5   STEP_TITLES_MIRRORING_CONFIGURED,
6   LOCAL_ROLE,
7   REMOTE_ROLE
8 } from './cephfs-mirroring-wizard-step.enum';
9 import { WizardStepsService } from '~/app/shared/services/wizard-steps.service';
10 import { WizardStepModel } from '~/app/shared/models/wizard-steps';
11 import { FormBuilder, FormGroup } from '@angular/forms';
12 @Component({
13   selector: 'cd-cephfs-mirroring-wizard',
14   templateUrl: './cephfs-mirroring-wizard.component.html',
15   standalone: false,
16   styleUrls: ['./cephfs-mirroring-wizard.component.scss']
17 })
18 export class CephfsMirroringWizardComponent implements OnInit {
19   steps: Step[] = [];
20   title: string = $localize`Create new CephFS Mirroring`;
21   description: string = $localize`Configure a new mirroring relationship between clusters`;
22   form: FormGroup;
23   showMessage: boolean = true;
24
25   LOCAL_ROLE = LOCAL_ROLE;
26   REMOTE_ROLE = REMOTE_ROLE;
27
28   private wizardStepsService = inject(WizardStepsService);
29   private fb = inject(FormBuilder);
30   private router = inject(Router);
31
32   sourceList: string[] = [
33     $localize`Sends data to remote clusters`,
34     $localize`Requires bootstrap token from target`,
35     $localize`Manages snapshot schedules`
36   ];
37
38   targetList: string[] = [
39     $localize`Receives data from source clusters`,
40     $localize`Generates bootstrap token`,
41     $localize`Stores replicated snapshots`
42   ];
43
44   constructor() {
45     this.form = this.fb.group({
46       localRole: [LOCAL_ROLE],
47       remoteRole: [null]
48     });
49   }
50
51   ngOnInit() {
52     this.wizardStepsService.setTotalSteps(STEP_TITLES_MIRRORING_CONFIGURED.length);
53
54     const stepsData = this.wizardStepsService.steps$.value;
55     this.steps = STEP_TITLES_MIRRORING_CONFIGURED.map((title, index) => ({
56       label: title,
57       onClick: () => this.goToStep(stepsData[index])
58     }));
59   }
60
61   goToStep(step: WizardStepModel) {
62     if (step) {
63       this.wizardStepsService.setCurrentStep(step);
64     }
65   }
66
67   onLocalRoleChange() {
68     this.form.patchValue({ localRole: LOCAL_ROLE, remoteRole: null });
69     this.showMessage = false;
70   }
71
72   onRemoteRoleChange() {
73     this.form.patchValue({ localRole: null, remoteRole: REMOTE_ROLE });
74     this.showMessage = true;
75   }
76
77   onSubmit() {}
78
79   onCancel() {
80     this.router.navigate(['/cephfs/mirroring']);
81   }
82 }