summaryrefslogtreecommitdiff
path: root/client/index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-12-16 00:56:31 +0100
committerJules Laplace <julescarbon@gmail.com>2018-12-16 00:56:31 +0100
commita890e18a12f2b3bb39eb2f1303de71d6fbb3915c (patch)
tree2d18cf6663223e29df452fa3907928830d468433 /client/index.js
parent3b10acc73247ec703ed47f0423e7d255a91f074e (diff)
displaying tabulators with CORS
Diffstat (limited to 'client/index.js')
-rw-r--r--client/index.js34
1 files changed, 30 insertions, 4 deletions
diff --git a/client/index.js b/client/index.js
index 2ee12c14..a8783522 100644
--- a/client/index.js
+++ b/client/index.js
@@ -3,6 +3,8 @@ import ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'
import { Provider } from 'react-redux'
import Tabulator from 'tabulator-tables'
+import csv from 'parse-csv'
+// import parse from 'csv-parse'
import { toArray } from './util'
import Applet from './applet'
@@ -21,7 +23,7 @@ function appendReactApplet(el, payload) {
function appendTabulator(el, payload) {
const table = new Tabulator(el, {
height: '311px',
- layout: 'fitColumns',
+ layout: 'fitDataFill',
placeholder: 'No Data Set',
columns: payload.fields.split(', ').map(field => {
switch (field) {
@@ -38,9 +40,33 @@ function appendTabulator(el, payload) {
// {title:"Driver", field:"car", align:"center", formatter:"tickCross", sorter:"boolean"},
})
let path = payload.opt
- let columns = payload.fields.split(',').map(s => s.trim())
- console.log(path, columns)
- table.setData(path)
+ // let columns = payload.fields.split(',').map(s => s.trim())
+ // console.log(path, columns)
+ fetch('https://nyc3.digitaloceanspaces.com/megapixels/v1/datasets/lfw/assets/lfw_names_gender_kg_min.csv', { mode: 'cors' })
+ .then(r => r.text())
+ .then(text => {
+ const data = csv.toJSON(text, { headers: { included: true } })
+ console.log(data)
+ table.setData(data)
+ // const parser = parse()
+ // console.log(parser)
+ // parser.on('readable', () => {
+ // let record
+ // let output = []
+ // do {
+ // record = parser.read()
+ // if (record) output.push(record)
+ // } while (record)
+ // output.shift()
+ // table.setData(output)
+ // })
+ // parser.on('error', err => {
+ // console.error(err.message)
+ // })
+ // parser.write(data)
+ // parser.end()
+ // table.setData(path, null, xs{ method: 'get', mode: 'cors', cache: 'no-cache' })
+ })
}
function appendApplets() {