mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
load service checkpoint
This commit is contained in:
committed by
Aiden McClelland
parent
0572855734
commit
24bb9125db
@@ -208,25 +208,14 @@ export class AppComponent {
|
||||
case ConnectionFailure.Diagnosing:
|
||||
message = new IonicSafeString('Running network diagnostics <ion-spinner style="padding: 0; margin: 0" name="dots"></ion-spinner>')
|
||||
break
|
||||
case ConnectionFailure.Embassy:
|
||||
message = 'Embassy appears to be offline.'
|
||||
link = 'https://docs.start9.com/support/FAQ/setup-faq.html#embassy-offline'
|
||||
break
|
||||
case ConnectionFailure.Tor:
|
||||
message = 'Browser unable to connect over Tor.'
|
||||
link = 'https://docs.start9.com/support/FAQ/setup-faq.html#tor-failure'
|
||||
break
|
||||
case ConnectionFailure.Internet:
|
||||
message = 'Phone or computer has no Internet.'
|
||||
break
|
||||
case ConnectionFailure.Lan:
|
||||
message = 'Embassy not found on Local Area Network.'
|
||||
link = 'https://docs.start9.com/support/FAQ/setup-faq.html#lan-failure'
|
||||
break
|
||||
case ConnectionFailure.Unknown:
|
||||
message = 'Unknown connection error. Please refresh the page.'
|
||||
link = 'https://docs.start9.com/support/FAQ/setup-faq.html#unknown-failure'
|
||||
break
|
||||
}
|
||||
await this.presentToastOffline(message, link)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { FEStatus, PkgStatusRendering, renderPkgStatus } from 'src/app/services/
|
||||
import { ConnectionFailure, ConnectionService } from 'src/app/services/connection.service'
|
||||
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
||||
import { AppConfigPage } from 'src/app/modals/app-config/app-config.page'
|
||||
import { PackageLoadingService } from 'src/app/services/package-loading.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-show',
|
||||
@@ -47,6 +48,7 @@ export class AppShowPage {
|
||||
private readonly embassyApi: ApiService,
|
||||
private readonly wizardBaker: WizardBaker,
|
||||
private readonly config: ConfigService,
|
||||
private readonly packageLoadingService: PackageLoadingService,
|
||||
public readonly patch: PatchDbService,
|
||||
public readonly connectionService: ConnectionService,
|
||||
) { }
|
||||
|
||||
@@ -1536,10 +1536,6 @@ export module Mock {
|
||||
// disk: '1TB SSD',
|
||||
// memory: '8GB',
|
||||
// },
|
||||
// 'connection-addresses': {
|
||||
// tor: ['http://privacy34kn4ez3y3nijweec6w4g54i3g54sdv7r5mr6soma3w4begyd.onion'],
|
||||
// clearnet: ['https://start9.com'],
|
||||
// },
|
||||
// },
|
||||
// 'package-data': {
|
||||
// 'bitcoind': bitcoind,
|
||||
|
||||
@@ -107,7 +107,7 @@ export module RR {
|
||||
|
||||
// ssh
|
||||
|
||||
export type GetSSHKeysReq = { } // ssh.get
|
||||
export type GetSSHKeysReq = { } // ssh.list
|
||||
export type GetSSHKeysRes = SSHKeys
|
||||
|
||||
export type AddSSHKeyReq = { pubkey: string } // ssh.add
|
||||
|
||||
@@ -171,7 +171,7 @@ export class LiveApiService extends ApiService {
|
||||
// ssh
|
||||
|
||||
async getSshKeys (params: RR.GetSSHKeysReq): Promise <RR.GetSSHKeysRes> {
|
||||
return this.http.rpcRequest({ method: 'ssh.get', params })
|
||||
return this.http.rpcRequest({ method: 'ssh.list', params })
|
||||
}
|
||||
|
||||
async addSshKey (params: RR.AddSSHKeyReq): Promise <RR.AddSSHKeyRes> {
|
||||
|
||||
@@ -39,13 +39,8 @@ export class ConnectionService {
|
||||
.pipe(
|
||||
distinctUntilChanged(),
|
||||
),
|
||||
// 3
|
||||
this.patch.watch$('server-info', 'connection-addresses')
|
||||
.pipe(
|
||||
distinctUntilChanged(),
|
||||
),
|
||||
])
|
||||
.subscribe(async ([network, patchConnection, addrs]) => {
|
||||
.subscribe(async ([network, patchConnection]) => {
|
||||
if (patchConnection !== PatchConnection.Disconnected) {
|
||||
this.connectionFailure$.next(ConnectionFailure.None)
|
||||
} else if (!network) {
|
||||
@@ -53,58 +48,17 @@ export class ConnectionService {
|
||||
} else if (!this.configService.isTor()) {
|
||||
this.connectionFailure$.next(ConnectionFailure.Lan)
|
||||
} else {
|
||||
// diagnosing
|
||||
this.connectionFailure$.next(ConnectionFailure.Diagnosing)
|
||||
|
||||
if (!addrs) {
|
||||
this.connectionFailure$.next(ConnectionFailure.Unknown)
|
||||
} else {
|
||||
const torSuccess = await this.testAddrs(addrs.tor)
|
||||
if (torSuccess) {
|
||||
// TOR SUCCESS, EMBASSY IS PROBLEM
|
||||
this.connectionFailure$.next(ConnectionFailure.Embassy)
|
||||
} else {
|
||||
const clearnetSuccess = await this.testAddrs(addrs.clearnet)
|
||||
if (clearnetSuccess) {
|
||||
// CLEARNET SUCCESS, TOR IS PROBLEM
|
||||
this.connectionFailure$.next(ConnectionFailure.Tor)
|
||||
} else {
|
||||
// INTERNET IS PROBLEM
|
||||
this.connectionFailure$.next(ConnectionFailure.Internet)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.connectionFailure$.next(ConnectionFailure.Tor)
|
||||
}
|
||||
})
|
||||
return [sub1, sub2]
|
||||
}
|
||||
|
||||
private async testAddrs (addrs: string[]): Promise<boolean> {
|
||||
if (!addrs.length) return true
|
||||
|
||||
const results = await Promise.all(addrs.map(async addr => {
|
||||
try {
|
||||
await this.httpService.httpRequest({
|
||||
method: Method.GET,
|
||||
url: addr,
|
||||
withCredentials: false,
|
||||
})
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}))
|
||||
return results.includes(true)
|
||||
}
|
||||
}
|
||||
|
||||
export enum ConnectionFailure {
|
||||
None = 'none',
|
||||
Diagnosing = 'diagnosing',
|
||||
Network = 'network',
|
||||
Embassy = 'embassy',
|
||||
Tor = 'tor',
|
||||
Lan = 'lan',
|
||||
Internet = 'internet',
|
||||
Unknown = 'unknown',
|
||||
}
|
||||
|
||||
45
ui/src/app/services/package-loading.service.ts
Normal file
45
ui/src/app/services/package-loading.service.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { InstallProgress } from './patch-db/data-model'
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PackageLoadingService {
|
||||
constructor () { }
|
||||
|
||||
transform (loadData: InstallProgress): ProgressData {
|
||||
console.log('LOAD DATA', loadData)
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ProgressData {
|
||||
totalProgress: number
|
||||
downloadProgress: number
|
||||
validateProgress: number
|
||||
unpackProgress: number
|
||||
isComplete: boolean
|
||||
}
|
||||
@@ -25,10 +25,6 @@ export interface ServerInfo {
|
||||
disk: string
|
||||
memory: string
|
||||
}
|
||||
'connection-addresses': {
|
||||
tor: string[]
|
||||
clearnet: string[]
|
||||
}
|
||||
}
|
||||
|
||||
export enum ServerStatus {
|
||||
|
||||
Reference in New Issue
Block a user