diff --git a/setup-wizard/src/app/app-routing.module.ts b/setup-wizard/src/app/app-routing.module.ts index 1abc13060..7348a7dc9 100644 --- a/setup-wizard/src/app/app-routing.module.ts +++ b/setup-wizard/src/app/app-routing.module.ts @@ -1,17 +1,17 @@ import { NgModule } from '@angular/core'; import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; -import { CanActivateHome, CanActivateRecover } from './guards/guards' const routes: Routes = [ { path: 'wizard', loadChildren: () => import('./pages/home/home.module').then( m => m.HomePageModule), - canActivate: [CanActivateHome], - }, { path: 'recover', loadChildren: () => import('./pages/recover/recover.module').then( m => m.RecoverPageModule), - canActivate: [CanActivateRecover] + }, + { + path: 'embassy', + loadChildren: () => import('./pages/embassy/embassy.module').then( m => m.EmbassyPageModule), }, ]; diff --git a/setup-wizard/src/app/app.component.html b/setup-wizard/src/app/app.component.html index 3cdc8b392..9e303b7df 100644 --- a/setup-wizard/src/app/app.component.html +++ b/setup-wizard/src/app/app.component.html @@ -1,7 +1,5 @@ - - - - - + + + diff --git a/setup-wizard/src/app/app.component.ts b/setup-wizard/src/app/app.component.ts index ef22b55b0..45247e64e 100644 --- a/setup-wizard/src/app/app.component.ts +++ b/setup-wizard/src/app/app.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit } from '@angular/core' -import { LoadingController, NavController, ToastController } from '@ionic/angular' -import { ApiService } from './services/api/api.service' +import { NavController } from '@ionic/angular' import { StateService } from './services/state.service' @Component({ @@ -11,51 +10,13 @@ import { StateService } from './services/state.service' export class AppComponent implements OnInit { constructor( - private readonly apiService: ApiService, - private readonly stateService: StateService, private readonly navCtrl: NavController, - private readonly toastController: ToastController, - private readonly loadingCtrl: LoadingController, + private stateService: StateService - ) { - this.apiService.watchError$.subscribe(error => { - if(error) { - this.presentToast(error) - } - }) - } + ) {} async ngOnInit() { - const loader = await this.loadingCtrl.create({ - message: 'Connecting to your Embassy' - }) - await loader.present() - try { - await this.stateService.getState() - if (this.stateService.recoveryDrive) { - await this.navCtrl.navigateForward(`/recover`) - } else { - await this.navCtrl.navigateForward(`/wizard`) - } - } catch (e) {} finally { - loader.dismiss() - } - } - - async presentToast(error: string) { - const toast = await this.toastController.create({ - header: 'Error', - message: error, - position: 'bottom', - buttons: [ - { - text: 'X', - role: 'cancel', - } - ] - }) - await toast.present() - - await toast.onDidDismiss() + this.stateService.reset() + await this.navCtrl.navigateForward(`/wizard`) } } diff --git a/setup-wizard/src/app/guards/guards.ts b/setup-wizard/src/app/guards/guards.ts deleted file mode 100644 index f7f076d99..000000000 --- a/setup-wizard/src/app/guards/guards.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Injectable } from '@angular/core' -import { CanActivate } from '@angular/router' -import { StateService } from '../services/state.service' - -@Injectable({ - providedIn: 'root', -}) -export class CanActivateHome implements CanActivate { - - constructor ( - private readonly stateService: StateService - ) {} - - canActivate (): boolean { - console.log(!!this.stateService.recoveryDrive) - return !!this.stateService.recoveryDrive ? false : true - } -} - -@Injectable({ - providedIn: 'root', -}) -export class CanActivateRecover implements CanActivate { - - constructor ( - private readonly stateService: StateService - ) {} - - canActivate (): boolean { - return this.stateService.dataDrive ? true : false - } -} diff --git a/setup-wizard/src/app/pages/embassy/embassy-routing.module.ts b/setup-wizard/src/app/pages/embassy/embassy-routing.module.ts new file mode 100644 index 000000000..a7d5e7a78 --- /dev/null +++ b/setup-wizard/src/app/pages/embassy/embassy-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { EmbassyPage } from './embassy.page'; + +const routes: Routes = [ + { + path: '', + component: EmbassyPage, + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class EmbassyPageRoutingModule {} diff --git a/setup-wizard/src/app/pages/embassy/embassy.module.ts b/setup-wizard/src/app/pages/embassy/embassy.module.ts new file mode 100644 index 000000000..144a67e22 --- /dev/null +++ b/setup-wizard/src/app/pages/embassy/embassy.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { IonicModule } from '@ionic/angular'; +import { FormsModule } from '@angular/forms'; +import { EmbassyPage } from './embassy.page'; +import { PasswordPageModule } from '../password/password.module'; + +import { EmbassyPageRoutingModule } from './embassy-routing.module'; + + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + IonicModule, + EmbassyPageRoutingModule, + PasswordPageModule, + ], + declarations: [EmbassyPage] +}) +export class EmbassyPageModule {} diff --git a/setup-wizard/src/app/pages/embassy/embassy.page.html b/setup-wizard/src/app/pages/embassy/embassy.page.html new file mode 100644 index 000000000..73986f7ac --- /dev/null +++ b/setup-wizard/src/app/pages/embassy/embassy.page.html @@ -0,0 +1,57 @@ + + + + + +
+ +
+ + + + {{ loading ? 'Loading Embassy Drives' : 'Select Embassy Drive'}} + + + + +

No Embassy drives found

+

Please connect an Embassy drive to your embassy and refresh the page.

+ + Refresh + +
+ + + + + + + + + + + + + + + + + + +

{{ drive.logicalname }}

+

{{ drive.labels.length ? drive.labels.join(' / ') : 'unnamed' }}

+

Using {{drive.used.toFixed(2)}} of {{drive.capacity.toFixed(2)}} GiB

+
+
+
+
+
+
+
+
+
+
diff --git a/setup-wizard/src/app/pages/embassy/embassy.page.scss b/setup-wizard/src/app/pages/embassy/embassy.page.scss new file mode 100644 index 000000000..509766613 --- /dev/null +++ b/setup-wizard/src/app/pages/embassy/embassy.page.scss @@ -0,0 +1,44 @@ +.selected { + border: 4px solid gray; +} + +ion-card-title { + margin: 24px 0; + font-family: 'Montserrat'; + font-size: x-large; + --color: var(--ion-color-light); +} + +// ion-item { +// --border-radius: 4px; +// --border-style: solid; +// --border-width: 1px; +// --border-color: var(--ion-color-light); +// } + +.input-label { + text-align: left; + padding-bottom: 2px; + font-size: small; + color: var(--ion-color-light); + font-weight: bold; +} + +.claim-button { + margin-inline-start: 0; + margin-inline-end: 0; + margin-top: 24px; + height: 48px; + --background: linear-gradient(45deg, var(--ion-color-light) 16%, var(--ion-color-medium) 150%); +} + +.card-footer { + text-align: left; + --background: rgb(222, 222, 222); + border-top: solid; + border-width: 1px; + border-color: var(--ion-color-medium); + ion-item { + --border-color: var(--ion-color-medium); + } +} \ No newline at end of file diff --git a/setup-wizard/src/app/pages/embassy/embassy.page.ts b/setup-wizard/src/app/pages/embassy/embassy.page.ts new file mode 100644 index 000000000..e9089929e --- /dev/null +++ b/setup-wizard/src/app/pages/embassy/embassy.page.ts @@ -0,0 +1,42 @@ +import { Component } from '@angular/core' +import { ModalController, NavController } from '@ionic/angular' +import { ApiService, EmbassyDrive } from 'src/app/services/api/api.service' +import { StateService } from 'src/app/services/state.service' +import { PasswordPage } from '../password/password.page' + +@Component({ + selector: 'embassy', + templateUrl: 'embassy.page.html', + styleUrls: ['embassy.page.scss'], +}) +export class EmbassyPage { + embassyDrives = [] + selectedDrive: EmbassyDrive = null + loading = true + + constructor( + private readonly apiService: ApiService, + private readonly navCtrl: NavController, + private modalController: ModalController, + private stateService: StateService + ) {} + + async ngOnInit() { + this.embassyDrives = await this.apiService.getEmbassyDrives() + this.loading = false + } + + async chooseDrive(drive: EmbassyDrive) { + const modal = await this.modalController.create({ + component: PasswordPage, + componentProps: { + embassyDrive: drive, + verify: false + } + }) + modal.onDidDismiss().then(async ret => { + if (!ret.data) return + }) + await modal.present(); + } +} diff --git a/setup-wizard/src/app/pages/home/home.page.html b/setup-wizard/src/app/pages/home/home.page.html index ef91a0d4d..ef021ae44 100644 --- a/setup-wizard/src/app/pages/home/home.page.html +++ b/setup-wizard/src/app/pages/home/home.page.html @@ -7,107 +7,37 @@ - - - {{ stateService.dataDrive ? 'Startup Options' : 'Select Data Drive'}} - - + -
-
-

No data drives found

-

Please connect a data drive to your embassy and refresh the page.

- - Refresh - -
-
- - - {{drive.logicalname}} - {{drive.labels}} - - - - Using {{drive.used}} out of {{drive.capacity}} bytes. - - -
- - Next - -
-
-
-
- - - Start Fresh - Get started with a brand new Embassy - - - - - Recover - Recover the data from an old embassy - - -
+ + + + Start Fresh + Get started with a brand new Embassy + + + + + + + Recover + Recover the data from an old embassy + +
- - - - -

- Choose drive to save all Embassy data to. -

-

- Spin up a brand new Embassy, or recover data from an old device. -

-
-
-
- -
- - diff --git a/setup-wizard/src/app/pages/home/home.page.ts b/setup-wizard/src/app/pages/home/home.page.ts index 1ccbd65a1..a4114e799 100644 --- a/setup-wizard/src/app/pages/home/home.page.ts +++ b/setup-wizard/src/app/pages/home/home.page.ts @@ -1,8 +1,5 @@ import { Component } from '@angular/core' -import { AlertController, ModalController, LoadingController } from '@ionic/angular' -import { ApiService, DataDrive } from 'src/app/services/api/api.service' -import { StateService } from 'src/app/services/state.service' -import { PasswordPage } from '../password/password.page' +import { NavController } from '@ionic/angular' @Component({ selector: 'home', @@ -10,109 +7,16 @@ import { PasswordPage } from '../password/password.page' styleUrls: ['home.page.scss'], }) export class HomePage { - dataDrives = [] - selectedDrive: DataDrive = null - console = console - constructor( - private readonly apiService: ApiService, - private readonly stateService: StateService, - private readonly alertController: AlertController, - private readonly modalController: ModalController, - private readonly loadingCtrl: LoadingController, + private readonly navCtrl: NavController, ) {} - async ngOnInit() { - if(!this.stateService.dataDrive) { - const loader = await this.loadingCtrl.create({ - message: 'Fetching data drives' - }) - await loader.present() - this.dataDrives = await this.apiService.getDataDrives() - loader.dismiss() - } + async recoverNav () { + await this.navCtrl.navigateForward(`/recover`, { animationDirection: 'forward' }) } - selectDrive(drive: DataDrive) { - if (drive.logicalname === this.selectedDrive?.logicalname) { - this.selectedDrive = null - } else { - this.selectedDrive = drive - } + async embassyNav () { + await this.navCtrl.navigateForward(`/embassy`, { animationDirection: 'forward' }) } - - async warn() { - const alert = await this.alertController.create({ - cssClass: 'my-custom-class', - header: 'Warning!', - message: 'This drive will be entirely wiped of all existing memory.', - backdropDismiss: false, - buttons: [ - { - text: 'Cancel', - role: 'cancel', - cssClass: 'cancel-button', - handler: () => { - this.selectedDrive = null - } - }, { - text: 'Okay', - cssClass: 'okay-button', - handler: async () => { - await this.chooseDrive() - } - } - ] - }); - - await alert.present(); - } - - async chooseDrive() { - const loader = await this.loadingCtrl.create({ - message: 'Selecting data drive' - }) - await loader.present() - try { - await this.apiService.selectDataDrive(this.selectedDrive.logicalname) - this.stateService.dataDrive = this.selectedDrive - } catch (e) { - } finally { - loader.dismiss() - } - } - - async presentPasswordModal() { - const modal = await this.modalController.create({ - component: PasswordPage, - backdropDismiss: false, - cssClass: 'pw-modal', - }) - modal.onDidDismiss().then(ret => { - if(ret.data) { - const pass = ret.data.password - if (pass) { - this.submitPassword(pass) - } - } - }) - await modal.present(); - } - - async submitPassword (pw: string) { - const loader = await this.loadingCtrl.create({ - message: 'Setting up your Embassy' - }) - await loader.present() - - try { - await this.apiService.submitPassword(pw) - console.log('reloading') - location.reload() - } catch (e) { - } finally { - loader.dismiss() - } - } - } + diff --git a/setup-wizard/src/app/pages/password/password.page.html b/setup-wizard/src/app/pages/password/password.page.html index 252465bde..cac59071c 100644 --- a/setup-wizard/src/app/pages/password/password.page.html +++ b/setup-wizard/src/app/pages/password/password.page.html @@ -1,26 +1,56 @@ - Enter Password - Create Password + Verify Recovery Drive Password + Set Password - -
-
- Password: -
-
- Password: - Verify Password: + +
+ +

Password:

+ +
+ +
+

Warning: After submit, any data currently stored on {{ embassyDrive.labels.length ? embassyDrive.labels.join(' / ') : embassyDrive.logicalname }} will be wiped.

+

Password:

+ + +

Verify Password:

+

{{error}}

-
- Cancel - Submit -
-
+ + + + + + Cancel + + + {{ verify ? 'Verify Password' : 'Submit' }} + + + + + diff --git a/setup-wizard/src/app/pages/password/password.page.scss b/setup-wizard/src/app/pages/password/password.page.scss index dae97d4ee..20c5e6fb9 100644 --- a/setup-wizard/src/app/pages/password/password.page.scss +++ b/setup-wizard/src/app/pages/password/password.page.scss @@ -1,7 +1,15 @@ .claim-button { margin-inline-start: 0; margin-inline-end: 0; - margin-top: 24px; + margin: 6px; height: 48px; --background: linear-gradient(45deg, var(--ion-color-light) 16%, var(--ion-color-medium) 150%); +} + +ion-input { + font-weight: 500; + --placeholder-font-weight: 400; + width: 100%; + background: var(--ion-color-dark); + border-radius: 3px; } \ No newline at end of file diff --git a/setup-wizard/src/app/pages/password/password.page.ts b/setup-wizard/src/app/pages/password/password.page.ts index d457de8c7..a33266b88 100644 --- a/setup-wizard/src/app/pages/password/password.page.ts +++ b/setup-wizard/src/app/pages/password/password.page.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core' -import { ModalController } from '@ionic/angular' -import { RecoveryDrive } from 'src/app/services/api/api.service' +import { LoadingController, ModalController } from '@ionic/angular' +import { ApiService, EmbassyDrive, RecoveryDrive } from 'src/app/services/api/api.service' @Component({ selector: 'password', @@ -9,51 +9,61 @@ import { RecoveryDrive } from 'src/app/services/api/api.service' }) export class PasswordPage { @Input() recoveryDrive: RecoveryDrive - - needsVer: boolean + @Input() embassyDrive: EmbassyDrive + @Input() verify: boolean error = '' password = '' passwordVer = '' constructor( - private modalController: ModalController + private modalController: ModalController, + private apiService: ApiService, + private loadingCtrl: LoadingController ) {} - ngOnInit() { - this.needsVer = !!this.recoveryDrive && !this.recoveryDrive.version.startsWith('0.2') + ngOnInit() { } + + async verifyPw () { + + if(!this.recoveryDrive) this.error = 'No recovery drive' // unreachable + const loader = await this.loadingCtrl.create({ + message: 'Verifying Password' + }) + await loader.present() + + try { + const isCorrectPassword = await this.apiService.verifyRecoveryPassword(this.recoveryDrive.logicalname, this.password) + if(isCorrectPassword) { + this.modalController.dismiss({ password: this.password }) + } else { + this.error = "Incorrect password provided" + } + } catch (e) { + this.error = 'Error connecting to Embassy' + } finally { + loader.dismiss() + } } - async submitPassword () { - if(!this.needsVer) { - this.validate() - if(!this.error) { - this.checkMatch() - } - this.modalController.dismiss({ - password: this.password, - }) - } else { - this.modalController.dismiss({ - password: this.password, - }) - } + async submitPw () { + this.validate() + if(this.error) return + + } validate () { if (this.password.length < 12) { this.error="*passwords must be 12 characters or greater" - } - } - - checkMatch () { - if (this.password !== this.passwordVer) { + } else if (this.password !== this.passwordVer) { this.error="*passwords dont match" } else { this.error = '' } } + cancel () { this.modalController.dismiss() } diff --git a/setup-wizard/src/app/pages/recover/recover.page.html b/setup-wizard/src/app/pages/recover/recover.page.html index 9878e971f..4f5f15765 100644 --- a/setup-wizard/src/app/pages/recover/recover.page.html +++ b/setup-wizard/src/app/pages/recover/recover.page.html @@ -7,50 +7,61 @@
- + - {{ stateService.recoveryDrive && stateService.polling ? 'Recovery Progress: ' + (100 * stateService.dataProgress) + '%' : 'Select Recovery Drive'}} + {{ loading ? 'Loading Recovery Drives' : 'Select Recovery Drive'}} + -
+

No recovery drives found

Please connect a recovery drive to your embassy and refresh the page.

-
-
-
- - - {{drive.logicalname}} - {{drive.name}} - - - - Currently running {{drive.version}} - - -
- + Refresh + + + + + + + + + + + + + + + + + + + + +

{{ drive.logicalname }}

+

{{ drive.name }}

+

Embassy version: {{drive.version}}

+
+ + + +
+
+ - Next - -
-
- -
-
+ > + Next + + + + - - - - -

- Choose drive recover Embassy data from. -

-

- Recovering old Embassy data. -

-
-
-
- -
- - 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;