diff --git a/ui/src/app/pages/apps-routes/app-list/app-list.page.html b/ui/src/app/pages/apps-routes/app-list/app-list.page.html index d4f05ce32..b39bea08d 100644 --- a/ui/src/app/pages/apps-routes/app-list/app-list.page.html +++ b/ui/src/app/pages/apps-routes/app-list/app-list.page.html @@ -146,8 +146,8 @@

{{ rec.version | displayEmver }}

- - + + diff --git a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts index 769e0300a..4e1939c82 100644 --- a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts +++ b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts @@ -10,6 +10,8 @@ import { isEmptyObject, exists } from 'src/app/util/misc.util' import { PackageLoadingService, ProgressData } from 'src/app/services/package-loading.service' import { ApiService } from 'src/app/services/api/embassy-api.service' import { ErrorToastService } from 'src/app/services/error-toast.service' +import { AlertController } from '@ionic/angular' +import { exec } from 'child_process' @Component({ selector: 'app-list', @@ -35,6 +37,7 @@ export class AppListPage { private readonly api: ApiService, private readonly patch: PatchDbService, private readonly errToast: ErrorToastService, + private readonly alertCtrl: AlertController, ) { } ngOnInit () { @@ -129,15 +132,37 @@ export class AppListPage { } } - async uninstall (pkg: RecoveredInfo, index: number): Promise { - pkg.installing = true - try { - await this.api.uninstallPackage({ id: pkg.id }) - this.recoveredPkgs.splice(index, 1) - } catch (e) { - this.errToast.present(e) - pkg.installing = false + async deleteRecovered (pkg: RecoveredInfo, index: number): Promise { + + const execute = async () => { + pkg.installing = true + try { + await this.api.deleteRecoveredPackage({ id: pkg.id }) + this.recoveredPkgs.splice(index, 1) + } 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 { diff --git a/ui/src/app/services/api/api.types.ts b/ui/src/app/services/api/api.types.ts index 65aa47610..1e861774c 100644 --- a/ui/src/app/services/api/api.types.ts +++ b/ui/src/app/services/api/api.types.ts @@ -178,6 +178,9 @@ export module RR { export type UninstallPackageReq = WithExpire<{ id: string }> // package.uninstall export type UninstallPackageRes = WithRevision + export type DeleteRecoveredPackageReq = { id: string } // package.delete-recovered + export type DeleteRecoveredPackageRes = WithRevision + export type DryConfigureDependencyReq = { 'dependency-id': string, 'dependent-id': string } // package.dependency.configure.dry export type DryConfigureDependencyRes = object diff --git a/ui/src/app/services/api/embassy-api.service.ts b/ui/src/app/services/api/embassy-api.service.ts index b0ba58b09..c99c1c901 100644 --- a/ui/src/app/services/api/embassy-api.service.ts +++ b/ui/src/app/services/api/embassy-api.service.ts @@ -175,6 +175,12 @@ export abstract class ApiService implements Source, Http { abstract dryConfigureDependency (params: RR.DryConfigureDependencyReq): Promise + protected abstract deleteRecoveredPackageRaw (params: RR.UninstallPackageReq): Promise + deleteRecoveredPackage = (params: RR.UninstallPackageReq) => this.syncResponse( + () => this.deleteRecoveredPackageRaw(params), + )() + + // 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 // state change you'd like to enact prior to request and expired when request terminates. diff --git a/ui/src/app/services/api/embassy-live-api.service.ts b/ui/src/app/services/api/embassy-live-api.service.ts index c19236eec..547882113 100644 --- a/ui/src/app/services/api/embassy-live-api.service.ts +++ b/ui/src/app/services/api/embassy-live-api.service.ts @@ -260,6 +260,10 @@ export class LiveApiService extends ApiService { return this.http.rpcRequest({ method: 'package.uninstall.dry', params }) } + async deleteRecoveredPackageRaw (params: RR.DeleteRecoveredPackageReq): Promise { + return this.http.rpcRequest({ method: 'package.delete-recovered', params }) + } + async uninstallPackageRaw (params: RR.UninstallPackageReq): Promise { return this.http.rpcRequest({ method: 'package.uninstall', params }) } diff --git a/ui/src/app/services/api/embassy-mock-api.service.ts b/ui/src/app/services/api/embassy-mock-api.service.ts index af2ff1ae5..de1c6383a 100644 --- a/ui/src/app/services/api/embassy-mock-api.service.ts +++ b/ui/src/app/services/api/embassy-mock-api.service.ts @@ -478,26 +478,32 @@ export class MockApiService extends ApiService { }, ] let res: any - try { - res = await this.http.rpcRequest>({ method: 'db.patch', params: { patch } }) - setTimeout(async () => { - const patch = [ - { - op: PatchOp.REMOVE, - path: `/package-data/${params.id}`, - }, - ] - this.http.rpcRequest>({ method: 'db.patch', params: { patch } }) - }, this.revertTime) - } catch (e) { + res = await this.http.rpcRequest>({ method: 'db.patch', params: { patch } }) + setTimeout(async () => { const patch = [ { op: PatchOp.REMOVE, - path: `/recovered-packages/${params.id}`, + path: `/package-data/${params.id}`, }, ] - res = await this.http.rpcRequest>({ method: 'db.patch', params: { patch } }) - } + this.http.rpcRequest>({ method: 'db.patch', params: { patch } }) + }, this.revertTime) + + + return res + } + + async deleteRecoveredPackageRaw (params: RR.DeleteRecoveredPackageReq): Promise { + await pauseFor(2000) + let res: any + + const patch = [ + { + op: PatchOp.REMOVE, + path: `/recovered-packages/${params.id}`, + }, + ] + res = await this.http.rpcRequest>({ method: 'db.patch', params: { patch } }) return res }