mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
enable UI during backups, fix state management bugs
This commit is contained in:
committed by
Aiden McClelland
parent
d5dd37b165
commit
896069f1a1
@@ -974,7 +974,7 @@ export module Mock {
|
||||
'signal-strength': 50,
|
||||
}
|
||||
|
||||
export const Disks: RR.GetDisksRes = [
|
||||
export const Drives: RR.GetDrivesRes = [
|
||||
{
|
||||
logicalname: '/dev/sda',
|
||||
model: null,
|
||||
|
||||
@@ -121,10 +121,10 @@ export module RR {
|
||||
export type CreateBackupReq = WithExpire<{ logicalname: string, password: string }> // backup.create
|
||||
export type CreateBackupRes = WithRevision<null>
|
||||
|
||||
// disk
|
||||
// drive
|
||||
|
||||
export type GetDisksReq = { } // disk.list
|
||||
export type GetDisksRes = DiskInfo[]
|
||||
export type GetDrivesReq = { } // disk.list
|
||||
export type GetDrivesRes = DriveInfo[]
|
||||
|
||||
export type GetBackupInfoReq = { logicalname: string, password: string } // disk.backup-info
|
||||
export type GetBackupInfoRes = BackupInfo
|
||||
@@ -287,7 +287,7 @@ export interface SessionMetadata {
|
||||
|
||||
export type PlatformType = 'cli' | 'ios' | 'ipad' | 'iphone' | 'android' | 'phablet' | 'tablet' | 'cordova' | 'capacitor' | 'electron' | 'pwa' | 'mobile' | 'mobileweb' | 'desktop' | 'hybrid'
|
||||
|
||||
export interface DiskInfo {
|
||||
export interface DriveInfo {
|
||||
logicalname: string
|
||||
vendor: string | null
|
||||
model: string | null
|
||||
@@ -300,10 +300,10 @@ export interface PartitionInfo {
|
||||
label: string | null
|
||||
capacity: number
|
||||
used: number | null
|
||||
'embassy-os': EmbassyOsDiskInfo | null
|
||||
'embassy-os': EmbassyOsDriveInfo | null
|
||||
}
|
||||
|
||||
export interface EmbassyOsDiskInfo {
|
||||
export interface EmbassyOsDriveInfo {
|
||||
version: string
|
||||
full: boolean
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
() => this.createBackupRaw(params),
|
||||
)()
|
||||
|
||||
// disk
|
||||
// drive
|
||||
|
||||
abstract getDisks (params: RR.GetDisksReq): Promise<RR.GetDisksRes>
|
||||
abstract getDrives (params: RR.GetDrivesReq): Promise<RR.GetDrivesRes>
|
||||
|
||||
abstract getBackupInfo (params: RR.GetBackupInfoReq): Promise<RR.GetBackupInfoRes>
|
||||
|
||||
|
||||
@@ -191,9 +191,9 @@ export class LiveApiService extends ApiService {
|
||||
return this.http.rpcRequest({ method: 'backup.create', params })
|
||||
}
|
||||
|
||||
// disk
|
||||
// drives
|
||||
|
||||
getDisks (params: RR.GetDisksReq): Promise <RR.GetDisksRes> {
|
||||
getDrives (params: RR.GetDrivesReq): Promise <RR.GetDrivesRes> {
|
||||
return this.http.rpcRequest({ method: 'disk.list', params })
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ export class MockApiService extends ApiService {
|
||||
async createBackupRaw (params: RR.CreateBackupReq): Promise<RR.CreateBackupRes> {
|
||||
await pauseFor(2000)
|
||||
const path = '/server-info/status'
|
||||
const patch = [
|
||||
let patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path,
|
||||
@@ -271,8 +271,37 @@ export class MockApiService extends ApiService {
|
||||
},
|
||||
]
|
||||
const res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
setTimeout(() => {
|
||||
const patch = [
|
||||
|
||||
const ids = ['bitcoind', 'lnd']
|
||||
|
||||
setTimeout(async () => {
|
||||
for (let i = 0; i < ids.length; i++) {
|
||||
const appPath = `/package-data/${ids[i]}/installed/status/main/status`
|
||||
let appPatch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: appPath,
|
||||
value: PackageMainStatus.BackingUp,
|
||||
},
|
||||
]
|
||||
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch: appPatch } })
|
||||
|
||||
await pauseFor(8000)
|
||||
|
||||
appPatch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path: appPath,
|
||||
value: PackageMainStatus.Stopped,
|
||||
},
|
||||
]
|
||||
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch: appPatch } })
|
||||
}
|
||||
|
||||
await pauseFor(1000)
|
||||
|
||||
// set server back to running
|
||||
patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path,
|
||||
@@ -280,15 +309,16 @@ export class MockApiService extends ApiService {
|
||||
},
|
||||
]
|
||||
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
}, this.revertTime)
|
||||
}, 200)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// disk
|
||||
// drives
|
||||
|
||||
async getDisks (params: RR.GetDisksReq): Promise<RR.GetDisksRes> {
|
||||
async getDrives (params: RR.GetDrivesReq): Promise<RR.GetDrivesRes> {
|
||||
await pauseFor(2000)
|
||||
return Mock.Disks
|
||||
return Mock.Drives
|
||||
}
|
||||
|
||||
async getBackupInfo (params: RR.GetBackupInfoReq): Promise<RR.GetBackupInfoRes> {
|
||||
|
||||
Reference in New Issue
Block a user