Commit 12efc756 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos

Merge branch 'issue_180' into 'master'

It fixes #180

Closes #180

See merge request !162
parents 4c7bac47 f5e0dc92
Pipeline #12575 passed with stages
in 4 minutes and 32 seconds
......@@ -18,6 +18,7 @@ import { BrowserRouter as Router, Route } from "react-router-dom";
import TagContainer from './containers/Logbook/TagContainer';
import { TAG_MANAGER_CONTEXT } from './constants/EventTypes';
import _ from 'lodash';
import queryString from 'query-string';
class App extends Component {
render() {
......@@ -30,7 +31,8 @@ class App extends Component {
<Route exact path="/search" component={MySearchPage} />
<Route exact path="/investigations" render={props => (<MyDataPage {...this.props} />)} />
<Route exact path="/investigations" render={props => (<MyDataPage location={props.location} {...this.props} />)} />
<Route exact path="/public" render={props => (<OpenDataPage {...this.props} />)} />
<Route exact path="/public/:prefix/:suffix" component={DOIPage} />
......@@ -115,13 +117,26 @@ class MySearchPage extends React.Component {
class MyDataPage extends React.Component {
render() {
var investigations = this.props.myInvestigations;
var params=queryString.parse(this.props.location.search);
/** Filter by beamline Name */
if (params.beamline){
var _this = this;
investigations = {
data : _.filter(this.props.scientistInstrumentInvestigations.data, function(inv){ return inv.investigationInstruments[0].instrument.name == params.beamline;}),
fetching : false,
fetched : true
}
}
return (
<div>
<MenuContainer />
<LoginContainer />
<ExpirationLoginContainer></ExpirationLoginContainer>
<div style={{ marginTop: '30px', marginLeft: '30px', marginRight: '30px' }}>
<InvestigationsContainer showInvestigationStats={true} linkProposal={true} openData={true} investigations={this.props.myInvestigations} />
<InvestigationsContainer showInvestigationStats={true} linkProposal={true} openData={true} investigations={investigations} />
</div>
</div>
);
......@@ -270,6 +285,7 @@ function mapStateToProps(state) {
datasets: state.datasets,
investigations: state.investigations,
myInvestigations: state.myInvestigations,
scientistInstrumentInvestigations: state.scientistInstrumentInvestigations,
releasedInvestigations: state.releasedInvestigations
};
}
......
import axios from "axios";
import { getInvestigationsByUser, getEmbargoedInvestigations, getReleasedInvestigations } from '../api/icat/icatPlus.js';
import { FECTH_INVESTIGATIONS, FECTH_MY_INVESTIGATIONS, FECTH_RELEASED_INVESTIGATIONS } from '../constants/ActionTypes';
import { getInvestigationsByUser, getEmbargoedInvestigations, getReleasedInvestigations, getInvestigationsByInstrumentScientist } from '../api/icat/icatPlus.js';
import { FECTH_INVESTIGATIONS, FECTH_MY_INVESTIGATIONS, FECTH_RELEASED_INVESTIGATIONS, FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS } from '../constants/ActionTypes';
export function fetchMyInvestigations(sessionId) {
return {
......@@ -22,3 +22,11 @@ export function fecthReleasedInvestigations(sessionId) {
payload: axios.get(getReleasedInvestigations(sessionId))
};
}
export function fecthInvestigationsAsInstrumentScientist(sessionId) {
return {
type: FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS,
payload: axios.get(getInvestigationsByInstrumentScientist(sessionId))
};
}
import $ from 'jquery';
import ICATPLUS from '../config/icat/icatPlus.js';
import { fetchMyInvestigations, fecthEmbargoedInvestigations, fecthReleasedInvestigations } from './investigations.js';
import { fetchMyInvestigations, fecthEmbargoedInvestigations, fecthReleasedInvestigations, fecthInvestigationsAsInstrumentScientist } from './investigations.js';
import { fetchDataCollections } from './datacollections.js';
import {
LOG_IN,
......@@ -43,7 +43,9 @@ export function doSignIn(plugin, username, password) {
if (data.sessionId){
dispatch({type: LOGGED_IN, fullName: data.fullName, lifeTimeMinutes : data.lifeTimeMinutes, name : data.name, username: username, isAdministrator: data.isAdministrator, sessionId: data.sessionId});
dispatch(fecthEmbargoedInvestigations(data.sessionId));
dispatch(fecthReleasedInvestigations(data.sessionId));
dispatch(fecthReleasedInvestigations(data.sessionId));
dispatch(fecthInvestigationsAsInstrumentScientist(data.sessionId));
dispatch(fetchMyInvestigations(data.sessionId));
dispatch(fetchDataCollections(data.sessionId));
......
......@@ -155,10 +155,17 @@ export function getReleasedInvestigations(sessionId) {
}
export function getInvestigationsByUser(sessionId) {
return ICATPLUS.server + "/catalogue/sessionId/investigation"
return ICATPLUS.server + "/catalogue/sessionId/investigation?useris=participant"
.replace("sessionId", sessionId);
}
export function getInvestigationsByInstrumentScientist(sessionId) {
return ICATPLUS.server + "/catalogue/sessionId/investigation?useris=instrumentscientist"
.replace("sessionId", sessionId);
}
export function getDatasetsById(sessionId, datasetIds) {
return ICATPLUS.server + "/catalogue/sessionId/dataset/id/datasetIds/dataset"
.replace("sessionId", sessionId)
......
import React from 'react';
import { Link } from 'react-router-dom';
import { LinkContainer } from 'react-router-bootstrap'
import { Glyphicon, Nav, NavItem, Navbar } from 'react-bootstrap';
import { Glyphicon, Nav, NavItem, Navbar, NavDropdown, MenuItem } from 'react-bootstrap';
import logo from '../../images/ebs.gif';
import './Menu.css';
import './glyhicon-spinner.css';
import BreadCrumbs from '../Breadcrumbs/BreadCrumbs.js';
import _ from 'lodash';
export class Menu extends React.Component {
constructor(props) {
......@@ -60,6 +60,36 @@ export class Menu extends React.Component {
}
getManagerMenuItem() {
if (this.props.scientistInstrumentInvestigations.fetching || this.props.scientistInstrumentInvestigations.data.length === 0) {
return null;
}
var instruments = _.uniq(_.map(this.props.scientistInstrumentInvestigations.data, function(inv){ return inv.investigationInstruments[0].instrument.name}));
if (instruments){
var _this = this;
function getBeamlineBadge(beamlineName){
return <span className="badge" style={{ marginLeft: '10px' }}>
{_.filter(_this.props.scientistInstrumentInvestigations.data, function(inv){ return inv.investigationInstruments[0].instrument.name === beamlineName}).length}
</span>;
}
const navDropdownTitle = (<span>Manager <span className="badge" style={{ marginLeft: '10px' }}>{instruments.length}</span> <sub style={{ color: 'red', fontSize: '10px', marginLeft: '5px' }}>NEW</sub></span> );
return <NavDropdown eventKey={3} title={navDropdownTitle} id="basic-nav-dropdown">
{instruments.map((value, index) => {
return <LinkContainer to={"/investigations?beamline="+ value}><MenuItem key={index}>{value} {getBeamlineBadge(value)}</MenuItem></LinkContainer>
})}
</NavDropdown>;
}
return null;
}
render() {
/** If there is not sessionId it means that we are not already been authenticated **/
......@@ -81,7 +111,7 @@ export class Menu extends React.Component {
<NavItem eventKey={2} href='/search'>
<span>
<Glyphicon style={{ fontSize: '20px' }} glyph="glyphicon glyphicon-search" />
<sub style={{ color: 'red', fontSize: '10px', marginLeft: '5px' }}>NEW</sub>
</span>
</NavItem>
</LinkContainer>
......@@ -93,12 +123,12 @@ export class Menu extends React.Component {
</LinkContainer>
{this.getOpenDataMenuItem()}
{this.getClosedDataMenuItem()}
<LinkContainer to='/selection'>
<NavItem eventKey={3} href='/selection'>
My Selection<span className="badge" style={{ marginLeft: '10px' }}>{this.props.selection.datasetIds.length}</span>
</NavItem>
</LinkContainer>
{this.getManagerMenuItem()}
</Nav>
<Nav pullRight>
<NavItem eventKey={2} onClick={this.onLogOutClicked} >
......
......@@ -51,26 +51,7 @@ getSearchBarStyle(){
}
render() {
const { SearchBar } = Search;
var pageOptions = {
showTotal : true,
hidePageListOnlyOnePage : true,
sizePerPageList: [ {
text: '5', value: 5
}, {
text: '10', value: 10
},, {
text: '25', value: 25
},{
text: '50', value: 50
},{
text: '100', value: 100
},{
text: '200', value: 200
},
{
text: 'All', value: this.props.data.length
} ]
};
return <ToolkitProvider
keyField="id"
data={this.props.data }
......
......@@ -29,6 +29,10 @@ export const FECTH_INVESTIGATIONS_DOI = "FECTH_INVESTIGATIONS_DOI";
export const FECTH_INVESTIGATIONS_DOI_FULFILLED = "FECTH_INVESTIGATIONS_DOI_FULFILLED";
export const FECTH_INVESTIGATIONS_DOI_PENDING = "FECTH_INVESTIGATIONS_DOI_PENDING";
export const FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS = "FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS";
export const FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS_FULFILLED = "FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS_FULFILLED";
export const FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS_PENDING = "FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS_PENDING";
/** datasets */
export const FECTH_DATASETS_BY_INVESTIGATION = "FECTH_DATASETS_BY_INVESTIGATION";
export const FECTH_DATASETS_BY_INVESTIGATION_FULFILLED = "FECTH_DATASETS_BY_INVESTIGATION_FULFILLED";
......
......@@ -14,6 +14,7 @@ class MenuContainer extends Component {
myInvestigations={this.props.myInvestigations}
investigations={this.props.investigations}
datacollections={this.props.datacollections}
scientistInstrumentInvestigations={this.props.scientistInstrumentInvestigations}
>
</Menu>;
}
......@@ -26,7 +27,8 @@ function mapStateToProps(state) {
investigations: state.investigations,
selection: state.selection,
breadcrumbsList: state.breadcrumbsList,
datacollections: state.datacollections
datacollections: state.datacollections,
scientistInstrumentInvestigations : state.scientistInstrumentInvestigations
};
}
......
......@@ -109,6 +109,7 @@ class MintSelectionContainer extends Component {
});
}*/
if (this.props.selection.datasetIds.length > 0) {
......@@ -151,6 +152,7 @@ class MintSelectionContainer extends Component {
this.retrieveSelectedDatasetsFromDatabase();
}*/
debugger
if ((!this.props.user) || (!this.props.user.sessionId)) {
return null;
}
......
......@@ -27,11 +27,6 @@ class SelectionContainer extends Component {
}
}
onLogbookButtonClicked() {
this.setState({
perspective: PERSPECTIVE.EVENTS
});
}
componentDidMount() {
this.retrieveSelectedDatasetsFromDatabase();
......@@ -41,7 +36,7 @@ class SelectionContainer extends Component {
retrieveSelectedDatasetsFromDatabase() {
if (this.props.selection.datasetIds.length > 0) {
axios.get(getDatasetsById(this.state.sessionId, this.props.selection.datasetIds))
.then(res => {
.then(res => {
this.setState({
datasets: res.data,
filtered: res.data,
......
......@@ -17,7 +17,7 @@ const datasets = (state = initialState, action) => {
state = {...state, data: [], fetched: false, fetching: true};
break;
}
case FECTH_DATASETS_BY_INVESTIGATION_FULFILLED:{
case FECTH_DATASETS_BY_INVESTIGATION_FULFILLED:{
state = {...state, data : action.payload.data.reverse(), fetched : true, fetching : false};
break;
}
......
......@@ -8,6 +8,7 @@ import breadcrumbsList from './breadcrumbs.js';
import investigations from './investigations.js';
import datacollections from './datacollections.js';
import releasedInvestigations from './releasedInvestigations.js';
import scientistInstrumentInvestigations from './scientistInstrumentInvestigations.js';
export default combineReducers({
user,
......@@ -18,5 +19,6 @@ export default combineReducers({
logbook,
selection,
breadcrumbsList,
datacollections
datacollections,
scientistInstrumentInvestigations
});
\ No newline at end of file
......@@ -15,10 +15,14 @@ const investigations = (state = initialState, action) => {
state = {...state, fetched: false, fetching: true}
break;
}
case FECTH_INVESTIGATIONS_FULFILLED: {
case FECTH_INVESTIGATIONS_FULFILLED: {
state = {...state, data: action.payload.data.map((object,i ) => object.Investigation), fetched: true, fetching: false}
break;
}
}
case LOG_OUT: {
state = {...state, "fetching": false, "fetched": false, data: []};
......
......@@ -20,12 +20,14 @@ const selection = (state = initialState, action) => {
break;
}
case ADD_DATASET_BY_ID: {
debugger
datasetIds = state.datasetIds;
datasetIds.push(action.payload);
state = { ...state, datasetIds: datasetIds }
break;
}
case REMOVE_DATASET_BY_ID: {
debugger
datasetIds = state.datasetIds.filter(function (o) { return o !== action.payload })
state = { ...state, datasetIds: datasetIds }
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