Commit c6ebae1f authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Adopted GUI to the latest API changes.

parent da7b1904
Pipeline #55108 passed with stages
in 22 minutes and 25 seconds
......@@ -9,7 +9,7 @@ import { withApi } from '../api'
class DFTSearchAggregations extends React.Component {
static propTypes = {
classes: PropTypes.object.isRequired,
quantities: PropTypes.object.isRequired,
statistics: PropTypes.object.isRequired,
metric: PropTypes.string.isRequired,
searchValues: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
......@@ -73,9 +73,9 @@ class DFTSearchAggregations extends React.Component {
}
render() {
const { classes, quantities, metric, searchValues, info } = this.props
const { classes, statistics, metric, searchValues, info } = this.props
if (quantities.code_name && info) {
if (statistics.code_name && info) {
// filter based on known codes, since elastic search might return 0 aggregations on
// obsolete code names
const filteredCodeNames = {}
......@@ -84,14 +84,14 @@ class DFTSearchAggregations extends React.Component {
}
defaultValue[metric] = 0
info.codes.forEach(key => {
filteredCodeNames[key] = quantities.code_name[key] || defaultValue
filteredCodeNames[key] = statistics.code_name[key] || defaultValue
})
quantities.code_name = filteredCodeNames
statistics.code_name = filteredCodeNames
}
const quantity = (key, title, scale) => (<QuantityHistogram
classes={{root: classes.quantity}} title={title || key} width={300}
data={quantities[key]} metric={metric}
data={statistics[key]} metric={metric}
value={searchValues[key]} defaultScale={scale}
onChanged={(selection) => this.handleQuantityChanged(key, selection)}/>)
......@@ -100,7 +100,7 @@ class DFTSearchAggregations extends React.Component {
<Card>
<CardContent>
<PeriodicTable
aggregations={quantities.atoms} metric={metric}
aggregations={statistics.atoms} metric={metric}
exclusive={this.state.exclusive}
values={searchValues.atoms || searchValues.only_atoms || []}
onChanged={(selection) => this.handleAtomsChanged(selection)}
......
......@@ -7,7 +7,7 @@ import QuantityHistogram from '../search/QuantityHistogram'
class EMSSearchAggregations extends React.Component {
static propTypes = {
classes: PropTypes.object.isRequired,
quantities: PropTypes.object.isRequired,
statistics: PropTypes.object.isRequired,
metric: PropTypes.string.isRequired,
searchValues: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired
......@@ -43,11 +43,11 @@ class EMSSearchAggregations extends React.Component {
}
render() {
const { classes, quantities, metric, searchValues } = this.props
const { classes, statistics, metric, searchValues } = this.props
const quantity = (key, title) => (<QuantityHistogram
classes={{root: classes.quantity}} title={title || key} width={300}
data={quantities[key]} metric={metric}
data={statistics[key]} metric={metric}
value={searchValues[key]}
onChanged={(selection) => this.handleQuantityChanged(key, selection)}/>)
......@@ -56,7 +56,7 @@ class EMSSearchAggregations extends React.Component {
<Card>
<CardContent>
<PeriodicTable
aggregations={quantities.atoms} metric={metric}
aggregations={statistics.atoms} metric={metric}
values={searchValues.atoms || []}
onChanged={(selection) => this.handleAtomsChanged(selection)}
/>
......
......@@ -36,9 +36,9 @@ class SearchAggregationsUnstyled extends React.Component {
render() {
const { classes, data, metrics, searchValues, domain, onChange, showDetails } = this.props
const { quantities } = data
const { statistics } = data
const selectedMetric = metrics.length === 0 ? 'code_runs' : metrics[0]
const useMetric = Object.keys(quantities.total.all).find(metric => metric !== 'code_runs') || 'code_runs'
const useMetric = Object.keys(statistics.total.all).find(metric => metric !== 'code_runs') || 'code_runs'
const metricsDefinitions = domain.searchMetrics
return (
......@@ -59,7 +59,7 @@ class SearchAggregationsUnstyled extends React.Component {
))}
</FormGroup>
</FormControl>
<domain.SearchAggregations quantities={quantities} searchValues={searchValues} metric={useMetric} onChange={onChange} />
<domain.SearchAggregations statistics={statistics} searchValues={searchValues} metric={useMetric} onChange={onChange} />
</div>
</div>
)
......
......@@ -124,11 +124,11 @@ class SearchBar extends React.Component {
getSuggestions(value) {
value = value.toLowerCase()
const { data: { quantities } } = this.props
const { data: { statistics } } = this.props
const suggestions = []
// filter out pseudo quantity total
const quantityKeys = Object.keys(quantities).filter(quantity => quantity !== 'total')
const quantityKeys = Object.keys(statistics).filter(quantity => quantity !== 'total')
// put authors to the end
const authorIndex = quantityKeys.indexOf('authors')
......@@ -137,7 +137,7 @@ class SearchBar extends React.Component {
}
quantityKeys.forEach(quantity => {
Object.keys(quantities[quantity]).forEach(quantityValue => {
Object.keys(statistics[quantity]).forEach(quantityValue => {
const quantityValueLower = quantityValue.toLowerCase()
if (quantityValueLower.startsWith(value) || (quantity === 'authors' && quantityValueLower.includes(value))) {
suggestions.push({
......
......@@ -103,7 +103,7 @@ class SearchPage extends React.Component {
pagination: {
total: 0
},
quantities: {
statistics: {
total: {
all: {
}
......@@ -208,7 +208,7 @@ class SearchPage extends React.Component {
const { classes, user, domain, loading } = this.props
const { data, searchState, searchResultListState, showDetails } = this.state
const { searchValues } = searchState
const { pagination: { total }, quantities } = data
const { pagination: { total }, statistics } = data
const ownerLabel = {
all: 'All entries',
......@@ -226,11 +226,11 @@ class SearchPage extends React.Component {
const withoutLogin = ['all']
const useMetric = Object.keys(quantities.total.all).find(metric => metric !== 'code_runs') || 'code_runs'
const useMetric = Object.keys(statistics.total.all).find(metric => metric !== 'code_runs') || 'code_runs'
const helperText = <span>
There are {Object.keys(domain.searchMetrics).map(key => {
return (key === useMetric || key === 'code_runs') ? <span key={key}>
{domain.searchMetrics[key].renderResultString(!loading && quantities.total.all[key] !== undefined ? quantities.total.all[key] : '...')}
{domain.searchMetrics[key].renderResultString(!loading && statistics.total.all[key] !== undefined ? statistics.total.all[key] : '...')}
</span> : ''
})}{Object.keys(searchValues).length ? ' left' : ''}.
</span>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment