mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
delete recovered
This commit is contained in:
committed by
Aiden McClelland
parent
7dcb4239df
commit
71ce2b064f
@@ -146,8 +146,8 @@
|
|||||||
<p>{{ rec.version | displayEmver }}</p>
|
<p>{{ rec.version | displayEmver }}</p>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
<div *ngIf="!rec.installing" slot="end">
|
<div *ngIf="!rec.installing" slot="end">
|
||||||
<ion-button fill="clear" color="danger" (click)="uninstall(rec, i)">
|
<ion-button fill="clear" color="danger" (click)="deleteRecovered(rec, i)">
|
||||||
<ion-icon slot="icon-only" name="close"></ion-icon>
|
<ion-icon slot="icon-only" name="trash"></ion-icon>
|
||||||
<!-- Remove -->
|
<!-- Remove -->
|
||||||
</ion-button>
|
</ion-button>
|
||||||
<ion-button fill="clear" color="success" (click)="install(rec)">
|
<ion-button fill="clear" color="success" (click)="install(rec)">
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import { isEmptyObject, exists } from 'src/app/util/misc.util'
|
|||||||
import { PackageLoadingService, ProgressData } from 'src/app/services/package-loading.service'
|
import { PackageLoadingService, ProgressData } from 'src/app/services/package-loading.service'
|
||||||
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||||
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
import { ErrorToastService } from 'src/app/services/error-toast.service'
|
||||||
|
import { AlertController } from '@ionic/angular'
|
||||||
|
import { exec } from 'child_process'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-list',
|
selector: 'app-list',
|
||||||
@@ -35,6 +37,7 @@ export class AppListPage {
|
|||||||
private readonly api: ApiService,
|
private readonly api: ApiService,
|
||||||
private readonly patch: PatchDbService,
|
private readonly patch: PatchDbService,
|
||||||
private readonly errToast: ErrorToastService,
|
private readonly errToast: ErrorToastService,
|
||||||
|
private readonly alertCtrl: AlertController,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
@@ -129,15 +132,37 @@ export class AppListPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async uninstall (pkg: RecoveredInfo, index: number): Promise<void> {
|
async deleteRecovered (pkg: RecoveredInfo, index: number): Promise<void> {
|
||||||
pkg.installing = true
|
|
||||||
try {
|
const execute = async () => {
|
||||||
await this.api.uninstallPackage({ id: pkg.id })
|
pkg.installing = true
|
||||||
this.recoveredPkgs.splice(index, 1)
|
try {
|
||||||
} catch (e) {
|
await this.api.deleteRecoveredPackage({ id: pkg.id })
|
||||||
this.errToast.present(e)
|
this.recoveredPkgs.splice(index, 1)
|
||||||
pkg.installing = false
|
} catch (e) {
|
||||||
|
this.errToast.present(e)
|
||||||
|
pkg.installing = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const alert = await this.alertCtrl.create({
|
||||||
|
header: 'Delete Data',
|
||||||
|
message: `This action will permanently delete all data associated with ${pkg.title}.`,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: 'Cancel',
|
||||||
|
role: 'cancel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Execute',
|
||||||
|
handler: () => {
|
||||||
|
execute()
|
||||||
|
},
|
||||||
|
cssClass: 'enter-click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
await alert.present()
|
||||||
}
|
}
|
||||||
|
|
||||||
private subscribeBoth (): Subscription {
|
private subscribeBoth (): Subscription {
|
||||||
|
|||||||
@@ -178,6 +178,9 @@ export module RR {
|
|||||||
export type UninstallPackageReq = WithExpire<{ id: string }> // package.uninstall
|
export type UninstallPackageReq = WithExpire<{ id: string }> // package.uninstall
|
||||||
export type UninstallPackageRes = WithRevision<null>
|
export type UninstallPackageRes = WithRevision<null>
|
||||||
|
|
||||||
|
export type DeleteRecoveredPackageReq = { id: string } // package.delete-recovered
|
||||||
|
export type DeleteRecoveredPackageRes = WithRevision<null>
|
||||||
|
|
||||||
export type DryConfigureDependencyReq = { 'dependency-id': string, 'dependent-id': string } // package.dependency.configure.dry
|
export type DryConfigureDependencyReq = { 'dependency-id': string, 'dependent-id': string } // package.dependency.configure.dry
|
||||||
export type DryConfigureDependencyRes = object
|
export type DryConfigureDependencyRes = object
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,12 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
|
|||||||
|
|
||||||
abstract dryConfigureDependency (params: RR.DryConfigureDependencyReq): Promise<RR.DryConfigureDependencyRes>
|
abstract dryConfigureDependency (params: RR.DryConfigureDependencyReq): Promise<RR.DryConfigureDependencyRes>
|
||||||
|
|
||||||
|
protected abstract deleteRecoveredPackageRaw (params: RR.UninstallPackageReq): Promise<RR.UninstallPackageRes>
|
||||||
|
deleteRecoveredPackage = (params: RR.UninstallPackageReq) => this.syncResponse(
|
||||||
|
() => this.deleteRecoveredPackageRaw(params),
|
||||||
|
)()
|
||||||
|
|
||||||
|
|
||||||
// Helper allowing quick decoration to sync the response patch and return the response contents.
|
// Helper allowing quick decoration to sync the response patch and return the response contents.
|
||||||
// Pass in a tempUpdate function which returns a UpdateTemp corresponding to a temporary
|
// Pass in a tempUpdate function which returns a UpdateTemp corresponding to a temporary
|
||||||
// state change you'd like to enact prior to request and expired when request terminates.
|
// state change you'd like to enact prior to request and expired when request terminates.
|
||||||
|
|||||||
@@ -260,6 +260,10 @@ export class LiveApiService extends ApiService {
|
|||||||
return this.http.rpcRequest({ method: 'package.uninstall.dry', params })
|
return this.http.rpcRequest({ method: 'package.uninstall.dry', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteRecoveredPackageRaw (params: RR.DeleteRecoveredPackageReq): Promise <RR.DeleteRecoveredPackageRes> {
|
||||||
|
return this.http.rpcRequest({ method: 'package.delete-recovered', params })
|
||||||
|
}
|
||||||
|
|
||||||
async uninstallPackageRaw (params: RR.UninstallPackageReq): Promise <RR.UninstallPackageRes> {
|
async uninstallPackageRaw (params: RR.UninstallPackageReq): Promise <RR.UninstallPackageRes> {
|
||||||
return this.http.rpcRequest({ method: 'package.uninstall', params })
|
return this.http.rpcRequest({ method: 'package.uninstall', params })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -478,26 +478,32 @@ export class MockApiService extends ApiService {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
let res: any
|
let res: any
|
||||||
try {
|
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||||
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
setTimeout(async () => {
|
||||||
setTimeout(async () => {
|
|
||||||
const patch = [
|
|
||||||
{
|
|
||||||
op: PatchOp.REMOVE,
|
|
||||||
path: `/package-data/${params.id}`,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
|
||||||
}, this.revertTime)
|
|
||||||
} catch (e) {
|
|
||||||
const patch = [
|
const patch = [
|
||||||
{
|
{
|
||||||
op: PatchOp.REMOVE,
|
op: PatchOp.REMOVE,
|
||||||
path: `/recovered-packages/${params.id}`,
|
path: `/package-data/${params.id}`,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||||
}
|
}, this.revertTime)
|
||||||
|
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
async deleteRecoveredPackageRaw (params: RR.DeleteRecoveredPackageReq): Promise<RR.DeleteAllNotificationsRes> {
|
||||||
|
await pauseFor(2000)
|
||||||
|
let res: any
|
||||||
|
|
||||||
|
const patch = [
|
||||||
|
{
|
||||||
|
op: PatchOp.REMOVE,
|
||||||
|
path: `/recovered-packages/${params.id}`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user