From 8f7075de3464fae83607423ec417a67934847088 Mon Sep 17 00:00:00 2001 From: Drew Ansbacher Date: Tue, 9 Nov 2021 10:29:36 -0700 Subject: [PATCH] success selector in init --- .../src/app/pages/init/init.module.ts | 3 + .../src/app/pages/init/init.page.html | 6 +- setup-wizard/src/app/pages/init/init.page.ts | 24 +- .../src/app/pages/success/success.module.ts | 1 + .../src/app/pages/success/success.page.html | 215 +++++++++--------- .../src/app/pages/success/success.page.scss | 4 + .../src/app/pages/success/success.page.ts | 21 -- .../src/app/services/state.service.ts | 1 + 8 files changed, 136 insertions(+), 139 deletions(-) diff --git a/setup-wizard/src/app/pages/init/init.module.ts b/setup-wizard/src/app/pages/init/init.module.ts index ba0808a5f..850f65bcd 100644 --- a/setup-wizard/src/app/pages/init/init.module.ts +++ b/setup-wizard/src/app/pages/init/init.module.ts @@ -3,13 +3,16 @@ import { CommonModule } from '@angular/common' import { IonicModule } from '@ionic/angular' import { InitPage } from './init.page' import { InitPageRoutingModule } from './init-routing.module' +import { SuccessPageModule } from '../success/success.module' @NgModule({ imports: [ CommonModule, IonicModule, InitPageRoutingModule, + SuccessPageModule, ], declarations: [InitPage], + exports: [InitPage], }) export class InitPageModule { } diff --git a/setup-wizard/src/app/pages/init/init.page.html b/setup-wizard/src/app/pages/init/init.page.html index 39aeb5a7a..ae1d6cc39 100644 --- a/setup-wizard/src/app/pages/init/init.page.html +++ b/setup-wizard/src/app/pages/init/init.page.html @@ -6,8 +6,8 @@
- - + + Initializing Embassy Progress: {{ progress | async }}% @@ -21,4 +21,4 @@ - \ No newline at end of file + diff --git a/setup-wizard/src/app/pages/init/init.page.ts b/setup-wizard/src/app/pages/init/init.page.ts index 3a535e354..d1bfcb2d1 100644 --- a/setup-wizard/src/app/pages/init/init.page.ts +++ b/setup-wizard/src/app/pages/init/init.page.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core' import { NavController } from '@ionic/angular' import { interval, Observable } from 'rxjs' import { finalize, take } from 'rxjs/operators' +import { StateService } from 'src/app/services/state.service' @Component({ selector: 'app-init', @@ -10,9 +11,10 @@ import { finalize, take } from 'rxjs/operators' }) export class InitPage { progress: Observable + showSuccess = false constructor ( - private readonly navCtrl: NavController, + private readonly stateService: StateService, ) { } ngOnInit () { @@ -20,9 +22,27 @@ export class InitPage { .pipe( take(101), finalize(() => { - this.navCtrl.navigateForward('/success') + this.stateService.embassyLoaded = true + setTimeout(() => this.download(), 500) }), ) } + + download () { + document.getElementById('tor-addr').innerHTML = this.stateService.torAddress + document.getElementById('lan-addr').innerHTML = this.stateService.lanAddress + document.getElementById('cert').setAttribute('href', 'data:application/x-x509-ca-cert;base64,' + encodeURIComponent(this.stateService.cert)) + let html = document.getElementById('downloadable').innerHTML + const filename = 'embassy-info.html' + + const elem = document.createElement('a') + elem.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(html)) + elem.setAttribute('download', filename) + elem.style.display = 'none' + + document.body.appendChild(elem) + elem.click() + document.body.removeChild(elem) + } } diff --git a/setup-wizard/src/app/pages/success/success.module.ts b/setup-wizard/src/app/pages/success/success.module.ts index 15a4a6a2b..38820b476 100644 --- a/setup-wizard/src/app/pages/success/success.module.ts +++ b/setup-wizard/src/app/pages/success/success.module.ts @@ -17,5 +17,6 @@ import { SuccessPageRoutingModule } from './success-routing.module' PasswordPageModule, ], declarations: [SuccessPage], + exports: [SuccessPage], }) export class SuccessPageModule { } diff --git a/setup-wizard/src/app/pages/success/success.page.html b/setup-wizard/src/app/pages/success/success.page.html index cb62d2e75..a83b5f07f 100644 --- a/setup-wizard/src/app/pages/success/success.page.html +++ b/setup-wizard/src/app/pages/success/success.page.html @@ -1,120 +1,109 @@ - - - - -
- -
+ + + + Setup Complete! + + +
+ +
+

Tor Instructions:

+ +
- - - - Setup Complete! - - -
- -
-

Tor Instructions:

- -
+
+
+

+ To use your Embassy over Tor, visit its unique Tor address from any Tor-enabled browser. + For a list of recommended browsers, click here. +

+
+

Tor Address

+ + + {{ stateService.torAddress }} + + + + + +
+
+
+
+ + +
+

LAN Instructions (Slightly Advanced):

+ +
-
-
-

- To use your Embassy over Tor, visit its unique Tor address from any Tor-enabled browser. - For a list of recommended browsers, click here. -

-
-

Tor Address

- - - {{ stateService.torAddress }} - - - - - -
-
-
-
- - -
-

LAN Instructions (Slightly Advanced):

- -
+
+
+

To use your Embassy locally, you must:

+
    +
  1. Currently be connected to the same Local Area Network (LAN) as your Embassy.
  2. +
  3. Download your Embassy's Root Certificate Authority.
  4. +
  5. Trust your Embassy's Root CA on both your computer/phone and in your browser settings.
  6. +
+

+ For step-by-step instructions, click + here. +

+ + + Download Root CA + + + +

LAN Address

+ + + {{ stateService.lanAddress }} + + + + + +
+
+
+
+
+ + Download this page + + +
+
+
+
-
-
-

To use your Embassy locally, you must:

-
    -
  1. Currently be connected to the same Local Area Network (LAN) as your Embassy.
  2. -
  3. Download your Embassy's Root Certificate Authority.
  4. -
  5. Trust your Embassy's Root CA on both your computer/phone and in your browser settings.
  6. -
-

- For step-by-step instructions, click - here. -

- - - Download Root CA - - - -

LAN Address

- - - {{ stateService.lanAddress }} - - - - - -
-
-
-
-
- - Download this page - - -
-
-
-
-
-
-
-
diff --git a/setup-wizard/src/app/pages/success/success.page.scss b/setup-wizard/src/app/pages/success/success.page.scss index 9083c1314..b160859a0 100644 --- a/setup-wizard/src/app/pages/success/success.page.scss +++ b/setup-wizard/src/app/pages/success/success.page.scss @@ -26,4 +26,8 @@ a { text-align: right; font-size: 24px; } +} + +.hiddenPage { + max-height: 0px; } \ No newline at end of file diff --git a/setup-wizard/src/app/pages/success/success.page.ts b/setup-wizard/src/app/pages/success/success.page.ts index 06bf38533..36fbf661a 100644 --- a/setup-wizard/src/app/pages/success/success.page.ts +++ b/setup-wizard/src/app/pages/success/success.page.ts @@ -16,10 +16,6 @@ export class SuccessPage { public readonly stateService: StateService, ) { } - ngAfterViewInit () { - setTimeout(() => this.download(), 500) - } - async copy (address: string): Promise { const success = await this.copyToClipboard(address) const message = success ? 'copied to clipboard!' : 'failed to copy' @@ -44,23 +40,6 @@ export class SuccessPage { document.getElementById('install-cert').click() } - download () { - document.getElementById('tor-addr').innerHTML = this.stateService.torAddress - document.getElementById('lan-addr').innerHTML = this.stateService.lanAddress - document.getElementById('cert').setAttribute('href', 'data:application/x-x509-ca-cert;base64,' + encodeURIComponent(this.stateService.cert)) - let html = document.getElementById('downloadable').innerHTML - const filename = 'embassy-info.html' - - const elem = document.createElement('a') - elem.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(html)) - elem.setAttribute('download', filename) - elem.style.display = 'none' - - document.body.appendChild(elem) - elem.click() - document.body.removeChild(elem) - } - private async copyToClipboard (str: string): Promise { const el = document.createElement('textarea') el.value = str diff --git a/setup-wizard/src/app/services/state.service.ts b/setup-wizard/src/app/services/state.service.ts index 9adbc81a7..4702cbd09 100644 --- a/setup-wizard/src/app/services/state.service.ts +++ b/setup-wizard/src/app/services/state.service.ts @@ -12,6 +12,7 @@ export class StateService { isMigrating: boolean polling = false + embassyLoaded = false storageDrive: DiskInfo embassyPassword: string