Commit 5bf42452 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos
Browse files

Merged with master

parents 9aee7186 22f8ec62
Pipeline #48306 passed with stage
in 4 minutes and 1 second
......@@ -11,6 +11,7 @@ import {
MenuItem,
Panel,
SplitButton,
Alert,
} from 'react-bootstrap';
import { getMintDOI } from '../../api/icat-plus/doi';
import BootstrapTable2 from 'react-bootstrap-table-next';
......@@ -25,6 +26,8 @@ class DOIForm extends React.Component {
selectedAuthors: [],
fetching: false,
fetched: false,
error: null,
successMessage: null,
};
this.addAuthor = this.addAuthor.bind(this);
......@@ -100,6 +103,11 @@ class DOIForm extends React.Component {
datasetIdList.push(this.props.datasets[i].id);
}
const url = getMintDOI(this.props.sessionId);
this.setState({
fetching: true,
fetched: false,
});
axios
.post(url, {
title,
......@@ -108,24 +116,20 @@ class DOIForm extends React.Component {
authors,
})
.then((response) => {
if (response) {
if (response.data) {
if (response.data.message) {
alert(`Your DOI has been created ${response.data.message}`);
}
}
}
this.setState({
fetching: false,
fetched: true,
error: null,
successMessage: `Your DOI has been created ${response.data.message}`,
});
})
.catch((error) => {
if (error) {
if (error.response) {
if (error.response.data) {
if (error.response.data.message) {
alert(error.response.data.message);
}
}
}
}
this.setState({
error: `There was an error during the minting the DOI. Contact administrators.${error}`,
fetching: false,
fetched: false,
successMessage: null,
});
});
}
......@@ -166,98 +170,126 @@ class DOIForm extends React.Component {
render() {
return (
<Form>
<FormGroup controlId="formControlsTextarea">
<ControlLabel>
Title <Mandatory />
</ControlLabel>
<FormControl
inputRef={(ref) => {
this.title = ref;
}}
componentClass="textarea"
placeholder=""
/>
</FormGroup>
<>
<Alert bsStyle="info">
<h4>Important!</h4>
<p>Only Principal investigators can mint a DOI</p>
</Alert>
{this.state.error && (
<Alert bsStyle="danger">
<h4>Oh snap! You got an error!</h4>
<p>{this.state.error}</p>
</Alert>
)}
{this.state.successMessage && (
<Alert bsStyle="success">
<h4>DOI has been minted successfully</h4>
<p>{this.state.successMessage}</p>
</Alert>
)}
<Form>
<FormGroup controlId="formControlsTextarea">
<ControlLabel>
Title <Mandatory />
</ControlLabel>
<FormControl
inputRef={(ref) => {
this.title = ref;
}}
componentClass="textarea"
placeholder=""
/>
</FormGroup>
<FormGroup controlId="formControlsTextarea">
<ControlLabel>
Abstract <Mandatory />
</ControlLabel>
<FormControl
inputRef={(ref) => {
this.abstract = ref;
}}
componentClass="textarea"
placeholder=""
/>
</FormGroup>
<br />
<Panel bsStyle="primary">
<Panel.Heading>
<Panel.Title>Authors</Panel.Title>
</Panel.Heading>
<FormGroup controlId="formControlsTextarea">
<ControlLabel>
Abstract <Mandatory />
</ControlLabel>
<FormControl
inputRef={(ref) => {
this.abstract = ref;
}}
componentClass="textarea"
placeholder=""
/>
</FormGroup>
<br />
<Panel bsStyle="primary">
<Panel.Heading>
<Panel.Title>Authors</Panel.Title>
</Panel.Heading>
<Panel.Body>
<Form inline componentClass="div">
<FormGroup controlId="formInlineName">
<ControlLabel>Name</ControlLabel>{' '}
<FormControl
inputRef={(ref) => {
this.name = ref;
}}
type="text"
/>
</FormGroup>{' '}
<FormGroup controlId="formInlineEmail" style={{ marginLeft: 10 }}>
<ControlLabel>Surname</ControlLabel>{' '}
<FormControl
inputRef={(ref) => {
this.surname = ref;
}}
/>
</FormGroup>{' '}
{this.renderButton()}
</Form>
<Panel.Body>
<Form inline componentClass="div">
<FormGroup controlId="formInlineName">
<ControlLabel>Name</ControlLabel>{' '}
<FormControl
inputRef={(ref) => {
this.name = ref;
}}
type="text"
/>
</FormGroup>{' '}
<FormGroup
controlId="formInlineEmail"
style={{ marginLeft: 10 }}
>
<ControlLabel>Surname</ControlLabel>{' '}
<FormControl
inputRef={(ref) => {
this.surname = ref;
}}
/>
</FormGroup>{' '}
{this.renderButton()}
</Form>
<br />
<br />
<Button
bsStyle="warning"
style={{ marginBottom: 10 }}
disabled={this.state.selectedAuthors.length === 0}
onClick={this.handleDeleteClick}
>
<Glyphicon glyph="trash" /> Delete
</Button>
<BootstrapTable2
keyField="id"
data={this.state.authors}
columns={[
{ dataField: 'id', text: '', hidden: true },
{ dataField: 'name', text: 'Name' },
{ dataField: 'surname', text: 'Surname' },
]}
selectRow={{
mode: 'checkbox',
clickToSelect: true,
selected: this.state.selectedAuthors,
onSelect: this.handleOnSelectUser,
onSelectAll: this.handleOnSelectAllUsers,
}}
striped
hover
condensed
/>
</Panel.Body>
</Panel>
<br />
{this.state.fetching && (
<Button className="btn btn-primary pull-right">
<Glyphicon className="spin" glyph="repeat" />
</Button>
)}
{!this.state.fetching && (
<Button
bsStyle="warning"
style={{ marginBottom: 10 }}
disabled={this.state.selectedAuthors.length === 0}
onClick={this.handleDeleteClick}
onClick={this.mint.bind(this)}
className="btn btn-primary pull-right"
>
<Glyphicon glyph="trash" /> Delete
Mint
</Button>
<BootstrapTable2
keyField="id"
data={this.state.authors}
columns={[
{ dataField: 'id', text: '', hidden: true },
{ dataField: 'name', text: 'Name' },
{ dataField: 'surname', text: 'Surname' },
]}
selectRow={{
mode: 'checkbox',
clickToSelect: true,
selected: this.state.selectedAuthors,
onSelect: this.handleOnSelectUser,
onSelectAll: this.handleOnSelectAllUsers,
}}
striped
hover
condensed
/>
</Panel.Body>
</Panel>
<br />
<Button
onClick={this.mint.bind(this)}
className="btn btn-primary pull-right"
>
Mint
</Button>
</Form>
)}
</Form>
</>
);
}
}
......
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