mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
New recovery flow
This commit is contained in:
committed by
Aiden McClelland
parent
221d99bfee
commit
17d0f9e533
@@ -990,6 +990,7 @@ export module Mock {
|
||||
},
|
||||
],
|
||||
capacity: 1000000000000,
|
||||
internal: true,
|
||||
},
|
||||
{
|
||||
logicalname: '/dev/sdb',
|
||||
@@ -1015,6 +1016,7 @@ export module Mock {
|
||||
},
|
||||
],
|
||||
capacity: 10000000000,
|
||||
internal: false,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1023,10 +1025,17 @@ export module Mock {
|
||||
timestamp: new Date().toISOString(),
|
||||
'package-backups': {
|
||||
bitcoind: {
|
||||
title: 'Bitcoin Core',
|
||||
version: '0.21.0',
|
||||
'os-version': '0.3.0',
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
'btc-rpc-proxy': {
|
||||
title: 'Bitcoin Proxy',
|
||||
version: '0.2.2',
|
||||
'os-version': '0.3.0',
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1614,11 +1623,9 @@ export module Mock {
|
||||
installed: {
|
||||
'last-backup': null,
|
||||
status: {
|
||||
configured: true,
|
||||
configured: false,
|
||||
main: {
|
||||
status: PackageMainStatus.Running,
|
||||
started: new Date().toISOString(),
|
||||
health: { },
|
||||
status: PackageMainStatus.Stopped,
|
||||
},
|
||||
'dependency-errors': { },
|
||||
},
|
||||
|
||||
@@ -157,8 +157,8 @@ export module RR {
|
||||
export type SetPackageConfigReq = WithExpire<DrySetPackageConfigReq> // package.config.set
|
||||
export type SetPackageConfigRes = WithRevision<null>
|
||||
|
||||
export type RestorePackageReq = WithExpire<{ id: string, logicalname: string, password: string }> // package.backup.restore
|
||||
export type RestorePackageRes = WithRevision<null>
|
||||
export type RestorePackagesReq = WithExpire<{ ids: string[], logicalname: string, password: string }> // package.backup.restore
|
||||
export type RestorePackagesRes = WithRevision<null>
|
||||
|
||||
export type ExecutePackageActionReq = { id: string, 'action-id': string, input?: object } // package.action
|
||||
export type ExecutePackageActionRes = ActionResponse
|
||||
@@ -300,6 +300,7 @@ export interface DriveInfo {
|
||||
model: string | null
|
||||
partitions: PartitionInfo[]
|
||||
capacity: number
|
||||
internal: boolean
|
||||
}
|
||||
|
||||
export interface PartitionInfo {
|
||||
@@ -319,14 +320,17 @@ export interface BackupInfo {
|
||||
version: string,
|
||||
timestamp: string,
|
||||
'package-backups': {
|
||||
[id: string]: {
|
||||
version: string
|
||||
'os-version': string
|
||||
timestamp: string
|
||||
}
|
||||
[id: string]: PackageBackupInfo
|
||||
}
|
||||
}
|
||||
|
||||
export interface PackageBackupInfo {
|
||||
title: string
|
||||
version: string
|
||||
'os-version': string
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
export interface ServerSpecs {
|
||||
[key: string]: string | number
|
||||
}
|
||||
|
||||
@@ -154,9 +154,9 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
||||
() => this.setPackageConfigRaw(params),
|
||||
)()
|
||||
|
||||
protected abstract restorePackageRaw (params: RR.RestorePackageReq): Promise<RR.RestorePackageRes>
|
||||
restorePackage = (params: RR.RestorePackageReq) => this.syncResponse(
|
||||
() => this.restorePackageRaw(params),
|
||||
protected abstract restorePackagesRaw (params: RR.RestorePackagesReq): Promise<RR.RestorePackagesRes>
|
||||
restorePackages = (params: RR.RestorePackagesReq) => this.syncResponse(
|
||||
() => this.restorePackagesRaw(params),
|
||||
)()
|
||||
|
||||
abstract executePackageAction (params: RR.ExecutePackageActionReq): Promise<RR.ExecutePackageActionRes>
|
||||
|
||||
@@ -236,8 +236,8 @@ export class LiveApiService extends ApiService {
|
||||
return this.http.rpcRequest({ method: 'package.config.set', params })
|
||||
}
|
||||
|
||||
async restorePackageRaw (params: RR.RestorePackageReq): Promise <RR.RestorePackageRes> {
|
||||
return this.http.rpcRequest({ method: 'package.restore', params })
|
||||
async restorePackagesRaw (params: RR.RestorePackagesReq): Promise <RR.RestorePackagesRes> {
|
||||
return this.http.rpcRequest({ method: 'package.backup.restore', params })
|
||||
}
|
||||
|
||||
async executePackageAction (params: RR.ExecutePackageActionReq): Promise <RR.ExecutePackageActionRes> {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { parsePropertiesPermissive } from 'src/app/util/properties.util'
|
||||
import { Mock } from './api.fixures'
|
||||
import { HttpService } from '../http.service'
|
||||
import markdown from 'raw-loader!src/assets/markdown/md-sample.md'
|
||||
import { Operation } from 'fast-json-patch'
|
||||
|
||||
@Injectable()
|
||||
export class MockApiService extends ApiService {
|
||||
@@ -413,28 +414,38 @@ export class MockApiService extends ApiService {
|
||||
return this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async restorePackageRaw (params: RR.RestorePackageReq): Promise<RR.RestorePackageRes> {
|
||||
async restorePackagesRaw (params: RR.RestorePackagesReq): Promise<RR.RestorePackagesRes> {
|
||||
await pauseFor(2000)
|
||||
const path = `/package-data/${params.id}/installed/status/main/status`
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path,
|
||||
value: PackageMainStatus.Restoring,
|
||||
},
|
||||
]
|
||||
const res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
setTimeout(() => {
|
||||
const patch = [
|
||||
{
|
||||
op: PatchOp.REPLACE,
|
||||
path,
|
||||
value: PackageMainStatus.Stopped,
|
||||
},
|
||||
]
|
||||
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
}, this.revertTime)
|
||||
return res
|
||||
const patch: Operation[] = params.ids.map(id => {
|
||||
|
||||
const initialProgress: InstallProgress = {
|
||||
size: 120,
|
||||
downloaded: 120,
|
||||
'download-complete': true,
|
||||
validated: 0,
|
||||
'validation-complete': false,
|
||||
unpacked: 0,
|
||||
'unpack-complete': false,
|
||||
}
|
||||
|
||||
const pkg: PackageDataEntry = {
|
||||
...Mock.LocalPkgs[id],
|
||||
state: PackageState.Restoring,
|
||||
'install-progress': initialProgress,
|
||||
installed: undefined,
|
||||
}
|
||||
|
||||
setTimeout(async () => {
|
||||
this.updateProgress(id, initialProgress)
|
||||
}, 2000)
|
||||
|
||||
return {
|
||||
op: 'add',
|
||||
path: `/package-data/${id}`,
|
||||
value: pkg,
|
||||
}
|
||||
})
|
||||
return this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||
}
|
||||
|
||||
async executePackageAction (params: RR.ExecutePackageActionReq): Promise<RR.ExecutePackageActionRes> {
|
||||
|
||||
Reference in New Issue
Block a user