<commit_before>import { Component, OnInit } from '@angular/core';
import { Zone } from '../../shared/models/zone.model';
import { ZoneService } from '../../shared/services/zone.service';
import { DiskOffering } from '../../shared/models/disk-offering.model';
import { DiskOfferingService } from '../../shared/services/disk-offering.service';
import { ResourceUsageService } from '../../shared/services/resource-usage.service';
import { MdlDialogReference } from 'angular2-mdl';


@Component({
  selector: 'cs-volume-creation',
  templateUrl: 'volume-creation.component.html',
  styleUrls: ['volume-creation.component.scss']
})
export class VolumeCreationComponent implements OnInit {
  public name: string;
  public zoneId: string;
  public zones: Array<Zone>;
  public diskOfferingId: string;
  public diskOfferings: Array<DiskOffering>;
  public showResizeSlider: boolean;
  public size = 1;

  public minSize = 1;
  public maxSize: number;

  constructor(
    private dialog: MdlDialogReference,
    private diskOfferingService: DiskOfferingService,
    private resourseUsageService: ResourceUsageService,
    private zoneService: ZoneService
  ) {}

  public ngOnInit(): void {
    this.getDiskOfferings();
    this.getZones();
    this.getSizeLimits();
  }

  public onCreate(): void {
    let params = {
      name: this.name,
      zoneId: this.zoneId,
      diskOfferingId: this.diskOfferingId
    };

    if (this.showResizeSlider) {
      params['size'] = this.size;
    }

    this.dialog.hide(params);
  }

  public updateDiskOffering(offering: DiskOffering): void {
    this.diskOfferingId = offering.id;
    this.showResizeSlider = offering.isCustomized;
  }

  private getZones(): void {
    this.zoneService.getList()
      .subscribe(zones => {
        this.zones = zones;
        if (this.zones.length) {
          this.zoneId = this.zones[0].id;
        }
      });
  }

  private getDiskOfferings(): void {
    this.diskOfferingService.getList()
      .subscribe(offerings => {
        this.diskOfferings = offerings;
        if (this.diskOfferings.length) {
          this.diskOfferingId = this.diskOfferings[0].id;
        }
      });
  }

  private getSizeLimits(): void {
    this.resourseUsageService.getResourceUsage()
      .subscribe(resourseUsage => {
        this.minSize = 1;
        this.size = this.minSize;
        this.maxSize = resourseUsage.available.primaryStorage;
      });
  }
}
<commit_msg>fixed volume creation component<commit_after>import { Component, OnInit } from '@angular/core';
import { Zone } from '../../shared/models/zone.model';
import { ZoneService } from '../../shared/services/zone.service';
import { DiskOffering } from '../../shared/models/disk-offering.model';
import { DiskOfferingService } from '../../shared/services/disk-offering.service';
import { ResourceUsageService } from '../../shared/services/resource-usage.service';
import { MdlDialogReference } from 'angular2-mdl';


@Component({
  selector: 'cs-volume-creation',
  templateUrl: 'volume-creation.component.html',
  styleUrls: ['volume-creation.component.scss']
})
export class VolumeCreationComponent implements OnInit {
  public name: string;
  public zoneId: string;
  public zones: Array<Zone>;
  public diskOfferingId: string;
  public diskOfferings: Array<DiskOffering>;
  public showResizeSlider: boolean;
  public size = 1;

  public minSize = 1;
  public maxSize: number;

  constructor(
    private dialog: MdlDialogReference,
    private diskOfferingService: DiskOfferingService,
    private resourceUsageService: ResourceUsageService,
    private zoneService: ZoneService
  ) {}

  public ngOnInit(): void {
    this.getDiskOfferings();
    this.getZones();
    this.getSizeLimits();
  }

  public onCreate(): void {
    let params = {
      name: this.name,
      zoneId: this.zoneId,
      diskOfferingId: this.diskOfferingId
    };

    if (this.showResizeSlider) {
      params['size'] = this.size;
    }

    this.dialog.hide(params);
  }

  public onCancel(): void {
    this.dialog.hide();
  }

  public updateDiskOffering(offering: DiskOffering): void {
    this.diskOfferingId = offering.id;
    this.showResizeSlider = offering.isCustomized;
  }

  private getZones(): void {
    this.zoneService.getList()
      .subscribe(zones => {
        this.zones = zones;
        if (this.zones.length) {
          this.zoneId = this.zones[0].id;
        }
      });
  }

  private getDiskOfferings(): void {
    this.diskOfferingService.getList()
      .subscribe(offerings => {
        this.diskOfferings = offerings;
        if (this.diskOfferings.length) {
          this.diskOfferingId = this.diskOfferings[0].id;
        }
      });
  }

  private getSizeLimits(): void {
    this.resourceUsageService.getResourceUsage()
      .subscribe(resourceUsage => {
        this.minSize = 1;
        this.size = this.minSize;
        this.maxSize = resourceUsage.available.primaryStorage;
      });
  }
}

{'fraction_non_alphanumeric': 0.12796112573395424, 'fraction_numerical': 0.0024296416278598906, 'mean_word_length': 3.126984126984127, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3108840', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1492, 'n_words': 295}