All files / src/app/shared/components/usage-bar usage-bar.component.ts

72.73% Statements 8/11
100% Branches 0/0
66.67% Functions 2/3
66.67% Lines 6/9

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 2697x             97x   97x   97x               97x         97x  
import { Component, Input, OnChanges } from '@angular/core';
 
@Component({
  selector: 'cd-usage-bar',
  template: require('./usage-bar.component.html'),
  styles: []
})
export class UsageBarComponent implements OnChanges {
  @Input()
  totalBytes: number;
  @Input()
  usedBytes: number;
 
  usedPercentage: number;
  freePercentage: number;
  freeBytes: number;
 
  constructor() {}
 
  ngOnChanges() {
    this.usedPercentage = Math.round((this.usedBytes / this.totalBytes) * 100);
    this.freePercentage = 100 - this.usedPercentage;
    this.freeBytes = this.totalBytes - this.usedBytes;
  }
}