]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/edit-site-name-modal/edit-site-name-modal.component.ts
check in ceph 17.2.3 sources
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / mirroring / edit-site-name-modal / edit-site-name-modal.component.ts
CommitLineData
9f95a23c
TL
1import { Component, OnInit } from '@angular/core';
2import { FormControl } from '@angular/forms';
3
f67539c2 4import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
9f95a23c 5
f67539c2
TL
6import { RbdMirroringService } from '~/app/shared/api/rbd-mirroring.service';
7import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
8import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
9import { FinishedTask } from '~/app/shared/models/finished-task';
10import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
9f95a23c
TL
11
12@Component({
13 selector: 'cd-edit-site-mode-modal',
14 templateUrl: './edit-site-name-modal.component.html',
15 styleUrls: ['./edit-site-name-modal.component.scss']
16})
17export class EditSiteNameModalComponent implements OnInit {
18 siteName: string;
19
20 editSiteNameForm: CdFormGroup;
21
22 constructor(
f67539c2
TL
23 public activeModal: NgbActiveModal,
24 public actionLabels: ActionLabelsI18n,
9f95a23c
TL
25 private rbdMirroringService: RbdMirroringService,
26 private taskWrapper: TaskWrapperService
27 ) {
28 this.createForm();
29 }
30
31 createForm() {
32 this.editSiteNameForm = new CdFormGroup({
33 siteName: new FormControl('', {})
34 });
35 }
36
37 ngOnInit() {
38 this.editSiteNameForm.get('siteName').setValue(this.siteName);
39 this.rbdMirroringService.getSiteName().subscribe((response: any) => {
40 this.editSiteNameForm.get('siteName').setValue(response.site_name);
41 });
42 }
43
44 update() {
45 const action = this.taskWrapper.wrapTaskAroundCall({
46 task: new FinishedTask('rbd/mirroring/site_name/edit', {}),
47 call: this.rbdMirroringService.setSiteName(this.editSiteNameForm.getValue('siteName'))
48 });
49
f67539c2
TL
50 action.subscribe({
51 error: () => this.editSiteNameForm.setErrors({ cdSubmitButton: true }),
52 complete: () => {
9f95a23c 53 this.rbdMirroringService.refresh();
f67539c2 54 this.activeModal.close();
9f95a23c 55 }
f67539c2 56 });
9f95a23c
TL
57 }
58}