0" style="padding-bottom: 15px;color: var(--ion-color-warning);">Warning: After submit, any data currently stored on {{ embassyDrive.labels.length ? embassyDrive.labels.join(' / ') : embassyDrive.logicalname }} will be wiped.
Password:
Verify Password:
Cancel
-
- {{ verify ? 'Verify Password' : 'Submit' }}
+
+ {{ !recoveryDrive ? 'Verify Password' : 'Submit' }}
diff --git a/setup-wizard/src/app/pages/password/password.page.ts b/setup-wizard/src/app/pages/password/password.page.ts
index a33266b88..4ef50f274 100644
--- a/setup-wizard/src/app/pages/password/password.page.ts
+++ b/setup-wizard/src/app/pages/password/password.page.ts
@@ -1,6 +1,7 @@
import { Component, Input } from '@angular/core'
import { LoadingController, ModalController } from '@ionic/angular'
import { ApiService, EmbassyDrive, RecoveryDrive } from 'src/app/services/api/api.service'
+import { StateService } from 'src/app/services/state.service'
@Component({
selector: 'password',
@@ -10,7 +11,6 @@ import { ApiService, EmbassyDrive, RecoveryDrive } from 'src/app/services/api/ap
export class PasswordPage {
@Input() recoveryDrive: RecoveryDrive
@Input() embassyDrive: EmbassyDrive
- @Input() verify: boolean
error = ''
password = ''
@@ -19,7 +19,8 @@ export class PasswordPage {
constructor(
private modalController: ModalController,
private apiService: ApiService,
- private loadingCtrl: LoadingController
+ private loadingCtrl: LoadingController,
+ private stateService: StateService
) {}
ngOnInit() { }
@@ -48,16 +49,34 @@ export class PasswordPage {
async submitPw () {
this.validate()
+ if (!this.error && this.password !== this.passwordVer) {
+ this.error="*passwords dont match"
+ }
+
if(this.error) return
+ const loader = await this.loadingCtrl.create({
+ message: 'Setting up your Embassy!'
+ })
+
+ await loader.present()
+ this.stateService.embassyDrive = this.embassyDrive
+ this.stateService.embassyPassword = this.password
+
+ try {
+ await this.stateService.setupEmbassy()
+ this.modalController.dismiss({ success: true })
+ } catch (e) {
+ this.error = e.message
+ } finally {
+ loader.dismiss()
+ }
}
validate () {
if (this.password.length < 12) {
- this.error="*passwords must be 12 characters or greater"
- } else if (this.password !== this.passwordVer) {
- this.error="*passwords dont match"
+ this.error="*password must be 12 characters or greater"
} else {
this.error = ''
}
diff --git a/setup-wizard/src/app/pages/recover/recover.page.html b/setup-wizard/src/app/pages/recover/recover.page.html
index 4f5f15765..59db3c6d7 100644
--- a/setup-wizard/src/app/pages/recover/recover.page.html
+++ b/setup-wizard/src/app/pages/recover/recover.page.html
@@ -60,18 +60,6 @@
Next
-
-
diff --git a/setup-wizard/src/app/pages/recover/recover.page.ts b/setup-wizard/src/app/pages/recover/recover.page.ts
index f61d62685..63a9f91be 100644
--- a/setup-wizard/src/app/pages/recover/recover.page.ts
+++ b/setup-wizard/src/app/pages/recover/recover.page.ts
@@ -41,8 +41,7 @@ export class RecoverPage {
const modal = await this.modalController.create({
component: PasswordPage,
componentProps: {
- recoveryDrive: this.selectedDrive,
- verify: true
+ recoveryDrive: this.selectedDrive
}
})
modal.onDidDismiss().then(async ret => {
diff --git a/setup-wizard/src/app/services/api/api.service.ts b/setup-wizard/src/app/services/api/api.service.ts
index b9ed35fc7..fa371189f 100644
--- a/setup-wizard/src/app/services/api/api.service.ts
+++ b/setup-wizard/src/app/services/api/api.service.ts
@@ -4,12 +4,15 @@ export abstract class ApiService {
protected error$: Subject = new Subject();
watchError$ = this.error$.asObservable();
abstract getEmbassyDrives (): Promise;
- abstract selectEmbassyDrive (logicalName: string): Promise;
abstract getRecoveryDrives (): Promise;
- abstract selectRecoveryDrive (logicalName: string, password: string): Promise;
abstract getDataTransferProgress (): Promise;
- abstract submitPassword (password: string): Promise;
abstract verifyRecoveryPassword (logicalname: string, password: string): Promise;
+ abstract setupEmbassy (setupInfo: {
+ embassyLogicalname: string,
+ embassyPassword: string
+ recoveryLogicalname?: string,
+ recoveryPassword?: string
+ }): Promise
}
export interface TransferProgress {
diff --git a/setup-wizard/src/app/services/api/mock-api.service.ts b/setup-wizard/src/app/services/api/mock-api.service.ts
index e69218543..475bf6f3d 100644
--- a/setup-wizard/src/app/services/api/mock-api.service.ts
+++ b/setup-wizard/src/app/services/api/mock-api.service.ts
@@ -58,11 +58,6 @@ export class MockApiService extends ApiService {
]
}
- async selectEmbassyDrive(drive) {
- await pauseFor(2000)
- return
- }
-
async getRecoveryDrives() {
await pauseFor(2000)
return [
@@ -79,20 +74,15 @@ export class MockApiService extends ApiService {
]
}
- async selectRecoveryDrive(logicalName, password) {
- await pauseFor(2000)
- return
- }
-
- async submitPassword(password) {
- await pauseFor(2000)
- return
- }
-
async verifyRecoveryPassword(logicalname, password) {
await pauseFor(2000)
return password.length > 8
}
+
+ async setupEmbassy (setupInfo){
+ await pauseFor(2000)
+ return
+ }
}
let tries = 0
diff --git a/setup-wizard/src/app/services/state.service.ts b/setup-wizard/src/app/services/state.service.ts
index 1f2957145..87d563c37 100644
--- a/setup-wizard/src/app/services/state.service.ts
+++ b/setup-wizard/src/app/services/state.service.ts
@@ -1,4 +1,5 @@
import { Injectable } from '@angular/core'
+import { BehaviorSubject } from 'rxjs';
import { ApiService, EmbassyDrive, RecoveryDrive } from './api/api.service'
@Injectable({
@@ -8,11 +9,12 @@ export class StateService {
polling = false
embassyDrive: EmbassyDrive;
+ embassyPassword: string
recoveryDrive: RecoveryDrive;
recoveryPassword: string
dataTransferProgress: { bytesTransfered: number; totalBytes: number } | null;
dataProgress = 0;
-
+ dataProgSubject = new BehaviorSubject(this.dataProgress)
constructor(
private readonly apiService: ApiService
) {}
@@ -21,15 +23,16 @@ export class StateService {
this.polling = false
this.embassyDrive = null
+ this.embassyPassword = null
this.recoveryDrive = null
this.recoveryPassword = null
this.dataTransferProgress = null
this.dataProgress = 0
}
- async pollDataTransferProgress() {
+ async pollDataTransferProgress(callback?: () => void) {
this.polling = true
- await pauseFor(7000)
+ await pauseFor(1000)
if (
this.dataTransferProgress?.totalBytes &&
@@ -43,8 +46,18 @@ export class StateService {
}
if (this.dataTransferProgress.totalBytes) {
this.dataProgress = this.dataTransferProgress.bytesTransfered / this.dataTransferProgress.totalBytes
+ this.dataProgSubject.next(this.dataProgress)
}
- this.pollDataTransferProgress()
+ this.pollDataTransferProgress(callback)
+ }
+
+ async setupEmbassy () {
+ await this.apiService.setupEmbassy({
+ embassyLogicalname: this.embassyDrive.logicalname,
+ embassyPassword: this.embassyPassword,
+ recoveryLogicalname: this.recoveryDrive?.logicalname,
+ recoveryPassword: this.recoveryPassword
+ })
}
}
diff --git a/setup-wizard/src/global.scss b/setup-wizard/src/global.scss
index 8597f7fd0..467d346a4 100644
--- a/setup-wizard/src/global.scss
+++ b/setup-wizard/src/global.scss
@@ -69,4 +69,14 @@ ion-item {
font-size: 28px;
margin-right: 10px;
}
+}
+
+.success-alert .alert-wrapper {
+ box-shadow: 4px 4px 30px var(--ion-color-light);
+ border: 1px solid rgba(255,255,255,.3);
+ background: var(--ion-color-light);
+}
+
+.success-alert .alert-title {
+ color: var(--ion-color-success);
}
\ No newline at end of file