]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-iqn-settings-modal/iscsi-target-iqn-settings-modal.component.ts
add stop-gap to fix compat with CPUs not supporting SSE 4.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / iscsi-target-iqn-settings-modal / iscsi-target-iqn-settings-modal.component.ts
1 import { Component, OnInit } from '@angular/core';
2 import { FormControl } from '@angular/forms';
3
4 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
5 import _ from 'lodash';
6
7 import { IscsiService } from '~/app/shared/api/iscsi.service';
8 import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
9 import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
10
11 @Component({
12 selector: 'cd-iscsi-target-iqn-settings-modal',
13 templateUrl: './iscsi-target-iqn-settings-modal.component.html',
14 styleUrls: ['./iscsi-target-iqn-settings-modal.component.scss']
15 })
16 export class IscsiTargetIqnSettingsModalComponent implements OnInit {
17 target_controls: FormControl;
18 target_default_controls: any;
19 target_controls_limits: any;
20
21 settingsForm: CdFormGroup;
22
23 constructor(
24 public activeModal: NgbActiveModal,
25 public iscsiService: IscsiService,
26 public actionLabels: ActionLabelsI18n
27 ) {}
28
29 ngOnInit() {
30 const fg: Record<string, FormControl> = {};
31 _.forIn(this.target_default_controls, (_value, key) => {
32 fg[key] = new FormControl(this.target_controls.value[key]);
33 });
34
35 this.settingsForm = new CdFormGroup(fg);
36 }
37
38 save() {
39 const settings = {};
40 _.forIn(this.settingsForm.controls, (control, key) => {
41 if (!(control.value === '' || control.value === null)) {
42 settings[key] = control.value;
43 }
44 });
45
46 this.target_controls.setValue(settings);
47 this.activeModal.close();
48 }
49
50 getTargetControlLimits(setting: string) {
51 if (this.target_controls_limits) {
52 return this.target_controls_limits[setting];
53 }
54 // backward compatibility
55 if (['Yes', 'No'].includes(this.target_default_controls[setting])) {
56 return { type: 'bool' };
57 }
58 return { type: 'int' };
59 }
60 }