]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-reweight-modal/osd-reweight-modal.component.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / osd / osd-reweight-modal / osd-reweight-modal.component.ts
1 import { Component, OnInit } from '@angular/core';
2 import { Validators } from '@angular/forms';
3
4 import { BsModalRef } from 'ngx-bootstrap/modal';
5
6 import { OsdService } from '../../../../shared/api/osd.service';
7 import { CdFormBuilder } from '../../../../shared/forms/cd-form-builder';
8 import { CdFormGroup } from '../../../../shared/forms/cd-form-group';
9
10 @Component({
11 selector: 'cd-osd-reweight-modal',
12 templateUrl: './osd-reweight-modal.component.html',
13 styleUrls: ['./osd-reweight-modal.component.scss']
14 })
15 export class OsdReweightModalComponent implements OnInit {
16 currentWeight = 1;
17 osdId: number;
18 reweightForm: CdFormGroup;
19
20 constructor(
21 public bsModalRef: BsModalRef,
22 private osdService: OsdService,
23 private fb: CdFormBuilder
24 ) {}
25
26 get weight() {
27 return this.reweightForm.get('weight');
28 }
29
30 ngOnInit() {
31 this.reweightForm = this.fb.group({
32 weight: this.fb.control(this.currentWeight, [
33 Validators.required,
34 Validators.max(1),
35 Validators.min(0)
36 ])
37 });
38 }
39
40 reweight() {
41 this.osdService
42 .reweight(this.osdId, this.reweightForm.value.weight)
43 .subscribe(() => this.bsModalRef.hide());
44 }
45 }