It fixes #117

parent 9418f4a8
*~
#ICAT+ configuration
/src/config/icat/icatPlus.js
/src/config/icat/icat.js
......
......@@ -3,8 +3,7 @@ import axios from "axios";
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { getDatasetsById } from '../../api/icat/icat.js'
import { getUsersByInvestigationIds } from '../../api/icat/icatPlus.js'
import { getUsersByInvestigationIds, getDatasetsById } from '../../api/icat/icatPlus.js'
import Loader from 'react-loader-advanced';
import { doSignIn } from '../../actions/login.js';
import { PERSPECTIVE } from '../../constants/Perspectives.js'
......@@ -31,7 +30,7 @@ class MintSelectionContainer extends Component {
investigationUsers: []
}
}
/*
groupBy = function (xs, key) {
return xs.reduce(function (rv, x) {
(rv[x[key]] = rv[x[key]] || []).push(x);
......@@ -50,7 +49,7 @@ class MintSelectionContainer extends Component {
datasets[datasetId] = {};
}
datasets[datasetId][key] = value;
/** Some metadata at level of dataset to be added as parameters of the dataset */
datasets[datasetId]["id"] = param[0];
datasets[datasetId]["name"] = param[1];
datasets[datasetId]["startDate"] = param[2];
......@@ -67,7 +66,7 @@ class MintSelectionContainer extends Component {
}
return array;
};
*/
onLogbookButtonClicked() {
this.setState({
......@@ -82,13 +81,15 @@ class MintSelectionContainer extends Component {
}
getUsersByInvestigationIds(investigationIds) {
getUsers(investigationIds) {
this.setState({
fetching: true
});
console.log(getUsersByInvestigationIds(this.state.sessionId, investigationIds))
debugger
axios.get(getUsersByInvestigationIds(this.state.sessionId, investigationIds))
.then(res => {
debugger
let investigationUsers = res.data;
this.setState({
investigationUsers: investigationUsers,
......@@ -98,6 +99,7 @@ class MintSelectionContainer extends Component {
})
.catch((error) => {
debugger
if (error.response) {
if (error.response.status === 403) {
this.props.doSignIn();
......@@ -107,30 +109,35 @@ class MintSelectionContainer extends Component {
}
retrieveSelectedDatasetsFromDatabase() {
if (!this.state.fetching) {
/*if (!this.state.fetching) {
this.setState({
fetching: true
});
}
}*/
if (this.props.selection.datasetIds.length > 0) {
axios.get(getDatasetsById(this.state.sessionId, this.state.username, this.props.selection.datasetIds))
console.log(getDatasetsById(this.state.sessionId, this.props.selection.datasetIds));
debugger
axios.get(getDatasetsById(this.state.sessionId, this.props.selection.datasetIds))
.then(res => {
debugger
try {
let datasets = this.parametersToDatasetObject(this.groupBy(res.data, 0));
let datasets = res.data;
this.setState({
datasets: datasets,
filtered: datasets,
fetching: false,
fetched: true
});
this.getUsersByInvestigationIds(_.uniq(datasets.map(function (o) { return o.investigationId })));
debugger
this.getUsers(_.uniq(datasets.map(function (o) { return o.investigation.id })));
}
catch (error) {
debugger
}
})
.catch((error) => {
debugger
if (error.response) {
if (error.response.status === 403) {
this.props.doLogOut();
......@@ -147,15 +154,16 @@ class MintSelectionContainer extends Component {
});
}
}
render() {
if (this.props.selection.datasetIds.length !== this.state.datasets.length) {
/*if (this.props.selection.datasetIds.length !== this.state.datasets.length) {
this.retrieveSelectedDatasetsFromDatabase();
}
}*/
/** TODO: To be implemented */
if (this.state.fetching) {
return null;
if ((!this.props.user) || (!this.props.user.sessionId)) {
return null;
}
const options = {
......
Markdown is supported
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