RED-6830: File size format pipe

This commit is contained in:
Adina Țeudan 2023-06-27 14:58:50 +03:00
parent 02d0089d0d
commit aa4516286e
2 changed files with 15 additions and 0 deletions

View File

@ -2,3 +2,4 @@ export * from './log.pipe';
export * from './humanize-camel-case.pipe';
export * from './capitalize.pipe';
export * from './humanize.pipe';
export * from './size.pipe';

View File

@ -0,0 +1,14 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'size',
standalone: true,
})
export class SizePipe implements PipeTransform {
transform(value: number): string {
if (value >= 1000 ** 3) {
return `${(value / 1000 ** 3).toFixed(2)} GB`;
}
return `${(value / 1000 ** 2).toFixed(2)} MB`;
}
}