mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
marketplace url install fix
This commit is contained in:
committed by
Drew Ansbacher
parent
8cb0186621
commit
d229aaf1b2
@@ -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,
|
||||
}),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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<void> {
|
||||
async deleteRecovered(pkg: RecoveredInfo): Promise<void> {
|
||||
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<unknown, boolean> {
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<null>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user