Progress bar (#377)

* looking for unnecessary watches

* on init data initialization

* prog pipe

* install progress everywhere

* titlecase status

* include updateing state in app show for install progress

Co-authored-by: Drew Ansbacher <drew.ansbacher@spiredigital.com>
Co-authored-by: Matt Hill <matthewonthemoon@gmail.com>
This commit is contained in:
Drew Ansbacher
2021-07-22 16:14:57 -06:00
committed by Aiden McClelland
parent dc923ea6fb
commit 4c294566d7
17 changed files with 120 additions and 50 deletions

View File

@@ -0,0 +1,39 @@
import { Pipe, PipeTransform } from '@angular/core'
import { InstallProgress } from '../services/patch-db/data-model'
@Pipe({
name: 'installState',
})
export class InstallState implements PipeTransform {
transform (loadData: InstallProgress): ProgressData {
const { downloaded, validated, unpacked, size } = loadData
const downloadWeight = 1
const validateWeight = .2
const unpackWeight = .7
const numerator = Math.floor(
downloadWeight * downloaded +
validateWeight * validated +
unpackWeight * unpacked)
const denominator = Math.floor(loadData.size * (downloadWeight + validateWeight + unpackWeight))
return {
totalProgress: Math.round(100 * numerator / denominator),
downloadProgress: Math.round(100 * downloaded / size),
validateProgress: Math.round(100 * validated / size),
unpackProgress: Math.round(100 * unpacked / size),
isComplete: loadData['download-complete'] && loadData['validation-complete'] && loadData['unpack-complete'],
}
}
}
export interface ProgressData {
totalProgress: number
downloadProgress: number
validateProgress: number
unpackProgress: number
isComplete: boolean
}