File

src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.ts

Implements

OnInit OnChanges

Metadata

selector cd-rbd-configuration-table
styleUrls ./rbd-configuration-list.component.scss
templateUrl ./rbd-configuration-list.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(formatterService: FormatterService, rbdConfigurationService: RbdConfigurationService, i18n: I18n)
Parameters :
Name Type Optional
formatterService FormatterService No
rbdConfigurationService RbdConfigurationService No
i18n I18n No

Inputs

data
Type : RbdConfigurationEntry[]

Methods

ngOnChanges
ngOnChanges()
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

configurationSourceTpl
Type : TemplateRef<any>
Decorators :
@ViewChild('configurationSourceTpl')
configurationValueTpl
Type : TemplateRef<any>
Decorators :
@ViewChild('configurationValueTpl')
Public formatterService
Type : FormatterService
poolConfigurationColumns
Type : CdTableColumn[]
poolConfTable
Type : TableComponent
Decorators :
@ViewChild('poolConfTable')
Readonly sourceField
Default value : RbdConfigurationSourceField
Readonly typeField
Default value : RbdConfigurationType
import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core';

import { I18n } from '@ngx-translate/i18n-polyfill';
import { TableComponent } from '../../../shared/datatable/table/table.component';
import { CdTableColumn } from '../../../shared/models/cd-table-column';
import {
  RbdConfigurationEntry,
  RbdConfigurationSourceField,
  RbdConfigurationType
} from '../../../shared/models/configuration';
import { RbdConfigurationSourcePipe } from '../../../shared/pipes/rbd-configuration-source.pipe';
import { FormatterService } from '../../../shared/services/formatter.service';
import { RbdConfigurationService } from '../../../shared/services/rbd-configuration.service';

@Component({
  selector: 'cd-rbd-configuration-table',
  templateUrl: './rbd-configuration-list.component.html',
  styleUrls: ['./rbd-configuration-list.component.scss']
})
export class RbdConfigurationListComponent implements OnInit, OnChanges {
  @Input()
  data: RbdConfigurationEntry[];
  poolConfigurationColumns: CdTableColumn[];
  @ViewChild('configurationSourceTpl')
  configurationSourceTpl: TemplateRef<any>;
  @ViewChild('configurationValueTpl')
  configurationValueTpl: TemplateRef<any>;
  @ViewChild('poolConfTable')
  poolConfTable: TableComponent;

  readonly sourceField = RbdConfigurationSourceField;
  readonly typeField = RbdConfigurationType;

  constructor(
    public formatterService: FormatterService,
    private rbdConfigurationService: RbdConfigurationService,
    private i18n: I18n
  ) {}

  ngOnInit() {
    this.poolConfigurationColumns = [
      { prop: 'displayName', name: this.i18n('Name') },
      { prop: 'description', name: this.i18n('Description') },
      { prop: 'name', name: this.i18n('Key') },
      {
        prop: 'source',
        name: this.i18n('Source'),
        cellTemplate: this.configurationSourceTpl,
        pipe: new RbdConfigurationSourcePipe()
      },
      { prop: 'value', name: this.i18n('Value'), cellTemplate: this.configurationValueTpl }
    ];
  }

  ngOnChanges(): void {
    if (!this.data) {
      return;
    }
    // Filter settings out which are not listed in RbdConfigurationService
    this.data = this.data.filter((row) =>
      this.rbdConfigurationService
        .getOptionFields()
        .map((o) => o.name)
        .includes(row.name)
    );
  }
}
<cd-table
  #poolConfTable
  [data]="data"
  [columns]="poolConfigurationColumns"
  identifier="name">
</cd-table>

<ng-template #configurationSourceTpl
             let-row="row"
             let-value="value">

  <div [ngSwitch]="value">
    <span *ngSwitchCase="'global'" i18n>{{ value | titlecase }}</span>
    <strong *ngSwitchCase="'image'" i18n>{{ value | titlecase }}</strong>
    <strong *ngSwitchCase="'pool'" i18n>{{ value | titlecase }}</strong>
  </div>
</ng-template>

<ng-template #configurationValueTpl
             let-row="row"
             let-value="value">
  <div [ngSwitch]="row.type">
    <span *ngSwitchCase="typeField.bps">{{ value | dimlessBinaryPerSecond }}</span>
    <span *ngSwitchCase="typeField.milliseconds">{{ value | milliseconds }}</span>
    <span *ngSwitchCase="typeField.iops">{{ value | iops }}</span>
    <span *ngSwitchDefault>{{ value }}</span>
  </div>
</ng-template>

./rbd-configuration-list.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""