This commit is contained in:
Drew Ansbacher
2021-06-30 11:29:13 -06:00
committed by Aiden McClelland
parent 1311f473f9
commit fbcf4cacdb
8 changed files with 96 additions and 26 deletions

View File

@@ -1,7 +1,8 @@
import { Component } from '@angular/core'
import { AlertController } from '@ionic/angular'
import { ApiService } from 'src/app/services/api/api.service'
import { AlertController, ModalController } 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: 'recover',
@@ -11,11 +12,13 @@ import { StateService } from 'src/app/services/state.service'
export class RecoverPage {
dataDrives = []
selectedDrive = null
selectedVersion = null
constructor(
private readonly apiService: ApiService,
private readonly stateService: StateService,
public alertController: AlertController,
private modalController: ModalController,
) {}
async ngOnInit() {
@@ -26,11 +29,15 @@ export class RecoverPage {
}
}
selectDrive(name: string) {
selectDrive(disk: EmbassyDrive) {
const name = disk['logical-name']
const version = disk.version
if (name === this.selectedDrive) {
this.selectedDrive = null
this.selectedVersion = null
} else {
this.selectedDrive = name
this.selectedVersion = version
}
}
@@ -60,9 +67,33 @@ export class RecoverPage {
}
async chooseDisk() {
await this.apiService.selectEmbassyDrive({logicalName: this.selectedDrive})
this.presentPasswordModal()
}
async presentPasswordModal() {
const modal = await this.modalController.create({
component: PasswordPage,
backdropDismiss: false,
componentProps: {
'version': this.selectedVersion,
}
})
modal.onDidDismiss().then(ret => {
if(ret.data.pwValid) {
this.submitPWAndDisk(ret.data.password)
}
})
await modal.present();
}
async submitPWAndDisk(pw: string) {
await this.apiService.selectEmbassyDrive({logicalName: this.selectedDrive}, pw)
this.stateService.recoveryDrive = this.selectedDrive
this.stateService.pollDataTransferProgress()
}
async navToEmbassy() {
// @TODO nav to embassy
}
}