X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/35ce0164f3863e7117fade1319ed3c2789bc216a..dfac252e5d6639c0bc6f106f1985fcdcd7402376:/src/common/config.ts diff --git a/src/common/config.ts b/src/common/config.ts index 146ca90a..2518c95e 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -51,7 +51,6 @@ export interface ClusterConfigJSON { }; Workbench: { ArvadosDocsite: string; - VocabularyURL: string; FileViewersConfigURL: string; WelcomePageHTML: string; InactivePageHTML: string; @@ -83,26 +82,41 @@ export interface ClusterConfigJSON { }; Collections: { ForwardSlashNameSubstitution: string; + ManagedProperties?: { + [key: string]: { + Function: string, + Value: string, + Protected?: boolean, + } + }, + TrustAllContent: boolean + }; + Volumes: { + [key: string]: { + StorageClasses: { + [key: string]: boolean; + } + } }; } export class Config { - baseUrl: string; - keepWebServiceUrl: string; - keepWebInlineServiceUrl: string; - remoteHosts: { + baseUrl!: string; + keepWebServiceUrl!: string; + keepWebInlineServiceUrl!: string; + remoteHosts!: { [key: string]: string }; - rootUrl: string; - uuidPrefix: string; - websocketUrl: string; - workbenchUrl: string; - workbench2Url: string; - vocabularyUrl: string; - fileViewersConfigUrl: string; - loginCluster: string; - clusterConfig: ClusterConfigJSON; - apiRevision: number; + rootUrl!: string; + uuidPrefix!: string; + websocketUrl!: string; + workbenchUrl!: string; + workbench2Url!: string; + vocabularyUrl!: string; + fileViewersConfigUrl!: string; + loginCluster!: string; + clusterConfig!: ClusterConfigJSON; + apiRevision!: number; } export const buildConfig = (clusterConfig: ClusterConfigJSON): Config => { @@ -123,6 +137,19 @@ export const buildConfig = (clusterConfig: ClusterConfigJSON): Config => { return config; }; +export const getStorageClasses = (config: Config): string[] => { + const classes: Set = new Set(['default']); + const volumes = config.clusterConfig.Volumes; + Object.keys(volumes).forEach(v => { + Object.keys(volumes[v].StorageClasses || {}).forEach(sc => { + if (volumes[v].StorageClasses[sc]) { + classes.add(sc); + } + }); + }); + return Array.from(classes); +}; + const getApiRevision = async (apiUrl: string) => { try { const dd = (await Axios.get(`${apiUrl}/${DISCOVERY_DOC_PATH}`)).data; @@ -135,7 +162,7 @@ const getApiRevision = async (apiUrl: string) => { const removeTrailingSlashes = (config: ClusterConfigJSON): ClusterConfigJSON => { const svcs: any = {}; - Object.keys(config.Services).map((s) => { + Object.keys(config.Services).forEach((s) => { svcs[s] = config.Services[s]; if (svcs[s].hasOwnProperty('ExternalURL')) { svcs[s].ExternalURL = svcs[s].ExternalURL.replace(/\/+$/, ''); @@ -176,15 +203,10 @@ remove the entire ${varName} entry from ${WORKBENCH_CONFIG_URL}`); } config.fileViewersConfigUrl = fileViewerConfigUrl; - let vocabularyUrl; if (workbenchConfig.VOCABULARY_URL !== undefined) { - warnLocalConfig("VOCABULARY_URL"); - vocabularyUrl = workbenchConfig.VOCABULARY_URL; - } - else { - vocabularyUrl = config.clusterConfig.Workbench.VocabularyURL || "/vocabulary-example.json"; + console.warn(`A value for VOCABULARY_URL was found in ${WORKBENCH_CONFIG_URL}. It will be ignored as the cluster already provides its own endpoint, you can safely remove it.`) } - config.vocabularyUrl = vocabularyUrl; + config.vocabularyUrl = getVocabularyURL(workbenchConfig.API_HOST); return { config, apiHost: workbenchConfig.API_HOST }; }); @@ -212,7 +234,6 @@ export const mockClusterConfigJSON = (config: Partial): Clust }, Workbench: { ArvadosDocsite: "", - VocabularyURL: "", FileViewersConfigURL: "", WelcomePageHTML: "", InactivePageHTML: "", @@ -244,7 +265,9 @@ export const mockClusterConfigJSON = (config: Partial): Clust }, Collections: { ForwardSlashNameSubstitution: "", + TrustAllContent: false, }, + Volumes: {}, ...config }); @@ -285,5 +308,7 @@ const getDefaultConfig = (): WorkbenchConfig => { export const ARVADOS_API_PATH = "arvados/v1"; export const CLUSTER_CONFIG_PATH = "arvados/v1/config"; +export const VOCABULARY_PATH = "arvados/v1/vocabulary"; export const DISCOVERY_DOC_PATH = "discovery/v1/apis/arvados/v1/rest"; -export const getClusterConfigURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${CLUSTER_CONFIG_PATH}?nocache=${(new Date()).getTime()}`; +export const getClusterConfigURL = (apiHost: string) => `https://${apiHost}/${CLUSTER_CONFIG_PATH}?nocache=${(new Date()).getTime()}`; +export const getVocabularyURL = (apiHost: string) => `https://${apiHost}/${VOCABULARY_PATH}?nocache=${(new Date()).getTime()}`;