mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
squashing the bugs
This commit is contained in:
committed by
Aiden McClelland
parent
7756841b1e
commit
d47dd28384
@@ -1,4 +1,5 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core'
|
||||
import { PackageLoadingService, ProgressData } from '../services/package-loading.service'
|
||||
import { InstallProgress } from '../services/patch-db/data-model'
|
||||
|
||||
@Pipe({
|
||||
@@ -6,37 +7,11 @@ import { InstallProgress } from '../services/patch-db/data-model'
|
||||
})
|
||||
export class InstallState implements PipeTransform {
|
||||
|
||||
constructor (
|
||||
private readonly pkgLoading: PackageLoadingService,
|
||||
) { }
|
||||
|
||||
transform (loadData: InstallProgress): ProgressData {
|
||||
let { downloaded, validated, unpacked, size, 'download-complete': downloadComplete, 'validation-complete': validationComplete, 'unpack-complete': unpackComplete } = loadData
|
||||
downloaded = downloadComplete ? size : downloaded
|
||||
validated = validationComplete ? size : validated
|
||||
unpacked = unpackComplete ? size : unpacked
|
||||
|
||||
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: downloadComplete && validationComplete && unpackComplete,
|
||||
}
|
||||
return this.pkgLoading.transform(loadData)
|
||||
}
|
||||
}
|
||||
|
||||
export interface ProgressData {
|
||||
totalProgress: number
|
||||
downloadProgress: number
|
||||
validateProgress: number
|
||||
unpackProgress: number
|
||||
isComplete: boolean
|
||||
}
|
||||
Reference in New Issue
Block a user