-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PXP-2464 fix/homepage chart REST API #476
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fa6b36c
fix(rest): add rest api for homepage chart
qingyashu 0437403
fix(access): add option for public index
qingyashu 8a40762
Merge branch 'master' into fix/homepage-chart-rest
qingyashu 633002e
Merge branch 'master' into fix/homepage-chart-rest
qingyashu 470044f
fix(404): if get 404 from datasets endpoint, hit graphql
qingyashu f850fcd
fix(login): check login status for public pages
qingyashu 1189529
Merge branch 'master' into fix/homepage-chart-rest
qingyashu 9893651
fix(login): providers return after rendering login will cause err
qingyashu b46c42d
fix(prop): default prop already set
qingyashu 0bb7c12
fix(undefined): checking undefined
qingyashu c30f7f1
fix(public): remove public option from config, redirect to login if 401
qingyashu 9efa45f
fix(constructor): move to componentDidMount
qingyashu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should go in
componentDidMount
, not the constructor.https://reactjs.org/docs/react-component.html#constructor