<commit_before>import React, { Component, PropTypes } from 'react';
import * as tus from 'tus-js-client';

export default class DataFileDataSourceSettings extends Component {
  constructor() {
    super();
    this.handleDragEnter = this.handleDragEnter.bind(this);
    this.handleDragOver = this.handleDragOver.bind(this);
    this.handleDrop = this.handleDrop.bind(this);
  }

  handleDragEnter(evt) {
    evt.stopPropagation();
    evt.preventDefault();
  }

  handleDragOver(evt) {
    evt.stopPropagation();
    evt.preventDefault();
  }

  handleDrop(evt) {
    evt.stopPropagation();
    evt.preventDefault();
    this.uploadFile(evt.dataTransfer.files[0]);
  }

  uploadFile(file) {
    const onChange = this.props.onChange;
    const upload = new tus.Upload(file, {
      endpoint: 'http://localhost:3030/api/files',
      onError(error) {
        console.error(`Failed because: ${error}`);
      },
      onProgress(bytesUploaded, bytesTotal) {
        const percentage = (bytesUploaded / bytesTotal * 100).toFixed(2);
        console.log(bytesUploaded, bytesTotal, `${percentage}%`);
      },
      onSuccess() {
        onChange({
          kind: 'DATA_FILE',
          url: upload.url,
          fileName: upload.file.name,
        });
      },
    });
    upload.start();
  }

  render() {
    return (
      <div
        className="DataFileFileSelection"
        onDragEnter={this.handleDragEnter}
        onDragOver={this.handleDragOver}
        onDrop={this.handleDrop}>
        <p className="dataFileUploadMessage">Drop file anywhere to upload</p>
        <p className="dataFileUploadMessage">or</p>
        <input
          className="dataFileUploadInput"
          ref="fileInput"
          type="file"
          onChange={() => {
            this.uploadFile(this.refs.fileInput.files[0]);
          }} />
      </div>
    );
  }
}

DataFileDataSourceSettings.propTypes = {
  dataset: PropTypes.object.isRequired,
  onChange: PropTypes.func.isRequired,
};<commit_msg>[#33] remove unused prop type<commit_after>import React, { Component, PropTypes } from 'react';
import * as tus from 'tus-js-client';

export default class DataFileDataSourceSettings extends Component {
  constructor() {
    super();
    this.handleDragEnter = this.handleDragEnter.bind(this);
    this.handleDragOver = this.handleDragOver.bind(this);
    this.handleDrop = this.handleDrop.bind(this);
  }

  handleDragEnter(evt) {
    evt.stopPropagation();
    evt.preventDefault();
  }

  handleDragOver(evt) {
    evt.stopPropagation();
    evt.preventDefault();
  }

  handleDrop(evt) {
    evt.stopPropagation();
    evt.preventDefault();
    this.uploadFile(evt.dataTransfer.files[0]);
  }

  uploadFile(file) {
    const onChange = this.props.onChange;
    const upload = new tus.Upload(file, {
      endpoint: 'http://localhost:3030/api/files',
      onError(error) {
        console.error(`Failed because: ${error}`);
      },
      onProgress(bytesUploaded, bytesTotal) {
        const percentage = (bytesUploaded / bytesTotal * 100).toFixed(2);
        console.log(bytesUploaded, bytesTotal, `${percentage}%`);
      },
      onSuccess() {
        onChange({
          kind: 'DATA_FILE',
          url: upload.url,
          fileName: upload.file.name,
        });
      },
    });
    upload.start();
  }

  render() {
    return (
      <div
        className="DataFileFileSelection"
        onDragEnter={this.handleDragEnter}
        onDragOver={this.handleDragOver}
        onDrop={this.handleDrop}>
        <p className="dataFileUploadMessage">Drop file anywhere to upload</p>
        <p className="dataFileUploadMessage">or</p>
        <input
          className="dataFileUploadInput"
          ref="fileInput"
          type="file"
          onChange={() => {
            this.uploadFile(this.refs.fileInput.files[0]);
          }} />
      </div>
    );
  }
}

DataFileDataSourceSettings.propTypes = {
  onChange: PropTypes.func.isRequired,
};
{'fraction_non_alphanumeric': 0.13594936708860758, 'fraction_numerical': 0.005569620253164557, 'mean_word_length': 2.7098591549295774, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '984113', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1208, 'n_words': 192}