-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
149 lines (139 loc) · 4.84 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
require('../../css/table-twbs.css');
var React = require('react');
var { DataTable } = require('react-data-components');
var d3 = require('d3');
var _ = require('lodash');
var App = React.createClass({
getInitialState(){
/*var data = this.props.rows.map((item, i) => {
item.ukey = i;
return item;
});*/
return {
tableColumns: this.props.cols,
data: this.props.data,
loading: 'loading false'
}
},
handleChange(data) {
console.log(data);
this.setState({
data: data
});
// console.log('Change', data);
},
handleClick() {
this.setState({
data: [
{
type: '*',
value: '*some.com',
},
{
type: 'app',
value: '*df.com',
},
{
type: 'site',
value: 'site.com',
}
]
});
},
handleState() {
this.setState({
loading: 'loading true'
});
},
render() {
return (
<div>
<button onClick={this.handleClick}>Change data</button>
<button onClick={this.handleState}>Change state</button>
<div>{this.state.loading}</div>
<DataTable
className="container"
keys={['ukey']}
columns={this.state.tableColumns}
initialData={this.state.data}
initialPageLength={5}
initialSortBy={{ prop: 'type', order: 'ascending' }}
pageLengthOptions={[5, 20, 50]}
onChange={this.handleChange}
/>
<pre>
<code>
{JSON.stringify(this.state.data, null, 2)}
</code>
</pre>
</div>
);
}
});
d3.csv('/555_TEST.csv', function (d) {
return d;
}, function (error, rows) {
// var data = _.uniq(rows);
var cols = [
{
title: 'type',
prop: 'type',
type: 'STRING',
sort: true,
search: true,
defaultContent: '*',
defaultValue: '*',
editor: {
type: 'dropdown',
options: [
{ label: '*', value: '*' },
{ label: 'app', value: 'app' },
{ label: 'site', value: 'site' }
]
}
},
{
title: 'Domain',
prop: 'value',
type: 'STRING',
sort: true,
search: true,
defaultContent: '<domain>',
editor: {
type: 'text'
}
},
];
React.render(<App data={[]} cols={cols}/>, document.body);
});
/*
[
{ title: 'Domain', prop: 'domain', validation: /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/,sort: true, search: true, defaultContent: '<name>' },
{ title: 'City', prop: 'city', sort: true, editable: false, defaultContent: '<city>' },
{ title: 'Street address', prop: 'address', defaultContent: '<street>' },
{ title: 'Phone', prop: 'phone', defaultContent: '<no phone>' }
],
[
{ ukey: 1, domain: 'google.com', city: 'city value2', address: 'address value', phone: '1,000,000' },
{ ukey: 2, domain: 'google.com', city: 'city value5', address: 'address value', phone: '9' },
{ ukey: 3, domain: 'google.com', city: 'city value1', address: 'address value', phone: '1' },
{ ukey: 4, domain: 'google.com', city: 'city value1', address: 'address value', phone: '300' },
{ ukey: 5, domain: 'google.com', city: 'city value1', address: 'address value', phone: '500' },
{ ukey: 6, domain: 'google.com', city: 'city value6', address: 'address value', phone: '9,999' },
{ ukey: 7, domain: 'ddd.val', city: 'city value6', address: 'address value', phone: '9,999' },
{ ukey: 8, domain: 'aadsw.val', city: 'city value2', address: 'address value', phone: '1,000,000' },
{ ukey: 9, domain: 'basdfa.val', city: 'city value5', address: 'address value', phone: '9' },
{ ukey: 10, domain: 'cadx.val', city: 'city value1', address: 'address value', phone: '1' },
{ ukey: 11, domain: 'wertw.val', city: 'city value1', address: 'address value', phone: '300' },
{ ukey: 12, domain: 'aadf.val', city: 'city value1', address: 'address value', phone: '500' },
{ ukey: 13, domain: 'ddd.va', city: 'city value6', address: 'address value', phone: '9,999' },
{ ukey: 14, domain: 'ddd.val', city: 'city value6', address: 'address value', phone: '9,999' },
{ ukey: 15, domain: 'aadsw.al', city: 'city value2', address: 'address value', phone: '1,000,000' },
{ ukey: 16, domain: 'basdfa.va', city: 'city value5', address: 'address value', phone: '9' },
{ ukey: 17, domain: 'cadx.va', city: 'city value1', address: 'address value', phone: '1' },
{ ukey: 18, domain: 'wertw.va', city: 'city value1', address: 'address value', phone: '300' },
{ ukey: 19, domain: 'aadf.val', city: 'city value1', address: 'address value', phone: '500' },
{ ukey: 20, domain: 'ddd.val', city: 'city value6', address: 'address value', phone: '9,999' },
{ ukey: 21, domain: 'ddd.al', city: 'city value6', address: 'address value', phone: '9,999' },
{ ukey: 22, domain: 'ddd.val', city: 'city value6', address: 'address value', phone: '9,999' }
]*/