mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
Wizard refactor 2 (#615)
* new flow and endpoints * functional * prod build errors addressed * little more cleanup * transfer progress fixed * tor address fix * remove eslint cause sucks * fix skeleton text color and wording Co-authored-by: Matt Hill <matthewonthemoon@gmail.com> Co-authored-by: Drew Ansbacher <drew.ansbacher@spiredigital.com>
This commit is contained in:
committed by
Aiden McClelland
parent
e58df7ec4a
commit
ed395699b3
@@ -1,16 +1,16 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { RecoverPage } from './recover.page';
|
||||
import { NgModule } from '@angular/core'
|
||||
import { RouterModule, Routes } from '@angular/router'
|
||||
import { RecoverPage } from './recover.page'
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: RecoverPage,
|
||||
}
|
||||
];
|
||||
},
|
||||
]
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class RecoverPageRoutingModule {}
|
||||
export class RecoverPageRoutingModule { }
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
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';
|
||||
import { PipesModule } from 'src/app/pipes/pipe.module';
|
||||
import { NgModule } from '@angular/core'
|
||||
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 { ProdKeyModalModule } from '../prod-key-modal/prod-key-modal.module'
|
||||
import { RecoverPageRoutingModule } from './recover-routing.module'
|
||||
import { PipesModule } from 'src/app/pipes/pipe.module'
|
||||
|
||||
|
||||
@NgModule({
|
||||
@@ -15,8 +16,9 @@ import { PipesModule } from 'src/app/pipes/pipe.module';
|
||||
IonicModule,
|
||||
RecoverPageRoutingModule,
|
||||
PasswordPageModule,
|
||||
ProdKeyModalModule,
|
||||
PipesModule,
|
||||
],
|
||||
declarations: [RecoverPage]
|
||||
declarations: [RecoverPage],
|
||||
})
|
||||
export class RecoverPageModule {}
|
||||
export class RecoverPageModule { }
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<ion-card color="dark">
|
||||
<ion-card-header class="ion-text-center" style="padding-bottom: 8px;">
|
||||
<ion-card-title>{{ loading ? 'Loading Recovery Drives' : 'Select Recovery Drive'}}</ion-card-title>
|
||||
<ion-card-title>Select Recovery Drive</ion-card-title>
|
||||
<ion-card-subtitle>Select the drive containing the Embassy you want to recover.</ion-card-subtitle>
|
||||
</ion-card-header>
|
||||
|
||||
@@ -50,17 +50,17 @@
|
||||
<span *ngIf="drive.vendor && drive.model"> - </span>
|
||||
{{ drive.model }}
|
||||
</h2>
|
||||
<h2> Embassy version: {{drive['embassy_os'].version}}</h2>
|
||||
<h2> Embassy version: {{drive['embassy-os'].version}}</h2>
|
||||
</ion-label>
|
||||
<ion-icon *ngIf="drive['embassy_os'].version.startsWith('0.2') || passwords[drive.logicalname]" color="success" slot="end" name="lock-open-outline"></ion-icon>
|
||||
<ion-icon *ngIf="!drive['embassy_os'].version.startsWith('0.2') && !passwords[drive.logicalname]" color="danger" slot="end" name="lock-closed-outline"></ion-icon>
|
||||
<ion-icon *ngIf="(drive['embassy-os'].version.startsWith('0.2') && stateService.hasProductKey) || passwords[drive.logicalname] || prodKeys[drive.logicalname]" color="success" slot="end" name="lock-open-outline"></ion-icon>
|
||||
<ion-icon *ngIf="(drive['embassy-os'].version.startsWith('0.2') && !stateService.hasProductKey && !prodKeys[drive.logicalname]) || (!drive['embassy-os'].version.startsWith('0.2') && !passwords[drive.logicalname])" color="danger" slot="end" name="lock-closed-outline"></ion-icon>
|
||||
|
||||
</ion-item>
|
||||
</ng-container>
|
||||
<ion-button
|
||||
(click)="selectRecoveryDrive()"
|
||||
color="light"
|
||||
[disabled]="!selectedDrive || (!passwords[selectedDrive.logicalname] && !selectedDrive['embassy_os'].version.startsWith('0.2'))"
|
||||
[disabled]="!selectedDrive || (!passwords[selectedDrive.logicalname] && !selectedDrive['embassy-os'].version.startsWith('0.2'))"
|
||||
class="claim-button"
|
||||
*ngIf="recoveryDrives.length"
|
||||
>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { iosTransitionAnimation, ModalController, NavController } from '@ionic/angular'
|
||||
import { ModalController, NavController } from '@ionic/angular'
|
||||
import { ApiService, DiskInfo } from 'src/app/services/api/api.service'
|
||||
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
||||
import { StateService } from 'src/app/services/state.service'
|
||||
import { PasswordPage } from '../password/password.page'
|
||||
import { ProdKeyModal } from '../prod-key-modal/prod-key-modal.page'
|
||||
|
||||
@Component({
|
||||
selector: 'app-recover',
|
||||
@@ -11,18 +12,19 @@ import { PasswordPage } from '../password/password.page'
|
||||
styleUrls: ['recover.page.scss'],
|
||||
})
|
||||
export class RecoverPage {
|
||||
passwords = {}
|
||||
passwords = { }
|
||||
prodKeys = { }
|
||||
recoveryDrives = []
|
||||
selectedDrive: DiskInfo = null
|
||||
loading = true
|
||||
|
||||
constructor(
|
||||
constructor (
|
||||
private readonly apiService: ApiService,
|
||||
private readonly navCtrl: NavController,
|
||||
private readonly modalController: ModalController,
|
||||
private readonly stateService: StateService,
|
||||
private readonly modalController: ModalController,
|
||||
readonly stateService: StateService,
|
||||
private readonly errorToastService: ErrorToastService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async ngOnInit () {
|
||||
await this.getDrives()
|
||||
@@ -37,7 +39,14 @@ export class RecoverPage {
|
||||
|
||||
async getDrives () {
|
||||
try {
|
||||
this.recoveryDrives = (await this.apiService.getDrives()).filter(d => !!d['embassy_os'])
|
||||
let drives = (await this.apiService.getDrives()).filter(d => !!d['embassy-os'])
|
||||
|
||||
if (!this.stateService.hasProductKey) {
|
||||
drives = drives.filter(d => d['embassy-os'].version.startsWith('0.2'))
|
||||
}
|
||||
|
||||
this.recoveryDrives = drives
|
||||
|
||||
} catch (e) {
|
||||
this.errorToastService.present(`${e.message}: ${e.data}`)
|
||||
} finally {
|
||||
@@ -45,7 +54,7 @@ export class RecoverPage {
|
||||
}
|
||||
}
|
||||
|
||||
async chooseDrive(drive: DiskInfo) {
|
||||
async chooseDrive (drive: DiskInfo) {
|
||||
|
||||
if (this.selectedDrive?.logicalname === drive.logicalname) {
|
||||
this.selectedDrive = null
|
||||
@@ -54,32 +63,51 @@ export class RecoverPage {
|
||||
this.selectedDrive = drive
|
||||
}
|
||||
|
||||
if (drive['embassy_os'].version.startsWith('0.2') || this.passwords[drive.logicalname]) return
|
||||
if ((drive['embassy-os'].version.startsWith('0.2') && this.stateService.hasProductKey) || this.passwords[drive.logicalname] || this.prodKeys[drive.logicalname]) return
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: PasswordPage,
|
||||
componentProps: {
|
||||
recoveryDrive: this.selectedDrive
|
||||
},
|
||||
cssClass: 'alertlike-modal',
|
||||
})
|
||||
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();
|
||||
if (this.stateService.hasProductKey) {
|
||||
const modal = await this.modalController.create({
|
||||
component: PasswordPage,
|
||||
componentProps: {
|
||||
recoveryDrive: this.selectedDrive,
|
||||
},
|
||||
cssClass: 'alertlike-modal',
|
||||
})
|
||||
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()
|
||||
} else {
|
||||
const modal = await this.modalController.create({
|
||||
component: ProdKeyModal,
|
||||
componentProps: {
|
||||
recoveryDrive: this.selectedDrive,
|
||||
},
|
||||
cssClass: 'alertlike-modal',
|
||||
})
|
||||
modal.onDidDismiss().then(async ret => {
|
||||
if (!ret.data) {
|
||||
this.selectedDrive = null
|
||||
} else if (ret.data.productKey) {
|
||||
this.prodKeys[drive.logicalname] = ret.data.productKey
|
||||
}
|
||||
|
||||
})
|
||||
await modal.present()
|
||||
}
|
||||
}
|
||||
|
||||
async selectRecoveryDrive() {
|
||||
async selectRecoveryDrive () {
|
||||
this.stateService.recoveryDrive = this.selectedDrive
|
||||
const pw = this.passwords[this.selectedDrive.logicalname]
|
||||
if(pw) {
|
||||
if (pw) {
|
||||
this.stateService.recoveryPassword = pw
|
||||
}
|
||||
await this.navCtrl.navigateForward(`/embassy`, { animationDirection: 'forward', animation: iosTransitionAnimation })
|
||||
}
|
||||
await this.navCtrl.navigateForward(`/embassy`)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user