]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { Component, Input, OnChanges } from '@angular/core'; |
2 | ||
3 | @Component({ | |
4 | selector: 'cd-usage-bar', | |
5 | templateUrl: './usage-bar.component.html', | |
6 | styleUrls: ['./usage-bar.component.scss'] | |
7 | }) | |
8 | export class UsageBarComponent implements OnChanges { | |
9 | @Input() | |
10 | totalBytes: number; | |
11 | @Input() | |
12 | usedBytes: number; | |
13 | ||
14 | usedPercentage: number; | |
15 | freePercentage: number; | |
16 | freeBytes: number; | |
17 | ||
18 | constructor() {} | |
19 | ||
20 | ngOnChanges() { | |
21 | this.usedPercentage = Math.round((this.usedBytes / this.totalBytes) * 100); | |
22 | this.freePercentage = 100 - this.usedPercentage; | |
23 | this.freeBytes = this.totalBytes - this.usedBytes; | |
24 | } | |
25 | } |