mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
* default to all category and fix rounding for progress * Update install-progress.pipe.ts
28 lines
878 B
TypeScript
28 lines
878 B
TypeScript
import { Pipe, PipeTransform } from '@angular/core'
|
|
import { T } from '@start9labs/start-sdk'
|
|
|
|
@Pipe({
|
|
name: 'installingProgressString',
|
|
})
|
|
export class InstallingProgressDisplayPipe implements PipeTransform {
|
|
transform(progress: T.Progress): string {
|
|
if (progress === true) return 'finalizing'
|
|
if (progress === false || progress === null || !progress.total)
|
|
return 'unknown %'
|
|
const percentage = Math.round((100 * progress.done) / progress.total)
|
|
|
|
return percentage < 99 ? String(percentage) + '%' : 'finalizing'
|
|
}
|
|
}
|
|
|
|
@Pipe({
|
|
name: 'installingProgress',
|
|
})
|
|
export class InstallingProgressPipe implements PipeTransform {
|
|
transform(progress: T.Progress): number {
|
|
if (progress === true) return 100
|
|
if (progress === false || progress === null || !progress.total) return 0
|
|
return Math.floor((100 * progress.done) / progress.total)
|
|
}
|
|
}
|