All files / src/app/ceph/cluster/osd/osd-pg-scrub-modal osd-pg-scrub-modal.component.ts

94.74% Statements 36/38
73.33% Branches 22/30
80% Functions 4/5
94.29% Lines 33/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 717x   7x 7x 7x   7x 7x 7x 7x   7x 7x 7x             7x             7x 2x     7x 2x   2x     2x 2x 2x 2x 2x   2x 2x 2x 2x     7x 1x   1x       1x   1x       1x             7x  
import { Component, ViewChild } from '@angular/core';
 
import { I18n } from '@ngx-translate/i18n-polyfill';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { forkJoin as observableForkJoin } from 'rxjs';
 
import { ConfigOptionComponent } from '../../../../shared/components/config-option/config-option.component';
import { ActionLabelsI18n } from '../../../../shared/constants/app.constants';
import { NotificationType } from '../../../../shared/enum/notification-type.enum';
import { CdFormGroup } from '../../../../shared/forms/cd-form-group';
import { Permissions } from '../../../../shared/models/permissions';
import { AuthStorageService } from '../../../../shared/services/auth-storage.service';
import { NotificationService } from '../../../../shared/services/notification.service';
import { OsdPgScrubModalOptions } from './osd-pg-scrub-modal.options';
 
@Component({
  selector: 'cd-osd-pg-scrub-modal',
  template: require('./osd-pg-scrub-modal.component.html'),
  styles: []
})
export class OsdPgScrubModalComponent {
  osdPgScrubForm: CdFormGroup;
  action: string;
  resource: string;
  permissions: Permissions;
 
  @ViewChild('basicOptionsValues')
  basicOptionsValues: ConfigOptionComponent;
  basicOptions: Array<string> = OsdPgScrubModalOptions.basicOptions;
 
  @ViewChild('advancedOptionsValues')
  advancedOptionsValues: ConfigOptionComponent;
  advancedOptions: Array<string> = OsdPgScrubModalOptions.advancedOptions;
 
  advancedEnabled = false;
 
  constructor(
    public bsModalRef: BsModalRef,
    private authStorageService: AuthStorageService,
    private notificationService: NotificationService,
    private i18n: I18n,
    public actionLabels: ActionLabelsI18n
  ) {
    this.osdPgScrubForm = new CdFormGroup({});
    this.resource = this.i18n('PG scrub options');
    this.action = this.actionLabels.EDIT;
    this.permissions = this.authStorageService.getPermissions();
  }
 
  submitAction() {
    const observables = [this.basicOptionsValues.saveValues()];
 
    Iif (this.advancedOptionsValues) {
      observables.push(this.advancedOptionsValues.saveValues());
    }
 
    observableForkJoin(observables).subscribe(
      () => {
        this.notificationService.show(
          NotificationType.success,
          this.i18n('Updated PG scrub options')
        );
        this.bsModalRef.hide();
      },
      () => {
        this.bsModalRef.hide();
      }
    );
  }
}