From d229aaf1b2ddfb7408594e694b62b4f5139605a1 Mon Sep 17 00:00:00 2001 From: Drew Ansbacher Date: Thu, 24 Feb 2022 16:38:03 -0700 Subject: [PATCH] marketplace url install fix --- .../install-wizard/prebaked-wizards.ts | 4 ++++ .../app-list-rec/app-list-rec.component.ts | 24 +++++++++++++------ .../marketplace-show/marketplace-show.page.ts | 1 + .../ui/src/app/services/api/api.types.ts | 1 + 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/frontend/projects/ui/src/app/components/install-wizard/prebaked-wizards.ts b/frontend/projects/ui/src/app/components/install-wizard/prebaked-wizards.ts index 8256a1d53..be1354165 100644 --- a/frontend/projects/ui/src/app/components/install-wizard/prebaked-wizards.ts +++ b/frontend/projects/ui/src/app/components/install-wizard/prebaked-wizards.ts @@ -9,12 +9,14 @@ import { TopbarParams, } from './install-wizard.component' import { ConfigService } from 'src/app/services/config.service' +import { MarketplaceService } from 'src/app/pages/marketplace-routes/marketplace.service' @Injectable({ providedIn: 'root' }) export class WizardBaker { constructor( private readonly embassyApi: ApiService, private readonly config: ConfigService, + private readonly marketplaceService: MarketplaceService, ) {} update(values: { @@ -78,6 +80,7 @@ export class WizardBaker { this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined, + 'marketplace-url': this.marketplaceService.marketplaceUrl, }), }, }, @@ -203,6 +206,7 @@ export class WizardBaker { this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined, + 'marketplace-url': this.marketplaceService.marketplaceUrl, }), }, }, diff --git a/frontend/projects/ui/src/app/pages/apps-routes/app-list/app-list-rec/app-list-rec.component.ts b/frontend/projects/ui/src/app/pages/apps-routes/app-list/app-list-rec/app-list-rec.component.ts index 56c188ef3..770a23f04 100644 --- a/frontend/projects/ui/src/app/pages/apps-routes/app-list/app-list-rec/app-list-rec.component.ts +++ b/frontend/projects/ui/src/app/pages/apps-routes/app-list/app-list-rec/app-list-rec.component.ts @@ -11,6 +11,7 @@ import { ErrorToastService } from 'src/app/services/error-toast.service' import { from, merge, OperatorFunction, pipe, Subject } from 'rxjs' import { catchError, mapTo, startWith, switchMap, tap } from 'rxjs/operators' import { RecoveredInfo } from 'src/app/util/parse-data-model' +import { MarketplaceService } from 'src/app/pages/marketplace-routes/marketplace.service' @Component({ selector: 'app-list-rec', @@ -32,7 +33,14 @@ export class AppListRecComponent { readonly installing$ = this.install$.pipe( switchMap(({ id, version }) => // Mapping each installation to API request - from(this.api.installPackage({ id, 'version-spec': `>=${version}`, 'version-priority': 'min' })).pipe( + from( + this.api.installPackage({ + id, + 'version-spec': `>=${version}`, + 'version-priority': 'min', + 'marketplace-url': this.marketplaceService.marketplaceUrl, + }), + ).pipe( // Mapping operation to true/false loading indication loading(this.errToast), ), @@ -47,20 +55,22 @@ export class AppListRecComponent { // Notifying parent component that package is removed from recovered items tap(() => this.deleted.emit()), // Mapping operation to true/false loading indication - loading(this.errToast)), + loading(this.errToast), + ), ), ) // Merging both true/false loading indicators to a single stream readonly loading$ = merge(this.installing$, this.deleting$) - constructor ( + constructor( private readonly api: ApiService, private readonly errToast: ErrorToastService, private readonly alertCtrl: AlertController, - ) { } + private readonly marketplaceService: MarketplaceService, + ) {} - async deleteRecovered (pkg: RecoveredInfo): Promise { + async deleteRecovered(pkg: RecoveredInfo): Promise { const alert = await this.alertCtrl.create({ header: 'Delete Data', message: `This action will permanently delete all data associated with ${pkg.title}.`, @@ -84,12 +94,12 @@ export class AppListRecComponent { } // Custom RxJS operator to turn asynchronous operation into a true/false loading indicator -function loading ( +function loading( errToast: ErrorToastService, ): OperatorFunction { return pipe( // Show notification on error - catchError((e) => from(errToast.present(e))), + catchError(e => from(errToast.present(e))), // Map any result to false to stop loading inidicator mapTo(false), // Start operation with true diff --git a/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts b/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts index d64ca7376..8ca35bc45 100644 --- a/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts +++ b/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts @@ -213,6 +213,7 @@ export class MarketplaceShowPage { await this.embassyApi.installPackage({ id, 'version-spec': version ? `=${version}` : undefined, + 'marketplace-url': this.marketplaceService.marketplaceUrl, }) } catch (e) { this.errToast.present(e) diff --git a/frontend/projects/ui/src/app/services/api/api.types.ts b/frontend/projects/ui/src/app/services/api/api.types.ts index e8e230e16..aec4f2d4d 100644 --- a/frontend/projects/ui/src/app/services/api/api.types.ts +++ b/frontend/projects/ui/src/app/services/api/api.types.ts @@ -180,6 +180,7 @@ export module RR { id: string 'version-spec'?: string 'version-priority'?: 'min' | 'max' + 'marketplace-url': string }> // package.install export type InstallPackageRes = WithRevision