feat(frontend): modernize Angular app
This commit is contained in:
21
ui/src/app/pipes/eta.pipe.ts
Normal file
21
ui/src/app/pipes/eta.pipe.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Pipe, PipeTransform } from "@angular/core";
|
||||
|
||||
@Pipe({
|
||||
name: 'eta',
|
||||
})
|
||||
export class EtaPipe implements PipeTransform {
|
||||
transform(value: number): string | null {
|
||||
if (value === null) {
|
||||
return null;
|
||||
}
|
||||
if (value < 60) {
|
||||
return `${Math.round(value)}s`;
|
||||
}
|
||||
if (value < 3600) {
|
||||
return `${Math.floor(value/60)}m ${Math.round(value%60)}s`;
|
||||
}
|
||||
const hours = Math.floor(value/3600)
|
||||
const minutes = value % 3600
|
||||
return `${hours}h ${Math.floor(minutes/60)}m ${Math.round(minutes%60)}s`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user