<commit_before>/*
 * == BSD2 LICENSE ==
 * Copyright (c) 2014, Tidepool Project
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the associated License, which is identical to the BSD 2-Clause
 * License as published by the Open Source Initiative at opensource.org.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the License for more details.
 *
 * You should have received a copy of the License along with this program; if
 * not, you can obtain one from Tidepool Project at tidepool.org.
 * == BSD2 LICENSE ==
 */

var _ = require('lodash');
var React = require('react');
var appState = require('../state/appState');
var appActions = require('../state/appActions');

var Loading = require('./Loading.jsx');
var Login = require('./Login.jsx');
var LoggedInAs = require('./LoggedInAs.jsx');
var Scan = require('./Scan.jsx');
var UploadList = require('./UploadList.jsx');
var ViewDataLink = require('./ViewDataLink.jsx');
var UploadSettings = require('./UploadSettings.jsx');

var config = require('../config');

var App = React.createClass({
  getInitialState: function() {
    return appState.getInitial();
  },

  componentWillMount: function() {
    appState.bindApp(this);
    appActions.bindApp(this);

    appActions.load(_.noop);

    this.appState = appState;
    this.appActions = appActions;
    this.localStore = require('../core/localStore');
    this.api = require('../core/api');
    this.device = require('../core/device');
  },

  render: function() {
    return (
      <div className={'App App--' + this.state.page}>
        <div className="App-header">{this.renderHeader()}</div>
        <div className="App-logo"></div>
        <div className="App-page">{this.renderPage()}</div>
        <div className="App-footer">{this.renderFooter()}</div>
      </div>
    );
  },

  renderHeader: function() {
    if (this.state.page === 'loading') {
      return null;
    }

    if (!this.appState.isLoggedIn()) {
      return this.renderSignupLink();
    }

    return <LoggedInAs
      user={this.state.user}
      onLogout={this.appActions.logout.bind(this.appActions)} />;
  },

  renderPage: function() {
    var page = this.state.page;

    if (page === 'loading') {
      return <Loading />;
    }

    if (page === 'login') {
      return <Login onLogin={this.appActions.login.bind(this.appActions)} />;
    }

    if (page === 'main') {
      return (
        <div>
          <UploadSettings
            user={this.state.user}
            onGroupChange={this.appActions.changeGroup.bind(this.appActions)} />
          <UploadList
            uploads={this.appState.uploadsWithFlags()}
            onUpload={this.appActions.upload.bind(this.appActions)}
            onReset={this.appActions.reset.bind(this.appActions)} />
          {this.renderViewDataLink()}
        </div>
      );
    }
<commit_msg>added targetId and disabled while uploading<commit_after>/*
 * == BSD2 LICENSE ==
 * Copyright (c) 2014, Tidepool Project
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the associated License, which is identical to the BSD 2-Clause
 * License as published by the Open Source Initiative at opensource.org.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the License for more details.
 *
 * You should have received a copy of the License along with this program; if
 * not, you can obtain one from Tidepool Project at tidepool.org.
 * == BSD2 LICENSE ==
 */

var _ = require('lodash');
var React = require('react');
var appState = require('../state/appState');
var appActions = require('../state/appActions');

var Loading = require('./Loading.jsx');
var Login = require('./Login.jsx');
var LoggedInAs = require('./LoggedInAs.jsx');
var Scan = require('./Scan.jsx');
var UploadList = require('./UploadList.jsx');
var ViewDataLink = require('./ViewDataLink.jsx');
var UploadSettings = require('./UploadSettings.jsx');

var config = require('../config');

var App = React.createClass({
  getInitialState: function() {
    return appState.getInitial();
  },

  componentWillMount: function() {
    appState.bindApp(this);
    appActions.bindApp(this);

    appActions.load(_.noop);

    this.appState = appState;
    this.appActions = appActions;
    this.localStore = require('../core/localStore');
    this.api = require('../core/api');
    this.device = require('../core/device');
  },

  render: function() {
    return (
      <div className={'App App--' + this.state.page}>
        <div className="App-header">{this.renderHeader()}</div>
        <div className="App-logo"></div>
        <div className="App-page">{this.renderPage()}</div>
        <div className="App-footer">{this.renderFooter()}</div>
      </div>
    );
  },

  renderHeader: function() {
    if (this.state.page === 'loading') {
      return null;
    }

    if (!this.appState.isLoggedIn()) {
      return this.renderSignupLink();
    }

    return <LoggedInAs
      user={this.state.user}
      onLogout={this.appActions.logout.bind(this.appActions)} />;
  },

  renderPage: function() {
    var page = this.state.page;

    if (page === 'loading') {
      return <Loading />;
    }

    if (page === 'login') {
      return <Login onLogin={this.appActions.login.bind(this.appActions)} />;
    }

    if (page === 'main') {
      return (
        <div>
          <UploadSettings
            user={this.state.user}
            targetId={this.state.targetId}
            isUploadInProgress={this.appState.hasUploadInProgress()}
            onGroupChange={this.appActions.changeGroup.bind(this.appActions)} />
          <UploadList
            uploads={this.appState.uploadsWithFlags()}
            onUpload={this.appActions.upload.bind(this.appActions)}
            onReset={this.appActions.reset.bind(this.appActions)} />
          {this.renderViewDataLink()}
        </div>
      );
    }

{'fraction_non_alphanumeric': 0.14941785252263906, 'fraction_numerical': 0.002263906856403622, 'mean_word_length': 3.0058290155440415, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '774142', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1804, 'n_words': 453}