# components/Dataset/DatasetSummary/DatasetSummary.js

## Maintainability

75.50

## Lines of code

98

## Difficulty

28.67

## Estimated Errors

0.60

## Function weight

### By Complexity

### By SLOC

import React from 'react'; import Moment from 'react-moment'; import { Grid, Row, Col, Image } from 'react-bootstrap'; import './DatasetSummary.css'; import { getFileByEventId } from '../../../api/icat/icatPlus.js'; class DatasetSummary extends React.Component { componentDidMount() { } getImageFromGalleyByIndex(index) { /** Checking gallery **/ var gallery = this.props.dataset.parameters.filter(function (o) { return o.name === "ResourcesGallery" }); if (gallery != null) { if (gallery.length > 0) { gallery = gallery[0].value.split(" "); if (gallery.length > index) { var url = getFileByEventId(this.props.sessionId, this.props.dataset.investigation.id, gallery[index] ); return <div><br /><Image src={url} thumbnail /></div>; } } } return null; } getParameterValue(name){ var sampleNameParameter = this.props.dataset.parameters.filter(function (o) { return o.name === name }); if (sampleNameParameter){ if (sampleNameParameter[0]){ return sampleNameParameter[0].value; } } } render() { return ( <Grid fluid> <Row> <Col xs={12} md={2}> <Grid fluid style={{marginTop:'30px'}}> <Row> <Col xs={4} sm={6} md={6}>Name</Col> <Col xs={8} sm={6} md={6} className='column_parameter_value'>{this.props.dataset.name}</Col> </Row> <Row> <Col xs={4} sm={6} md={6}>Definition</Col> <Col xs={8} sm={6} md={6} className='column_parameter_value'>{this.getParameterValue("definition")}</Col> </Row> <Row> <Col xs={4} sm={6} md={6}>Start</Col> <Col xs={8} sm={6} md={6} className='column_parameter_value'><Moment parse="YYYY-MM-DD HH:mm" format="LTS">{this.props.dataset.startDate}</Moment></Col> </Row> <Row> <Col xs={4} sm={6} md={6}>End</Col> <Col xs={8} sm={6} md={6} className='column_parameter_value'><Moment parse="YYYY-MM-DD HH:mm" format="LTS">{this.props.dataset.endDate}</Moment></Col> </Row> <Row> <Col xs={4} sm={6} md={6}>Sample</Col> <Col xs={8} sm={6} md={6} className='column_parameter_value'>{this.getParameterValue("Sample_name")}</Col> </Row> <Row> <Col xs={4} sm={6} md={6}>Description</Col> <Col xs={8} sm={6} md={6} className='column_parameter_value'>{this.getParameterValue("Sample_description")}</Col> </Row> </Grid> </Col> <Col xs={12} sm={12} md={2}> {this.getImageFromGalleyByIndex(0)} </Col> <Col xs={12} sm={12} md={2}> {this.getImageFromGalleyByIndex(1)} </Col> <Col xs={12} sm={12} md={2}> {this.getImageFromGalleyByIndex(2)} </Col> <Col xs={12} sm={12} md={2}> {this.getImageFromGalleyByIndex(3)} </Col> <Col xs={12} sm={12} md={2}> {this.getImageFromGalleyByIndex(4)} </Col> </Row> </Grid> ); } } export default DatasetSummary;