mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
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:
committed by
Aiden McClelland
parent
dc923ea6fb
commit
4c294566d7
39
ui/src/app/pipes/install-state.pipe.ts
Normal file
39
ui/src/app/pipes/install-state.pipe.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user