From ee89e3ce1fa9c542d4b068d269557c34648c51b3 Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Thu, 21 Mar 2019 16:29:32 -0700 Subject: [PATCH 1/9] add grapQLbutton for singlestructure view + show energy correction if present --- app/components/SingleStructureView/index.js | 33 ++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/app/components/SingleStructureView/index.js b/app/components/SingleStructureView/index.js index ab8025ec..7b3a95d2 100644 --- a/app/components/SingleStructureView/index.js +++ b/app/components/SingleStructureView/index.js @@ -17,6 +17,7 @@ import { } from 'utils/functions'; import GeometryCanvasWithOptions from 'components/GeometryCanvasWithOptions'; +import GraphQlbutton from 'components/GraphQlbutton'; const initialState = { Formula: '', @@ -39,10 +40,31 @@ class SingleStructureView extends React.Component { // eslint-disable-line react constructor(props) { super(props); this.state = initialState; + this.state.printquery = `query{systems( uniqueId: "${this.props.selectedSystem.aseId}" ) { + edges { + node { + Formula + energy + numbers + initialMagmoms + magmoms + magmom + charges + momenta + calculator + keyValuePairs + calculatorParameters + publication { + title + authors + doi + } + } + } +}}`; } render() { const energy = this.props.selectedSystem.energy || this.state.energy || 0.0; - let x; let y; let z; @@ -72,11 +94,11 @@ class SingleStructureView extends React.Component { // eslint-disable-line react } From e338b8d5b70417a35ce523814f392cd47cfc71c9 Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Fri, 22 Mar 2019 09:16:35 -0700 Subject: [PATCH 2/9] make sure all publication info is shown --- app/utils/functions.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/utils/functions.js b/app/utils/functions.js index 9c9e0a5e..422bb5e1 100644 --- a/app/utils/functions.js +++ b/app/utils/functions.js @@ -86,10 +86,11 @@ export const prettyPrintReference = (ref) => {restoreSC(author)} )).reduce((prev, curr) => [prev, '; ', curr]))}. : null } - {(ref.journal !== '' && typeof ref.journal !== 'undefined' && ref.journal !== null) ? {ref.journal}, : null } - {(ref.volume !== '' && typeof ref.volume !== 'undefined' && ref.volume !== null) ? {ref.volume} : null} - {(ref.year !== '' && typeof ref.year !== 'undefined' && ref.year !== null) ? ({ref.year}). : null} - {(ref.pages !== '' && typeof ref.pages !== 'undefined' && ref.pages !== null) ? {ref.pages}. : null} + {(ref.journal !== '' && typeof ref.journal !== 'undefined' && ref.journal !== null) ? {ref.journal}. : null } + {(ref.volume !== '' && typeof ref.volume !== 'undefined' && ref.volume !== null) ? {ref.volume} : null} + {(ref.number !== '' && typeof ref.number !== 'undefined' && ref.number !== null) ? {ref.number} : null} + {(ref.pages !== '' && typeof ref.pages !== 'undefined' && ref.pages !== null) ? {', '}{ref.pages} : null} + {(ref.year !== '' && typeof ref.year !== 'undefined' && ref.year !== null) ? ({ref.year}) : null} ); From 33b92fd4f5033ac30bf184ae1441efc30af11dda Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Fri, 22 Mar 2019 14:17:40 -0700 Subject: [PATCH 3/9] make publication load faster --- app/components/Publications/index.js | 136 +++++++-------------------- 1 file changed, 34 insertions(+), 102 deletions(-) diff --git a/app/components/Publications/index.js b/app/components/Publications/index.js index 68e683b3..8df9854e 100644 --- a/app/components/Publications/index.js +++ b/app/components/Publications/index.js @@ -82,115 +82,48 @@ class Publications extends React.Component { // eslint-disable-line react/prefer this.clickPublication = this.clickPublication.bind(this); this.loadPreviewCif = this.loadPreviewCif.bind(this); this.backToList = this.backToList.bind(this); - - if (_.get(props, 'routeParams.pubId', '') !== '') { - const publicationQuery = { - ttl: 300, - query: `{publications(pubId: "${this.state.pubId}") { - edges { - node { - id - pubId - title - authors - pages - volume - journal - doi - pubtextsearch - } - } -}}` }; - - axios(newGraphQLRoot, - { - method: 'post', - data: publicationQuery, - }).then((response) => { - this.setState({ - reference: _.get(response, - 'data.data.publications.edges[0].node', - {}), - }); - }); - } } componentDidMount() { - const mtimeQuery = `{systems(first:50, keyValuePairs: "~", jsonkey: "pub_id", distinct: true) { -totalCount - edges { - node { - keyValuePairs - mtime - } - } -}}`; + const yearQuery = '{publications { edges { node { year } } }}'; axios.post(newGraphQLRoot, { - query: mtimeQuery, + query: yearQuery, }) - .then((mtimeResponse) => { - const mtimes = mtimeResponse.data.data.systems.edges.map((n) => (n.node.mtime)); - const sortedMtimes = mtimes.slice().sort((a, b) => b - a); - const systemPubIds = mtimeResponse.data.data.systems.edges.map((n) => (JSON.parse(n.node.keyValuePairs).pub_id)); - let orderedPubIds = sortedMtimes.map((sortedMtime) => systemPubIds[mtimes.indexOf(sortedMtime)]); - orderedPubIds = Array.from(new Set(orderedPubIds)); - const yearQuery = '{publications { edges { node { year } } }}'; - axios.post(newGraphQLRoot, { - query: yearQuery, - }) - .then((response) => { - let years = response.data.data.publications.edges.map((n) => n.node.year); - years = [...new Set(years)].sort().reverse().filter((x) => x !== null); - this.setState({ - years, - }); - years.map((year) => { - const query = `{publications (year: ${year}) { edges { node { doi title year authors journal pages pubId pubtextsearch } } }}`; - return axios.post(newGraphQLRoot, { - query, - }) - .then((yearResponse) => { - let references = yearResponse.data.data.publications.edges + .then((response) => { + let years = response.data.data.publications.edges.map((n) => n.node.year); + years = [...new Set(years)].sort().reverse().filter((x) => x !== null); + this.setState({ + years, + }); + years.map((year) => { + const query = `{publications (year: ${year}, order: "-stime") { edges { node { doi title year authors journal volume number pages pubId pubtextsearch } } }}`; + return axios.post(newGraphQLRoot, { + query, + }) + .then((yearResponse) => { + let references = yearResponse.data.data.publications.edges .map((n) => (n.node)); - references = [...new Set(references)]; - const dois = yearResponse.data.data.publications.edges.map((n) => (n.node.doi)); - const titles = yearResponse.data.data.publications.edges.map((n) => (n.node.title)); - const pubIds = yearResponse.data.data.publications.edges.map((n) => (n.node.pubId)); - const pubIndices = []; - orderedPubIds.map((orderedPubId) => { - if (pubIds.includes(orderedPubId)) { - pubIndices.push(pubIds.indexOf(orderedPubId)); - } - return pubIndices; - }); - pubIds.map((pubId, index) => { - if (!orderedPubIds.includes(pubId)) { - pubIndices.push(index); - } - return pubIndices; - }); - const allReferences = this.state.references; - const allDois = this.state.dois; - const allTitles = this.state.titles; - const allPubIds = this.state.pubIds; + references = [...new Set(references)]; + const dois = yearResponse.data.data.publications.edges.map((n) => (n.node.doi)); + const titles = yearResponse.data.data.publications.edges.map((n) => (n.node.title)); - allReferences[year] = pubIndices.map((p) => references[p]); - allDois[year] = pubIndices.map((p) => dois[p]); - allTitles[year] = pubIndices.map((p) => titles[p]); - allPubIds[year] = pubIndices.map((p) => pubIds[p]); + const allReferences = this.state.references; + const allDois = this.state.dois; + const allTitles = this.state.titles; - this.setState({ - references: allReferences, - dois: allDois, - titles: allTitles, - }); - }) - .catch(() => { - }) - ; - }); + allReferences[year] = references; + allDois[year] = dois; + allTitles[year] = titles; + + this.setState({ + references: allReferences, + dois: allDois, + titles: allTitles, + }); + }) + .catch(() => { + }); }); - }); + }); } backToList() { this.setState({ @@ -391,7 +324,6 @@ totalCount if (!notFound.every((x) => x)) { return null; } - if (this.state.titles[year][j] !== null) { return ( From d06034b371fd6f8b871ef65d7ea459eb7096ff0e Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Fri, 22 Mar 2019 14:25:56 -0700 Subject: [PATCH 4/9] add energycorrection to props --- app/containers/EnergiesPage/Input.js | 1 + .../EnergiesPage/MatchingReactions.js | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/containers/EnergiesPage/Input.js b/app/containers/EnergiesPage/Input.js index 8801fa12..404fdf68 100644 --- a/app/containers/EnergiesPage/Input.js +++ b/app/containers/EnergiesPage/Input.js @@ -191,6 +191,7 @@ class EnergiesPageInput extends React.Component { // eslint-disable-line react/p chemicalComposition reactionSystems { name + energyCorrection aseId } } diff --git a/app/containers/EnergiesPage/MatchingReactions.js b/app/containers/EnergiesPage/MatchingReactions.js index 81d69060..72c53954 100644 --- a/app/containers/EnergiesPage/MatchingReactions.js +++ b/app/containers/EnergiesPage/MatchingReactions.js @@ -129,13 +129,15 @@ class MatchingReactions extends React.Component { // eslint-disable-line react/p loading: true, }); this.props.saveLoading(true); - let catappIds; - let catappNames; + let cathubIds; + let cathubNames; + let catenergyCorrections; if (typeof reaction.reactionSystems !== 'undefined' && reaction.reactionSystems !== null) { - catappIds = (reaction.reactionSystems.map((x) => x.aseId)); - catappNames = (reaction.reactionSystems.map((x) => x.name)); + cathubIds = (reaction.reactionSystems.map((x) => x.aseId)); + cathubNames = (reaction.reactionSystems.map((x) => x.name)); + catenergyCorrections = (reaction.reactionSystems.map((x) => x.energyCorrection)); } else { - catappIds = {}; + cathubIds = {}; snackbarActions.open('Scroll down for detailed structure.'); } @@ -160,9 +162,10 @@ class MatchingReactions extends React.Component { // eslint-disable-line react/p }); this.props.clearSystems(); - catappIds.map((key, index) => { + cathubIds.map((key, index) => { let aseId = key; - const name = catappNames[index]; + const name = cathubNames[index]; + const energyCorrection = catenergyCorrections[index]; if (typeof aseId === 'object') { aseId = aseId[1]; } @@ -189,6 +192,7 @@ class MatchingReactions extends React.Component { // eslint-disable-line react/p node.Facet = reaction.facet; node.publication = this.props.publication; node.aseId = aseId; + node.energyCorrection = energyCorrection; node.key = name; node.full_key = node.Formula; const ads = name.replace('star', ' @'); From 498e8351138e824a8110074c12cc9ec6aa687190 Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Fri, 22 Mar 2019 14:45:39 -0700 Subject: [PATCH 5/9] improve loading time by using stime from publications --- app/containers/HomePage/index.js | 64 ++++++++++++-------------------- 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/app/containers/HomePage/index.js b/app/containers/HomePage/index.js index d0139dfc..701089db 100644 --- a/app/containers/HomePage/index.js +++ b/app/containers/HomePage/index.js @@ -125,53 +125,35 @@ export class HomePage extends React.PureComponent { // eslint-disable-line react }, 2000 ); }); - axios.post(newGraphQLRoot, { - query: `{systems(order:"mtime", last: 1) { + } + }); + axios.post(newGraphQLRoot, { + query: `{publications(stime: 0, op: ">", order: "stime", last: 1) { + totalCount edges { node { - Mtime - publication { - pubId - } + pubId + Stime + title + authors + journal + pages + volume + year + doi } } }}`, - }).then((lpidResponse) => { - const lastPubId = _.get(lpidResponse, 'data.data.systems.edges[0].node.publication[0].pubId'); - const lastPublicationTime = _.get(lpidResponse, 'data.data.systems.edges[0].node.Mtime'); - const pubTimeArray = lastPublicationTime.split(' '); - pubTimeArray.splice(3, 1, ','); - this.setState({ - lastPublicationTime: pubTimeArray.join(' ').replace(' ,', ''), - }); - axios.post(newGraphQLRoot, { - query: `{publications(pubId:"${lastPubId}") { - edges { - node { title authors journal pages volume year doi pubId } - } -}}`, - }).then((lpResponse) => { - this.setState({ - lastPublication: _.get(lpResponse, 'data.data.publications.edges[0].node'), - }); - }); - }); - } - }); - axios.post(newGraphQLRoot, { query: '{publications(first: 0) { totalCount edges { node { id } } }}' }).then((response) => { - if (response.data.data.reactions === null) { - this.setState({ - loading: false, - error: true, - }); - } else { - this.setState({ - loading: false, - publications: response.data.data.publications.totalCount, - }); - } + }).then((lpidResponse) => { + const lastPublicationTime = _.get(lpidResponse, 'data.data.publications.edges[0].node.Stime'); + const pubTimeArray = lastPublicationTime.split(' '); + pubTimeArray.splice(3, 1, ','); + this.setState({ + lastPublicationTime: pubTimeArray.join(' ').replace(' ,', ''), + lastPublication: _.get(lpidResponse, 'data.data.publications.edges[0].node'), + publications: _.get(lpidResponse, 'data.data.publications.totalCount'), + }); }); - axios.post(newGraphQLRoot, { query: '{publications (authors:"~", distinct: true) { edges { node { authors } } }}', }).then((response) => { From 9393b0173a84b9e8e006c9cdcbc431e428650d7e Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Fri, 22 Mar 2019 14:49:42 -0700 Subject: [PATCH 6/9] WIP Apps marked with Beta --- app/components/Apps/filteredApps.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/components/Apps/filteredApps.js b/app/components/Apps/filteredApps.js index 0814bb9a..d066e726 100644 --- a/app/components/Apps/filteredApps.js +++ b/app/components/Apps/filteredApps.js @@ -44,9 +44,17 @@ class FilteredApps extends React.Component { // eslint-disable-line react/prefer elevation={0} > -

- {getAppIcon(app.title)} - {'\u00A0'}{app.title}

+ {(app.title === 'Activity Maps' || app.title === 'Scaling Relations' || app.title === 'Pourbaix Diagrams') ? +

+ {getAppIcon(app.title)} + {'\u00A0'}{app.title}{' (Beta) '} +

+ : +

+ {getAppIcon(app.title)} + {'\u00A0'}{app.title} +

+ }
{app.tooltip}
From fb7d71636e35aba19dc0ee12cf219b493b8ca5e3 Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Mon, 25 Mar 2019 07:21:11 -0700 Subject: [PATCH 7/9] removed jens from list --- app/utils/constants.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/utils/constants.js b/app/utils/constants.js index 3c4b82ae..5f0ee1e9 100644 --- a/app/utils/constants.js +++ b/app/utils/constants.js @@ -102,8 +102,6 @@ module.exports = { 'http://suncat.stanford.edu/people/kirsten-winther'], 'Max Hoffmann': ['Software Engineer. Former postdoc, SLAC National Accelerator Laboratory', 'http://suncat.stanford.edu/people/max-hoffmann'], - 'Jens N\u00F8rskov': ['Villum Kann Rasmussen Professor, Technical University of Denmark', - 'http://www.staff.dtu.dk/jkno'], 'Jacob Boes': ['Postdoc, SLAC National Accelerator Laboratory', 'http://suncat.stanford.edu/people/jacob-russell-boes'], 'Osman Mamun': ['Postdoc, SLAC National Accelerator Laboratory', From 85341dc969bc61eac1c066ef862511fa098e7272 Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Mon, 25 Mar 2019 07:28:07 -0700 Subject: [PATCH 8/9] more contact info --- app/components/About/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/components/About/index.js b/app/components/About/index.js index 804dca20..7bc970af 100644 --- a/app/components/About/index.js +++ b/app/components/About/index.js @@ -47,17 +47,18 @@ class About extends React.Component { // eslint-disable-line react/prefer-statel

License

- ccLogoBig
Except where otherwise noted, content on Catalysis-Hub is licensed under a {' '} Creative Commons Attribution 4.0 International License .
+ ccLogoBig
-

People

+

People and Contact

+
The platform is developed at the SUNCAT Center for Interface Science and Catalysis, SLAC National Accelerator Laboratory, Stanford University. Contact information for the primary people involved is provided below. For technical support please contact postdoc Kirsten Winther at winther@stanford.edu.
    {Object.keys(people).map((name, i) => (
  • From 086233d7df43544427fdbd9fdfb85589ba2bf69f Mon Sep 17 00:00:00 2001 From: Kirsten Winther Date: Mon, 25 Mar 2019 07:32:15 -0700 Subject: [PATCH 9/9] fix typo --- app/containers/EnergiesPage/Input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/containers/EnergiesPage/Input.js b/app/containers/EnergiesPage/Input.js index 404fdf68..2f082683 100644 --- a/app/containers/EnergiesPage/Input.js +++ b/app/containers/EnergiesPage/Input.js @@ -274,7 +274,7 @@ class EnergiesPageInput extends React.Component { // eslint-disable-line react/p
    A quick guide:
    • Leave fields blank if you {"don't"} want to impose any restrictions.
    • -
    • For the Reactants and Product fields, choose the chemical species taking part in the left- and/or right hand side of the chemical reaction respectively. The phase of the molecules and elements can also be specified, such that {"'CO2gas'"} refers to CO2 in the gas phase, whereas {"'CO2*'"} refers to CO2 adsorbed on the surface.
    • +
    • For the Reactants and Products fields, choose the chemical species taking part in the left- and/or right hand side of the chemical reaction respectively. The phase of the molecules and elements can also be specified, such that {"'CO2gas'"} refers to CO2 in the gas phase, whereas {"'CO2*'"} refers to CO2 adsorbed on the surface.
    • In the Surface field, enter the (reduced) chemical composition of the surface, or a sum of elements that must be present, such as {"'Ag+'"} or {"'Ag+Sr'"}.