Commit dd9654b3 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos

Merge branch 'issue_181' into 'master'

It fixes #181

Closes #181

See merge request !164
parents 79affc16 39768408
Pipeline #12584 passed with stages
in 5 minutes and 35 seconds
......@@ -131,7 +131,7 @@ class MyDataPage extends React.Component {
}
return (
<div>
<div >
<MenuContainer />
<LoginContainer />
<ExpirationLoginContainer></ExpirationLoginContainer>
......
......@@ -203,6 +203,13 @@ export function createEventFromBase64(sessionId, investigationId) {
.replace("investigationId", investigationId);
}
export function getInvestigationUsersByInvestigationId(sessionId, investigationId) {
return ICATPLUS.server + "/catalogue/sessionId/investigation/id/investigationId/investigationusers"
.replace("sessionId", sessionId)
.replace("investigationId", investigationId);
}
/** To be removed from here */
var IDS =
{
......
......@@ -7,6 +7,8 @@ import Loading from "../../components/Loading.js";
import DOIBadge from "../../components/doi/DOIBadge.js";
import { stringifyBytesSize } from "../Helpers.js";
import ResponsiveTable from "../Table/ResponsiveTable.js";
import InvestigationWidget from '../Investigation/InvestigationWidget.js';
import {
SAMPLE_COUNT,
FILE_COUNT,
......@@ -31,14 +33,14 @@ class InvestigationTable extends React.Component {
}
beamlineFormatter(cell, row) {
return <span style={{fontWeight:'bold'}}>{cell.toUpperCase()}</span>;
return <span style={{ fontWeight: 'bold' }}>{cell.toUpperCase()}</span>;
}
nameFormatter(cell, investigation, rowIndex, extraData) {
if (extraData.props.linkProposal || extraData.props.user.isAdministrator) {
return (
<Link to={`/investigation/${investigation.id}/datasets`}>
<Button bsSize="xsmall" style={{width:120, textAlign:'left'}}><Glyphicon glyph="circle-arrow-right" /><span style={{marginLeft:'10px'}}>{investigation.name} </span></Button>
<Link to={`/investigation/${investigation.id}/datasets`}>
<Button bsSize="xsmall" style={{ width: 120, textAlign: 'left' }}><Glyphicon glyph="circle-arrow-right" /><span style={{ marginLeft: '10px' }}>{investigation.name} </span></Button>
</Link>
);
} else {
......@@ -55,7 +57,7 @@ class InvestigationTable extends React.Component {
}
volumeFormatter(cell, investigation, rowIndex, extraData) {
var volume = _.find(investigation.parameters, function(o) {
var volume = _.find(investigation.parameters, function (o) {
return o.name === VOLUME;
});
if (volume) {
......@@ -68,37 +70,37 @@ class InvestigationTable extends React.Component {
}
experimentFormatter(cell, investigation, rowIndex, extraData) {
return <Grid style={{textAlign:'center'}}>
<Row className="show-grid">
<Col xs={12} md={12}>
{extraData.nameFormatter(investigation.name, investigation, rowIndex, extraData)}
</Col>
</Row>
<Row className="show-grid">
<Col xs={12} md={12}>
{extraData.beamlineFormatter(investigation.visitId, investigation, rowIndex, extraData)}
</Col>
</Row>
<Row className="show-grid">
<Col xs={12}>
<div style={{color:'gray', fontStyle:'italic'}}>{investigation.summary}</div>
</Col>
</Row>
<Row className="show-grid" style={{fontSize:'10px'}}>
<Col xs={12} >
<span >{extraData.doiFormatter(investigation.doi, investigation, rowIndex, extraData)}</span>
</Col>
</Row>
</Grid>;
return <Grid style={{ textAlign: 'center' }}>
<Row className="show-grid">
<Col xs={12} md={12}>
{extraData.nameFormatter(investigation.name, investigation, rowIndex, extraData)}
</Col>
</Row>
<Row className="show-grid">
<Col xs={12} md={12}>
{extraData.beamlineFormatter(investigation.visitId, investigation, rowIndex, extraData)}
</Col>
</Row>
<Row className="show-grid">
<Col xs={12}>
<div style={{ color: 'gray', fontStyle: 'italic' }}>{investigation.summary}</div>
</Col>
</Row>
<Row className="show-grid" style={{ fontSize: '10px' }}>
<Col xs={12} >
<span >{extraData.doiFormatter(investigation.doi, investigation, rowIndex, extraData)}</span>
</Col>
</Row>
</Grid>;
}
/**
* This looks into the parameters of the investigation
*/
getParameter(investigation, parameterName) {
var parameter = _.find(investigation.parameters, function(o) {
var parameter = _.find(investigation.parameters, function (o) {
return o.name === parameterName;
});
if (parameter) {
......@@ -132,7 +134,7 @@ class InvestigationTable extends React.Component {
}
datasetCountFormatter(cell, investigation, rowIndex, extraData) {
var datasetCount = _.find(investigation.parameters, function(o) {
var datasetCount = _.find(investigation.parameters, function (o) {
return o.name === DATASET_COUNT;
});
if (datasetCount) {
......@@ -176,11 +178,11 @@ class InvestigationTable extends React.Component {
}
componentDidMount() {
componentDidMount() {
}
getColumns() {
getColumns() {
return [
{
text: "id",
......@@ -198,10 +200,10 @@ class InvestigationTable extends React.Component {
return { width: "50%", textAlign: "center" };
},
responsiveHeaderStyle: {
xs: { width: "100%"},
sm: { width: "100%"},
md: { hidden : true },
lg: { hidden : true },
xs: { width: "100%" },
sm: { width: "100%" },
md: { hidden: true },
lg: { hidden: true },
}
},
{
......@@ -215,8 +217,8 @@ class InvestigationTable extends React.Component {
return { width: "50%", textAlign: "center" };
},
responsiveHeaderStyle: {
xs: { hidden : true },
sm: { hidden : true },
xs: { hidden: true },
sm: { hidden: true },
md: { width: "140px", textAlign: "center" },
lg: { width: "140px", textAlign: "center" }
}
......@@ -227,8 +229,8 @@ class InvestigationTable extends React.Component {
formatter: this.beamlineFormatter,
sort: true,
responsiveHeaderStyle: {
xs: { hidden : true },
sm: { hidden : true },
xs: { hidden: true },
sm: { hidden: true },
md: { width: "140px", textAlign: "center" },
lg: { width: "140px", textAlign: "center" }
}
......@@ -238,21 +240,21 @@ class InvestigationTable extends React.Component {
dataField: "summary",
sort: true,
responsiveHeaderStyle: {
xs: { hidden : true},
sm: { hidden : true },
xs: { hidden: true },
sm: { hidden: true },
}
},
{
{
text: "Datasets",
dataField: "datasets",
dataField: "datasets",
formatter: this.datasetCountFormatter,
formatExtraData: this,
formatExtraData: this,
responsiveHeaderStyle: {
xs: { hidden : true },
sm: { hidden : true },
md: { hidden : true },
lg: { hidden : !this.props.showInvestigationStats, width: "150px" }
xs: { hidden: true },
sm: { hidden: true },
md: { hidden: true },
lg: { hidden: !this.props.showInvestigationStats, width: "150px" }
}
},
{
......@@ -261,9 +263,9 @@ class InvestigationTable extends React.Component {
formatter: this.dateFormatter,
sort: true,
responsiveHeaderStyle: {
xs: { hidden : true },
sm: { hidden : true },
md: { hidden : true },
xs: { hidden: true },
sm: { hidden: true },
md: { hidden: true },
lg: { width: "110px", textAlign: "center" }
}
},
......@@ -273,9 +275,9 @@ class InvestigationTable extends React.Component {
formatter: this.doiFormatter,
sort: true,
responsiveHeaderStyle: {
xs: { hidden : true },
sm: { hidden : true },
md: { hidden : true },
xs: { hidden: true },
sm: { hidden: true },
md: { hidden: true },
lg: { width: "300px", textAlign: "center" }
}
}
......@@ -283,16 +285,51 @@ class InvestigationTable extends React.Component {
}
render() {
const expandRow = {
showExpandColumn: true,
//expandByColumnOnly: true,
expanded: this.props.expanded,
expandColumnPosition: 'right',
expandHeaderColumnRenderer: ({ isAnyExpands }) => {
if (isAnyExpands) {
return <span style={{ fontSize: '18px' }}><Glyphicon glyph="zoom-out" /></span>;
}
return <span style={{ fontSize: '18px' }}><Glyphicon glyph="zoom-in" /></span>;
},
expandColumnRenderer: ({ expanded }) => {
if (expanded) {
return (
<Glyphicon glyph="zoom-out" />
);
}
return (
<Glyphicon glyph="zoom-in" />
);
},
renderer: investigation => {
return (
<InvestigationWidget
investigation={investigation}
sessionId={this.props.user.sessionId} >
</InvestigationWidget>
);
}
};
if (this.props.fetching) {
return <Loading message="Loading investigations" />;
}
return (
<ResponsiveTable
<ResponsiveTable
keyField="id"
data={this.props.investigations}
columns={this.getColumns()}
expandRow={expandRow}
/>
);
}
......
import React from 'react';
import { Badge, Tab, Tabs, Panel } from 'react-bootstrap';
import { getInvestigationUsersByInvestigationId } from '../../api/icat/icatPlus.js';
import axios from 'axios';
import ResponsiveTable from "../Table/ResponsiveTable.js";
class InvestigationWidget extends React.Component {
constructor(props) {
super(props);
this.state = {
investigationUsers : [],
fetched: false,
fetching: false
}
}
componentDidMount() {
axios.get(getInvestigationUsersByInvestigationId(this.props.sessionId, this.props.investigation.id))
.then(res => {
this.setState({
investigationUsers: res.data,
fetching: false,
fetched: true,
});
})
.catch((error) => {
this.setState({
fetching: false,
fetched: false,
});
});
}
getColumns() {
return [
{
text: "id",
dataField: "name",
hidden: true
},
{
text: "Name",
dataField: "fullName"
},
{
text: "Role",
dataField: "role"
}
]
};
render() {
return <Panel >
<Panel.Body >
<Tabs id="tabs">
<Tab style={{margin:30}} eventKey={1} title="Participants">
<ResponsiveTable
keyField="id"
data={this.state.investigationUsers}
columns={this.getColumns()}
/>
</Tab>
</Tabs>
</Panel.Body>
<Panel.Footer>
</Panel.Footer>
</Panel>
}
/*
<Tab eventKey={12} title="DOI" mountOnEnter={true}>
<DatasetDOIList dataset={dataset} sessionId={this.props.sessionId}> ></DatasetDOIList>
</Tab>
*/
}
export default InvestigationWidget;
......@@ -22,7 +22,7 @@ class InvestigationsContainer extends Component {
}
return (
<div>
<div style={{marginBottom:100}}>
<Loader show={this.props.investigations.fetching} >
<InvestigationTable user={this.props.user}
linkProposal={this.props.linkProposal}
......
......@@ -16,8 +16,7 @@ const scientistInstrumentInvestigations = (state = initialState, action) => {
state = {...state, fetched: false, fetching: true};
break;
}
case FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS_FULFILLED: {
debugger
case FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS_FULFILLED: {
state = {...state, data: action.payload.data.map((object,i ) => object.Investigation), fetched: true, fetching: false}
break;
}
......
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