mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 06:19:44 +00:00
working
This commit is contained in:
committed by
Aiden McClelland
parent
8f0e0a392e
commit
834de9ab54
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RecoverPage } from './recover.page';
|
||||
import { PasswordPageModule } from '../password/password.module';
|
||||
|
||||
import { RecoverPageRoutingModule } from './recover-routing.module';
|
||||
|
||||
@@ -12,7 +13,8 @@ import { RecoverPageRoutingModule } from './recover-routing.module';
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
RecoverPageRoutingModule
|
||||
RecoverPageRoutingModule,
|
||||
PasswordPageModule,
|
||||
],
|
||||
declarations: [RecoverPage]
|
||||
})
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<div *ngIf="!stateService.recoveryDrive">
|
||||
<h2 color="light">Select Data Drive</h2>
|
||||
<h2 color="light">Select Recovery Drive</h2>
|
||||
<ion-card
|
||||
*ngFor="let drive of dataDrives"
|
||||
(click)="selectDrive(drive)"
|
||||
button="true"
|
||||
[class.selected]="selectedDrive === drive['logical-name']"
|
||||
[class.selected]="selectedDrive?.logicalname === drive.logicalname"
|
||||
color="light"
|
||||
>
|
||||
<ion-card-header>
|
||||
<ion-card-title>{{drive["logical-name"]}}</ion-card-title>
|
||||
<ion-card-title>{{drive.logicalname}}</ion-card-title>
|
||||
<ion-card-subtitle>{{drive.name}}</ion-card-subtitle>
|
||||
</ion-card-header>
|
||||
|
||||
@@ -24,15 +24,15 @@
|
||||
Currently running {{drive.version}}
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
<ion-button (click)="warn()" color="primary" [disabled]="!selectedDrive">Next</ion-button>
|
||||
<ion-button (click)="chooseDrive()" color="primary" [disabled]="!selectedDrive">Next</ion-button>
|
||||
</div>
|
||||
<div *ngIf="stateService.recoveryDrive">
|
||||
<h2>Progress: {{ 100 * stateService.dataProgress }}% <ion-spinner *ngIf="stateService.dataProgress != 1"></ion-spinner> </h2>
|
||||
<h2>Progress: {{ 100 * stateService.dataProgress }}% <ion-spinner *ngIf="stateService.dataProgress !== 1"></ion-spinner> </h2>
|
||||
<ion-progress-bar value="{{stateService.dataProgress}}"></ion-progress-bar>
|
||||
<ion-button
|
||||
(click)="navToEmbassy()"
|
||||
color="primary"
|
||||
[disabled]="stateService.dataProgress != 1"
|
||||
[disabled]="stateService.dataProgress !== 1"
|
||||
>
|
||||
Go To Embassy
|
||||
</ion-button>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { AlertController, ModalController } from '@ionic/angular'
|
||||
import { ApiService, EmbassyDrive } from 'src/app/services/api/api.service'
|
||||
import { AlertController, ModalController, LoadingController } 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'
|
||||
|
||||
@@ -11,62 +11,33 @@ import { PasswordPage } from '../password/password.page'
|
||||
})
|
||||
export class RecoverPage {
|
||||
dataDrives = []
|
||||
selectedDrive = null
|
||||
selectedVersion = null
|
||||
selectedDrive: RecoveryDrive = null
|
||||
|
||||
constructor(
|
||||
private readonly apiService: ApiService,
|
||||
private readonly stateService: StateService,
|
||||
public alertController: AlertController,
|
||||
private modalController: ModalController,
|
||||
private readonly loadingCtrl: LoadingController,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
if(!this.stateService.recoveryDrive) {
|
||||
this.dataDrives = await this.apiService.getEmbassyDrives()
|
||||
this.dataDrives = await this.apiService.getRecoveryDrives()
|
||||
} else {
|
||||
this.stateService.pollDataTransferProgress()
|
||||
}
|
||||
}
|
||||
|
||||
selectDrive(disk: EmbassyDrive) {
|
||||
const name = disk['logical-name']
|
||||
const version = disk.version
|
||||
if (name === this.selectedDrive) {
|
||||
selectDrive(drive: RecoveryDrive) {
|
||||
if (drive.logicalname === this.selectedDrive?.logicalname) {
|
||||
this.selectedDrive = null
|
||||
this.selectedVersion = null
|
||||
} else {
|
||||
this.selectedDrive = name
|
||||
this.selectedVersion = version
|
||||
this.selectedDrive = drive
|
||||
}
|
||||
}
|
||||
|
||||
async warn() {
|
||||
const alert = await this.alertController.create({
|
||||
cssClass: 'my-custom-class',
|
||||
header: 'Warning!',
|
||||
message: 'Once you select this the recovery process will begin.',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Cancel',
|
||||
role: 'cancel',
|
||||
cssClass: 'secondary',
|
||||
handler: () => {
|
||||
this.selectedDrive = null
|
||||
}
|
||||
}, {
|
||||
text: 'Okay',
|
||||
handler: async () => {
|
||||
await this.chooseDisk()
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
await alert.present();
|
||||
}
|
||||
|
||||
async chooseDisk() {
|
||||
async chooseDrive() {
|
||||
this.presentPasswordModal()
|
||||
}
|
||||
|
||||
@@ -75,25 +46,38 @@ export class RecoverPage {
|
||||
component: PasswordPage,
|
||||
backdropDismiss: false,
|
||||
componentProps: {
|
||||
'version': this.selectedVersion,
|
||||
recoveryDrive: this.selectedDrive,
|
||||
}
|
||||
})
|
||||
modal.onDidDismiss().then(ret => {
|
||||
if(ret.data.pwValid) {
|
||||
this.submitPWAndDisk(ret.data.password)
|
||||
const pass = ret.data.password
|
||||
if(pass) {
|
||||
this.submitPWAndDrive(pass)
|
||||
}
|
||||
})
|
||||
await modal.present();
|
||||
}
|
||||
|
||||
async submitPWAndDisk(pw: string) {
|
||||
await this.apiService.selectEmbassyDrive({logicalName: this.selectedDrive}, pw)
|
||||
this.stateService.recoveryDrive = this.selectedDrive
|
||||
this.stateService.pollDataTransferProgress()
|
||||
async submitPWAndDrive(pw: string) {
|
||||
const loader = await this.loadingCtrl.create({
|
||||
message: 'Validating password'
|
||||
})
|
||||
await loader.present()
|
||||
|
||||
try {
|
||||
await this.apiService.selectRecoveryDrive(this.selectedDrive.logicalname, pw)
|
||||
this.stateService.recoveryDrive = this.selectedDrive
|
||||
this.stateService.pollDataTransferProgress()
|
||||
} catch (e) {
|
||||
} finally {
|
||||
loader.dismiss()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async navToEmbassy() {
|
||||
// @TODO nav to embassy
|
||||
location.reload()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user