<commit_before>/* eslint new-cap: ["error", { "properties": false }] */
var $ = require('jquery');
import Dropzone from 'dropzone';

/**
 * Create a table from the metadata return after parsing the excel docs.
 * @return {object} datatable creation method
 */
const tableCreator = (function() {
  /**
   * Create an object of the headers title and text.
   * @param {array} headers list of table headers
   * @return {array} of formatted data for table headers.
   */
  function transformHeaders(headers) {
    return headers.map(function(h) {
      return {title: h, data: h};
    });
  }

  /**
   * Crate the datatable
   * @param {array} data for the table
   */
  return function createTable(data) {
    var nameCol = data.headers.indexOf('NLEP #');
    var headers = transformHeaders(data.headers);
    $('#metadata-table').DataTable({
      scrollX: true,
      data: data.metadata,
      columns: headers,
      createdRow: function(row, data) {
        if (data.sampleId === '') {
          $(row).addClass('bg-danger');
        }
      },
      columnDefs: [
        {
          targets: nameCol,
          render: function(data, type, row) {
            var id = row.sampleId;
            if (id === '') {
              return data;
            }
            return `<a href="/samples/${id}">${data}</a>`;
          }
        }
      ]
    });
  };
})();

Dropzone.options.metadataDropzone = {
  paramName: 'file',<commit_msg>Cleaned up table creation code.<commit_after>/* eslint new-cap: ["error", { "properties": false }] */
var $ = require('jquery');
import Dropzone from 'dropzone';

/**
 * Create a table from the metadata return after parsing the excel docs.
 */
const tableCreator = data => {
  const nameCol = data.headers.indexOf('NLEP #');
  const headers = transformHeaders(data.headers);

  /**
   * Create an object of the headers title and text.
   * @param {array} headers list of table headers
   * @return {array} of formatted data for table headers.
   */
  function transformHeaders(headers) {
    return headers.map(function(h) {
      return {title: h, data: h};
    });
  }

  $('#metadata-table').DataTable({
    scrollX: true,
    data: data.metadata,
    columns: headers,
    createdRow: function(row, data) {
      if (data.sampleId === '') {
        $(row).addClass('bg-danger');
      }
    },
    columnDefs: [
      {
        targets: nameCol,
        render: function(data, type, row) {
          var id = row.sampleId;
          if (id === '') {
            return data;
          }
          return `<a href="/samples/${id}">${data}</a>`;
        }
      }
    ]
  });
}

// Configuration for dropzone.js allowing for user to
// upload their excel files.
Dropzone.options.metadataDropzone = {
  paramName: 'file',
{'fraction_non_alphanumeric': 0.14896701703515766, 'fraction_numerical': 0.0, 'mean_word_length': 2.3782129742962055, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 8, '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': '3400302', 'n_tokens_mistral': 827, 'n_tokens_neox': 814, 'n_words': 229}