<commit_before>import m from 'mithril'
import Row from './row'
import {columnHeader} from './settings'

let Table = {};

Table.controller = function controller (attrs, children) {
  let c = {
    files:           attrs.files,
    colConfig:       attrs.colConfig,
    /*listHeaders:     cc => cc.filter( k => k.visible ).toArray(),*/
    sort: k => {alert('SOULD SORT: ' + k)} //TODO
  }
  //console.log( c.files() )
  return c;
}

Table.view = function view (c, attrs, children) {
  return (
    <div>
      <h2>Table</h2>
      <table>
        <thead>
        { columnHeader.filter( x => x.get( 'visible' ))
          .map(x => <th onclick={() => { c.sort(x.get( 'id' )) } }>{ m.trust(x.get( 'name' )) }</th> ).toJS()
        }
        </thead>
        <tbody>
        { c.files().map( file => {
          return <Row file={file} colConfig={c.colConfig()}/>
        } ).toJS() }
        </tbody>
      </table>
    </div>
  )
}

export default Table<commit_msg>add keys to components in mithril<commit_after>import m from 'mithril'
import Row from './row'
import {columnHeader} from './settings'

let Table = {};

Table.controller = function controller (attrs, children) {
  let c = {
    files:     attrs.files,
    colConfig: attrs.colConfig,
    columnHeader: columnHeader,
    sort:      k => {alert( 'SOULD SORT: ' + k )} //TODO
  }
  //console.log( c.files() )
  return c;
}

Table.view = function view (c, attrs, children) {
  return (
    <div>
      <h2>Table</h2>
      <table>
        <thead>
        { c.columnHeader
          .filter( x => x.get( 'visible' ) )
          .map( x => <th
            key={ x.get('id') }
            onclick={() => { c.sort(x.get( 'id' )) } }>
            { m.trust( x.get( 'name' ) ) }
          </th> ).toJS()
        }
        </thead>
        <tbody>
        { c.files().map( file => {
          return <Row
            key={ file.get('index') }
            file={file}
            colConfig={c.colConfig()}/>
        } ).toJS() }
        </tbody>
      </table>
    </div>
  )
}

export default Table
{'fraction_non_alphanumeric': 0.18439024390243902, 'fraction_numerical': 0.001951219512195122, 'mean_word_length': 1.8407202216066483, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 41, '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': '4171451', 'n_tokens_mistral': 706, 'n_tokens_neox': 705, 'n_words': 168}