1 import { Component, OnInit } from '@angular/core';
2 import { FormControl } from '@angular/forms';
4 import * as _ from 'lodash';
5 import { BsModalRef } from 'ngx-bootstrap/modal';
7 import { IscsiService } from '../../../shared/api/iscsi.service';
8 import { CdFormGroup } from '../../../shared/forms/cd-form-group';
11 selector: 'cd-iscsi-target-iqn-settings-modal',
12 templateUrl: './iscsi-target-iqn-settings-modal.component.html',
13 styleUrls: ['./iscsi-target-iqn-settings-modal.component.scss']
15 export class IscsiTargetIqnSettingsModalComponent implements OnInit {
16 target_controls: FormControl;
17 target_default_controls: any;
19 settingsForm: CdFormGroup;
22 constructor(public modalRef: BsModalRef, public iscsiService: IscsiService) {}
26 this.helpText = this.iscsiService.targetAdvancedSettings;
28 _.forIn(this.target_default_controls, (_value, key) => {
29 fg[key] = new FormControl(this.target_controls.value[key]);
32 this.settingsForm = new CdFormGroup(fg);
37 _.forIn(this.settingsForm.controls, (control, key) => {
38 if (!(control.value === '' || control.value === null)) {
39 settings[key] = control.value;
43 this.target_controls.setValue(settings);
48 return ['Yes', 'No'].indexOf(this.target_default_controls[control]) !== -1;