diff --git a/gui/public/env.js b/gui/public/env.js index 41e5f8be41545a334ac8700a422dabcc767adb20..1f5c4b3af96c567290824f4a1f80531ee8ad74e7 100644 --- a/gui/public/env.js +++ b/gui/public/env.js @@ -12,5 +12,6 @@ window.nomadEnv = { "isBeta": false, "usesBetaData": false, "officialUrl": "https://nomad-lab.eu/prod/rae/gui" - } + }, + 'encyclopediaEnabled': true } diff --git a/gui/src/components/dft/DFTEntryOverview.js b/gui/src/components/dft/DFTEntryOverview.js index 24da010b92d3b4038eb0ebcd66fbb8c554a65d0d..302f477c3bed9b3a33177c70b2252f8bb3af9b16 100644 --- a/gui/src/components/dft/DFTEntryOverview.js +++ b/gui/src/components/dft/DFTEntryOverview.js @@ -1,32 +1,40 @@ import React from 'react' import PropTypes from 'prop-types' -import { Typography, Button, makeStyles, Tooltip } from '@material-ui/core' +import { Typography, Tooltip, Link } from '@material-ui/core' import Quantity from '../Quantity' import _ from 'lodash' -import {appBase} from '../../config' - -const useStyles = makeStyles(theme => ({ - actions: { - marginTop: theme.spacing(1), - textAlign: 'right', - margin: -theme.spacing(1) - } -})) +import {appBase, encyclopediaEnabled} from '../../config' export default function DFTEntryOverview(props) { - const classes = useStyles() const {data} = props if (!data.dft) { return <Typography color="error">No metadata available</Typography> } - const material_name = entry => entry.encyclopedia.material.material_name + const material_name = entry => { + let name + try { + name = entry.encyclopedia.material.material_name + } catch {} + name = name || 'unnamed' + + if (encyclopediaEnabled && data.encyclopedia && data.encyclopedia.material && data.published && !data.with_embargo) { + const url = `${appBase}/encyclopedia/#/material/${data.encyclopedia.material.material_id}` + return ( + <Tooltip title="Show the material of this entry in the NOMAD Encyclopedia."> + <Link href={url}>{name}</Link> + </Tooltip> + ) + } else { + return name + } + } return <div> <Quantity column> <Quantity row> <Quantity quantity="formula" label='formula' noWrap {...props} /> - <Quantity quantity={material_name} label='material name' noWrap {...props} /> + <Quantity quantity={material_name} label='material' noWrap {...props} /> </Quantity> <Quantity row> <Quantity quantity="dft.code_name" label='dft code' noWrap {...props} /> @@ -46,15 +54,6 @@ export default function DFTEntryOverview(props) { </Quantity> </Quantity> </Quantity> - {data.encyclopedia && data.encyclopedia.material && - <div className={classes.actions}> - <Tooltip title="Show the material of this entry in the NOMAD Encyclopedia."> - <Button color="primary" href={`${appBase}/encyclopedia/#/material/${data.encyclopedia.material.material_id}`}> - material - </Button> - </Tooltip> - </div> - } </div> } diff --git a/gui/src/config.js b/gui/src/config.js index a07d1c517d6332214ae4b443df7d8a857b21aacc..68018ad4920c37ca29653948f8636f3b7ae214ea 100644 --- a/gui/src/config.js +++ b/gui/src/config.js @@ -14,6 +14,7 @@ export const keycloakRealm = window.nomadEnv.keycloakRealm export const keycloakClientId = window.nomadEnv.keycloakClientId export const debug = window.nomadEnv.debug || false export const matomoEnabled = window.nomadEnv.matomoEnabled +export const encyclopediaEnabled = window.nomadEnv.encyclopediaEnabled export const email = 'webmaster@nomad-coe.eu' export const maxLogsToShow = 50 diff --git a/ops/helm/nomad/templates/api-deployment.yaml b/ops/helm/nomad/templates/api-deployment.yaml index b342d721d29032f98b1b047d511bf1b9c6cd687a..0febc3ecaf7c01970a35f12619d022bcf51d3cc0 100644 --- a/ops/helm/nomad/templates/api-deployment.yaml +++ b/ops/helm/nomad/templates/api-deployment.yaml @@ -99,7 +99,8 @@ data: "isBeta": {{ .Values.version.isBeta }}, "usesBetaData": {{ .Values.version.usesBetaData }}, "officialUrl": "{{ .Values.version.officialUrl }}" - } + }, + "encyclopediaEnabled": {{ .Values.gui.encyclopediaEnabled }} }; --- apiVersion: v1 diff --git a/ops/helm/nomad/values.yaml b/ops/helm/nomad/values.yaml index d89815747ceaa43f3464e430f29b272e8ab2206d..b94852dce2530948357291713fd064bc71ed970e 100644 --- a/ops/helm/nomad/values.yaml +++ b/ops/helm/nomad/values.yaml @@ -86,6 +86,8 @@ gui: matomoEnabled: false ## automatically gz based on header gzip: true + ## enable links to the 'new' encyclopedia + encyclopediaEnabled: false ## Everything concerning the nginx that serves the gui, proxies the api # It is run via NodePort service