<commit_before>import React, { Component } from 'react';
import PropTypes from 'proptypes';
import Filter from './Filter.jsx';
import filterData from './filter-data.js';

class Filters extends Component {

  static propTypes = {
    filters: PropTypes.array,
    addFilter: PropTypes.func,
    removeFilter: PropTypes.func,
    updateFilter: PropTypes.func
  }

  addFilter = (type) => {
    return () => {
      this.props.addFilter({ type, value: '', exclude: false });
    };
  }

  render() {
    return (
      <div id="filter-div">
        <ul className="list-group">
          <li className="list-group-item active">
            {Object.keys(filterData).map(filterName => <span className="col" key={filterName} onClick={this.addFilter(filterName)}>{filterName}</span>)}
          </li>
          {
            this.props.filters.map((filter, index) => {
              return filter && <Filter data={filter} key={index} index={index} update={this.props.updateFilter} remove={this.props.removeFilter} />;
            })
          }
        </ul>
      </div>
    );
  }
}
export default Filters;<commit_msg>Load filter types from database<commit_after>import React, { Component } from 'react';
import PropTypes from 'proptypes';
import Filter from './Filter.jsx';
import axios from 'axios';

class Filters extends Component {

  componentWillMount = () => {
    this.setState({ filterTypes: [] });
    axios.get('http://localhost:8080/filters')
      .then(({ data }) => {
        this.setState({ filterTypes: data });
      });
  }

  static propTypes = {
    filters: PropTypes.array,
    addFilter: PropTypes.func,
    removeFilter: PropTypes.func,
    updateFilter: PropTypes.func
  }

  addFilter = (type) => {
    return () => {
      this.props.addFilter({ type, value: '', exclude: false });
    };
  }

  render() {
    return (
      <div id="filter-div">
        <ul className="list-group">
          <li className="list-group-item active">
            {this.state.filterTypes.map(filter => <span className="col" key={filter.id} onClick={this.addFilter(filter.type)}>{filter.type}</span>)}
          </li>
          {
            this.props.filters.map((filter, index) => {
              return filter && <Filter data={filter} key={index} index={index} update={this.props.updateFilter} remove={this.props.removeFilter} />;
            })
          }
        </ul>
      </div>
    );
  }
}
export default Filters;
{'fraction_non_alphanumeric': 0.15932482503087692, 'fraction_numerical': 0.0016467682173734047, 'mean_word_length': 2.6377245508982035, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 31, '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': '755972', 'n_tokens_mistral': 714, 'n_tokens_neox': 716, 'n_words': 150}