]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-reweight-modal/osd-reweight-modal.component.ts
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / osd / osd-reweight-modal / osd-reweight-modal.component.ts
CommitLineData
11fdf7f2
TL
1import { Component, OnInit } from '@angular/core';
2import { Validators } from '@angular/forms';
3
f67539c2 4import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
11fdf7f2 5
f67539c2
TL
6import { OsdService } from '~/app/shared/api/osd.service';
7import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
8import { CdFormBuilder } from '~/app/shared/forms/cd-form-builder';
9import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
11fdf7f2
TL
10
11@Component({
12 selector: 'cd-osd-reweight-modal',
13 templateUrl: './osd-reweight-modal.component.html',
14 styleUrls: ['./osd-reweight-modal.component.scss']
15})
16export class OsdReweightModalComponent implements OnInit {
17 currentWeight = 1;
18 osdId: number;
19 reweightForm: CdFormGroup;
20
21 constructor(
f67539c2
TL
22 public actionLabels: ActionLabelsI18n,
23 public activeModal: NgbActiveModal,
11fdf7f2
TL
24 private osdService: OsdService,
25 private fb: CdFormBuilder
26 ) {}
27
28 get weight() {
29 return this.reweightForm.get('weight');
30 }
31
32 ngOnInit() {
33 this.reweightForm = this.fb.group({
20effc67 34 weight: this.fb.control(this.currentWeight, [Validators.required])
11fdf7f2
TL
35 });
36 }
37
38 reweight() {
39 this.osdService
40 .reweight(this.osdId, this.reweightForm.value.weight)
f67539c2 41 .subscribe(() => this.activeModal.close());
11fdf7f2
TL
42 }
43}