<commit_before>import React from 'react';
import request from 'superagent';

export default class ToleranceList extends React.Component {
  constructor(props){
    //Create the constructor for the component
    super(props);
    this.state = {tolerances: []};

    this.renderNode = this.renderNode.bind(this);
  }

  onObjectTreeNodeClick(node, self){
      // TODO: do something when we click a tolerance
    }

  renderNode(node){
      let cName = 'node';
        if(node.id == this.state) cName= 'node running-node';
      return <ol
          id={node.id}
          className={cName}
          onClick={this.onObjectTreeNodeClick.bind(this, node)}
          onMouseDown={function(e){e.stopPropagation()}}
          style={{"paddingLeft" : "5px"}}
          key={node.id} >
          {node.icon}
          <span className="textbox-tolerance">{node.name}</span>
      </ol>;
  }

  componentDidMount(){
      let url = "/v2/nc/projects/"+this.props.pid+"/tolerances/";
      let resCb = function(err,res){ //Callback function for response
            if(!err && res.ok){
              // Node preprocessing
              let nodes = [];
              let nodeCheck = (node)=>{
                node.icon = <span className={'icon-tolerance ' + 'tolerance-' + node.type}></span>;
                //if(node.children) node.children.forEach(nodeCheck);
                //node.children = [];
                //if(node.type === "workingstep")
                nodes.push(node);
              };
              let json = JSON.parse(res.text);
              nodeCheck(json);
              this.setState({tolerances: nodes});
            }
      }
      resCb = resCb.bind(this); //Needs to bind this in order to have correct this
      request
        .get(url)
        .end(resCb);
  }

  render(){
    return (
      <div className='m-tree'>
        {this.state.tolerances.map((tolerance, i) => {
          return <div className='m-node' key={i}>
            {this.renderNode(tolerance)}
          </div>;
        })}
      </div>
    );
  }
}

ToleranceList.propTypes = {cbMode: React.PropTypes.func.isRequired, cbTree: React.PropTypes.func.isRequired,
                                pid: React.PropTypes.string.isRequired}<commit_msg>lots of boxes<commit_after>import React from 'react';
import request from 'superagent';

export default class ToleranceList extends React.Component {
  constructor(props){
    //Create the constructor for the component
    super(props);
    this.state = {tolerances: []};

    this.renderNode = this.renderNode.bind(this);
  }

  onObjectTreeNodeClick(node, self){
      // TODO: do something when we click a tolerance
    }

  renderNode(node){
      let cName = 'node';
        if(node.id == this.state) cName= 'node running-node';
      return <ol
          id={node.id}
          className={cName}
          onClick={this.onObjectTreeNodeClick.bind(this, node)}
          onMouseDown={function(e){e.stopPropagation()}}
          style={{"paddingLeft" : "5px"}}
          key={node.id} >
          {node.icon}
          <span className="textbox-tolerance">{node.name}</span>
      </ol>;
  }

  componentDidMount(){
      let url = "/v2/nc/projects/"+this.props.pid+"/tolerances/";
      let resCb = function(err,res){ //Callback function for response
            if(!err && res.ok){
              // Node preprocessing
              let json = JSON.parse(res.text);

              let nodes = json;
              this.setState({tolerances: nodes});
            }
      }
      resCb = resCb.bind(this); //Needs to bind this in order to have correct this
      request
        .get(url)
        .end(resCb);
  }

  render(){
    return (
      <div className='m-tree'>
        {this.state.tolerances.map((tolerance, i) => {
          return <div className='m-node' key={i}>
            {this.renderNode(tolerance)}
          </div>;
        })}
      </div>
    );
  }
}

ToleranceList.propTypes = {cbMode: React.PropTypes.func.isRequired, cbTree: React.PropTypes.func.isRequired,
                                pid: React.PropTypes.string.isRequired}
{'fraction_non_alphanumeric': 0.1409346709077563, 'fraction_numerical': 0.0009787129924149743, 'mean_word_length': 2.034892353377877, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 24, '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': '3863816', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1209, 'n_words': 249}