File

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

Implements

OnChanges

Metadata

selector cd-usage-bar
styleUrls ./usage-bar.component.scss
templateUrl ./usage-bar.component.html

Index

Properties
Methods
Inputs

Constructor

constructor()

Inputs

totalBytes
Type : number
usedBytes
Type : number

Methods

ngOnChanges
ngOnChanges()
Returns : void

Properties

freeBytes
Type : number
freePercentage
Type : number
usedPercentage
Type : number
import { Component, Input, OnChanges } from '@angular/core';

@Component({
  selector: 'cd-usage-bar',
  templateUrl: './usage-bar.component.html',
  styleUrls: ['./usage-bar.component.scss']
})
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;
  }
}
<ng-template #usageTooltipTpl>
  <table>
    <tr>
      <td class="text-left">Used:&nbsp;</td>
      <td class="text-right"><strong> {{ usedBytes | dimlessBinary }}</strong></td>
    </tr>
    <tr>
      <td class="text-left">Free:&nbsp;</td>
      <td class="'text-right"><strong>{{ freeBytes | dimlessBinary }}</strong></td>
    </tr>
  </table>
</ng-template>

<div class="progress oaprogress"
     data-placement="left"
     [tooltip]="usageTooltipTpl">
  <div class="progress-bar progress-bar-info"
       role="progressbar"
       [style.width]="usedPercentage + '%'">
    <span>{{ usedPercentage }}%</span>
  </div>
  <div class="progress-bar progress-bar-freespace"
       role="progressbar"
       [style.width]="freePercentage + '%'">
  </div>
</div>

./usage-bar.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""