mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-02 05:23:14 +00:00
Wizard refactor 2 (#615)
* new flow and endpoints * functional * prod build errors addressed * little more cleanup * transfer progress fixed * tor address fix * remove eslint cause sucks * fix skeleton text color and wording Co-authored-by: Matt Hill <matthewonthemoon@gmail.com> Co-authored-by: Drew Ansbacher <drew.ansbacher@spiredigital.com>
This commit is contained in:
committed by
Aiden McClelland
parent
e58df7ec4a
commit
ed395699b3
@@ -1,52 +1,55 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { BehaviorSubject } from 'rxjs'
|
||||
import { ApiService, DiskInfo } from './api/api.service'
|
||||
import { ErrorToastService } from './error-toast.service';
|
||||
import { ErrorToastService } from './error-toast.service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class StateService {
|
||||
hasProductKey: boolean
|
||||
isMigrating: boolean
|
||||
|
||||
polling = false
|
||||
|
||||
storageDrive: DiskInfo;
|
||||
storageDrive: DiskInfo
|
||||
embassyPassword: string
|
||||
recoveryDrive: DiskInfo;
|
||||
recoveryDrive: DiskInfo
|
||||
recoveryPassword: string
|
||||
dataTransferProgress: { bytesTransfered: number; totalBytes: number } | null;
|
||||
dataProgress = 0;
|
||||
dataTransferProgress: { bytesTransferred: number; totalBytes: number } | null
|
||||
dataProgress = 0
|
||||
dataProgSubject = new BehaviorSubject(this.dataProgress)
|
||||
|
||||
torAddress: string
|
||||
|
||||
constructor(
|
||||
constructor (
|
||||
private readonly apiService: ApiService,
|
||||
private readonly errorToastService: ErrorToastService
|
||||
) {}
|
||||
private readonly errorToastService: ErrorToastService,
|
||||
) { }
|
||||
|
||||
async pollDataTransferProgress(callback?: () => void) {
|
||||
async pollDataTransferProgress (callback?: () => void) {
|
||||
this.polling = true
|
||||
await pauseFor(1000)
|
||||
|
||||
if (
|
||||
this.dataTransferProgress?.totalBytes &&
|
||||
this.dataTransferProgress.bytesTransfered === this.dataTransferProgress.totalBytes
|
||||
) {return }
|
||||
|
||||
this.dataTransferProgress.bytesTransferred === this.dataTransferProgress.totalBytes
|
||||
) return
|
||||
|
||||
let progress
|
||||
|
||||
let progress
|
||||
try {
|
||||
progress =await this.apiService.getDataTransferProgress()
|
||||
progress = await this.apiService.getRecoveryStatus()
|
||||
} catch (e) {
|
||||
this.errorToastService.present(`${e.message}: ${e.details}`)
|
||||
}
|
||||
if (progress) {
|
||||
this.dataTransferProgress = {
|
||||
bytesTransfered: progress['bytes-transfered'],
|
||||
totalBytes: progress['total-bytes']
|
||||
bytesTransferred: progress['bytes-transferred'],
|
||||
totalBytes: progress['total-bytes'],
|
||||
}
|
||||
if (this.dataTransferProgress.totalBytes) {
|
||||
this.dataProgress = this.dataTransferProgress.bytesTransfered / this.dataTransferProgress.totalBytes
|
||||
this.dataProgress = this.dataTransferProgress.bytesTransferred / this.dataTransferProgress.totalBytes
|
||||
this.dataProgSubject.next(this.dataProgress)
|
||||
}
|
||||
}
|
||||
@@ -58,13 +61,13 @@ export class StateService {
|
||||
'embassy-logicalname': this.storageDrive.logicalname,
|
||||
'embassy-password': this.embassyPassword,
|
||||
'recovery-logicalname': this.recoveryDrive?.logicalname,
|
||||
'recovery-password': this.recoveryPassword
|
||||
'recovery-password': this.recoveryPassword,
|
||||
})
|
||||
return { torAddress: ret['tor-address'] }
|
||||
return { torAddress: ret }
|
||||
}
|
||||
}
|
||||
|
||||
export const pauseFor = (ms: number) => {
|
||||
const promise = new Promise(resolve => setTimeout(resolve, ms))
|
||||
return promise
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user