mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
drive return type update
This commit is contained in:
committed by
Aiden McClelland
parent
6b3570e150
commit
c21ebd2c5e
@@ -44,8 +44,8 @@
|
||||
<ion-icon slot="start" name="save-outline"></ion-icon>
|
||||
<ion-label class="ion-text-wrap">
|
||||
<h1>{{ drive.logicalname }}</h1>
|
||||
<h2 style="min-height: 19px;">{{ drive.labels.length ? drive.labels.join(' / ') : 'unnamed' }}</h2>
|
||||
<p> Using {{drive.used.toFixed(2)}} of {{drive.capacity.toFixed(2)}} GiB</p>
|
||||
<h2 style="min-height: 19px;">{{ getLabelLabel(drive) }}</h2>
|
||||
<p> Using {{ getUsage(drive) }} of {{drive.capacity.toFixed(2)}} GiB</p>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ng-container>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { iosTransitionAnimation, LoadingController, ModalController, NavController } from '@ionic/angular'
|
||||
import { ApiService, EmbassyDrive } from 'src/app/services/api/api.service'
|
||||
import { ApiService, Drive } from 'src/app/services/api/api.service'
|
||||
import { StateService } from 'src/app/services/state.service'
|
||||
import { PasswordPage } from '../password/password.page'
|
||||
|
||||
@@ -11,7 +11,7 @@ import { PasswordPage } from '../password/password.page'
|
||||
})
|
||||
export class EmbassyPage {
|
||||
embassyDrives = []
|
||||
selectedDrive: EmbassyDrive = null
|
||||
selectedDrive: Drive = null
|
||||
loading = true
|
||||
window = window
|
||||
|
||||
@@ -24,11 +24,12 @@ export class EmbassyPage {
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.embassyDrives = await this.apiService.getEmbassyDrives()
|
||||
const drives = (await this.apiService.getDrives()).filter(d => !d['embassy-os'])
|
||||
this.embassyDrives = (await this.apiService.getDrives()).filter(d => !d['embassy-os'])
|
||||
this.loading = false
|
||||
}
|
||||
|
||||
async chooseDrive(drive: EmbassyDrive) {
|
||||
async chooseDrive(drive: Drive) {
|
||||
const modal = await this.modalController.create({
|
||||
component: PasswordPage,
|
||||
componentProps: {
|
||||
@@ -62,4 +63,19 @@ export class EmbassyPage {
|
||||
})
|
||||
await modal.present();
|
||||
}
|
||||
|
||||
getLabelLabel(drive: Drive) {
|
||||
const labels = drive.partitions.map(p => p.label).filter(l => !!l)
|
||||
return labels.length ? labels.join(' / ') : 'unnamed'
|
||||
}
|
||||
|
||||
getUsage(drive: Drive) {
|
||||
let usage = 0
|
||||
drive.partitions.forEach(par => {
|
||||
if(par.used) {
|
||||
usage += par.used
|
||||
}
|
||||
})
|
||||
return usage.toFixed(2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<form (ngSubmit)="!!recoveryDrive ? verifyPw() : submitPw()">
|
||||
<div style="padding: 8px 24px;">
|
||||
<p *ngIf="!!embassyDrive">Choose a password for your embassy. You will need it every time you log in. If you lose it you will be permanently locked out of your embassy.</p>
|
||||
<p *ngIf="embassyDrive && embassyDrive.used > 0" style="padding-bottom: 15px;color: var(--ion-color-warning);"><b>Warning:</b> After submit, any data currently stored on <b>{{ embassyDrive.labels.length ? embassyDrive.labels.join(' / ') : embassyDrive.logicalname }}</b> will be wiped.</p>
|
||||
<p *ngIf="embassyDrive && getUsage(embassyDrive) > 0" style="padding-bottom: 15px;color: var(--ion-color-warning);"><b>Warning:</b> After submit, any data currently stored on <b>{{ getLabelLabel(embassyDrive) }}</b> will be wiped.</p>
|
||||
|
||||
<h4 class="input-label">
|
||||
Password:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { LoadingController, ModalController } from '@ionic/angular'
|
||||
import { ApiService, EmbassyDrive, RecoveryDrive } from 'src/app/services/api/api.service'
|
||||
import { ApiService, Drive } from 'src/app/services/api/api.service'
|
||||
import { StateService } from 'src/app/services/state.service'
|
||||
|
||||
@Component({
|
||||
@@ -9,8 +9,8 @@ import { StateService } from 'src/app/services/state.service'
|
||||
styleUrls: ['password.page.scss'],
|
||||
})
|
||||
export class PasswordPage {
|
||||
@Input() recoveryDrive: RecoveryDrive
|
||||
@Input() embassyDrive: EmbassyDrive
|
||||
@Input() recoveryDrive: Drive
|
||||
@Input() embassyDrive: Drive
|
||||
|
||||
pwError = ''
|
||||
password = ''
|
||||
@@ -53,7 +53,6 @@ export class PasswordPage {
|
||||
|
||||
async submitPw () {
|
||||
this.validate()
|
||||
console.log('here')
|
||||
if (this.password !== this.passwordVer) {
|
||||
this.verError="*passwords do not match"
|
||||
}
|
||||
@@ -84,4 +83,19 @@ export class PasswordPage {
|
||||
cancel () {
|
||||
this.modalController.dismiss()
|
||||
}
|
||||
|
||||
getLabelLabel(drive: Drive) {
|
||||
const labels = drive.partitions.map(p => p.label).filter(l => !!l)
|
||||
return labels.length ? labels.join(' / ') : 'unnamed'
|
||||
}
|
||||
|
||||
getUsage(drive: Drive) {
|
||||
let usage = 0
|
||||
drive.partitions.forEach(par => {
|
||||
if(par.used) {
|
||||
usage += par.used
|
||||
}
|
||||
})
|
||||
return usage
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,17 +44,17 @@
|
||||
<ion-icon slot="start" name="save-outline"></ion-icon>
|
||||
<ion-label class="ion-text-wrap">
|
||||
<h1>{{ drive.logicalname }}</h1>
|
||||
<h2>{{ drive.name }}</h2>
|
||||
<p> Embassy version: {{drive.version}}</p>
|
||||
<h2>{{ drive['embassy-os'].name }}</h2>
|
||||
<p> Embassy version: {{drive['embassy-os'].version}}</p>
|
||||
</ion-label>
|
||||
<ion-icon *ngIf="drive.version.startsWith('0.2') || passwords[drive.logicalname]" color="success" slot="end" name="lock-open-outline"></ion-icon>
|
||||
<ion-icon *ngIf="!drive.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') || 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-item>
|
||||
</ng-container>
|
||||
<ion-button
|
||||
(click)="selectRecoveryDrive()"
|
||||
[disabled]="!selectedDrive || (!passwords[selectedDrive.logicalname] && !selectedDrive.version.startsWith('0.2'))"
|
||||
[disabled]="!selectedDrive || (!passwords[selectedDrive.logicalname] && !selectedDrive['embassy-os'].version.startsWith('0.2'))"
|
||||
class="claim-button"
|
||||
>
|
||||
Next
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { iosTransitionAnimation, ModalController, NavController } from '@ionic/angular'
|
||||
import { ApiService, RecoveryDrive } from 'src/app/services/api/api.service'
|
||||
import { ApiService, Drive } from 'src/app/services/api/api.service'
|
||||
import { StateService } from 'src/app/services/state.service'
|
||||
import { PasswordPage } from '../password/password.page'
|
||||
|
||||
@@ -12,7 +12,7 @@ import { PasswordPage } from '../password/password.page'
|
||||
export class RecoverPage {
|
||||
passwords = {}
|
||||
recoveryDrives = []
|
||||
selectedDrive: RecoveryDrive = null
|
||||
selectedDrive: Drive = null
|
||||
loading = true
|
||||
window = window
|
||||
|
||||
@@ -24,11 +24,11 @@ export class RecoverPage {
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.recoveryDrives = await this.apiService.getRecoveryDrives()
|
||||
this.recoveryDrives = (await this.apiService.getDrives()).filter(d => !!d['embassy-os'])
|
||||
this.loading = false
|
||||
}
|
||||
|
||||
async chooseDrive(drive: RecoveryDrive) {
|
||||
async chooseDrive(drive: Drive) {
|
||||
|
||||
if (this.selectedDrive?.logicalname === drive.logicalname) {
|
||||
this.selectedDrive = null
|
||||
@@ -37,7 +37,7 @@ export class RecoverPage {
|
||||
this.selectedDrive = drive
|
||||
}
|
||||
|
||||
if (drive.version.startsWith('0.2') || this.passwords[drive.logicalname]) return
|
||||
if (drive['embassy-os'].version.startsWith('0.2') || this.passwords[drive.logicalname]) return
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: PasswordPage,
|
||||
|
||||
Reference in New Issue
Block a user