# src/components/Instrument/InstrumentDetectorWidget.js

## Maintainability

75.82

## Lines of code

63

## Difficulty

23.32

## Estimated Errors

0.38

## Function weight

### By Complexity

### By SLOC

import React from 'react'; import { getDatasetParameterByName, getDatasetParameterByPrefixName } from '../../helpers/DatasetHelper.js'; import ParameterTableWidget from './ParameterTableWidget.js'; class InstrumentDetectorWidget extends React.Component { constructor(props) { super(props); } getDetectorWidget(index){ var parameters = getDatasetParameterByPrefixName(this.props.dataset, "InstrumentDetector0" + index); if (parameters){ if (parameters.length > 0){ return <DetectorWidget detectorIndex={index} name = {getDatasetParameterByName(this.props.dataset, "InstrumentDetector0" + index + "_name")} positionersValue = {getDatasetParameterByName(this.props.dataset, "InstrumentDetector0" + index + "Positioners_value")} positionersName = {getDatasetParameterByName(this.props.dataset, "InstrumentDetector0" + index + "Positioners_name")} positionersRoisValue = {getDatasetParameterByName(this.props.dataset, "InstrumentDetector0" + index + "PositionersRois_value")} positionersRoisName = {getDatasetParameterByName(this.props.dataset, "InstrumentDetector0" + index + "PositionersRois_name")} ></DetectorWidget>; } } } render(){ var detectors = []; for(var i = 1; i < 10; i++){ var detector = this.getDetectorWidget(i); if (detector){ detectors.push(detector); } } return <div className="container-fluid"> <h3>Detectors</h3> <div className="row"> {detectors.map(function (detector, i) { return <div>{detector}</div> })} </div> </div>; } } export default InstrumentDetectorWidget; class DetectorWidget extends React.Component { render(){ return <div className="col-sm-1"> <table className="table table-condensed"> <thead> <tr> <th colspan="2"># {this.props.detectorIndex} {this.props.name}</th> </tr> </thead> <ParameterTableWidget names={this.props.positionersName} values={this.props.positionersValue} ></ParameterTableWidget> </table> </div>; } };