diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts index 06608c4e9..195d754a5 100644 --- a/ui/src/app/app.component.ts +++ b/ui/src/app/app.component.ts @@ -208,25 +208,14 @@ export class AppComponent { case ConnectionFailure.Diagnosing: message = new IonicSafeString('Running network diagnostics ') 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) } diff --git a/ui/src/app/pages/apps-routes/app-show/app-show.page.ts b/ui/src/app/pages/apps-routes/app-show/app-show.page.ts index 4050f0da7..6a97b11e9 100644 --- a/ui/src/app/pages/apps-routes/app-show/app-show.page.ts +++ b/ui/src/app/pages/apps-routes/app-show/app-show.page.ts @@ -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, ) { } diff --git a/ui/src/app/services/api/api.fixures.ts b/ui/src/app/services/api/api.fixures.ts index 365f4c9a3..2bdce56fb 100644 --- a/ui/src/app/services/api/api.fixures.ts +++ b/ui/src/app/services/api/api.fixures.ts @@ -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, diff --git a/ui/src/app/services/api/api.types.ts b/ui/src/app/services/api/api.types.ts index dbe527483..aff83cd9e 100644 --- a/ui/src/app/services/api/api.types.ts +++ b/ui/src/app/services/api/api.types.ts @@ -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 diff --git a/ui/src/app/services/api/embassy-live-api.service.ts b/ui/src/app/services/api/embassy-live-api.service.ts index 52fcca814..07d7fb113 100644 --- a/ui/src/app/services/api/embassy-live-api.service.ts +++ b/ui/src/app/services/api/embassy-live-api.service.ts @@ -171,7 +171,7 @@ export class LiveApiService extends ApiService { // ssh async getSshKeys (params: RR.GetSSHKeysReq): Promise { - return this.http.rpcRequest({ method: 'ssh.get', params }) + return this.http.rpcRequest({ method: 'ssh.list', params }) } async addSshKey (params: RR.AddSSHKeyReq): Promise { diff --git a/ui/src/app/services/connection.service.ts b/ui/src/app/services/connection.service.ts index 1669f83e1..cf8fe157e 100644 --- a/ui/src/app/services/connection.service.ts +++ b/ui/src/app/services/connection.service.ts @@ -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 { - 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', } diff --git a/ui/src/app/services/package-loading.service.ts b/ui/src/app/services/package-loading.service.ts new file mode 100644 index 000000000..918251a51 --- /dev/null +++ b/ui/src/app/services/package-loading.service.ts @@ -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 +} \ No newline at end of file diff --git a/ui/src/app/services/patch-db/data-model.ts b/ui/src/app/services/patch-db/data-model.ts index c225f5893..9fc43acfd 100644 --- a/ui/src/app/services/patch-db/data-model.ts +++ b/ui/src/app/services/patch-db/data-model.ts @@ -25,10 +25,6 @@ export interface ServerInfo { disk: string memory: string } - 'connection-addresses': { - tor: string[] - clearnet: string[] - } } export enum ServerStatus {