spec updates

This commit is contained in:
Drew Ansbacher
2021-09-13 18:06:02 +02:00
committed by Aiden McClelland
parent c21ebd2c5e
commit 77495cb674
9 changed files with 66 additions and 61 deletions

View File

@@ -11,18 +11,12 @@ setup.disk.list
Response Response
{ {
logicalname: string logicalname : string,
partitions: { vendor : string | null,
logicalname: string model : string | null,
label: string | null partitions : PartitionInfo[],
capacity: number capacity : number,
used: number | null embassy_os : EmbassyOsDiskInfo | null,
}[],
capacity: number
'embassy-os': {
version: string
name: string
} | null
}[] }[]
setup.recovery.status setup.recovery.status

View File

@@ -1,6 +1,6 @@
import { Component } from '@angular/core' import { Component } from '@angular/core'
import { iosTransitionAnimation, LoadingController, ModalController, NavController } from '@ionic/angular' import { iosTransitionAnimation, LoadingController, ModalController, NavController } from '@ionic/angular'
import { ApiService, Drive } from 'src/app/services/api/api.service' import { ApiService, DiskInfo } from 'src/app/services/api/api.service'
import { StateService } from 'src/app/services/state.service' import { StateService } from 'src/app/services/state.service'
import { PasswordPage } from '../password/password.page' import { PasswordPage } from '../password/password.page'
@@ -11,7 +11,7 @@ import { PasswordPage } from '../password/password.page'
}) })
export class EmbassyPage { export class EmbassyPage {
embassyDrives = [] embassyDrives = []
selectedDrive: Drive = null selectedDrive: DiskInfo = null
loading = true loading = true
window = window window = window
@@ -24,12 +24,12 @@ export class EmbassyPage {
) {} ) {}
async ngOnInit() { async ngOnInit() {
const drives = (await this.apiService.getDrives()).filter(d => !d['embassy-os']) const drives = (await this.apiService.getDrives()).filter(d => !d['embassy_os'])
this.embassyDrives = (await this.apiService.getDrives()).filter(d => !d['embassy-os']) this.embassyDrives = (await this.apiService.getDrives()).filter(d => !d['embassy_os'])
this.loading = false this.loading = false
} }
async chooseDrive(drive: Drive) { async chooseDrive(drive: DiskInfo) {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: PasswordPage, component: PasswordPage,
componentProps: { componentProps: {
@@ -64,12 +64,12 @@ export class EmbassyPage {
await modal.present(); await modal.present();
} }
getLabelLabel(drive: Drive) { getLabelLabel(drive: DiskInfo) {
const labels = drive.partitions.map(p => p.label).filter(l => !!l) const labels = drive.partitions.map(p => p.label).filter(l => !!l)
return labels.length ? labels.join(' / ') : 'unnamed' return labels.length ? labels.join(' / ') : 'unnamed'
} }
getUsage(drive: Drive) { getUsage(drive: DiskInfo) {
let usage = 0 let usage = 0
drive.partitions.forEach(par => { drive.partitions.forEach(par => {
if(par.used) { if(par.used) {

View File

@@ -1,6 +1,6 @@
import { Component, Input } from '@angular/core' import { Component, Input } from '@angular/core'
import { LoadingController, ModalController } from '@ionic/angular' import { LoadingController, ModalController } from '@ionic/angular'
import { ApiService, Drive } from 'src/app/services/api/api.service' import { ApiService, DiskInfo } from 'src/app/services/api/api.service'
import { StateService } from 'src/app/services/state.service' import { StateService } from 'src/app/services/state.service'
@Component({ @Component({
@@ -9,8 +9,8 @@ import { StateService } from 'src/app/services/state.service'
styleUrls: ['password.page.scss'], styleUrls: ['password.page.scss'],
}) })
export class PasswordPage { export class PasswordPage {
@Input() recoveryDrive: Drive @Input() recoveryDrive: DiskInfo
@Input() embassyDrive: Drive @Input() embassyDrive: DiskInfo
pwError = '' pwError = ''
password = '' password = ''
@@ -84,12 +84,12 @@ export class PasswordPage {
this.modalController.dismiss() this.modalController.dismiss()
} }
getLabelLabel(drive: Drive) { getLabelLabel(drive: DiskInfo) {
const labels = drive.partitions.map(p => p.label).filter(l => !!l) const labels = drive.partitions.map(p => p.label).filter(l => !!l)
return labels.length ? labels.join(' / ') : 'unnamed' return labels.length ? labels.join(' / ') : 'unnamed'
} }
getUsage(drive: Drive) { getUsage(drive: DiskInfo) {
let usage = 0 let usage = 0
drive.partitions.forEach(par => { drive.partitions.forEach(par => {
if(par.used) { if(par.used) {

View File

@@ -44,17 +44,17 @@
<ion-icon slot="start" name="save-outline"></ion-icon> <ion-icon slot="start" name="save-outline"></ion-icon>
<ion-label class="ion-text-wrap"> <ion-label class="ion-text-wrap">
<h1>{{ drive.logicalname }}</h1> <h1>{{ drive.logicalname }}</h1>
<h2>{{ drive['embassy-os'].name }}</h2> <h2>{{ drive.model }}</h2>
<p> Embassy version: {{drive['embassy-os'].version}}</p> <p> Embassy version: {{drive['embassy_os'].version}}</p>
</ion-label> </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="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') && !passwords[drive.logicalname]" color="danger" slot="end" name="lock-closed-outline"></ion-icon>
</ion-item> </ion-item>
</ng-container> </ng-container>
<ion-button <ion-button
(click)="selectRecoveryDrive()" (click)="selectRecoveryDrive()"
[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" class="claim-button"
> >
Next Next

View File

@@ -1,6 +1,6 @@
import { Component } from '@angular/core' import { Component } from '@angular/core'
import { iosTransitionAnimation, ModalController, NavController } from '@ionic/angular' import { iosTransitionAnimation, ModalController, NavController } from '@ionic/angular'
import { ApiService, Drive } from 'src/app/services/api/api.service' import { ApiService, DiskInfo } from 'src/app/services/api/api.service'
import { StateService } from 'src/app/services/state.service' import { StateService } from 'src/app/services/state.service'
import { PasswordPage } from '../password/password.page' import { PasswordPage } from '../password/password.page'
@@ -12,7 +12,7 @@ import { PasswordPage } from '../password/password.page'
export class RecoverPage { export class RecoverPage {
passwords = {} passwords = {}
recoveryDrives = [] recoveryDrives = []
selectedDrive: Drive = null selectedDrive: DiskInfo = null
loading = true loading = true
window = window window = window
@@ -24,11 +24,11 @@ export class RecoverPage {
) {} ) {}
async ngOnInit() { async ngOnInit() {
this.recoveryDrives = (await this.apiService.getDrives()).filter(d => !!d['embassy-os']) this.recoveryDrives = (await this.apiService.getDrives()).filter(d => !!d['embassy_os'])
this.loading = false this.loading = false
} }
async chooseDrive(drive: Drive) { async chooseDrive(drive: DiskInfo) {
if (this.selectedDrive?.logicalname === drive.logicalname) { if (this.selectedDrive?.logicalname === drive.logicalname) {
this.selectedDrive = null this.selectedDrive = null
@@ -37,7 +37,7 @@ export class RecoverPage {
this.selectedDrive = drive 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.passwords[drive.logicalname]) return
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: PasswordPage, component: PasswordPage,

View File

@@ -4,7 +4,7 @@ export abstract class ApiService {
protected error$: Subject<string> = new Subject(); protected error$: Subject<string> = new Subject();
watchError$ = this.error$.asObservable(); watchError$ = this.error$.asObservable();
abstract verifyProductKey (key: string): Promise<VerifyProductKeyRes>; abstract verifyProductKey (key: string): Promise<VerifyProductKeyRes>;
abstract getDrives (): Promise<Drive[]>; abstract getDrives (): Promise<DiskInfo[]>;
abstract getDataTransferProgress (): Promise<TransferProgressRes>; abstract getDataTransferProgress (): Promise<TransferProgressRes>;
abstract verifyRecoveryPassword (logicalname: string, password: string): Promise<boolean>; abstract verifyRecoveryPassword (logicalname: string, password: string): Promise<boolean>;
abstract setupEmbassy (setupInfo: { abstract setupEmbassy (setupInfo: {
@@ -29,17 +29,22 @@ export interface SetupEmbassyRes {
"tor-address": string "tor-address": string
} }
export interface Drive { export interface DiskInfo {
logicalname: string logicalname: string,
partitions: { vendor: string | null,
logicalname: string model: string | null,
label: string | null partitions: PartitionInfo[],
capacity: number capacity: number,
used: number | null embassy_os: EmbassyOsDiskInfo | null,
}[], }
capacity: number
'embassy-os': { interface PartitionInfo {
version: string logicalname: string,
name: string label: string | null,
} | null capacity: number,
}[] used: number | null,
}
interface EmbassyOsDiskInfo {
version: string,
}

View File

@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { ApiService, Drive, SetupEmbassyRes, TransferProgressRes, VerifyProductKeyRes } from './api.service' import { ApiService, DiskInfo, SetupEmbassyRes, TransferProgressRes, VerifyProductKeyRes } from './api.service'
import { HttpService } from './http.service' import { HttpService } from './http.service'
@Injectable({ @Injectable({
@@ -26,7 +26,7 @@ export class LiveApiService extends ApiService {
} }
async getDrives() { async getDrives() {
return this.http.rpcRequest<Drive[]>({ return this.http.rpcRequest<DiskInfo[]>({
method: 'setup.disk.list', method: 'setup.disk.list',
params: {} params: {}
}) })

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { pauseFor } from '../state.service' import { pauseFor } from '../state.service'
import { ApiService } from './api.service' import { ApiService, DiskInfo } from './api.service'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -30,6 +30,8 @@ export class MockApiService extends ApiService {
async getDrives() { async getDrives() {
return [ return [
{ {
vendor: 'vendor',
model: 'model',
logicalname: 'Name1', logicalname: 'Name1',
partitions: [{ partitions: [{
logicalname: 'Name1', logicalname: 'Name1',
@@ -43,9 +45,11 @@ export class MockApiService extends ApiService {
used: 200.1255312 used: 200.1255312
}], }],
capacity: 150000, capacity: 150000,
'embassy-os': null 'embassy_os': null
}, },
{ {
vendor: 'vendor',
model: 'model',
logicalname: 'Name2', logicalname: 'Name2',
partitions: [{ partitions: [{
logicalname: 'Name2', logicalname: 'Name2',
@@ -54,9 +58,11 @@ export class MockApiService extends ApiService {
used: 0.00, used: 0.00,
}], }],
capacity: 1600.01234, capacity: 1600.01234,
'embassy-os': null 'embassy_os': null
}, },
{ {
vendor: 'vendor',
model: 'model',
logicalname: 'Name3', logicalname: 'Name3',
partitions: [{ partitions: [{
logicalname: 'Name3', logicalname: 'Name3',
@@ -65,12 +71,13 @@ export class MockApiService extends ApiService {
used: null used: null
}], }],
capacity: 100000, capacity: 100000,
'embassy-os': { 'embassy_os': {
version: '0.3.3', version: '0.3.3',
name: 'My Embassy'
} }
}, },
{ {
vendor: 'vendor',
model: 'model',
logicalname: 'Name4', logicalname: 'Name4',
partitions: [{ partitions: [{
logicalname: 'Name4', logicalname: 'Name4',
@@ -79,9 +86,8 @@ export class MockApiService extends ApiService {
used: null used: null
}], }],
capacity: 10000, capacity: 10000,
'embassy-os': { 'embassy_os': {
version: '0.2.7', version: '0.2.7',
name: 'My Embassy'
} }
} }

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { ApiService, Drive } from './api/api.service' import { ApiService, DiskInfo } from './api/api.service'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -8,9 +8,9 @@ import { ApiService, Drive } from './api/api.service'
export class StateService { export class StateService {
polling = false polling = false
embassyDrive: Drive; embassyDrive: DiskInfo;
embassyPassword: string embassyPassword: string
recoveryDrive: Drive; recoveryDrive: DiskInfo;
recoveryPassword: string recoveryPassword: string
dataTransferProgress: { bytesTransfered: number; totalBytes: number } | null; dataTransferProgress: { bytesTransfered: number; totalBytes: number } | null;
dataProgress = 0; dataProgress = 0;