mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +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:
|
case ConnectionFailure.Diagnosing:
|
||||||
message = new IonicSafeString('Running network diagnostics <ion-spinner style="padding: 0; margin: 0" name="dots"></ion-spinner>')
|
message = new IonicSafeString('Running network diagnostics <ion-spinner style="padding: 0; margin: 0" name="dots"></ion-spinner>')
|
||||||
break
|
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:
|
case ConnectionFailure.Tor:
|
||||||
message = 'Browser unable to connect over Tor.'
|
message = 'Browser unable to connect over Tor.'
|
||||||
link = 'https://docs.start9.com/support/FAQ/setup-faq.html#tor-failure'
|
link = 'https://docs.start9.com/support/FAQ/setup-faq.html#tor-failure'
|
||||||
break
|
break
|
||||||
case ConnectionFailure.Internet:
|
|
||||||
message = 'Phone or computer has no Internet.'
|
|
||||||
break
|
|
||||||
case ConnectionFailure.Lan:
|
case ConnectionFailure.Lan:
|
||||||
message = 'Embassy not found on Local Area Network.'
|
message = 'Embassy not found on Local Area Network.'
|
||||||
link = 'https://docs.start9.com/support/FAQ/setup-faq.html#lan-failure'
|
link = 'https://docs.start9.com/support/FAQ/setup-faq.html#lan-failure'
|
||||||
break
|
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)
|
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 { ConnectionFailure, ConnectionService } from 'src/app/services/connection.service'
|
||||||
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
||||||
import { AppConfigPage } from 'src/app/modals/app-config/app-config.page'
|
import { AppConfigPage } from 'src/app/modals/app-config/app-config.page'
|
||||||
|
import { PackageLoadingService } from 'src/app/services/package-loading.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-show',
|
selector: 'app-show',
|
||||||
@@ -47,6 +48,7 @@ export class AppShowPage {
|
|||||||
private readonly embassyApi: ApiService,
|
private readonly embassyApi: ApiService,
|
||||||
private readonly wizardBaker: WizardBaker,
|
private readonly wizardBaker: WizardBaker,
|
||||||
private readonly config: ConfigService,
|
private readonly config: ConfigService,
|
||||||
|
private readonly packageLoadingService: PackageLoadingService,
|
||||||
public readonly patch: PatchDbService,
|
public readonly patch: PatchDbService,
|
||||||
public readonly connectionService: ConnectionService,
|
public readonly connectionService: ConnectionService,
|
||||||
) { }
|
) { }
|
||||||
|
|||||||
@@ -1536,10 +1536,6 @@ export module Mock {
|
|||||||
// disk: '1TB SSD',
|
// disk: '1TB SSD',
|
||||||
// memory: '8GB',
|
// memory: '8GB',
|
||||||
// },
|
// },
|
||||||
// 'connection-addresses': {
|
|
||||||
// tor: ['http://privacy34kn4ez3y3nijweec6w4g54i3g54sdv7r5mr6soma3w4begyd.onion'],
|
|
||||||
// clearnet: ['https://start9.com'],
|
|
||||||
// },
|
|
||||||
// },
|
// },
|
||||||
// 'package-data': {
|
// 'package-data': {
|
||||||
// 'bitcoind': bitcoind,
|
// 'bitcoind': bitcoind,
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export module RR {
|
|||||||
|
|
||||||
// ssh
|
// ssh
|
||||||
|
|
||||||
export type GetSSHKeysReq = { } // ssh.get
|
export type GetSSHKeysReq = { } // ssh.list
|
||||||
export type GetSSHKeysRes = SSHKeys
|
export type GetSSHKeysRes = SSHKeys
|
||||||
|
|
||||||
export type AddSSHKeyReq = { pubkey: string } // ssh.add
|
export type AddSSHKeyReq = { pubkey: string } // ssh.add
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ export class LiveApiService extends ApiService {
|
|||||||
// ssh
|
// ssh
|
||||||
|
|
||||||
async getSshKeys (params: RR.GetSSHKeysReq): Promise <RR.GetSSHKeysRes> {
|
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> {
|
async addSshKey (params: RR.AddSSHKeyReq): Promise <RR.AddSSHKeyRes> {
|
||||||
|
|||||||
@@ -39,13 +39,8 @@ export class ConnectionService {
|
|||||||
.pipe(
|
.pipe(
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
),
|
),
|
||||||
// 3
|
|
||||||
this.patch.watch$('server-info', 'connection-addresses')
|
|
||||||
.pipe(
|
|
||||||
distinctUntilChanged(),
|
|
||||||
),
|
|
||||||
])
|
])
|
||||||
.subscribe(async ([network, patchConnection, addrs]) => {
|
.subscribe(async ([network, patchConnection]) => {
|
||||||
if (patchConnection !== PatchConnection.Disconnected) {
|
if (patchConnection !== PatchConnection.Disconnected) {
|
||||||
this.connectionFailure$.next(ConnectionFailure.None)
|
this.connectionFailure$.next(ConnectionFailure.None)
|
||||||
} else if (!network) {
|
} else if (!network) {
|
||||||
@@ -53,58 +48,17 @@ export class ConnectionService {
|
|||||||
} else if (!this.configService.isTor()) {
|
} else if (!this.configService.isTor()) {
|
||||||
this.connectionFailure$.next(ConnectionFailure.Lan)
|
this.connectionFailure$.next(ConnectionFailure.Lan)
|
||||||
} else {
|
} else {
|
||||||
// diagnosing
|
this.connectionFailure$.next(ConnectionFailure.Tor)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return [sub1, sub2]
|
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 {
|
export enum ConnectionFailure {
|
||||||
None = 'none',
|
None = 'none',
|
||||||
Diagnosing = 'diagnosing',
|
Diagnosing = 'diagnosing',
|
||||||
Network = 'network',
|
Network = 'network',
|
||||||
Embassy = 'embassy',
|
|
||||||
Tor = 'tor',
|
Tor = 'tor',
|
||||||
Lan = 'lan',
|
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
|
disk: string
|
||||||
memory: string
|
memory: string
|
||||||
}
|
}
|
||||||
'connection-addresses': {
|
|
||||||
tor: string[]
|
|
||||||
clearnet: string[]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ServerStatus {
|
export enum ServerStatus {
|
||||||
|
|||||||
Reference in New Issue
Block a user