<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Plato - components/Instrument/InstrumentWidget.js</title>

  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="">

  <!--[if lt IE 9]>
  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->

  <link href="../../assets/css/vendor/morris.css" rel="stylesheet" type="text/css">
  <link href="../../assets/css/vendor/bootstrap.css" rel="stylesheet" type="text/css">
  <link href="../../assets/css/vendor/font-awesome.css" rel="stylesheet" type="text/css">
  <link href="../../assets/css/vendor/codemirror.css" rel="stylesheet" type="text/css">
  <link href="../../assets/css/plato.css" rel="stylesheet" type="text/css">
  <link href="../../assets/css/plato-file.css" rel="stylesheet" type="text/css">

</head>

<body>

<div class="navbar navbar-fixed-top">
  <div class="container">
    <a class="navbar-brand" href="https://github.com/the-simian/es6-plato">ES6 Plato on Github</a>
    <ul class="nav navbar-nav">
      <li>
        <a href="../../index.html">Report Home</a>
      </li>
      <li class="active">
        <a href="display.html">Summary Display</a>
      </li>
    </ul>
  </div>
</div>

<div class="jumbotron">
  <div class="container">
    <h1>components/Instrument/InstrumentWidget.js</h1>
  </div>
</div>

<div class="container aggregate-stats">
  <div class="row">
    <div class="col-md-6">
      <h2 class="header">Maintainability <a href="http://blogs.msdn.com/b/codeanalysis/archive/2007/11/20/maintainability-index-range-and-meaning.aspx"><i class="icon icon-info-sign" rel="popover" data-placement="top" data-trigger="hover" data-content="A value between 0 and 100 that represents the relative ease of maintaining the code. A high value means better maintainability." data-original-title="Maintainability Index"  data-container="body"></i></a></h2>
      <p class="stat">59.85</p>
    </div>
    <div class="col-md-6">
      <h2 class="header">Lines of code <i class="icon icon-info-sign" rel="popover" data-placement="top" data-trigger="hover" data-content="Source Lines of Code / Logical Lines of Code" data-original-title="SLOC/LSLOC" data-container="body"></i></h2>
      <p class="stat">92</p>
    </div>
  </div>
  <div class="row historical">
    <div class="col-md-6">
      <p id="chart_historical_maint" class="chart"></p>
    </div>
    <div class="col-md-6">
      <p id="chart_historical_sloc" class="chart"></p>
    </div>
  </div>
  <div class="row">
    <div class="col-md-6">
      <h2 class="header">Difficulty  <a href="http://en.wikipedia.org/wiki/Halstead_complexity_measures"><i class="icon icon-info-sign" rel="popover" data-placement="top" data-trigger="hover" data-content="The difficulty measure is related to the difficulty of the program to write or understand." data-original-title="Difficulty" data-container="body"></i></a></h2>
      <p class="stat">28.21</p>
    </div>
    <div class="col-md-6">
      <h2 class="header">Estimated Errors  <a href="http://en.wikipedia.org/wiki/Halstead_complexity_measures"><i class="icon icon-info-sign" rel="popover" data-placement="top" data-trigger="hover" data-content="Halstead's delivered bugs is an estimate for the number of errors in the implementation." data-original-title="Delivered Bugs" data-container="body"></i></a></h2>
      <p class="stat">0.72</p>
    </div>
  </div>
</div>

<div class="container charts">
  <div class="row">
    <h2 class="header">Function weight</h2>
  </div>
  <div class="row">
    <div class="col-md-6">
      <h3 class="chart-header">By Complexity <a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity"><i class="icon icon-info-sign" rel="popover" data-placement="top" data-trigger="hover" data-content="This metric counts the number of distinct paths through a block of code. Lower values are better." data-original-title="Cyclomatic Complexity" data-container="body"></i></a></h3>
      <div id="fn-by-complexity" class="stat"></div>
    </div>
    <div class="col-md-6">
      <h3 class="chart-header">By SLOC  <i class="icon icon-info-sign" rel="popover" data-placement="top" data-trigger="hover" data-content="Source Lines of Code / Logical Lines of Code" data-original-title="SLOC/LSLOC" data-container="body"></i></h3>
      <div id="fn-by-sloc" class="stat"></div>
    </div>
  </div>
</div>

<div class="container">
  <div class="row">
    <textarea id="file-source" class="col-md-12">import React from &#039;react&#039;;
import _ from &#039;lodash&#039;;
import InstrumentDetectorWidget from &#039;./InstrumentDetectorWidget.js&#039;;
import InstrumentSlitWidget from &#039;./InstrumentSlitWidget.js&#039;;
import ParameterTableWidget from &#039;./ParameterTableWidget.js&#039;;
import { getDatasetParameterByName, getDatasetParameterByPrefixName } from &#039;../../helpers/DatasetHelper.js&#039;;

class InstrumentWidget extends React.Component {

  render() {  
    var instrumentParameters = getDatasetParameterByPrefixName(this.props.dataset, &quot;Instrument&quot;);
    if (instrumentParameters.length === 0){
        return null;
    }    

    return &lt;div style={{fontSize:&#039;12px&#039;}}&gt;     

      &lt;InstrumentWidgetSection
          header=&quot;Monochromator&quot;
          parameters={[
            { name : &quot;Energy&quot;,      value : getDatasetParameterByName(this.props.dataset, &quot;InstrumentMonochromator_energy&quot;)},
            { name : &quot;Wavelength&quot;,  value : getDatasetParameterByName(this.props.dataset, &quot;InstrumentMonochromator_wavelength&quot;)},
            { name : &quot;d_spacing&quot;,   value : getDatasetParameterByName(this.props.dataset, &quot;InstrumentMonochromatorCrystal_d_spacing&quot;)},
            { name : &quot;Reflection&quot;,  value : getDatasetParameterByName(this.props.dataset, &quot;InstrumentMonochromatorCrystal_reflection&quot;)},
            { name : &quot;Type&quot;,        value : getDatasetParameterByName(this.props.dataset, &quot;InstrumentMonochromatorCrystal_type&quot;)},
            { name : &quot;Usage&quot;,       value : getDatasetParameterByName(this.props.dataset, &quot;InstrumentMonochromatorCrystal_usage&quot;)}

          ]}
      &gt;&lt;/InstrumentWidgetSection&gt;


      &lt;InstrumentDetectorWidget dataset={this.props.dataset}&gt;&lt;/InstrumentDetectorWidget&gt;


      &lt;InstrumentSlitWidget dataset={this.props.dataset}&gt;&lt;/InstrumentSlitWidget&gt;
       
      &lt;InstrumentWidgetSection
          header=&quot;Optics&quot;
          names={getDatasetParameterByPrefixName(this.props.dataset, &quot;InstrumentOpticsPositioners_name&quot;)}
          values={getDatasetParameterByPrefixName(this.props.dataset, &quot;InstrumentOpticsPositioners_value&quot;)}
      &gt;
       &lt;/InstrumentWidgetSection&gt;

        &lt;InstrumentWidgetSection
          header=&quot;Positioners&quot;
          names={getDatasetParameterByPrefixName(this.props.dataset, &quot;InstrumentPositioners_name&quot;)}
          values={getDatasetParameterByPrefixName(this.props.dataset, &quot;InstrumentPositioners_value&quot;)}
      &gt;
       &lt;/InstrumentWidgetSection&gt;
      
    &lt;/div&gt;;        
  }
}

export default InstrumentWidget;



class InstrumentWidgetSection extends React.Component {
  render() { 
    var names = null; 
    var values = null;             
    if (this.props.values &amp;&amp; this.props.names){
          /** This is a comma separeted pair of name-values 
          * names = [{&quot;name&quot;:&quot;InstrumentOpticsPositioners_name&quot;,&quot;value&quot;:&quot; m2angle m0tz m0tyrot mono enmono r2theta r2gamma &quot;}]
          * values = [{&quot;name&quot;:&quot;InstrumentOpticsPositioners_value&quot;,&quot;value&quot;:&quot; 26 -22 6.7 19.244 5.99885 -0.0829958 -0.456489 -0.820325 5.5 0.85 -18.5746 -4.49 5.96497 5.86713 6.06281 5.86713 7.5 100 0.141575 -0.511 NaN NaN NaN NaN NaN NaN 0&quot;}]
          */
          
          if (this.props.values.length &gt; 0 &amp;&amp; this.props.names.length &gt; 0){
              names = this.props.names[0].value;
              values = this.props.values[0].value;
          }
    }
    
    if (!names &amp;&amp; !values &amp;&amp; (!this.props.parameters || this.props.parameters === 0 || !_.find(this.props.parameters, function(parameter){ console.log(parameter.name); return parameter.value }))){
        return null;
    }

    
    
    
    return &lt;div className=&quot;container-fluid&quot;&gt;     
                    &lt;br /&gt;           
                    &lt;span style={{fontSize:&#039;16px&#039;, fontWeight:&#039;bold&#039;}} &gt;{this.props.header}&lt;/span&gt;
                        &lt;div class=&quot;row&quot;&gt;
                            &lt;div class=&quot;col-sm-2&quot;&gt;
                                &lt;ParameterTableWidget names={names} values={values} parameters={this.props.parameters}&gt;&lt;/ParameterTableWidget&gt;	        
                            &lt;/div&gt;  
                        &lt;/div&gt;                                        	           
                    &lt;/div&gt;;         
  }
}</textarea>
  </div>
</div>

<footer class="footer">
  <div class="container">
    <p>.</p>
  </div>
</footer>

<script type="text/html" id="complexity-popover-template">
  <div class="complexity-notice">
    Complexity : {{ complexity.cyclomatic }} <br>
    Length : {{ complexity.halstead.length }} <br>
    Difficulty : {{ complexity.halstead.difficulty.toFixed(2) }} <br>
    Est # bugs : {{ complexity.halstead.bugs.toFixed(2) }}<br>
  </div>
</script>

<script type="text/javascript" src="../../assets/scripts/bundles/core-bundle.js"></script>
<script type="text/javascript" src="../../assets/scripts/bundles/codemirror.js"></script>
<script type="text/javascript" src="../../assets/scripts/codemirror.markpopovertext.js"></script>
<script type="text/javascript" src="report.js"></script>
<script type="text/javascript" src="report.history.js"></script>
<script type="text/javascript" src="../../assets/scripts/plato-file.js"></script>
</body>
</html>
