From e04225d3e56293cca6076e97e5a9589d503ce6d6 Mon Sep 17 00:00:00 2001 From: Manuel Spuhler Date: Tue, 12 Nov 2019 14:02:25 +0100 Subject: [PATCH] Fixed local mode --- src/components/API/Core.tsx | 23 +++++++++++++---------- src/components/API/Utils.tsx | 3 ++- src/components/App/Container.tsx | 9 ++++++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/components/API/Core.tsx b/src/components/API/Core.tsx index b74643865..83891e420 100644 --- a/src/components/API/Core.tsx +++ b/src/components/API/Core.tsx @@ -4,6 +4,7 @@ import { backendURL } from '../API'; import { ENABLED_ALGORITHMS, UI_HIDDEN_PARAMETERS } from '../constants'; import { Engine } from './Experiment'; import { buildWorkflowAlgorithmList } from './WorkflowAPIAdapter'; +import { InstanceMode } from '../App/App'; export interface Variable { code: string; @@ -288,7 +289,7 @@ class Core extends Container { } }; - public algorithms = async (): Promise => { + public algorithms = async (mode: InstanceMode): Promise => { const exaremeAlgorithms = await this.exaremeAlgorithms(); this.setState(state => ({ ...state, @@ -299,15 +300,17 @@ class Core extends Container { error: undefined })); - const workflows = await this.workflows(); - this.setState(state => ({ - ...state, - algorithms: [ - ...(state.algorithms || []), - ...((workflows && workflows.data) || []) - ], - error: workflows.error ? workflows.error : undefined - })); + if (mode === InstanceMode.Federation) { + const workflows = await this.workflows(); + this.setState(state => ({ + ...state, + algorithms: [ + ...(state.algorithms || []), + ...((workflows && workflows.data) || []) + ], + error: workflows.error ? workflows.error : undefined + })); + } return Promise.resolve(); }; diff --git a/src/components/API/Utils.tsx b/src/components/API/Utils.tsx index 0df4a6e71..df25b22cb 100644 --- a/src/components/API/Utils.tsx +++ b/src/components/API/Utils.tsx @@ -6,6 +6,7 @@ import APIExperiment, { } from './Experiment'; import APIModel, { ModelResponse, ModelState } from './Model'; import config from './RequestHeaders'; +import { InstanceMode } from '../App/App'; const apiModel = new APIModel(config); const apiExperiment = new APIExperiment(config); @@ -48,7 +49,7 @@ const createWorkflowPayload = async ( parameters: AlgorithmParameter[], modelSlug: string ): Promise => { - await apiCore.algorithms(); + await apiCore.algorithms(InstanceMode.Local); const algorithms = apiCore.state.algorithms || []; const selectedAlgorithm = algorithms.find(a => a.code === experimentCode); diff --git a/src/components/App/Container.tsx b/src/components/App/Container.tsx index 29253fc51..650638b6e 100644 --- a/src/components/App/Container.tsx +++ b/src/components/App/Container.tsx @@ -41,10 +41,11 @@ class AppContainer extends React.Component { // } // Conf written by dockerize + let appConfig: AppConfig; const response = await fetch(`${webURL}/static/config.json`); try { const config = await response.json(); - const appConfig = { + appConfig = { ...config, mode: config.mode === 'federation' @@ -57,7 +58,7 @@ class AppContainer extends React.Component { ReactGA.initialize(appConfig.ga); } } catch (e) { - const appConfig: AppConfig = { + appConfig = { instanceName: 'MIP DEV', mode: InstanceMode.Local, version: 'alpha' @@ -75,7 +76,9 @@ class AppContainer extends React.Component { this.apiUser.profile({ username }), this.apiExperiment.all(), this.apiCore.fetchPathologies(), - this.apiCore.algorithms(), + this.apiCore.algorithms( + (appConfig && appConfig.mode) || InstanceMode.Local + ), this.apiCore.articles(), this.apiModel.all() ]);