From e8854465f634c3c875d0e45d58c5ce6398efb2ea Mon Sep 17 00:00:00 2001 From: SC Van Nostrand Date: Tue, 16 Jan 2024 11:52:44 -0500 Subject: [PATCH] initial copy from dfci/cbioportal-frontend --- fileMock.js | 1 - font-awesome.config.js | 12 - jest.config.ts | 27 - lerna.json | 9 - loaders/testwriter.js | 59 -- .../src/generated/CBioPortalAPI.ts | 676 +++++++++++++++++- .../generated/CBioPortalAPIInternal-docs.json | 350 +++++++++ src/pages/staticPages/importer/Importer.tsx | 124 ++++ .../staticPages/importer/ImporterHelp.tsx | 102 +++ .../staticPages/importer/ImporterStudy.tsx | 400 +++++++++++ src/pages/staticPages/importer/LogDisplay.tsx | 115 +++ .../staticPages/importer/importerUtil.ts | 35 + src/routes.tsx | 15 + 13 files changed, 1806 insertions(+), 119 deletions(-) delete mode 100644 fileMock.js delete mode 100644 font-awesome.config.js delete mode 100644 jest.config.ts delete mode 100644 lerna.json delete mode 100644 loaders/testwriter.js create mode 100644 src/pages/staticPages/importer/Importer.tsx create mode 100644 src/pages/staticPages/importer/ImporterHelp.tsx create mode 100644 src/pages/staticPages/importer/ImporterStudy.tsx create mode 100644 src/pages/staticPages/importer/LogDisplay.tsx create mode 100644 src/pages/staticPages/importer/importerUtil.ts diff --git a/fileMock.js b/fileMock.js deleted file mode 100644 index 86059f36292..00000000000 --- a/fileMock.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'test-file-stub'; diff --git a/font-awesome.config.js b/font-awesome.config.js deleted file mode 100644 index 15c275ea996..00000000000 --- a/font-awesome.config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - styles: { - mixins: true, - core: true, - icons: true, - path: true, - }, - styleLoader: require('extract-text-webpack-plugin').extract( - 'style-loader', - 'css-loader!sass-loader' - ), -}; diff --git a/jest.config.ts b/jest.config.ts deleted file mode 100644 index 7dc24211e4e..00000000000 --- a/jest.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { InitialOptionsTsJest } from 'ts-jest/dist/types'; - -const config: InitialOptionsTsJest = { - preset: 'ts-jest/presets/js-with-ts', - moduleNameMapper: { - '\\.(css|sass|less|scss)$': 'identity-obj-proxy', - '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': - '/fileMock.js', - '^containers(.*)$': '/src/containers$1', - '^components(.*)$': '/src/components$1', - '^config(.*)$': '/src/config$1', - '^utils(.*)$': '/src/utils$1', - '^styles(.*)$': '/src/styles$1', - '^pages(.*)$': '/src/pages$1', - '^shared(.*)$': '/src/shared$1', - '^test(.*)$': '/src/test$1', - }, - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.test.json', - }, - }, - setupFiles: ['/src/setupTests.ts', 'jest-canvas-mock'], - testMatch: ['/src/**/*.spec.ts', '/src/**/*.spec.tsx'], -}; - -export default config; diff --git a/lerna.json b/lerna.json deleted file mode 100644 index 7af40f567cd..00000000000 --- a/lerna.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "npmClient": "yarn", - "packages": [ - ".", - "packages/*" - ], - "version": "independent", - "useWorkspaces": true -} diff --git a/loaders/testwriter.js b/loaders/testwriter.js deleted file mode 100644 index f9ccc588841..00000000000 --- a/loaders/testwriter.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -var loaderUtils = require('loader-utils'); -var SourceNode = require('source-map').SourceNode; -var SourceMapConsumer = require('source-map').SourceMapConsumer; -var FOOTER = '/*** EXPORTS FROM exports-loader ***/\n'; -module.exports = function(content, sourceMap) { - if (this.cacheable) this.cacheable(); - var query = loaderUtils.getOptions(this) || {}; - var exports = []; - var keys = Object.keys(query); - - content = content.replace(/\/\/testIt([^f]*)function ([^\(]*)/gim, function( - $0, - $2, - $1 - ) { - var params = $2.replace(/\n/g, ''); - return `var old_${$1} = ${$1}; ${$1} = exports.${$1} = - function(){ - return window._handleTestReports(arguments,old_${$1},'${params}',this); - }; - ${$0.replace(/\/\/testIt[^f]*/m, '')}`; - }); - - if (keys.length == 1 && typeof query[keys[0]] == 'boolean') { - //console.log("exporting 1"); - exports.push('module.exports = ' + keys[0] + ';'); - } else { - //console.log("exporting 2"); - keys.forEach(function(name) { - var mod = name; - if (typeof query[name] == 'string') { - mod = query[name]; - } - //console.log("exporting", name); - exports.push( - 'exports[' + JSON.stringify(name) + '] = (' + mod + ');' - ); - }); - } - if (sourceMap) { - var currentRequest = loaderUtils.getCurrentRequest(this); - var node = SourceNode.fromStringWithSourceMap( - content, - new SourceMapConsumer(sourceMap) - ); - node.add('\n\n' + FOOTER + exports.join('\n')); - var result = node.toStringWithSourceMap({ - file: currentRequest, - }); - this.callback(null, result.code, result.map.toJSON()); - return; - } - - return content + '\n\n' + FOOTER + exports.join('\n'); -}; diff --git a/packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI.ts b/packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI.ts index 37a607442e9..4d3a224ed1f 100644 --- a/packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI.ts +++ b/packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI.ts @@ -391,6 +391,52 @@ export type GenomicDataFilter = { 'values': Array < DataFilterValue > +}; +export type ImportLog = { + 'id': number + + 'logType': string + + 'passed': string + + 'rawText': string + + 'requester': string + + 'startDate': string + + 'studyId': string + + 'testRun': boolean + + 'text': string + +}; +export type ImportStudy = { + 'importDate': string + + 'importLogs': Array < string > + + 'importRunning': boolean + + 'imported': boolean + + 'name': string + + 'studyId': string + + 'studyPath': string + + 'users': Array < string > + + 'validated': boolean + + 'validationDate': string + + 'validationLogs': Array < string > + + 'validationRunning': boolean + }; export type Info = { 'dbVersion': string @@ -2824,11 +2870,11 @@ export default class CBioPortalAPI { return response.body; }); }; - getInfoUsingGETURL(parameters: { + getAllImporterStudiesUsingGETURL(parameters: { $queryParameters ? : any }): string { let queryParameters: any = {}; - let path = '/info'; + let path = '/importer/'; if (parameters.$queryParameters) { Object.keys(parameters.$queryParameters).forEach(function(parameterName) { @@ -2841,18 +2887,18 @@ export default class CBioPortalAPI { }; /** - * Get information about the running instance + * Get a list of all studies in the importer * @method - * @name CBioPortalAPI#getInfoUsingGET + * @name CBioPortalAPIInternal#getAllImporterStudiesUsingGET */ - getInfoUsingGETWithHttpInfo(parameters: { + getAllImporterStudiesUsingGETWithHttpInfo(parameters: { $queryParameters ? : any, $domain ? : string }): Promise < request.Response > { const domain = parameters.$domain ? parameters.$domain : this.domain; const errorHandlers = this.errorHandlers; const request = this.request; - let path = '/info'; + let path = '/importer/'; let body: any; let queryParameters: any = {}; let headers: any = {}; @@ -2873,15 +2919,623 @@ export default class CBioPortalAPI { }; /** - * Get information about the running instance + * Get a list of all studies in the importer * @method - * @name CBioPortalAPI#getInfoUsingGET + * @name CBioPortalAPIInternal#getAllImporterStudiesUsingGET */ - getInfoUsingGET(parameters: { + getAllImporterStudiesUsingGET(parameters: { + $queryParameters ? : any, + $domain ? : string + }): Promise < Array < ImportStudy > + > { + return this.getAllImporterStudiesUsingGETWithHttpInfo(parameters).then(function(response: request.Response) { + return response.body; + }); + }; + getImporterStudyUsingGETURL(parameters: { + 'studyId': string, + $queryParameters ? : any + }): string { + let queryParameters: any = {}; + let path = '/importer/{studyId}'; + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + let keys = Object.keys(queryParameters); + return this.domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : ''); + }; + + /** + * Get study details + * @method + * @name CBioPortalAPIInternal#getImporterStudyUsingGET + * @param {string} studyId - studyId + */ + getImporterStudyUsingGETWithHttpInfo(parameters: { + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < request.Response > { + const domain = parameters.$domain ? parameters.$domain : this.domain; + const errorHandlers = this.errorHandlers; + const request = this.request; + let path = '/importer/{studyId}'; + let body: any; + let queryParameters: any = {}; + let headers: any = {}; + let form: any = {}; + return new Promise(function(resolve, reject) { + headers['Accept'] = 'application/json'; + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters['studyId'] === undefined) { + reject(new Error('Missing required parameter: studyId')); + return; + } + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + + request('GET', domain + path, body, headers, queryParameters, form, reject, resolve, errorHandlers); + + }); + }; + + /** + * Get study details + * @method + * @name CBioPortalAPIInternal#getImporterStudyUsingGET + * @param {string} studyId - studyId + */ + getImporterStudyUsingGET(parameters: { + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < ImportStudy > { + return this.getImporterStudyUsingGETWithHttpInfo(parameters).then(function(response: request.Response) { + return response.body; + }); + }; + runTrialImportUsingGETURL(parameters: { + 'authenticated' ? : boolean, + 'authorities0Authority' ? : string, + 'credentials' ? : {}, + 'details' ? : {}, + 'principal' ? : {}, + 'studyId': string, + $queryParameters ? : any + }): string { + let queryParameters: any = {}; + let path = '/importer/{studyId}/import'; + if (parameters['authenticated'] !== undefined) { + queryParameters['authenticated'] = parameters['authenticated']; + } + + if (parameters['authorities0Authority'] !== undefined) { + queryParameters['authorities[0].authority'] = parameters['authorities0Authority']; + } + + if (parameters['credentials'] !== undefined) { + queryParameters['credentials'] = parameters['credentials']; + } + + if (parameters['details'] !== undefined) { + queryParameters['details'] = parameters['details']; + } + + if (parameters['principal'] !== undefined) { + queryParameters['principal'] = parameters['principal']; + } + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + let keys = Object.keys(queryParameters); + return this.domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : ''); + }; + + /** + * Run a trial import of the studyId + * @method + * @name CBioPortalAPIInternal#runTrialImportUsingGET + * @param {boolean} authenticated - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {string} authorities0Authority - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} credentials - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} details - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} principal - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {string} studyId - studyId + */ + runTrialImportUsingGETWithHttpInfo(parameters: { + 'authenticated' ? : boolean, + 'authorities0Authority' ? : string, + 'credentials' ? : {}, + 'details' ? : {}, + 'principal' ? : {}, + 'studyId': string, $queryParameters ? : any, $domain ? : string - }): Promise < Info > { - return this.getInfoUsingGETWithHttpInfo(parameters).then(function(response: request.Response) { + }): Promise < request.Response > { + const domain = parameters.$domain ? parameters.$domain : this.domain; + const errorHandlers = this.errorHandlers; + const request = this.request; + let path = '/importer/{studyId}/import'; + let body: any; + let queryParameters: any = {}; + let headers: any = {}; + let form: any = {}; + return new Promise(function(resolve, reject) { + headers['Accept'] = 'application/json'; + + if (parameters['authenticated'] !== undefined) { + queryParameters['authenticated'] = parameters['authenticated']; + } + + if (parameters['authorities0Authority'] !== undefined) { + queryParameters['authorities[0].authority'] = parameters['authorities0Authority']; + } + + if (parameters['credentials'] !== undefined) { + queryParameters['credentials'] = parameters['credentials']; + } + + if (parameters['details'] !== undefined) { + queryParameters['details'] = parameters['details']; + } + + if (parameters['principal'] !== undefined) { + queryParameters['principal'] = parameters['principal']; + } + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters['studyId'] === undefined) { + reject(new Error('Missing required parameter: studyId')); + return; + } + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + + request('GET', domain + path, body, headers, queryParameters, form, reject, resolve, errorHandlers); + + }); + }; + + /** + * Run a trial import of the studyId + * @method + * @name CBioPortalAPIInternal#runTrialImportUsingGET + * @param {boolean} authenticated - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {string} authorities0Authority - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} credentials - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} details - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} principal - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {string} studyId - studyId + */ + runTrialImportUsingGET(parameters: { + 'authenticated' ? : boolean, + 'authorities0Authority' ? : string, + 'credentials' ? : {}, + 'details' ? : {}, + 'principal' ? : {}, + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < string > { + return this.runTrialImportUsingGETWithHttpInfo(parameters).then(function(response: request.Response) { + return response.body; + }); + }; + runTrialValidationUsingGETURL(parameters: { + 'authenticated' ? : boolean, + 'authorities0Authority' ? : string, + 'credentials' ? : {}, + 'details' ? : {}, + 'principal' ? : {}, + 'studyId': string, + $queryParameters ? : any + }): string { + let queryParameters: any = {}; + let path = '/importer/{studyId}/validate'; + if (parameters['authenticated'] !== undefined) { + queryParameters['authenticated'] = parameters['authenticated']; + } + + if (parameters['authorities0Authority'] !== undefined) { + queryParameters['authorities[0].authority'] = parameters['authorities0Authority']; + } + + if (parameters['credentials'] !== undefined) { + queryParameters['credentials'] = parameters['credentials']; + } + + if (parameters['details'] !== undefined) { + queryParameters['details'] = parameters['details']; + } + + if (parameters['principal'] !== undefined) { + queryParameters['principal'] = parameters['principal']; + } + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + let keys = Object.keys(queryParameters); + return this.domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : ''); + }; + + /** + * Run a trial validation of the studyId + * @method + * @name CBioPortalAPIInternal#runTrialValidationUsingGET + * @param {boolean} authenticated - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {string} authorities0Authority - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} credentials - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} details - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} principal - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {string} studyId - studyId + */ + runTrialValidationUsingGETWithHttpInfo(parameters: { + 'authenticated' ? : boolean, + 'authorities0Authority' ? : string, + 'credentials' ? : {}, + 'details' ? : {}, + 'principal' ? : {}, + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < request.Response > { + const domain = parameters.$domain ? parameters.$domain : this.domain; + const errorHandlers = this.errorHandlers; + const request = this.request; + let path = '/importer/{studyId}/validate'; + let body: any; + let queryParameters: any = {}; + let headers: any = {}; + let form: any = {}; + return new Promise(function(resolve, reject) { + headers['Accept'] = 'application/json'; + + if (parameters['authenticated'] !== undefined) { + queryParameters['authenticated'] = parameters['authenticated']; + } + + if (parameters['authorities0Authority'] !== undefined) { + queryParameters['authorities[0].authority'] = parameters['authorities0Authority']; + } + + if (parameters['credentials'] !== undefined) { + queryParameters['credentials'] = parameters['credentials']; + } + + if (parameters['details'] !== undefined) { + queryParameters['details'] = parameters['details']; + } + + if (parameters['principal'] !== undefined) { + queryParameters['principal'] = parameters['principal']; + } + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters['studyId'] === undefined) { + reject(new Error('Missing required parameter: studyId')); + return; + } + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + + request('GET', domain + path, body, headers, queryParameters, form, reject, resolve, errorHandlers); + + }); + }; + + /** + * Run a trial validation of the studyId + * @method + * @name CBioPortalAPIInternal#runTrialValidationUsingGET + * @param {boolean} authenticated - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {string} authorities0Authority - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} credentials - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} details - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {object} principal - A web service for supplying JSON formatted data to cBioPortal clients. Please note that this API is currently in beta and subject to change. + * @param {string} studyId - studyId + */ + runTrialValidationUsingGET(parameters: { + 'authenticated' ? : boolean, + 'authorities0Authority' ? : string, + 'credentials' ? : {}, + 'details' ? : {}, + 'principal' ? : {}, + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < string > { + return this.runTrialValidationUsingGETWithHttpInfo(parameters).then(function(response: request.Response) { + return response.body; + }); + }; + getInfoUsingGETURL(parameters: { + $queryParameters ? : any + }): string { + let queryParameters: any = {}; + let path = '/info'; + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + let keys = Object.keys(queryParameters); + return this.domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : ''); + }; + + /** + * Get information about the running instance + * @method + * @name CBioPortalAPI#getInfoUsingGET + */ + getInfoUsingGETWithHttpInfo(parameters: { + $queryParameters ? : any, + $domain ? : string + }): Promise < request.Response > { + const domain = parameters.$domain ? parameters.$domain : this.domain; + const errorHandlers = this.errorHandlers; + const request = this.request; + let path = '/info'; + let body: any; + let queryParameters: any = {}; + let headers: any = {}; + let form: any = {}; + return new Promise(function(resolve, reject) { + headers['Accept'] = 'application/json'; + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + + request('GET', domain + path, body, headers, queryParameters, form, reject, resolve, errorHandlers); + + }); + }; + + /** + * Get information about the running instance + * @method + * @name CBioPortalAPI#getInfoUsingGET + */ + getInfoUsingGET(parameters: { + $queryParameters ? : any, + $domain ? : string + }): Promise < Info > { + return this.getInfoUsingGETWithHttpInfo(parameters).then(function(response: request.Response) { + return response.body; + }); + }; + getAllLogsForStudyUsingGETURL(parameters: { + 'logType': string, + 'studyId': string, + $queryParameters ? : any + }): string { + let queryParameters: any = {}; + let path = '/logs/{logType}/{studyId}'; + + path = path.replace('{logType}', parameters['logType'] + ''); + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + let keys = Object.keys(queryParameters); + return this.domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : ''); + }; + + /** + * Get the specified log file + * @method + * @name CBioPortalAPIInternal#getAllLogsForStudyUsingGET + * @param {string} logType - logType + * @param {string} studyId - studyId + */ + getAllLogsForStudyUsingGETWithHttpInfo(parameters: { + 'logType': string, + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < request.Response > { + const domain = parameters.$domain ? parameters.$domain : this.domain; + const errorHandlers = this.errorHandlers; + const request = this.request; + let path = '/logs/{logType}/{studyId}'; + let body: any; + let queryParameters: any = {}; + let headers: any = {}; + let form: any = {}; + return new Promise(function(resolve, reject) { + headers['Accept'] = 'application/json'; + + path = path.replace('{logType}', parameters['logType'] + ''); + + if (parameters['logType'] === undefined) { + reject(new Error('Missing required parameter: logType')); + return; + } + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters['studyId'] === undefined) { + reject(new Error('Missing required parameter: studyId')); + return; + } + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + + request('GET', domain + path, body, headers, queryParameters, form, reject, resolve, errorHandlers); + + }); + }; + + /** + * Get the specified log file + * @method + * @name CBioPortalAPIInternal#getAllLogsForStudyUsingGET + * @param {string} logType - logType + * @param {string} studyId - studyId + */ + getAllLogsForStudyUsingGET(parameters: { + 'logType': string, + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < Array < ImportLog > + > { + return this.getAllLogsForStudyUsingGETWithHttpInfo(parameters).then(function(response: request.Response) { + return response.body; + }); + }; + getLogUsingGETURL(parameters: { + 'id': string, + 'logType': string, + 'studyId': string, + $queryParameters ? : any + }): string { + let queryParameters: any = {}; + let path = '/logs/{logType}/{studyId}/{id}'; + + path = path.replace('{id}', parameters['id'] + ''); + + path = path.replace('{logType}', parameters['logType'] + ''); + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + let keys = Object.keys(queryParameters); + return this.domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : ''); + }; + + /** + * Get the specified log file + * @method + * @name CBioPortalAPIInternal#getLogUsingGET + * @param {string} id - id + * @param {string} logType - logType + * @param {string} studyId - studyId + */ + getLogUsingGETWithHttpInfo(parameters: { + 'id': string, + 'logType': string, + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < request.Response > { + const domain = parameters.$domain ? parameters.$domain : this.domain; + const errorHandlers = this.errorHandlers; + const request = this.request; + let path = '/logs/{logType}/{studyId}/{id}'; + let body: any; + let queryParameters: any = {}; + let headers: any = {}; + let form: any = {}; + return new Promise(function(resolve, reject) { + headers['Accept'] = 'application/json'; + + path = path.replace('{id}', parameters['id'] + ''); + + if (parameters['id'] === undefined) { + reject(new Error('Missing required parameter: id')); + return; + } + + path = path.replace('{logType}', parameters['logType'] + ''); + + if (parameters['logType'] === undefined) { + reject(new Error('Missing required parameter: logType')); + return; + } + + path = path.replace('{studyId}', parameters['studyId'] + ''); + + if (parameters['studyId'] === undefined) { + reject(new Error('Missing required parameter: studyId')); + return; + } + + if (parameters.$queryParameters) { + Object.keys(parameters.$queryParameters).forEach(function(parameterName) { + var parameter = parameters.$queryParameters[parameterName]; + queryParameters[parameterName] = parameter; + }); + } + + request('GET', domain + path, body, headers, queryParameters, form, reject, resolve, errorHandlers); + + }); + }; + + /** + * Get the specified log file + * @method + * @name CBioPortalAPIInternal#getLogUsingGET + * @param {string} id - id + * @param {string} logType - logType + * @param {string} studyId - studyId + */ + getLogUsingGET(parameters: { + 'id': string, + 'logType': string, + 'studyId': string, + $queryParameters ? : any, + $domain ? : string + }): Promise < ImportLog > { + return this.getLogUsingGETWithHttpInfo(parameters).then(function(response: request.Response) { return response.body; }); }; diff --git a/packages/cbioportal-ts-api-client/src/generated/CBioPortalAPIInternal-docs.json b/packages/cbioportal-ts-api-client/src/generated/CBioPortalAPIInternal-docs.json index 8538aa9df9d..0082c2d5c90 100644 --- a/packages/cbioportal-ts-api-client/src/generated/CBioPortalAPIInternal-docs.json +++ b/packages/cbioportal-ts-api-client/src/generated/CBioPortalAPIInternal-docs.json @@ -75,6 +75,10 @@ "name": "Gene Sets", "description": " " }, + { + "name": "Import", + "description": " " + }, { "name": "Mutation Spectrums", "description": " " @@ -1669,6 +1673,264 @@ } } }, + "/importer/": { + "get": { + "tags": [ + "Import" + ], + "summary": "Get a list of all studies in the importer", + "operationId": "getAllImporterStudiesUsingGET", + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ImportStudy" + } + } + } + }, + "deprecated": false + } + }, + "/importer/{studyId}": { + "get": { + "tags": [ + "Import" + ], + "summary": "Get study details", + "operationId": "getImporterStudyUsingGET", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "studyId", + "in": "path", + "description": "studyId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/ImportStudy" + } + } + }, + "deprecated": false + } + }, + "/importer/{studyId}/import": { + "get": { + "tags": [ + "Import" + ], + "summary": "Run a trial import of the studyId", + "operationId": "runTrialImportUsingGET", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "authenticated", + "in": "query", + "required": false, + "type": "boolean" + }, + { + "name": "authorities[0].authority", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "credentials", + "in": "query", + "required": false, + "type": "object" + }, + { + "name": "details", + "in": "query", + "required": false, + "type": "object" + }, + { + "name": "principal", + "in": "query", + "required": false, + "type": "object" + }, + { + "name": "studyId", + "in": "path", + "description": "studyId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + }, + "deprecated": false + } + }, + "/importer/{studyId}/validate": { + "get": { + "tags": [ + "Import" + ], + "summary": "Run a trial validation of the studyId", + "operationId": "runTrialValidationUsingGET", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "authenticated", + "in": "query", + "required": false, + "type": "boolean" + }, + { + "name": "authorities[0].authority", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "credentials", + "in": "query", + "required": false, + "type": "object" + }, + { + "name": "details", + "in": "query", + "required": false, + "type": "object" + }, + { + "name": "principal", + "in": "query", + "required": false, + "type": "object" + }, + { + "name": "studyId", + "in": "path", + "description": "studyId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + }, + "deprecated": false + } + }, + "/logs/{logType}/{studyId}": { + "get": { + "tags": [ + "Import" + ], + "summary": "Get the specified log file", + "operationId": "getAllLogsForStudyUsingGET", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "logType", + "in": "path", + "description": "logType", + "required": true, + "type": "string" + }, + { + "name": "studyId", + "in": "path", + "description": "studyId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ImportLog" + } + } + } + }, + "deprecated": false + } + }, + "/logs/{logType}/{studyId}/{id}": { + "get": { + "tags": [ + "Import" + ], + "summary": "Get the specified log file", + "operationId": "getLogUsingGET", + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "description": "id", + "required": true, + "type": "string" + }, + { + "name": "logType", + "in": "path", + "description": "logType", + "required": true, + "type": "string" + }, + { + "name": "studyId", + "in": "path", + "description": "studyId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/ImportLog" + } + } + }, + "deprecated": false + } + }, "/molecular-profile-sample-counts/fetch": { "post": { "tags": [ @@ -4669,6 +4931,94 @@ }, "title": "GroupStatistics" }, + "ImportLog": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "logType": { + "type": "string" + }, + "passed": { + "type": "string" + }, + "rawText": { + "type": "string" + }, + "requester": { + "type": "string" + }, + "startDate": { + "type": "string", + "format": "date-time" + }, + "studyId": { + "type": "string" + }, + "testRun": { + "type": "boolean" + }, + "text": { + "type": "string" + } + }, + "title": "ImportLog" + }, + "ImportStudy": { + "type": "object", + "properties": { + "importDate": { + "type": "string", + "format": "date-time" + }, + "importLogs": { + "type": "array", + "items": { + "type": "string" + } + }, + "importRunning": { + "type": "boolean" + }, + "imported": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "studyId": { + "type": "string" + }, + "studyPath": { + "type": "string" + }, + "users": { + "type": "array", + "items": { + "type": "string" + } + }, + "validated": { + "type": "boolean" + }, + "validationDate": { + "type": "string", + "format": "date-time" + }, + "validationLogs": { + "type": "array", + "items": { + "type": "string" + } + }, + "validationRunning": { + "type": "boolean" + } + }, + "title": "ImportStudy" + }, "MolecularProfileCaseIdentifier": { "type": "object", "required": [ diff --git a/src/pages/staticPages/importer/Importer.tsx b/src/pages/staticPages/importer/Importer.tsx new file mode 100644 index 00000000000..3dd0b69d57b --- /dev/null +++ b/src/pages/staticPages/importer/Importer.tsx @@ -0,0 +1,124 @@ +import * as React from 'react'; +import { Link } from 'react-router-dom'; +import autobind from 'autobind-decorator'; +import { observable, action } from 'mobx'; +import { observer } from 'mobx-react'; + +import internalclient from 'shared/api/cbioportalInternalClientInstance'; +import { ImportStudy } from 'cbioportal-ts-api-client'; +import { remoteData } from 'cbioportal-frontend-commons'; + +import { dateOrNever, parseUrlParams } from './importerUtil'; +import ImporterHelp from './ImporterHelp'; + +const panelStyle = { + width: '50%', + margin: '20px auto', + borderRadius: '5px', + padding: '5px', + background: '#ededed', +}; + +@observer +export default class Importer extends React.Component<{}, {}> { + @observable + private displayHelp: boolean = !!parseUrlParams().help; + + constructor(_: {}) { + super(_); + } + + @observable + private studies = remoteData({ + await: () => [], + invoke: async () => { + return internalclient.getAllImporterStudiesUsingGET({}); + }, + }); + + @autobind + @action + onHelpClick() { + window.location.search = 'help=1'; + } + + renderStudy(study: ImportStudy): JSX.Element { + return ( + + + {study.name} + + {dateOrNever(study.validationDate)} + {dateOrNever(study.importDate)} + {study.imported ? 'Up to Date' : 'Out of Date'} + + ); + } + + renderStudies(studies: ImportStudy[]): JSX.Element[] { + return studies.map(s => this.renderStudy(s)); + } + + public render() { + if (this.displayHelp) { + return ; + } + + if (this.studies.isPending) { + return
Loading...
; + } + + if (this.studies.isError) { + return
Error loading study.
; + } + + return ( +
+

cBioPortal Importer Dashboard

+

+ This dashboard allows you to view validation and import logs + for studies that you have access to.{} + You can also validate and test import of newly updated data. + Note that importing using this dashboard{} + is a test import only and will not result in an updated + study in cBioPortal.{} + Official imports occur each night. +

+

+ Successful validation will soon be required to import + studies, so it is important to ensure your{} + studies are passing validation. +

+ + + + + + + + + + + {this.renderStudies( + this.studies.result as ImportStudy[] + )} + +
StudyLast Successful ValidationLast Successful ImportStatus
+ +
+ ); + } +} diff --git a/src/pages/staticPages/importer/ImporterHelp.tsx b/src/pages/staticPages/importer/ImporterHelp.tsx new file mode 100644 index 00000000000..a7fc6d19191 --- /dev/null +++ b/src/pages/staticPages/importer/ImporterHelp.tsx @@ -0,0 +1,102 @@ +import * as React from 'react'; +import { observer } from 'mobx-react'; + +@observer +export default class ImporterHelp extends React.Component<{}, {}> { + onHelpClose() { + window.location.search = ''; + } + + render() { + return ( +
+

Help

+

+ Welcome to the new importer. The importer has two major + pages: an overview page, and a details page. +

+
+

+

Overview Page

+ The overview page can be found{' '} + here. It shows the + importer status of all the studies you have access to. Each + row in the table corresponds to a study in the cBioPortal. + If you click on a study in the table, you can go to the + study details page. +

+
+

+

Study Detail Page

+ The study detail page shows the details of a study according + to the importer. It{} + has three sections of information: study access, study + validation, and study import. +

+

+

Access

+ The centered section near the top of the page shows what + people have access to this study. This list is taken from + the cBioPortal database, which is update every 15 minutes + with the latest list from dropbox. +

+

+

Validation

+ Below and to the left of the access section is validation + information. This section shows all validation runs for this + study, and allows you to execute a validation run. To start + a run, you can press the Run Test Validation button. When + you do this and refresh the page, you will see a new log + entry with a status of validation pending- this is the run + you just started. Only one validation run can be executing + for each study at a time. When a run is finished, you can + view the results by clicking either the View HTML Report or + View Raw Log buttons. The HTML report is generally easier to + read, but we give you access to both reports just in case. +

+

+ The importer accesses the files for your study on Dropbox + via a FUSE mount. Updates you make to dropbox persist fairly + quickly, but you may want to wait 30 seconds after making a + change to a dropbox file before running validation, just to + give those changes a fair chance to persist. +

+

+

Import

+ Just like with the old importer, your study is updated every + night if the importer detects any changes to the related + files. These automated import logs show up in the import + logs section, which is located to the right of the + validation section. Similar to the validation section, the + import section shows all import runs, and allows you to run + a test import run. There is one critical difference - when + you run a test import, you are testing to make sure that the + import will work, but you are not doing an actual import. + You can use test imports to verify that your study will + import correctly, but you'll still have to wait overnight + for your study to update in the cBioPortal. +

+ +
+ ); + } +} diff --git a/src/pages/staticPages/importer/ImporterStudy.tsx b/src/pages/staticPages/importer/ImporterStudy.tsx new file mode 100644 index 00000000000..1035c644259 --- /dev/null +++ b/src/pages/staticPages/importer/ImporterStudy.tsx @@ -0,0 +1,400 @@ +import * as React from 'react'; +import { Link } from 'react-router-dom'; +import { Button } from 'react-bootstrap'; + +import { MobxPromiseUnionType } from 'mobxpromise'; +import { observer } from 'mobx-react'; +import { observable, action, computed } from 'mobx'; +import autobind from 'autobind-decorator'; + +import { remoteData } from 'cbioportal-frontend-commons'; + +import internalclient from 'shared/api/cbioportalInternalClientInstance'; +import { ImportStudy, ImportLog } from 'cbioportal-ts-api-client'; + +import { dateOrNever, parseUrlParams } from './importerUtil'; +import ImporterHelp from './ImporterHelp'; + +const panelStyle = { + width: '50%', + margin: '10px', + borderRadius: '5px', + padding: '5px', + background: '#ededed', +}; + +const IMPORTING_TEXT = + 'Your import is running. This process can take several minutes depending ' + + 'on the size of your study. Refresh the page to see if it has completed.'; +const VALIDATING_TEXT = + 'Your validation is running. This process can take several minutes' + + ' depending on the size of your study. Refresh the page to see if it has completed.'; + +export type ImporterStudyProps = { + match: { + params: { + studyId: string; + }; + }; +}; + +@observer +export default class ImporterStudy extends React.Component< + ImporterStudyProps, + {} +> { + @observable + private displayHelp: boolean = !!parseUrlParams().help; + @observable + private importClicked: boolean = true; + @observable + private validateClicked: boolean = true; + @observable + private importLogs: MobxPromiseUnionType; + @observable + private validationLogs: MobxPromiseUnionType; + @observable + private study: MobxPromiseUnionType; + @observable + private importButtonInfo: JSX.Element; + @observable + private validationButtonInfo: JSX.Element; + + constructor(props: ImporterStudyProps) { + super(props); + const self = this; + const studyId = props.match.params.studyId; + + this.study = remoteData({ + await: () => [], + invoke: async () => { + return internalclient.getImporterStudyUsingGET({ + studyId: studyId, + }); + }, + onResult: (study: ImportStudy) => { + self.updateButtonStates(study); + }, + }); + + this.importLogs = remoteData({ + await: () => [], + invoke: async () => { + return internalclient.getAllLogsForStudyUsingGET({ + logType: 'import', + studyId: studyId, + }); + }, + }); + + this.validationLogs = remoteData({ + await: () => [], + invoke: async () => { + return internalclient.getAllLogsForStudyUsingGET({ + logType: 'validation', + studyId: studyId, + }); + }, + }); + } + + @autobind + updateButtonStates(study: ImportStudy) { + this.importClicked = study.importRunning; + this.validateClicked = study.validationRunning; + + if (this.importClicked) { + this.importButtonInfo =

{IMPORTING_TEXT}

; + } + + if (this.validateClicked) { + this.validationButtonInfo =

{VALIDATING_TEXT}

; + } + } + + renderLogs(logs: ImportLog[]): JSX.Element[] { + return logs.map(log => { + var rowClass = 'pending'; + if (log.passed === 'passed') { + rowClass = 'positive'; + } + if (log.passed === 'failed') { + rowClass = 'negative'; + } + return ( + + {dateOrNever(log.startDate)} + + + + + + + + + + + {log.requester} + + {log.logType === 'import' + ? log.testRun + ? 'test import ' + : 'cBioPortal import ' + : 'validation '} + {log.passed} + + + ); + }); + } + + @computed + private get importButtonText() { + return this.importClicked + ? 'Running test import...' + : 'Run Test Import'; + } + + @computed + private get validationButtonText() { + return this.validateClicked + ? 'Running test validation...' + : 'Run Test Validation'; + } + + @computed + private get lastTestImport(): string { + if (this.importLogs.isPending) { + return 'Loading...'; + } + + const passingTestImports = this.importLogs.result!.filter( + log => log.testRun && log.passed === 'passed' + ); + if (passingTestImports.length == 0) { + return 'Never'; + } + return dateOrNever(passingTestImports[0].startDate); + } + + @computed + private get lastProdImport(): string { + if (this.importLogs.isPending) { + return 'Loading...'; + } + + const passingTestImports = this.importLogs.result!.filter( + log => !log.testRun && log.passed === 'passed' + ); + if (passingTestImports.length == 0) { + return 'Never'; + } + return dateOrNever(passingTestImports[0].startDate); + } + + @computed + get lastValidation(): string { + if (this.validationLogs.isPending) { + return 'Loading...'; + } + + const passingValidations = this.validationLogs.result!.filter( + log => log.passed === 'passed' + ); + if (passingValidations.length == 0) { + return 'Never'; + } + return dateOrNever(passingValidations[0].startDate); + } + + @autobind + @action + onImportClick() { + this.importClicked = true; + internalclient.runTrialImportUsingGET({ + studyId: this.study.result!.studyId, + }); + this.importButtonInfo =

{IMPORTING_TEXT}

; + } + + @autobind + @action + onValidationClick() { + this.validateClicked = true; + internalclient.runTrialValidationUsingGET({ + studyId: this.study.result!.studyId, + }); + this.validationButtonInfo =

{VALIDATING_TEXT}

; + } + + @autobind + @action + onHelpClick() { + window.location.search = 'help=1'; + } + + render() { + if (this.displayHelp) { + return ; + } + if (this.study.isPending) { + return
Loading...
; + } + if (this.study.isError) { + return
Error loading study
; + } + const study = this.study.result as ImportStudy; + return ( +
+

+ Import and Validation for {study.name} +

+
+ + The following users have permission to view this study:{' '} + +

{study.users.join(', ')}

+
+
+
+

+ Last successful validation: + {this.lastValidation} +

+

+ + {this.validationButtonInfo} +

+

+ Validation logs: +

+ Below are logs of all validation attempts, both + manually triggered and automated nightly{} + runs. Successful validation will soon be + required to import studies, so it is important{} + to ensure your studies are passing validation. + You can manually trigger a validation run{} + at any time with the button below. +

+ + + + + + + + + {this.validationLogs.isPending ? ( + + + + + ) : ( + this.renderLogs( + this.validationLogs + .result as ImportLog[] + ) + )} +
Start DateTriggered ByStatus
Loading...
+

+
+
+

+ Last successful import to cBioPortal: + {this.lastProdImport} +

+

+ Last successful test import: + {this.lastTestImport} +

+

+ + {this.importButtonInfo} +

+

+ Import logs: +

+ Below are logs of all attempted imports, both + manually triggered and automated nightly{} + runs. Manually triggered runs are tests to + confirm that import can successfully occur but{} + these test runs will not result in an updated + study in cBioPortal. Official imports occur{} + each night. +

+ + + + + + + + + {this.importLogs.isPending ? ( + + + + + ) : ( + this.renderLogs( + this.importLogs.result as ImportLog[] + ) + )} +
Start DateTriggered ByStatus
Loading...
+

+
+
+ + + + +
+ ); + } +} diff --git a/src/pages/staticPages/importer/LogDisplay.tsx b/src/pages/staticPages/importer/LogDisplay.tsx new file mode 100644 index 00000000000..9b40a7807c0 --- /dev/null +++ b/src/pages/staticPages/importer/LogDisplay.tsx @@ -0,0 +1,115 @@ +import * as React from 'react'; +import { ImportLog } from 'cbioportal-ts-api-client'; +import internalClient from '../../../shared/api/cbioportalInternalClientInstance'; +import { MobxPromiseUnionType } from 'mobxpromise'; +import { remoteData } from 'cbioportal-frontend-commons'; +import { observer } from 'mobx-react'; +import { observable } from 'mobx'; +import { Link } from 'react-router-dom'; +import { dateOrNever } from './importerUtil'; + +type LogDisplayProps = { + routeParams: { + logType: string; + studyId: string; + logId: string; + }; + location: { + query: { + raw: string; + }; + }; +}; + +const divStyle = { + width: '50rem', + minWidth: '800px', + margin: '0 auto', +}; + +@observer +export default class LogDisplay extends React.Component { + @observable + private log: MobxPromiseUnionType; + + constructor(props: LogDisplayProps) { + super(props); + + this.log = remoteData({ + await: () => [], + invoke: async () => { + return internalClient.getLogUsingGET({ + logType: this.props.routeParams.logType, + studyId: this.props.routeParams.studyId, + id: this.props.routeParams.logId, + }); + }, + }); + } + + renderLog(log: ImportLog): JSX.Element { + if (this.props.location.query.raw === 'false') { + return

; + } + if (!log.rawText) { + return ; + } + const lines = log.rawText.split('\n').map((line, i) => ( + + {line} +
+
+ )); + return

{lines}
; + } + + render() { + if (this.log.isPending) { + return
Loading log...
; + } + if (this.log.isError) { + return ( +
+ Error retrieving log: {this.log.result} +
+ ); + } + const logFile = this.log.result as ImportLog; + return ( +
+ + + +

+ {logFile.logType === 'import' ? 'Import ' : 'Validation '}{' '} + log {logFile.id} +

+

+ Study Id: + {logFile.studyId} +

+

+ Test Run: + {logFile.testRun ? 'Yes' : 'No'} +

+

+ Run Started: + {dateOrNever(logFile.startDate)} +

+

+ Log contents: +

+ {this.renderLog(logFile)} +
+ ); + } +} diff --git a/src/pages/staticPages/importer/importerUtil.ts b/src/pages/staticPages/importer/importerUtil.ts new file mode 100644 index 00000000000..21137b1f33a --- /dev/null +++ b/src/pages/staticPages/importer/importerUtil.ts @@ -0,0 +1,35 @@ +export function dateOrNever(dateStr: string | undefined | null): string { + if (!dateStr) { + return 'Never'; + } + const date = new Date(dateStr); + const pieces = [ + date.getFullYear(), + date.getMonth() + 1, + date.getDate(), + date.getHours() > 12 ? date.getHours() - 12 : date.getHours(), + date.getMinutes(), + date.getSeconds(), + ].map(n => twoDig(n)); + const amPm = date.getHours() > 12 ? 'PM' : 'AM'; + + return `${pieces[0]}-${pieces[1]}-${pieces[2]} ${pieces[3]}:${pieces[4]}:${pieces[5]} ${amPm}`; +} + +function twoDig(num: number): string { + if (num > 9) { + return num.toString(); + } + return '0' + num.toString(); +} + +export function parseUrlParams() { + return window.location.search + .substring(1) + .split('&') + .map(p => p.split('=')) + .reduce((a, c) => { + a[c[0]] = c[1]; + return a; + }, {} as any); +} diff --git a/src/routes.tsx b/src/routes.tsx index 36f9bb3271e..10852fa9417 100755 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -111,6 +111,15 @@ const ErrorPage = SuspenseWrapper( // @ts-ignore React.lazy(() => import('./pages/resultsView/ErrorPage')) ); +const Importer = SuspenseWrapper( + React.lazy(() => import('./pages/staticPages/importer/Importer')) +); +const ImporterStudy = SuspenseWrapper( + React.lazy(() => import('./pages/staticPages/importer/ImporterStudy')) +); +const LogDisplay = SuspenseWrapper( + React.lazy(() => import('./pages/staticPages/importer/LogDisplay')) +); import $ from 'jquery'; import { getBrowserWindow } from 'cbioportal-frontend-commons'; @@ -439,6 +448,12 @@ export const makeRoutes = () => { ) )} /> + + +