-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PXP-2464 fix/homepage chart REST API (#476)
* fix(rest): add rest api for homepage chart * fix(access): add option for public index * fix(404): if get 404 from datasets endpoint, hit graphql * fix(login): check login status for public pages * fix(login): providers return after rendering login will cause err * fix(prop): default prop already set * fix(undefined): checking undefined * fix(public): remove public option from config, redirect to login if 401 * fix(constructor): move to componentDidMount
- Loading branch information
Showing
16 changed files
with
261 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,24 @@ | |
"text": "The website combines government datasets from 3 divisions of NIAID to create clean, easy to navigate visualizations for data-driven discovery within Allergy and Infectious Diseases.", | ||
"contact": "If you have any questions about access or the registration process, please contact ", | ||
"email": "[email protected]" | ||
} | ||
}, | ||
"footerLogos": [ | ||
{ | ||
"src": "/src/img/gen3.png", | ||
"href": "https://ctds.uchicago.edu/gen3", | ||
"alt": "Gen3 Data Commons" | ||
}, | ||
{ | ||
"src": "/src/img/createdby.png", | ||
"href": "https://ctds.uchicago.edu/", | ||
"alt": "Center for Translational Data Science at the University of Chicago" | ||
}, | ||
{ | ||
"src": "/src/img/sponsors/niaid.png", | ||
"href": "https://niaid.bionimbus.org", | ||
"alt": "NIAID Data Hub" | ||
} | ||
] | ||
}, | ||
"featureFlags": { | ||
"explorer": true | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import _ from 'underscore'; | ||
import { fetchWithCreds } from '../actions'; | ||
import { homepageChartNodes, datasetUrl } from '../localconf'; | ||
import getReduxStore from '../reduxStore'; | ||
import getProjectsList from './relayer'; | ||
|
||
const updateRedux = async projectNodeCounts => getReduxStore().then( | ||
(store) => { | ||
store.dispatch({ | ||
type: 'RECEIVE_PROJECT_NODE_DATASETS', | ||
projectNodeCounts, | ||
homepageChartNodes, | ||
fileNodes: store.getState().submission.file_nodes, | ||
}); | ||
}, | ||
(err) => { | ||
console.error('WARNING: failed to load redux store', err); | ||
return 'ERR'; | ||
}, | ||
); | ||
|
||
const getProjectNodeCounts = async (callback) => { | ||
const resultStatus = { needLogin: false }; | ||
if (typeof homepageChartNodes === 'undefined') { | ||
getProjectsList(); | ||
callback(resultStatus); | ||
return; | ||
} | ||
|
||
const store = await getReduxStore(); | ||
const fileNodes = store.getState().submission.file_nodes; | ||
const nodesForIndexChart = homepageChartNodes.map(item => item.node); | ||
const nodesToRequest = _.union(fileNodes, nodesForIndexChart); | ||
const url = `${datasetUrl}?nodes=${nodesToRequest.join(',')}`; | ||
|
||
fetchWithCreds({ | ||
path: url, | ||
}).then((res) => { | ||
switch (res.status) { | ||
case 200: | ||
updateRedux(res.data); | ||
callback(resultStatus); | ||
break; | ||
case 404: | ||
// Shouldn't happen, this means peregrine datasets endpoint not enabled | ||
console.error(`REST endpoint ${datasetUrl} not enabled in Peregrine yet.`); | ||
callback(resultStatus); | ||
break; | ||
case 401: | ||
case 403: | ||
resultStatus.needLogin = true; | ||
callback(resultStatus); | ||
break; | ||
default: | ||
break; | ||
} | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
}; | ||
|
||
export default getProjectNodeCounts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.