<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Plato - App.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>App.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">76.37</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">392</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">33.08</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">2.01</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, { Component } from &#039;react&#039;;
import { connect } from &#039;react-redux&#039;;
import &#039;./App.css&#039;;
import &quot;babel-polyfill&quot;;
import { Panel, Glyphicon, Alert, Grid, Row, Col } from &#039;react-bootstrap&#039;;
import LoginContainer from &#039;./containers/LoginContainer.js&#039;;
import ExpirationLoginContainer from &#039;./containers/ExpirationLoginContainer.js&#039;;
import InvestigationsContainer from &#039;./containers/InvestigationsContainer.js&#039;;
import DataCollectionsContainer from &#039;./containers/DataCollectionsContainer.js&#039;;
import CameraContainer from &#039;./containers/CameraContainer.js&#039;;
import MenuContainer from &#039;./containers/MenuContainer.js&#039;;
import InvestigationContainer from &#039;./containers/Investigation/InvestigationContainer.js&#039;;
import SearchContainer from &#039;./containers/SearchContainer.js&#039;;
import SelectionContainer from &#039;./containers/Selection/SelectionContainer.js&#039;;
import MintSelectionContainer from &#039;./containers/Selection/MintSelectionContainer.js&#039;;
import UserManagementContainer from &#039;./containers/UserManagementContainer.js&#039;;
import DataStatisticsContainer from &#039;./containers/DataStatisticsContainer.js&#039;; 
import Footer from &#039;./components/Footer.js&#039;;
import { BrowserRouter as Router, Route } from &quot;react-router-dom&quot;;
import _ from &#039;lodash&#039;;
import tinyParams from &#039;tiny-params&#039;;
import UI from &#039;./config/ui/config.js&#039;;
import maintenanceImage from &#039;./images/maintenance.jpg&#039;;
import maintenanceImage2 from &#039;./images/maintenance2.jpg&#039;;
import maintenanceImage3 from &#039;./images/maintenance3.jpg&#039;;
import maintenanceImage4 from &#039;./images/maintenance4.jpg&#039;;
import TagsManagerContainer from &#039;./containers/Logbook/Tags/TagsManagerContainer&#039;;

class App extends Component {
    render() {


        if (UI.status.offline.enabled == true) {
            return &lt;Router&gt;
                &lt;div&gt;
                    &lt;Route path=&quot;/&quot; component={OfflinePage} /&gt;
                &lt;/div&gt;
            &lt;/Router&gt;

        }

        return (
            &lt;Router&gt;
                &lt;div&gt;
                    &lt;Route exact path=&quot;/&quot; component={MyDataPage} /&gt;

                    &lt;Route exact path=&quot;/home&quot; component={MyDataPage} /&gt;

                    &lt;Route exact path=&quot;/search&quot; component={MySearchPage} /&gt;

                    &lt;Route exact path=&quot;/investigations&quot; render={props =&gt; (&lt;MyDataPage location={props.location} {...this.props}  /&gt;)} /&gt;
                    
                    &lt;Route exact path=&quot;/usermanagement&quot; component={UserManagementPage} /&gt;

                    &lt;Route exact path=&quot;/public&quot; render={props =&gt; (&lt;OpenDataPage {...this.props} /&gt;)} /&gt;
                    &lt;Route exact path=&quot;/public/:prefix/:suffix&quot; component={DOIPage} /&gt;

                    &lt;Route exact path=&quot;/closed&quot; render={props =&gt; (&lt;ClosedDataPage {...this.props} /&gt;)} /&gt;

                    &lt;Route exact path=&quot;/investigation/:investigationId/datasets&quot; component={DatasetsPage} /&gt;
                    &lt;Route exact path=&quot;/investigation/:investigationId/events/tagManager&quot; component={EventTagPage} /&gt;
                    &lt;Route exact path=&quot;/investigation/:investigationId/events&quot; component={EventsPage} /&gt;
                    &lt;Route exact path=&quot;/investigation/:investigationId/camera&quot; component={CameraPage} /&gt;

                    &lt;Route exact path=&quot;/selection&quot; component={SelectionPage} /&gt;
                    &lt;Route exact path=&quot;/selection/mint&quot; component={MintSelectionPage} /&gt;


                    &lt;Route exact path=&quot;/manager/stats&quot; component={ManagerStatsPage} /&gt;

                    &lt;Footer&gt;&lt;/Footer&gt;
                &lt;/div&gt;
            &lt;/Router&gt;
        );
    }

}

class OfflinePage extends React.Component {
    render() {
        return (
            &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;Grid style={{ marginTop: 100 }}&gt;
                    &lt;Row&gt;
                        &lt;Col xs={3}&gt;&lt;img alt=&quot;&quot; src={maintenanceImage} style={{ height: &#039;200px&#039;, widht: &#039;200px&#039; }} /&gt;&lt;/Col&gt;
                        &lt;Col xs={3}&gt;&lt;/Col&gt;
                        &lt;Col xs={3}&gt;&lt;img alt=&quot;&quot; src={maintenanceImage3} style={{ height: &#039;200px&#039;, widht: &#039;200px&#039; }} /&gt;&lt;/Col&gt;
                        &lt;Col xs={3}&gt;&lt;/Col&gt;
                    &lt;/Row&gt;

                    &lt;Row&gt;
                        &lt;Col&gt;&lt;/Col&gt;
                        &lt;Col&gt;
                            &lt;Alert style={{ textAlign: &#039;center&#039; }} bsStyle=&quot;warning&quot;&gt;
                                &lt;strong&gt;Offline Message!&lt;/strong&gt;&lt;br /&gt; &lt;h1&gt;{UI.status.offline.message}&lt;/h1&gt;
                            &lt;/Alert&gt;
                        &lt;/Col&gt;
                        &lt;Col&gt;
                            &lt;Col xs={3}&gt;&lt;/Col&gt;
                            &lt;Col xs={3}&gt;&lt;img alt=&quot;&quot; src={maintenanceImage2} style={{ height: &#039;200px&#039;, widht: &#039;200px&#039; }} /&gt;&lt;/Col&gt;
                            &lt;Col xs={3}&gt;&lt;/Col&gt;
                            &lt;Col xs={3}&gt;&lt;img alt=&quot;&quot; src={maintenanceImage4} style={{ height: &#039;200px&#039;, widht: &#039;200px&#039; }} /&gt;&lt;/Col&gt;

                        &lt;/Col&gt;
                    &lt;/Row&gt;
                &lt;/Grid&gt;
                &lt;Footer&gt;&lt;/Footer&gt;
            &lt;/div&gt;
        );
    }
}


class DOIPage extends React.Component {
    render() {
        return (
            &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
                &lt;InvestigationContainer doi={this.props.match.params.prefix + &quot;/&quot; + this.props.match.params.suffix} isDOI={true} activeTab={1} {...this.props} /&gt;

            &lt;/div&gt;
        );
    }
}

class UserManagementPage extends React.Component {
    render() {
        return (
            &lt;div&gt;
            &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
                &lt;div style={{ marginTop: &#039;30px&#039;, marginLeft: &#039;30px&#039;, marginRight: &#039;30px&#039; }}&gt;
                    &lt;UserManagementContainer {...this.props}&gt;&lt;/UserManagementContainer&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        );
    }
}

class ManagerStatsPage extends React.Component {
    render() {
        return (
            &lt;div&gt;
            &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
                &lt;div style={{ marginTop: &#039;30px&#039;, marginLeft: &#039;30px&#039;, marginRight: &#039;30px&#039; }}&gt;
                    &lt;DataStatisticsContainer {...this.props}&gt;&lt;/DataStatisticsContainer&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        );
    }
}


class SelectionPage extends React.Component {
    render() {
        return (
            &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
                &lt;SelectionContainer {...this.props} /&gt;
            &lt;/div&gt;
        );
    }
}

class MintSelectionPage extends React.Component {
    render() {
        return (
            &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
                &lt;MintSelectionContainer investigationId={this.props.match.params.investigationId} {...this.props} /&gt;
            &lt;/div&gt;
        );
    }
}


class MySearchPage extends React.Component {
    render() {
        return (
            &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;

                &lt;div style={{ marginTop: &#039;30px&#039;, marginLeft: &#039;30px&#039;, marginRight: &#039;30px&#039; }}&gt;
                    &lt;SearchContainer linkProposal={true} openData={true} investigations={this.props.myInvestigations} /&gt;
                &lt;/div&gt;


            &lt;/div&gt;
        );
    }
}

class MyDataPage extends React.Component {
    render() {
        var investigations = this.props.myInvestigations;
        var params = tinyParams(window.location.href)
        /** Filter by beamline Name */
        if (params.beamline) {
            var _this = this;

            investigations = {
                data : _.filter(this.props.scientistInstrumentInvestigations.data, 
                    function(inv){ 
                        if (inv.investigationInstruments.length == 0){ 
                            //** some old investigation might have not instrument **/ 
                            return; } 
                        return inv.investigationInstruments[0].instrument.name == params.beamline;}),
                fetching : false,
                fetched : true
            }
        }

        return (
            &lt;div &gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
                &lt;div style={{ marginTop: &#039;30px&#039;, marginLeft: &#039;30px&#039;, marginRight: &#039;30px&#039; }}&gt;
                    &lt;InvestigationsContainer showInvestigationStats={true} linkProposal={true} openData={true} investigations={investigations} /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        );
    }
}

class ClosedDataPage extends React.Component {
    render() {
        if ((!this.props.user) || (!this.props.user.sessionId)) {
            return &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
            &lt;/div&gt;;
        }
        return (
            &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;

                &lt;Panel bsStyle=&#039;danger&#039; style={{ marginTop: &#039;30px&#039;, marginLeft: &#039;30px&#039;, marginRight: &#039;30px&#039; }}&gt;
                    &lt;Panel.Heading&gt;
                        &lt;Panel.Title componentClass=&quot;h2&quot;&gt; &lt;Glyphicon glyph=&quot;lock&quot; style={{ marginRight: &quot;10px&quot; }} /&gt;These investigations are under embargo&lt;/Panel.Title&gt;
                    &lt;/Panel.Heading&gt;
                    &lt;Panel&gt;
                        &lt;Panel.Body&gt;
                            &lt;InvestigationsContainer showInvestigationStats={this.props.user.isAdministrator} linkProposal={false} investigations={this.props.investigations} openData={false} {...this.props} /&gt;
                        &lt;/Panel.Body&gt;
                    &lt;/Panel&gt;
                &lt;/Panel&gt;
            &lt;/div&gt;
        );
    }
}

class OpenDataPage extends React.Component {
    render() {
        if ((!this.props.user) || (!this.props.user.sessionId)) {
            return &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
            &lt;/div&gt;;
        }

        var filterNotPublications = function (data) {
            return _.filter(data, function (o) { return _.find(o.parameters, function (p) { return (p.name == &quot;instrumentNames&quot; &amp;&amp; p.value == &quot;PUBLISHER&quot;) }) });
        }
        var filterPublications = function (data) {
            return _.filter(data, function (o) { return _.find(o.parameters, function (p) { return (p.name == &quot;instrumentNames&quot; &amp;&amp; p.value != &quot;PUBLISHER&quot;) }) });
        }

        return (
            &lt;div&gt;
                &lt;MenuContainer /&gt;
                &lt;LoginContainer /&gt;
                &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
                &lt;Panel bsStyle=&quot;primary&quot; style={{ marginTop: &#039;30px&#039;, marginLeft: &#039;30px&#039;, marginRight: &#039;30px&#039; }}&gt;
                    &lt;Panel.Heading &gt;
                        &lt;Panel.Title componentClass=&quot;h2&quot;&gt; &lt;Glyphicon glyph=&quot;eye-open&quot; /&gt; Open Data Collections&lt;/Panel.Title&gt;
                    &lt;/Panel.Heading&gt;

                    &lt;Panel.Body&gt;
                        &lt;DataCollectionsContainer filterFunction={filterPublications} openData={true} /&gt;
                    &lt;/Panel.Body&gt;

                &lt;/Panel&gt;


                &lt;Panel bsStyle=&quot;success&quot; style={{ marginTop: &#039;30px&#039;, marginLeft: &#039;30px&#039;, marginRight: &#039;30px&#039; }}&gt;
                    &lt;Panel.Heading &gt;
                        &lt;Panel.Title componentClass=&quot;h2&quot;&gt; &lt;Glyphicon glyph=&quot;eye-open&quot; /&gt; Public Documents&lt;/Panel.Title&gt;
                    &lt;/Panel.Heading&gt;

                    &lt;Panel.Body&gt;
                        &lt;DataCollectionsContainer filterFunction={filterNotPublications} openData={true} /&gt;
                    &lt;/Panel.Body&gt;

                &lt;/Panel&gt;

                &lt;Panel bsStyle=&quot;primary&quot; style={{ marginTop: &#039;30px&#039;, marginLeft: &#039;30px&#039;, marginRight: &#039;30px&#039; }}&gt;
                    &lt;Panel.Heading &gt;
                        &lt;Panel.Title componentClass=&quot;h2&quot;&gt; &lt;Glyphicon glyph=&quot;eye-open&quot; /&gt; Open Investigations&lt;/Panel.Title&gt;
                    &lt;/Panel.Heading&gt;

                    &lt;Panel.Body&gt;
                        &lt;InvestigationsContainer
                            linkProposal={true}
                            investigations={this.props.releasedInvestigations}
                            closedData={false}
                            showInvestigationStats={true}
                        /&gt;
                    &lt;/Panel.Body&gt;

                &lt;/Panel&gt;

            &lt;/div&gt;
        );
    }
}


function DatasetsPage(props) {
    return (
        &lt;div&gt;
            &lt;MenuContainer /&gt;
            &lt;LoginContainer /&gt;
            &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
            &lt;InvestigationContainer activeTab={1} investigationId={props.match.params.investigationId} {...props} /&gt;
        &lt;/div&gt;
    );
}

function EventsPage(props) {
    return (
        &lt;div&gt;
            &lt;MenuContainer /&gt;
            &lt;LoginContainer /&gt;
            &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
            &lt;InvestigationContainer activeTab={3} investigationId={props.match.params.investigationId} {...props} /&gt;
        &lt;/div&gt;
    );
}

function EventTagPage(props) {
    return (
        &lt;div&gt;
            &lt;MenuContainer /&gt;
            &lt;LoginContainer /&gt;
            &lt;ExpirationLoginContainer&gt;&lt;/ExpirationLoginContainer&gt;
            &lt;TagsManagerContainer investigationId={props.match.params.investigationId} /&gt;
        &lt;/div&gt;
    );
}

function CameraPage(props) {
    return (
        &lt;div&gt;
            &lt;CameraContainer investigationId={props.match.params.investigationId} /&gt;
        &lt;/div&gt;
    );
}

function mapStateToProps(state) {
    return {
        user: state.user,
        selection: state.selection,
        datasets: state.datasets,
        investigations: state.investigations,
        myInvestigations: state.myInvestigations,
        scientistInstrumentInvestigations: state.scientistInstrumentInvestigations,
        releasedInvestigations: state.releasedInvestigations
    };
}



export default (connect(
    mapStateToProps
)(App));

</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>
