1 import { Component, OnInit, inject } from '@angular/core';
2 import { Step } from 'carbon-components-angular';
3 import { Router } from '@angular/router';
5 STEP_TITLES_MIRRORING_CONFIGURED,
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';
13 selector: 'cd-cephfs-mirroring-wizard',
14 templateUrl: './cephfs-mirroring-wizard.component.html',
16 styleUrls: ['./cephfs-mirroring-wizard.component.scss']
18 export class CephfsMirroringWizardComponent implements OnInit {
20 title: string = $localize`Create new CephFS Mirroring`;
21 description: string = $localize`Configure a new mirroring relationship between clusters`;
23 showMessage: boolean = true;
25 LOCAL_ROLE = LOCAL_ROLE;
26 REMOTE_ROLE = REMOTE_ROLE;
28 private wizardStepsService = inject(WizardStepsService);
29 private fb = inject(FormBuilder);
30 private router = inject(Router);
32 sourceList: string[] = [
33 $localize`Sends data to remote clusters`,
34 $localize`Requires bootstrap token from target`,
35 $localize`Manages snapshot schedules`
38 targetList: string[] = [
39 $localize`Receives data from source clusters`,
40 $localize`Generates bootstrap token`,
41 $localize`Stores replicated snapshots`
45 this.form = this.fb.group({
46 localRole: [LOCAL_ROLE],
52 this.wizardStepsService.setTotalSteps(STEP_TITLES_MIRRORING_CONFIGURED.length);
54 const stepsData = this.wizardStepsService.steps$.value;
55 this.steps = STEP_TITLES_MIRRORING_CONFIGURED.map((title, index) => ({
57 onClick: () => this.goToStep(stepsData[index])
61 goToStep(step: WizardStepModel) {
63 this.wizardStepsService.setCurrentStep(step);
68 this.form.patchValue({ localRole: LOCAL_ROLE, remoteRole: null });
69 this.showMessage = false;
72 onRemoteRoleChange() {
73 this.form.patchValue({ localRole: null, remoteRole: REMOTE_ROLE });
74 this.showMessage = true;
80 this.router.navigate(['/cephfs/mirroring']);