+ >
+ Next
+
+
+
+
-
-
-
-
-
-
diff --git a/setup-wizard/src/app/pages/recover/recover.page.scss b/setup-wizard/src/app/pages/recover/recover.page.scss
index d8b406cba..314c967aa 100644
--- a/setup-wizard/src/app/pages/recover/recover.page.scss
+++ b/setup-wizard/src/app/pages/recover/recover.page.scss
@@ -1,5 +1,7 @@
.selected {
- border: 4px solid gray;
+ border-radius: 8px;
+ border: 4px solid var(--ion-color-secondary);
+ box-shadow: 4px 4px 16px var(--ion-color-light);
}
ion-card-title {
diff --git a/setup-wizard/src/app/pages/recover/recover.page.ts b/setup-wizard/src/app/pages/recover/recover.page.ts
index 18512fa6d..f61d62685 100644
--- a/setup-wizard/src/app/pages/recover/recover.page.ts
+++ b/setup-wizard/src/app/pages/recover/recover.page.ts
@@ -1,5 +1,5 @@
import { Component } from '@angular/core'
-import { AlertController, ModalController, LoadingController } from '@ionic/angular'
+import { ModalController, NavController } from '@ionic/angular'
import { ApiService, RecoveryDrive } from 'src/app/services/api/api.service'
import { StateService } from 'src/app/services/state.service'
import { PasswordPage } from '../password/password.page'
@@ -10,86 +10,58 @@ import { PasswordPage } from '../password/password.page'
styleUrls: ['recover.page.scss'],
})
export class RecoverPage {
+ passwords = {}
recoveryDrives = []
selectedDrive: RecoveryDrive = null
loading = true
constructor(
private readonly apiService: ApiService,
- private readonly stateService: StateService,
- public alertController: AlertController,
+ private readonly navCtrl: NavController,
private modalController: ModalController,
- private readonly loadingCtrl: LoadingController,
+ private stateService: StateService
) {}
async ngOnInit() {
- if(!this.stateService.recoveryDrive) {
- const loader = await this.loadingCtrl.create({
- message: 'Fetching recovery drives'
- })
- await loader.present()
- this.recoveryDrives = await this.apiService.getRecoveryDrives()
-
- loader.dismiss()
- this.loading = false
- } else {
- this.loading = false
- this.stateService.pollDataTransferProgress()
- }
+ this.recoveryDrives = await this.apiService.getRecoveryDrives()
+ this.loading = false
}
- selectDrive(drive: RecoveryDrive) {
- if (drive.logicalname === this.selectedDrive?.logicalname) {
+ async chooseDrive(drive: RecoveryDrive) {
+
+ if (this.selectedDrive?.logicalname === drive.logicalname) {
this.selectedDrive = null
+ return
} else {
this.selectedDrive = drive
}
- }
- async chooseDrive() {
- this.presentPasswordModal()
- }
+ if (drive.version.startsWith('0.2') || this.passwords[drive.logicalname]) return
- async presentPasswordModal() {
const modal = await this.modalController.create({
component: PasswordPage,
- backdropDismiss: false,
- cssClass: 'pw-modal',
componentProps: {
recoveryDrive: this.selectedDrive,
+ verify: true
}
})
- modal.onDidDismiss().then(ret => {
- if(ret.data) {
- const pass = ret.data.password
- if(pass) {
- this.submitPWAndDrive(pass)
- }
+ modal.onDidDismiss().then(async ret => {
+ if (!ret.data) {
+ this.selectedDrive = null
+ } else if(ret.data.password) {
+ this.passwords[drive.logicalname] = ret.data.password
}
+
})
await modal.present();
}
- async submitPWAndDrive(pw: string) {
- const loader = await this.loadingCtrl.create({
- message: 'Validating password'
- })
- await loader.present()
-
- try {
- this.stateService.recoveryDrive = this.selectedDrive
- await this.apiService.selectRecoveryDrive(this.selectedDrive.logicalname, pw)
- this.stateService.pollDataTransferProgress()
- } catch (e) {
- } finally {
- loader.dismiss()
- }
-
-
+ async selectRecoveryDrive() {
+ this.stateService.recoveryDrive = this.selectedDrive
+ const pw = this.passwords[this.selectedDrive.logicalname]
+ if(pw) {
+ this.stateService.recoveryPassword = pw
+ }
+ await this.navCtrl.navigateForward(`/embassy`, { animationDirection: 'forward' })
}
-
- async navToEmbassy() {
- location.reload()
- }
-
}
diff --git a/setup-wizard/src/app/services/api/api.service.ts b/setup-wizard/src/app/services/api/api.service.ts
index 701d9a299..b9ed35fc7 100644
--- a/setup-wizard/src/app/services/api/api.service.ts
+++ b/setup-wizard/src/app/services/api/api.service.ts
@@ -3,18 +3,13 @@ import { Subject } from 'rxjs'
export abstract class ApiService {
protected error$: Subject
= new Subject();
watchError$ = this.error$.asObservable();
- abstract getState (): Promise;
- abstract getDataDrives (): Promise;
- abstract selectDataDrive (logicalName: string): Promise;
+ 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;
-}
-
-export interface State {
- 'data-drive': DataDrive | null;
- 'recovery-drive': RecoveryDrive | null;
+ abstract verifyRecoveryPassword (logicalname: string, password: string): Promise;
}
export interface TransferProgress {
@@ -22,7 +17,7 @@ export interface TransferProgress {
'total-bytes': number;
}
-export interface DataDrive {
+export interface EmbassyDrive {
logicalname: string;
labels: string[];
capacity: number;
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 b53d9c2bf..e69218543 100644
--- a/setup-wizard/src/app/services/api/mock-api.service.ts
+++ b/setup-wizard/src/app/services/api/mock-api.service.ts
@@ -14,14 +14,14 @@ export class MockApiService extends ApiService {
async getState() {
await pauseFor(2000)
return {
- 'data-drive':
- // null,
- {
- logicalname: 'name1',
- labels: ['label 1', 'label 2'],
- capacity: 1600,
- used: 200,
- },
+ 'embassy-drive':
+ null,
+ // {
+ // logicalname: 'name1',
+ // labels: ['label 1', 'label 2'],
+ // capacity: 1600,
+ // used: 200,
+ // },
'recovery-drive':
null,
// {
@@ -40,25 +40,25 @@ export class MockApiService extends ApiService {
}
}
- async getDataDrives() {
+ async getEmbassyDrives() {
await pauseFor(2000)
return [
{
logicalname: 'Name1',
labels: ['label 1', 'label 2'],
- capacity: 1600,
- used: 200,
+ capacity: 1600.66666,
+ used: 200.1255312,
},
{
logicalname: 'Name2',
labels: [],
- capacity: 1600,
- used: 0,
+ capacity: 1600.01234,
+ used: 0.00,
}
]
}
- async selectDataDrive(drive) {
+ async selectEmbassyDrive(drive) {
await pauseFor(2000)
return
}
@@ -67,9 +67,14 @@ export class MockApiService extends ApiService {
await pauseFor(2000)
return [
{
- logicalname: 'name1',
+ logicalname: 'Name1',
version: '0.3.3',
name: 'My Embassy'
+ },
+ {
+ logicalname: 'Name2',
+ version: '0.2.7',
+ name: 'My Embassy'
}
]
}
@@ -83,6 +88,11 @@ export class MockApiService extends ApiService {
await pauseFor(2000)
return
}
+
+ async verifyRecoveryPassword(logicalname, password) {
+ await pauseFor(2000)
+ return password.length > 8
+ }
}
let tries = 0
diff --git a/setup-wizard/src/app/services/state.service.ts b/setup-wizard/src/app/services/state.service.ts
index 86f26a2af..1f2957145 100644
--- a/setup-wizard/src/app/services/state.service.ts
+++ b/setup-wizard/src/app/services/state.service.ts
@@ -1,15 +1,15 @@
import { Injectable } from '@angular/core'
-import { ApiService, DataDrive, RecoveryDrive } from './api/api.service'
+import { ApiService, EmbassyDrive, RecoveryDrive } from './api/api.service'
@Injectable({
providedIn: 'root'
})
export class StateService {
- loading = true
polling = false
- dataDrive: DataDrive;
+ embassyDrive: EmbassyDrive;
recoveryDrive: RecoveryDrive;
+ recoveryPassword: string
dataTransferProgress: { bytesTransfered: number; totalBytes: number } | null;
dataProgress = 0;
@@ -17,15 +17,14 @@ export class StateService {
private readonly apiService: ApiService
) {}
- async getState() {
- this.loading = true
- const state = await this.apiService.getState()
- if(state) {
- this.dataDrive = state['data-drive']
- this.recoveryDrive = state['recovery-drive']
+ reset() {
+ this.polling = false
- this.loading = false
- }
+ this.embassyDrive = null
+ this.recoveryDrive = null
+ this.recoveryPassword = null
+ this.dataTransferProgress = null
+ this.dataProgress = 0
}
async pollDataTransferProgress() {
diff --git a/setup-wizard/src/theme/variables.scss b/setup-wizard/src/theme/variables.scss
index b45f8d437..b59b0fe2f 100644
--- a/setup-wizard/src/theme/variables.scss
+++ b/setup-wizard/src/theme/variables.scss
@@ -3,6 +3,9 @@
/** Ionic CSS Variables **/
:root {
+ --ion-text-color: var(--ion-color-dark);
+ --ion-text-color-rgb: var(--ion-color-dark-rgb);
+
--ion-font-family: 'Benton Sans';
/** primary **/
--ion-color-primary: #428cff;
@@ -53,12 +56,12 @@
--ion-color-danger-tint: #ff5b71;
/** dark **/
- --ion-color-dark: #f4f5f8;
- --ion-color-dark-rgb: 244,245,248;
+ --ion-color-dark: #e0e0e0;
+ --ion-color-dark-rgb: 224,224,224;
--ion-color-dark-contrast: #000000;
--ion-color-dark-contrast-rgb: 0,0,0;
- --ion-color-dark-shade: #d7d8da;
- --ion-color-dark-tint: #f5f6f9;
+ --ion-color-dark-shade: #bfbfbf;
+ --ion-color-dark-tint: #d8d8d8;
/** medium **/
--ion-color-medium: #989aa2;