]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / iscsi-target-image-settings-modal / iscsi-target-image-settings-modal.component.ts
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 }