diff --git a/setup-wizard/docs.txt b/setup-wizard/docs.txt index 9870613b2..58d75ff2c 100644 --- a/setup-wizard/docs.txt +++ b/setup-wizard/docs.txt @@ -11,18 +11,12 @@ setup.disk.list Response { - logicalname: string - partitions: { - logicalname: string - label: string | null - capacity: number - used: number | null - }[], - capacity: number - 'embassy-os': { - version: string - name: string - } | null + logicalname : string, + vendor : string | null, + model : string | null, + partitions : PartitionInfo[], + capacity : number, + embassy_os : EmbassyOsDiskInfo | null, }[] setup.recovery.status diff --git a/setup-wizard/src/app/pages/embassy/embassy.page.ts b/setup-wizard/src/app/pages/embassy/embassy.page.ts index afa262b27..414f2e3fc 100644 --- a/setup-wizard/src/app/pages/embassy/embassy.page.ts +++ b/setup-wizard/src/app/pages/embassy/embassy.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' 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 { PasswordPage } from '../password/password.page' @@ -11,7 +11,7 @@ import { PasswordPage } from '../password/password.page' }) export class EmbassyPage { embassyDrives = [] - selectedDrive: Drive = null + selectedDrive: DiskInfo = null loading = true window = window @@ -24,12 +24,12 @@ export class EmbassyPage { ) {} async ngOnInit() { - const drives = (await this.apiService.getDrives()).filter(d => !d['embassy-os']) - this.embassyDrives = (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.loading = false } - async chooseDrive(drive: Drive) { + async chooseDrive(drive: DiskInfo) { const modal = await this.modalController.create({ component: PasswordPage, componentProps: { @@ -64,12 +64,12 @@ export class EmbassyPage { await modal.present(); } - getLabelLabel(drive: Drive) { + getLabelLabel(drive: DiskInfo) { const labels = drive.partitions.map(p => p.label).filter(l => !!l) return labels.length ? labels.join(' / ') : 'unnamed' } - getUsage(drive: Drive) { + getUsage(drive: DiskInfo) { let usage = 0 drive.partitions.forEach(par => { if(par.used) { diff --git a/setup-wizard/src/app/pages/password/password.page.ts b/setup-wizard/src/app/pages/password/password.page.ts index 8066a3bf5..3e706d6a7 100644 --- a/setup-wizard/src/app/pages/password/password.page.ts +++ b/setup-wizard/src/app/pages/password/password.page.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core' 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' @Component({ @@ -9,8 +9,8 @@ import { StateService } from 'src/app/services/state.service' styleUrls: ['password.page.scss'], }) export class PasswordPage { - @Input() recoveryDrive: Drive - @Input() embassyDrive: Drive + @Input() recoveryDrive: DiskInfo + @Input() embassyDrive: DiskInfo pwError = '' password = '' @@ -84,12 +84,12 @@ export class PasswordPage { this.modalController.dismiss() } - getLabelLabel(drive: Drive) { + getLabelLabel(drive: DiskInfo) { const labels = drive.partitions.map(p => p.label).filter(l => !!l) return labels.length ? labels.join(' / ') : 'unnamed' } - getUsage(drive: Drive) { + getUsage(drive: DiskInfo) { let usage = 0 drive.partitions.forEach(par => { if(par.used) { diff --git a/setup-wizard/src/app/pages/recover/recover.page.html b/setup-wizard/src/app/pages/recover/recover.page.html index 38a45c3ec..96ce0b4bd 100644 --- a/setup-wizard/src/app/pages/recover/recover.page.html +++ b/setup-wizard/src/app/pages/recover/recover.page.html @@ -44,17 +44,17 @@ {{ drive.logicalname }} - {{ drive['embassy-os'].name }} - Embassy version: {{drive['embassy-os'].version}} + {{ drive.model }} + Embassy version: {{drive['embassy_os'].version}} - - + + Next diff --git a/setup-wizard/src/app/pages/recover/recover.page.ts b/setup-wizard/src/app/pages/recover/recover.page.ts index 2fdeb9cd5..c0812357f 100644 --- a/setup-wizard/src/app/pages/recover/recover.page.ts +++ b/setup-wizard/src/app/pages/recover/recover.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' 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 { PasswordPage } from '../password/password.page' @@ -12,7 +12,7 @@ import { PasswordPage } from '../password/password.page' export class RecoverPage { passwords = {} recoveryDrives = [] - selectedDrive: Drive = null + selectedDrive: DiskInfo = null loading = true window = window @@ -24,11 +24,11 @@ export class RecoverPage { ) {} 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 } - async chooseDrive(drive: Drive) { + async chooseDrive(drive: DiskInfo) { if (this.selectedDrive?.logicalname === drive.logicalname) { this.selectedDrive = null @@ -37,7 +37,7 @@ 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.passwords[drive.logicalname]) return const modal = await this.modalController.create({ component: PasswordPage, diff --git a/setup-wizard/src/app/services/api/api.service.ts b/setup-wizard/src/app/services/api/api.service.ts index 7a2c75401..657944830 100644 --- a/setup-wizard/src/app/services/api/api.service.ts +++ b/setup-wizard/src/app/services/api/api.service.ts @@ -4,7 +4,7 @@ export abstract class ApiService { protected error$: Subject = new Subject(); watchError$ = this.error$.asObservable(); abstract verifyProductKey (key: string): Promise; - abstract getDrives (): Promise; + abstract getDrives (): Promise; abstract getDataTransferProgress (): Promise; abstract verifyRecoveryPassword (logicalname: string, password: string): Promise; abstract setupEmbassy (setupInfo: { @@ -29,17 +29,22 @@ export interface SetupEmbassyRes { "tor-address": string } -export interface Drive { - logicalname: string - partitions: { - logicalname: string - label: string | null - capacity: number - used: number | null - }[], - capacity: number - 'embassy-os': { - version: string - name: string - } | null -}[] +export interface DiskInfo { + logicalname: string, + vendor: string | null, + model: string | null, + partitions: PartitionInfo[], + capacity: number, + embassy_os: EmbassyOsDiskInfo | null, +} + +interface PartitionInfo { + logicalname: string, + label: string | null, + capacity: number, + used: number | null, +} + +interface EmbassyOsDiskInfo { + version: string, +} \ No newline at end of file diff --git a/setup-wizard/src/app/services/api/live-api.service.ts b/setup-wizard/src/app/services/api/live-api.service.ts index 15d5e9f2f..fffc19050 100644 --- a/setup-wizard/src/app/services/api/live-api.service.ts +++ b/setup-wizard/src/app/services/api/live-api.service.ts @@ -1,5 +1,5 @@ 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' @Injectable({ @@ -26,7 +26,7 @@ export class LiveApiService extends ApiService { } async getDrives() { - return this.http.rpcRequest({ + return this.http.rpcRequest({ method: 'setup.disk.list', params: {} }) diff --git a/setup-wizard/src/app/services/api/mock-api.service.ts b/setup-wizard/src/app/services/api/mock-api.service.ts index 6c5f87c51..95f5f44e4 100644 --- a/setup-wizard/src/app/services/api/mock-api.service.ts +++ b/setup-wizard/src/app/services/api/mock-api.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' import { pauseFor } from '../state.service' -import { ApiService } from './api.service' +import { ApiService, DiskInfo } from './api.service' @Injectable({ providedIn: 'root' @@ -30,6 +30,8 @@ export class MockApiService extends ApiService { async getDrives() { return [ { + vendor: 'vendor', + model: 'model', logicalname: 'Name1', partitions: [{ logicalname: 'Name1', @@ -43,9 +45,11 @@ export class MockApiService extends ApiService { used: 200.1255312 }], capacity: 150000, - 'embassy-os': null + 'embassy_os': null }, { + vendor: 'vendor', + model: 'model', logicalname: 'Name2', partitions: [{ logicalname: 'Name2', @@ -54,9 +58,11 @@ export class MockApiService extends ApiService { used: 0.00, }], capacity: 1600.01234, - 'embassy-os': null + 'embassy_os': null }, { + vendor: 'vendor', + model: 'model', logicalname: 'Name3', partitions: [{ logicalname: 'Name3', @@ -65,12 +71,13 @@ export class MockApiService extends ApiService { used: null }], capacity: 100000, - 'embassy-os': { + 'embassy_os': { version: '0.3.3', - name: 'My Embassy' } }, { + vendor: 'vendor', + model: 'model', logicalname: 'Name4', partitions: [{ logicalname: 'Name4', @@ -79,9 +86,8 @@ export class MockApiService extends ApiService { used: null }], capacity: 10000, - 'embassy-os': { + 'embassy_os': { version: '0.2.7', - name: 'My Embassy' } } diff --git a/setup-wizard/src/app/services/state.service.ts b/setup-wizard/src/app/services/state.service.ts index b6877a7d7..8e58e7ba8 100644 --- a/setup-wizard/src/app/services/state.service.ts +++ b/setup-wizard/src/app/services/state.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' import { BehaviorSubject } from 'rxjs'; -import { ApiService, Drive } from './api/api.service' +import { ApiService, DiskInfo } from './api/api.service' @Injectable({ providedIn: 'root' @@ -8,9 +8,9 @@ import { ApiService, Drive } from './api/api.service' export class StateService { polling = false - embassyDrive: Drive; + embassyDrive: DiskInfo; embassyPassword: string - recoveryDrive: Drive; + recoveryDrive: DiskInfo; recoveryPassword: string dataTransferProgress: { bytesTransfered: number; totalBytes: number } | null; dataProgress = 0;
Embassy version: {{drive['embassy-os'].version}}
Embassy version: {{drive['embassy_os'].version}}