mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
Feature/install wizard disk info (#1923)
* update disk res for install wizard (#1914) * change types to match setup api Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { IonicModule } from '@ionic/angular'
|
||||
import { FormsModule } from '@angular/forms'
|
||||
import { HomePage } from './home.page'
|
||||
import { SwiperModule } from 'swiper/angular'
|
||||
import { UnitConversionPipesModule } from '@start9labs/shared'
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
@@ -20,6 +21,7 @@ const routes: Routes = [
|
||||
IonicModule,
|
||||
RouterModule.forChild(routes),
|
||||
SwiperModule,
|
||||
UnitConversionPipesModule,
|
||||
],
|
||||
declarations: [HomePage],
|
||||
})
|
||||
|
||||
@@ -31,50 +31,61 @@
|
||||
<ion-item
|
||||
*ngFor="let disk of disks"
|
||||
button
|
||||
detail="true"
|
||||
(click)="next(disk)"
|
||||
>
|
||||
<ion-icon
|
||||
color="dark"
|
||||
slot="start"
|
||||
name="save-outline"
|
||||
size="large"
|
||||
color="dark"
|
||||
></ion-icon>
|
||||
<ion-label>{{ disk.logicalname }}</ion-label>
|
||||
<ion-label class="ion-text-wrap">
|
||||
<h1>
|
||||
{{ disk.vendor || 'Unknown Vendor' }} - {{ disk.model ||
|
||||
'Unknown Model' }}
|
||||
</h1>
|
||||
<h2>
|
||||
{{ disk.logicalname }} - {{ disk.capacity | convertBytes
|
||||
}}
|
||||
</h2>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ng-template>
|
||||
<ng-template swiperSlide>
|
||||
<ion-item
|
||||
*ngIf="selectedDisk?.['embassy-data']"
|
||||
*ngIf="!!selectedDisk?.guid"
|
||||
button
|
||||
(click)="tryInstall(false)"
|
||||
>
|
||||
<ion-icon
|
||||
color="dark"
|
||||
slot="start"
|
||||
size="large"
|
||||
name="medkit-outline"
|
||||
></ion-icon>
|
||||
<ion-label>
|
||||
<h2>
|
||||
<h1>
|
||||
<ion-text color="success">Re-Install embassyOS</ion-text>
|
||||
</h2>
|
||||
<h4>Will preserve existing embassyOS data</h4>
|
||||
</h1>
|
||||
<h2>Will preserve existing embassyOS data</h2>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
<ion-item button lines="none" (click)="tryInstall(true)">
|
||||
<ion-icon
|
||||
color="dark"
|
||||
slot="start"
|
||||
size="large"
|
||||
name="download-outline"
|
||||
></ion-icon>
|
||||
<ion-label>
|
||||
<h2>
|
||||
<h1>
|
||||
<ion-text
|
||||
[color]="selectedDisk?.['embassy-data'] ? 'danger' : 'success'"
|
||||
>{{ selectedDisk?.['embassy-data'] ? 'Factory Reset' :
|
||||
'Install embassyOS' }}</ion-text
|
||||
[color]="!!selectedDisk?.guid ? 'danger' : 'success'"
|
||||
>{{ !!selectedDisk?.guid ? 'Factory Reset' : 'Install
|
||||
embassyOS' }}</ion-text
|
||||
>
|
||||
</h2>
|
||||
<h4>Will delete existing data on disk</h4>
|
||||
</h1>
|
||||
<h2>Will delete existing data on disk</h2>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ng-template>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { AlertController, IonicSlides, LoadingController } from '@ionic/angular'
|
||||
import { ApiService, Disk } from 'src/app/services/api/api.service'
|
||||
import { ApiService } from 'src/app/services/api/api.service'
|
||||
import SwiperCore, { Swiper } from 'swiper'
|
||||
import { DiskInfo } from '@start9labs/shared'
|
||||
|
||||
SwiperCore.use([IonicSlides])
|
||||
|
||||
@@ -12,8 +13,8 @@ SwiperCore.use([IonicSlides])
|
||||
})
|
||||
export class HomePage {
|
||||
swiper?: Swiper
|
||||
disks: Disk[] = []
|
||||
selectedDisk?: Disk
|
||||
disks: DiskInfo[] = []
|
||||
selectedDisk?: DiskInfo
|
||||
error = ''
|
||||
|
||||
constructor(
|
||||
@@ -36,7 +37,7 @@ export class HomePage {
|
||||
this.swiper = swiper
|
||||
}
|
||||
|
||||
next(disk: Disk) {
|
||||
next(disk: DiskInfo) {
|
||||
this.selectedDisk = disk
|
||||
this.swiper?.slideNext(500)
|
||||
}
|
||||
@@ -48,13 +49,15 @@ export class HomePage {
|
||||
async tryInstall(overwrite: boolean) {
|
||||
if (!this.selectedDisk) return
|
||||
|
||||
const { logicalname, 'embassy-data': embassyData } = this.selectedDisk
|
||||
const { logicalname, guid } = this.selectedDisk
|
||||
|
||||
if (embassyData && !overwrite) {
|
||||
const hasEmbassyData = !!guid
|
||||
|
||||
if (hasEmbassyData && !overwrite) {
|
||||
return this.install(logicalname, overwrite)
|
||||
}
|
||||
|
||||
await this.presentAlertDanger(logicalname, embassyData)
|
||||
await this.presentAlertDanger(logicalname, hasEmbassyData)
|
||||
}
|
||||
|
||||
private async install(logicalname: string, overwrite: boolean) {
|
||||
@@ -73,10 +76,13 @@ export class HomePage {
|
||||
}
|
||||
}
|
||||
|
||||
private async presentAlertDanger(logicalname: string, embassyData: boolean) {
|
||||
const message = embassyData
|
||||
? 'This action will COMPLETELY erase your existing Embassy data'
|
||||
: `This action will COMPLETELY erase the disk <b>${logicalname}</b> and install embassyOS!`
|
||||
private async presentAlertDanger(
|
||||
logicalname: string,
|
||||
hasEmbassyData: boolean,
|
||||
) {
|
||||
const message = hasEmbassyData
|
||||
? 'This action COMPLETELY erases your existing Embassy data'
|
||||
: `This action COMPLETELY erases the disk ${logicalname} and installs embassyOS`
|
||||
|
||||
const alert = await this.alertCtrl.create({
|
||||
header: 'Warning',
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { DiskInfo } from '@start9labs/shared'
|
||||
|
||||
export abstract class ApiService {
|
||||
abstract getDisks(): Promise<GetDisksRes> // install.status
|
||||
abstract getDisks(): Promise<GetDisksRes> // install.disk.list
|
||||
abstract install(params: InstallReq): Promise<void> // install.execute
|
||||
abstract reboot(): Promise<void> // install.reboot
|
||||
}
|
||||
|
||||
export type GetDisksRes = Disk[]
|
||||
export type Disk = {
|
||||
logicalname: string
|
||||
'embassy-data': boolean
|
||||
}
|
||||
export type GetDisksRes = DiskInfo[]
|
||||
|
||||
export type InstallReq = {
|
||||
logicalname: string
|
||||
|
||||
@@ -13,7 +13,7 @@ export class LiveApiService implements ApiService {
|
||||
|
||||
async getDisks(): Promise<GetDisksRes> {
|
||||
return this.rpcRequest({
|
||||
method: 'install.status',
|
||||
method: 'install.disk.list',
|
||||
params: {},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,12 +8,48 @@ export class MockApiService implements ApiService {
|
||||
await pauseFor(500)
|
||||
return [
|
||||
{
|
||||
logicalname: 'abcdefgh',
|
||||
'embassy-data': false,
|
||||
logicalname: 'abcd',
|
||||
vendor: 'Samsung',
|
||||
model: 'T5',
|
||||
partitions: [
|
||||
{
|
||||
logicalname: 'pabcd',
|
||||
label: null,
|
||||
capacity: 73264762332,
|
||||
used: null,
|
||||
'embassy-os': {
|
||||
version: '0.2.17',
|
||||
full: true,
|
||||
'password-hash':
|
||||
'$argon2d$v=19$m=1024,t=1,p=1$YXNkZmFzZGZhc2RmYXNkZg$Ceev1I901G6UwU+hY0sHrFZ56D+o+LNJ',
|
||||
'wrapped-key': null,
|
||||
},
|
||||
},
|
||||
],
|
||||
capacity: 123456789123,
|
||||
guid: 'uuid-uuid-uuid-uuid',
|
||||
},
|
||||
{
|
||||
logicalname: '12345678',
|
||||
'embassy-data': true,
|
||||
logicalname: 'dcba',
|
||||
vendor: 'Crucial',
|
||||
model: 'MX500',
|
||||
partitions: [
|
||||
{
|
||||
logicalname: 'pbcba',
|
||||
label: null,
|
||||
capacity: 73264762332,
|
||||
used: null,
|
||||
'embassy-os': {
|
||||
version: '0.3.1',
|
||||
full: true,
|
||||
'password-hash':
|
||||
'$argon2d$v=19$m=1024,t=1,p=1$YXNkZmFzZGZhc2RmYXNkZg$Ceev1I901G6UwU+hY0sHrFZ56D+o+LNJ',
|
||||
'wrapped-key': null,
|
||||
},
|
||||
},
|
||||
],
|
||||
capacity: 123456789123,
|
||||
guid: null,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,11 +4,8 @@ import {
|
||||
LoadingController,
|
||||
ModalController,
|
||||
} from '@ionic/angular'
|
||||
import {
|
||||
ApiService,
|
||||
CifsBackupTarget,
|
||||
EmbassyOSRecoveryInfo,
|
||||
} from 'src/app/services/api/api.service'
|
||||
import { ApiService, CifsBackupTarget } from 'src/app/services/api/api.service'
|
||||
import { EmbassyOSDiskInfo } from '@start9labs/shared'
|
||||
import { PasswordPage } from '../password/password.page'
|
||||
|
||||
@Component({
|
||||
@@ -61,7 +58,7 @@ export class CifsModal {
|
||||
}
|
||||
|
||||
private async presentModalPassword(
|
||||
embassyOS: EmbassyOSRecoveryInfo,
|
||||
embassyOS: EmbassyOSDiskInfo,
|
||||
): Promise<void> {
|
||||
const target: CifsBackupTarget = {
|
||||
...this.cifs,
|
||||
|
||||
@@ -8,10 +8,9 @@ import {
|
||||
import {
|
||||
ApiService,
|
||||
BackupRecoverySource,
|
||||
DiskInfo,
|
||||
DiskRecoverySource,
|
||||
} from 'src/app/services/api/api.service'
|
||||
import { ErrorToastService } from '@start9labs/shared'
|
||||
import { DiskInfo, ErrorToastService } from '@start9labs/shared'
|
||||
import { StateService } from 'src/app/services/state.service'
|
||||
import { PasswordPage } from '../../modals/password/password.page'
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<h2 class="target-label">Physical Drive</h2>
|
||||
<div class="ion-text-left ion-padding-bottom">
|
||||
<p>
|
||||
Restore your Emabssy from a physcial drive that is plugged
|
||||
Restore your Embassy from a physical drive that is plugged
|
||||
directly into your Embassy.
|
||||
</p>
|
||||
<br />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { AlertController, NavController } from '@ionic/angular'
|
||||
import { ApiService, DiskInfo } from 'src/app/services/api/api.service'
|
||||
import { ErrorToastService } from '@start9labs/shared'
|
||||
import { ApiService } from 'src/app/services/api/api.service'
|
||||
import { DiskInfo, ErrorToastService } from '@start9labs/shared'
|
||||
import { StateService } from 'src/app/services/state.service'
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as jose from 'node-jose'
|
||||
import { DiskListResponse, EmbassyOSDiskInfo } from '@start9labs/shared'
|
||||
export abstract class ApiService {
|
||||
pubkey?: jose.JWK.Key
|
||||
|
||||
@@ -6,7 +7,7 @@ export abstract class ApiService {
|
||||
abstract getPubKey(): Promise<void> // setup.get-pubkey
|
||||
abstract getDrives(): Promise<DiskListResponse> // setup.disk.list
|
||||
abstract getRecoveryStatus(): Promise<RecoveryStatusRes> // setup.recovery.status
|
||||
abstract verifyCifs(cifs: CifsRecoverySource): Promise<EmbassyOSRecoveryInfo> // setup.cifs.verify
|
||||
abstract verifyCifs(cifs: CifsRecoverySource): Promise<EmbassyOSDiskInfo> // setup.cifs.verify
|
||||
abstract importDrive(importInfo: ImportDriveReq): Promise<SetupEmbassyRes> // setup.attach
|
||||
abstract setupEmbassy(setupInfo: SetupEmbassyReq): Promise<SetupEmbassyRes> // setup.execute
|
||||
abstract setupComplete(): Promise<SetupEmbassyRes> // setup.complete
|
||||
@@ -48,15 +49,6 @@ export type SetupEmbassyRes = {
|
||||
'root-ca': string
|
||||
}
|
||||
|
||||
export type EmbassyOSRecoveryInfo = {
|
||||
version: string
|
||||
full: boolean
|
||||
'password-hash': string | null
|
||||
'wrapped-key': string | null
|
||||
}
|
||||
|
||||
export type DiskListResponse = DiskInfo[]
|
||||
|
||||
export type DiskBackupTarget = {
|
||||
vendor: string | null
|
||||
model: string | null
|
||||
@@ -64,7 +56,7 @@ export type DiskBackupTarget = {
|
||||
label: string | null
|
||||
capacity: number
|
||||
used: number | null
|
||||
'embassy-os': EmbassyOSRecoveryInfo | null
|
||||
'embassy-os': EmbassyOSDiskInfo | null
|
||||
}
|
||||
|
||||
export type CifsBackupTarget = {
|
||||
@@ -72,7 +64,7 @@ export type CifsBackupTarget = {
|
||||
path: string
|
||||
username: string
|
||||
mountable: boolean
|
||||
'embassy-os': EmbassyOSRecoveryInfo | null
|
||||
'embassy-os': EmbassyOSDiskInfo | null
|
||||
}
|
||||
|
||||
export type DiskRecoverySource = {
|
||||
@@ -99,25 +91,8 @@ export type CifsRecoverySource = {
|
||||
password: Encrypted | null
|
||||
}
|
||||
|
||||
export type DiskInfo = {
|
||||
logicalname: string
|
||||
vendor: string | null
|
||||
model: string | null
|
||||
partitions: PartitionInfo[]
|
||||
capacity: number
|
||||
guid: string | null // cant back up if guid exists, but needed if migrating
|
||||
}
|
||||
|
||||
export type RecoveryStatusRes = {
|
||||
'bytes-transferred': number
|
||||
'total-bytes': number
|
||||
complete: boolean
|
||||
}
|
||||
|
||||
export type PartitionInfo = {
|
||||
logicalname: string
|
||||
label: string | null
|
||||
capacity: number
|
||||
used: number | null
|
||||
'embassy-os': EmbassyOSRecoveryInfo | null
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import {
|
||||
DiskListResponse,
|
||||
EmbassyOSDiskInfo,
|
||||
encodeBase64,
|
||||
HttpService,
|
||||
isRpcError,
|
||||
@@ -9,10 +11,7 @@ import {
|
||||
import {
|
||||
ApiService,
|
||||
CifsRecoverySource,
|
||||
DiskListResponse,
|
||||
DiskMigrateSource,
|
||||
DiskRecoverySource,
|
||||
EmbassyOSRecoveryInfo,
|
||||
GetStatusRes,
|
||||
ImportDriveReq,
|
||||
RecoveryStatusRes,
|
||||
@@ -68,7 +67,7 @@ export class LiveApiService extends ApiService {
|
||||
|
||||
async verifyCifs(source: CifsRecoverySource) {
|
||||
source.path = source.path.replace('/\\/g', '/')
|
||||
return this.rpcRequest<EmbassyOSRecoveryInfo>({
|
||||
return this.rpcRequest<EmbassyOSDiskInfo>({
|
||||
method: 'setup.cifs.verify',
|
||||
params: source,
|
||||
})
|
||||
|
||||
@@ -14,3 +14,29 @@ export interface Log {
|
||||
timestamp: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export type DiskListResponse = DiskInfo[]
|
||||
|
||||
export interface DiskInfo {
|
||||
logicalname: string
|
||||
vendor: string | null
|
||||
model: string | null
|
||||
partitions: PartitionInfo[]
|
||||
capacity: number
|
||||
guid: string | null
|
||||
}
|
||||
|
||||
export interface PartitionInfo {
|
||||
logicalname: string
|
||||
label: string | null
|
||||
capacity: number
|
||||
used: number | null
|
||||
'embassy-os': EmbassyOSDiskInfo | null
|
||||
}
|
||||
|
||||
export type EmbassyOSDiskInfo = {
|
||||
version: string
|
||||
full: boolean
|
||||
'password-hash': string | null
|
||||
'wrapped-key': string | null
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
DependencyError,
|
||||
Manifest,
|
||||
} from 'src/app/services/patch-db/data-model'
|
||||
import { LogsRes, ServerLogsReq } from '@start9labs/shared'
|
||||
import { EmbassyOSDiskInfo, LogsRes, ServerLogsReq } from '@start9labs/shared'
|
||||
|
||||
export module RR {
|
||||
// DB
|
||||
@@ -332,13 +332,6 @@ export type PlatformType =
|
||||
|
||||
export type BackupTarget = DiskBackupTarget | CifsBackupTarget
|
||||
|
||||
export interface EmbassyOSRecoveryInfo {
|
||||
version: string
|
||||
full: boolean
|
||||
'password-hash': string | null
|
||||
'wrapped-key': string | null
|
||||
}
|
||||
|
||||
export interface DiskBackupTarget {
|
||||
type: 'disk'
|
||||
vendor: string | null
|
||||
@@ -347,7 +340,7 @@ export interface DiskBackupTarget {
|
||||
label: string | null
|
||||
capacity: number
|
||||
used: number | null
|
||||
'embassy-os': EmbassyOSRecoveryInfo | null
|
||||
'embassy-os': EmbassyOSDiskInfo | null
|
||||
}
|
||||
|
||||
export interface CifsBackupTarget {
|
||||
@@ -356,7 +349,7 @@ export interface CifsBackupTarget {
|
||||
path: string
|
||||
username: string
|
||||
mountable: boolean
|
||||
'embassy-os': EmbassyOSRecoveryInfo | null
|
||||
'embassy-os': EmbassyOSDiskInfo | null
|
||||
}
|
||||
|
||||
export type RecoverySource = DiskRecoverySource | CifsRecoverySource
|
||||
@@ -374,28 +367,6 @@ export interface CifsRecoverySource {
|
||||
password: string
|
||||
}
|
||||
|
||||
export interface DiskInfo {
|
||||
logicalname: string
|
||||
vendor: string | null
|
||||
model: string | null
|
||||
partitions: PartitionInfo[]
|
||||
capacity: number
|
||||
guid: string | null
|
||||
}
|
||||
|
||||
export interface PartitionInfo {
|
||||
logicalname: string
|
||||
label: string | null
|
||||
capacity: number
|
||||
used: number | null
|
||||
'embassy-os': EmbassyOsDiskInfo | null
|
||||
}
|
||||
|
||||
export interface EmbassyOsDiskInfo {
|
||||
version: string
|
||||
full: boolean
|
||||
}
|
||||
|
||||
export interface BackupInfo {
|
||||
version: string
|
||||
timestamp: string
|
||||
|
||||
Reference in New Issue
Block a user