]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
310942a590ab707ef5ddd9ec9779af11b709bcef
[ceph-ci.git] /
1 import { Component, OnInit } from '@angular/core';
2
3 import * as _ from 'lodash';
4 import { BsModalRef } from 'ngx-bootstrap/modal';
5
6 import { IscsiService } from '../../../shared/api/iscsi.service';
7
8 @Component({
9   selector: 'cd-iscsi-target-image-settings-modal',
10   templateUrl: './iscsi-target-image-settings-modal.component.html',
11   styleUrls: ['./iscsi-target-image-settings-modal.component.scss']
12 })
13 export class IscsiTargetImageSettingsModalComponent implements OnInit {
14   image: string;
15   imagesSettings: any;
16   disk_default_controls: any;
17   backstores: any;
18
19   model: any;
20   helpText: any;
21
22   constructor(public modalRef: BsModalRef, public iscsiService: IscsiService) {}
23
24   ngOnInit() {
25     this.helpText = this.iscsiService.imageAdvancedSettings;
26
27     this.model = _.cloneDeep(this.imagesSettings[this.image]);
28     _.forEach(this.backstores, (backstore) => {
29       this.model[backstore] = this.model[backstore] || {};
30     });
31   }
32
33   save() {
34     const backstore = this.model.backstore;
35     const settings = {};
36     _.forIn(this.model[backstore], (value, key) => {
37       if (!(value === '' || value === null)) {
38         settings[key] = value;
39       }
40     });
41     this.imagesSettings[this.image]['backstore'] = backstore;
42     this.imagesSettings[this.image][backstore] = settings;
43     this.imagesSettings = { ...this.imagesSettings };
44     this.modalRef.hide();
45   }
46 }