mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
working
This commit is contained in:
committed by
Aiden McClelland
parent
fbcf4cacdb
commit
b761c3dabd
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HomePage } from './home.page';
|
||||
import { PasswordPageModule } from '../password/password.module';
|
||||
|
||||
import { HomePageRoutingModule } from './home-routing.module';
|
||||
|
||||
@@ -12,7 +13,8 @@ import { HomePageRoutingModule } from './home-routing.module';
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
HomePageRoutingModule
|
||||
HomePageRoutingModule,
|
||||
PasswordPageModule,
|
||||
],
|
||||
declarations: [HomePage]
|
||||
})
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<div *ngIf="!stateService.selectedDataDrive">
|
||||
<div *ngIf="!stateService.dataDrive">
|
||||
<h2 color="light">Select Data 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.labels}}</ion-card-subtitle>
|
||||
</ion-card-header>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</ion-card>
|
||||
<ion-button (click)="warn()" color="primary" [disabled]="!selectedDrive">Next</ion-button>
|
||||
</div>
|
||||
<div *ngIf="stateService.selectedDataDrive">
|
||||
<div *ngIf="stateService.dataDrive">
|
||||
<ion-card
|
||||
(click)="presentPasswordModal()"
|
||||
button="true"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { AlertController, ModalController } from '@ionic/angular'
|
||||
import { ApiService } from 'src/app/services/api/api.service'
|
||||
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'
|
||||
|
||||
@@ -11,26 +11,27 @@ import { PasswordPage } from '../password/password.page'
|
||||
})
|
||||
export class HomePage {
|
||||
dataDrives = []
|
||||
selectedDrive = null
|
||||
selectedDrive: DataDrive = null
|
||||
|
||||
constructor(
|
||||
private readonly apiService: ApiService,
|
||||
private readonly stateService: StateService,
|
||||
private readonly alertController: AlertController,
|
||||
private modalController: ModalController,
|
||||
private readonly modalController: ModalController,
|
||||
private readonly loadingCtrl: LoadingController,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
if(!this.stateService.selectedDataDrive) {
|
||||
this.dataDrives = await this.apiService.getStorageDisks()
|
||||
if(!this.stateService.dataDrive) {
|
||||
this.dataDrives = await this.apiService.getDataDrives()
|
||||
}
|
||||
}
|
||||
|
||||
selectDrive(name: string) {
|
||||
if (name === this.selectedDrive) {
|
||||
selectDrive(drive: DataDrive) {
|
||||
if (drive.logicalname === this.selectedDrive?.logicalname) {
|
||||
this.selectedDrive = null
|
||||
} else {
|
||||
this.selectedDrive = name
|
||||
this.selectedDrive = drive
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ export class HomePage {
|
||||
const alert = await this.alertController.create({
|
||||
cssClass: 'my-custom-class',
|
||||
header: 'Warning!',
|
||||
message: 'This disk will be entirely wiped of all memory.',
|
||||
message: 'This drive will be entirely wiped of all memory.',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Cancel',
|
||||
@@ -50,7 +51,7 @@ export class HomePage {
|
||||
}, {
|
||||
text: 'Okay',
|
||||
handler: async () => {
|
||||
await this.chooseDisk()
|
||||
await this.chooseDrive()
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -59,30 +60,38 @@ export class HomePage {
|
||||
await alert.present();
|
||||
}
|
||||
|
||||
async chooseDisk() {
|
||||
await this.apiService.selectStorageDisk({logicalName: this.selectedDrive})
|
||||
this.stateService.selectedDataDrive = this.selectedDrive
|
||||
async chooseDrive() {
|
||||
await this.apiService.selectDataDrive(this.selectedDrive.logicalname)
|
||||
this.stateService.dataDrive = this.selectedDrive
|
||||
}
|
||||
|
||||
async presentPasswordModal() {
|
||||
const modal = await this.modalController.create({
|
||||
component: PasswordPage,
|
||||
backdropDismiss: false,
|
||||
componentProps: {
|
||||
'version': null,
|
||||
}
|
||||
backdropDismiss: false
|
||||
})
|
||||
modal.onDidDismiss().then(ret => {
|
||||
if(ret.data.pwValid) {
|
||||
this.submitPassword(ret.data.password)
|
||||
const pass = ret.data.password
|
||||
if (pass) {
|
||||
this.submitPassword(pass)
|
||||
}
|
||||
})
|
||||
await modal.present();
|
||||
}
|
||||
|
||||
async submitPassword (pw: string) {
|
||||
await this.apiService.submitPassword(pw)
|
||||
// @TODO navigate to embassyOS
|
||||
const loader = await this.loadingCtrl.create({
|
||||
message: 'Setting up your Embassy'
|
||||
})
|
||||
await loader.present()
|
||||
|
||||
try {
|
||||
await this.apiService.submitPassword(pw)
|
||||
location.reload()
|
||||
} catch (e) {
|
||||
} finally {
|
||||
loader.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<div *ngIf="!needsVer">
|
||||
<div *ngIf="needsVer">
|
||||
<h2>Enter Password</h2>
|
||||
<ion-input type="password" [(ngModel)]="password">Password:</ion-input>
|
||||
</div>
|
||||
|
||||
<div *ngIf="needsVer">
|
||||
<div *ngIf="!needsVer">
|
||||
<h2>Create Password</h2>
|
||||
<ion-input type="password" [(ngModel)]="password">Password:</ion-input>
|
||||
<ion-input type="password" [(ngModel)]="passwordVer">Verify Password:</ion-input>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { ModalController } from '@ionic/angular'
|
||||
import { RecoveryDrive } from 'src/app/services/api/api.service'
|
||||
|
||||
@Component({
|
||||
selector: 'password',
|
||||
@@ -7,9 +8,9 @@ import { ModalController } from '@ionic/angular'
|
||||
styleUrls: ['password.page.scss'],
|
||||
})
|
||||
export class PasswordPage {
|
||||
@Input() version: string | null
|
||||
@Input() recoveryDrive: RecoveryDrive
|
||||
|
||||
needsVer = true
|
||||
needsVer: boolean
|
||||
|
||||
error = ''
|
||||
password = ''
|
||||
@@ -20,27 +21,20 @@ export class PasswordPage {
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.needsVer = !this.version?.startsWith('0.3')
|
||||
console.log('needs', this.needsVer)
|
||||
this.needsVer = !!this.recoveryDrive && !this.recoveryDrive.version.startsWith('0.2')
|
||||
}
|
||||
|
||||
async submitPassword () {
|
||||
if (this.needsVer && this.password !== this.passwordVer) {
|
||||
if (!this.needsVer && this.password !== this.passwordVer) {
|
||||
this.error="*passwords dont match"
|
||||
} else {
|
||||
this.dismiss(true)
|
||||
this.modalController.dismiss({
|
||||
password: this.password,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
cancel () {
|
||||
this.dismiss(false)
|
||||
this.modalController.dismiss()
|
||||
}
|
||||
|
||||
dismiss(submitted: boolean) {
|
||||
this.modalController.dismiss({
|
||||
pwValid: submitted,
|
||||
pw: this.password
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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