UNPKG

@finos/legend-application-marketplace

Version:
71 lines 3.17 kB
/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ProviderResult, } from '@finos/legend-server-marketplace'; import { flow, makeObservable, observable } from 'mobx'; import { VendorDataProviderType } from '../pages/VendorData/LegendMarketplaceVendorData.js'; export class LegendMarketPlaceVendorDataState { applicationStore; store; marketplaceServerClient; responseLimit = 10; dataFeedProviders = []; terminalProviders = []; terminalProvidersAsDataProducts = []; addOnProviders = []; providerDisplayState = VendorDataProviderType.ALL; constructor(applicationStore, store) { makeObservable(this, { dataFeedProviders: observable, terminalProviders: observable, addOnProviders: observable, populateProviders: observable, providerDisplayState: observable, setProviderDisplayState: observable, terminalProvidersAsDataProducts: observable, init: flow, }); this.applicationStore = applicationStore; this.store = store; this.marketplaceServerClient = store.marketplaceServerClient; } *init() { try { yield this.populateProviders(); this.terminalProvidersAsDataProducts = this.terminalProviders.map((provider) => ({ description: provider.description, provider: provider.providerName, type: 'vendor', })); } catch (error) { this.applicationStore.notificationService.notifyError(`Failed to initialize vendors: ${error}`); } } setProviderDisplayState(value) { this.providerDisplayState = value; } async populateProviders() { try { this.dataFeedProviders = (await this.marketplaceServerClient.getVendorsByCategory(encodeURIComponent('Periodic Datafeed'), this.responseLimit)).map((json) => ProviderResult.serialization.fromJson(json)); this.terminalProviders = (await this.marketplaceServerClient.getVendorsByCategory(encodeURIComponent('Desktop'), this.responseLimit)).map((json) => ProviderResult.serialization.fromJson(json)); this.addOnProviders = (await this.marketplaceServerClient.getVendorsByCategory(encodeURIComponent('Add-on'), this.responseLimit)).map((json) => ProviderResult.serialization.fromJson(json)); } catch (error) { this.applicationStore.notificationService.notifyError(`Failed to fetch vendors: ${error}`); } } } //# sourceMappingURL=LegendMarketPlaceVendorDataState.js.map