File

src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.ts

Implements

OnInit

Metadata

selector cd-iscsi-target-image-settings-modal
styleUrls ./iscsi-target-image-settings-modal.component.scss
templateUrl ./iscsi-target-image-settings-modal.component.html

Index

Properties
Methods

Constructor

constructor(modalRef: BsModalRef, iscsiService: IscsiService)
Parameters :
Name Type Optional
modalRef BsModalRef No
iscsiService IscsiService No

Methods

ngOnInit
ngOnInit()
Returns : void
save
save()
Returns : void

Properties

backstores
Type : any
disk_default_controls
Type : any
helpText
Type : any
image
Type : string
imagesSettings
Type : any
Public iscsiService
Type : IscsiService
Public modalRef
Type : BsModalRef
model
Type : any
import { Component, OnInit } from '@angular/core';

import * as _ from 'lodash';
import { BsModalRef } from 'ngx-bootstrap/modal';

import { IscsiService } from '../../../shared/api/iscsi.service';

@Component({
  selector: 'cd-iscsi-target-image-settings-modal',
  templateUrl: './iscsi-target-image-settings-modal.component.html',
  styleUrls: ['./iscsi-target-image-settings-modal.component.scss']
})
export class IscsiTargetImageSettingsModalComponent implements OnInit {
  image: string;
  imagesSettings: any;
  disk_default_controls: any;
  backstores: any;

  model: any;
  helpText: any;

  constructor(public modalRef: BsModalRef, public iscsiService: IscsiService) {}

  ngOnInit() {
    this.helpText = this.iscsiService.imageAdvancedSettings;

    this.model = _.cloneDeep(this.imagesSettings[this.image]);
    _.forEach(this.backstores, (backstore) => {
      this.model[backstore] = this.model[backstore] || {};
    });
  }

  save() {
    const backstore = this.model.backstore;
    const settings = {};
    _.forIn(this.model[backstore], (value, key) => {
      if (!(value === '' || value === null)) {
        settings[key] = value;
      }
    });
    this.imagesSettings[this.image]['backstore'] = backstore;
    this.imagesSettings[this.image][backstore] = settings;
    this.imagesSettings = { ...this.imagesSettings };
    this.modalRef.hide();
  }
}
<cd-modal>
  <ng-container class="modal-title">
    <ng-container i18n>Settings</ng-container>&nbsp;
    <small>{{ image }}</small>
  </ng-container>

  <ng-container class="modal-content">
    <div class="modal-body">
      <p class="alert-warning"
         i18n>Changing these parameters from their default values is usually not necessary.</p>

      <!-- BACKSTORE -->
      <div class="form-group row"
           *ngIf="backstores.length > 1">
        <div class="col-sm-12">
          <label class="control-label"
                 i18n>Backstore</label>
          <select id="backstore"
                  name="backstore"
                  class="form-control"
                  [(ngModel)]="model.backstore">
            <option *ngFor="let bs of backstores"
                    [value]="bs">{{ bs }}</option>
          </select>
        </div>
      </div>

      <!-- CONTROLS -->
      <ng-container *ngFor="let bs of backstores">
        <ng-container *ngIf="model.backstore === bs">
          <div class="form-group row"
               *ngFor="let setting of disk_default_controls[bs] | keyvalue">
            <div class="col-sm-12">
              <label class="control-label"
                     for="{{ setting.key }}">{{ setting.key }}</label>
              <input type="number"
                     class="form-control"
                     [(ngModel)]="model[bs][setting.key]">
              <span class="help-block">{{ helpText[setting.key]?.help }}</span>
            </div>
          </div>
        </ng-container>
      </ng-container>
    </div>

    <div class="modal-footer">
      <div class="button-group text-right">
        <button class="btn btn-sm btn-primary"
                (click)="save()"
                i18n>Confirm</button>
        <cd-back-button [back]="modalRef.hide"
                        name="Cancel"
                        i18n-name>
        </cd-back-button>
      </div>
    </div>
  </ng-container>
</cd-modal>

./iscsi-target-image-settings-modal.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""