0af843be
Renato De Donato
filters + alasql
|
1
2
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
|
89558a41
Renato De Donato
datatype, provide...
|
3
4
|
<link rel="import" href="../select-fields-controllet/select-fields-controllet.html" />
<link rel="import" href="../data-table-controllet/data-table-controllet.html" />
|
256ece27
Renato De Donato
new controllet
|
5
|
<link rel="import" href="../expert-query-controllet/expert-query-controllet.html" />
|
0af843be
Renato De Donato
filters + alasql
|
6
|
|
89558a41
Renato De Donato
datatype, provide...
|
7
8
9
10
11
|
<link rel="import" href="../providers-utility-controllet/providers-utility-controllet.html" />
<script type="text/javascript" src="../../alasql-utility/alasql.min.js"></script>
<script type="text/javascript" src="../../alasql-utility/alasql-utility.js"></script>
|
706288a2
Renato De Donato
geojson incoming
|
12
|
<script type="text/javascript" src="../../bower_components/jsdatachecker/jsdatachecker.min.js"></script>
|
89558a41
Renato De Donato
datatype, provide...
|
13
|
|
0af843be
Renato De Donato
filters + alasql
|
14
15
16
|
<dom-module id="select-data-controllet">
<style is="custom-style">
|
89558a41
Renato De Donato
datatype, provide...
|
17
18
|
#select_data_controllet_container {
|
0af843be
Renato De Donato
filters + alasql
|
19
20
|
display: flex;
flex-direction: row;
|
89558a41
Renato De Donato
datatype, provide...
|
21
|
margin-top: 8px;
|
0af843be
Renato De Donato
filters + alasql
|
22
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
23
24
25
26
27
|
#select_data_controllet_container * {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
|
0af843be
Renato De Donato
filters + alasql
|
28
|
}
|
0af843be
Renato De Donato
filters + alasql
|
29
|
|
89558a41
Renato De Donato
datatype, provide...
|
30
31
32
33
34
35
36
37
38
39
|
#select_data_controllet_container #fields_container {
height: 100%;
width: 20%;
min-width: 192px;
}
#select_data_controllet_container #right_container {
height: 100%;
width: calc(80% - 24px);
margin-left: 24px;
|
0af843be
Renato De Donato
filters + alasql
|
40
41
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
42
43
|
#select_data_controllet_container #table_container {
height: calc(100% - 72px);
|
0af843be
Renato De Donato
filters + alasql
|
44
|
width: 100%;
|
0af843be
Renato De Donato
filters + alasql
|
45
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
46
|
|
256ece27
Renato De Donato
new controllet
|
47
|
#select_data_controllet_container #expert_container {
|
89558a41
Renato De Donato
datatype, provide...
|
48
|
height: 48px;
|
0af843be
Renato De Donato
filters + alasql
|
49
|
width: 100%;
|
89558a41
Renato De Donato
datatype, provide...
|
50
|
margin-top: 24px;
|
0af843be
Renato De Donato
filters + alasql
|
51
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
52
|
|
0af843be
Renato De Donato
filters + alasql
|
53
54
55
56
|
</style>
<template>
|
89558a41
Renato De Donato
datatype, provide...
|
57
58
59
60
61
62
63
64
65
|
<providers-utility-controllet></providers-utility-controllet>
<div id="select_data_controllet_container">
<div id="fields_container">
<select-fields-controllet id="select_fields"></select-fields-controllet>
</div>
<div id="right_container">
<div id="table_container">
<data-table-controllet id="data_table"></data-table-controllet>
|
0af843be
Renato De Donato
filters + alasql
|
66
|
</div>
|
256ece27
Renato De Donato
new controllet
|
67
68
|
<div id="expert_container">
<expert-query-controllet id="expert"></expert-query-controllet>
|
0af843be
Renato De Donato
filters + alasql
|
69
|
</div>
|
89558a41
Renato De Donato
datatype, provide...
|
70
|
</div>
|
0af843be
Renato De Donato
filters + alasql
|
71
72
|
</div>
|
89558a41
Renato De Donato
datatype, provide...
|
73
|
|
0af843be
Renato De Donato
filters + alasql
|
74
75
76
77
78
79
80
81
82
|
</template>
<script>
Polymer({
is : 'select-data-controllet',
properties : {
|
89558a41
Renato De Donato
datatype, provide...
|
83
|
dataUrl : {
|
0af843be
Renato De Donato
filters + alasql
|
84
|
type : String,
|
89558a41
Renato De Donato
datatype, provide...
|
85
|
value : undefined
|
0af843be
Renato De Donato
filters + alasql
|
86
87
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
88
89
|
data : {
type : Object,
|
0af843be
Renato De Donato
filters + alasql
|
90
91
92
|
value : undefined
},
|
89558a41
Renato De Donato
datatype, provide...
|
93
94
95
|
filters : {
type : Array,
value : []
|
98d9d8a5
Renato De Donato
filters+groupby
|
96
97
|
},
|
256ece27
Renato De Donato
new controllet
|
98
99
100
101
102
|
aggregators : {
type : Array,
value : []
},
|
89558a41
Renato De Donato
datatype, provide...
|
103
|
selectedFields : {
|
98d9d8a5
Renato De Donato
filters+groupby
|
104
|
type : Array,
|
a53fbbed
Renato De Donato
select-dataset ne...
|
105
|
value : []
|
89558a41
Renato De Donato
datatype, provide...
|
106
|
}
|
0af843be
Renato De Donato
filters + alasql
|
107
108
109
110
|
},
listeners: {
|
256ece27
Renato De Donato
new controllet
|
111
|
'expert-controllet_show': '_resizeExpertWindow',
|
89558a41
Renato De Donato
datatype, provide...
|
112
|
'select-fields-controllet_selected-fields': '_updateFields',
|
256ece27
Renato De Donato
new controllet
|
113
114
|
'filters-controllet_filters': '_updateFilters',
'aggregators-controllet_aggregators': '_updateAggregators'
|
0af843be
Renato De Donato
filters + alasql
|
115
116
117
|
},
ready : function() {
|
0af843be
Renato De Donato
filters + alasql
|
118
119
120
121
122
123
|
},
attached : function(){
this._resize();
var that = this;
window.addEventListener("resize", function() { that._resize(); });
|
a53fbbed
Renato De Donato
select-dataset ne...
|
124
125
|
},
|
256ece27
Renato De Donato
new controllet
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
getFields : function() {
if(this.aggregators && this.aggregators.length) {
var selectedFields = [];
for (var i = 0; i < this.aggregators.length; i++) {
if(this.aggregators[i]["operation"] == "GROUP BY")
selectedFields.push(this.aggregators[i]["field"]);
else
selectedFields.push(this.aggregators[i]["operation"] + "(" + this.aggregators[i]["field"] + ")");
}
return selectedFields;
}
return this.selectedFields;
},
|
89558a41
Renato De Donato
datatype, provide...
|
140
|
getSelectedFields : function() {
|
256ece27
Renato De Donato
new controllet
|
141
|
return this.selectedFields;
|
0af843be
Renato De Donato
filters + alasql
|
142
143
|
},
|
98d9d8a5
Renato De Donato
filters+groupby
|
144
|
getFilters : function() {
|
89558a41
Renato De Donato
datatype, provide...
|
145
|
return this.filters;
|
98d9d8a5
Renato De Donato
filters+groupby
|
146
147
|
},
|
256ece27
Renato De Donato
new controllet
|
148
149
150
151
|
getAggregators : function() {
return this.aggregators;
},
|
89558a41
Renato De Donato
datatype, provide...
|
152
|
getData : function() {
|
0f4f5f1b
Renato De Donato
new datalets mult...
|
153
|
var converter = new DataTypeConverter();
|
256ece27
Renato De Donato
new controllet
|
154
155
|
var data = alasql_QUERY(this.data, this.selectedFields, this.filters, null, null);
|
0f4f5f1b
Renato De Donato
new datalets mult...
|
156
157
158
159
|
var result = converter.inferJsonDataType(data, ["*"]);
result = converter.cast(result);
data = result.dataset;
|
256ece27
Renato De Donato
new controllet
|
160
161
162
163
164
165
166
|
if(this.aggregators && this.aggregators.length) {
data = alasql_QUERY(data, this.selectedFields, null, this.aggregators, null);
result = converter.inferJsonDataType(data, ["*"]);
result = converter.cast(result);
data = result.dataset;
}
|
0f4f5f1b
Renato De Donato
new datalets mult...
|
167
|
return data;
|
0af843be
Renato De Donato
filters + alasql
|
168
169
|
},
|
4f438cd9
Renato De Donato
datalets-modifier
|
170
171
172
|
setSelectedFields : function(selectedFields) {
this.async(function() {
var selectedIndices = utility_getSelectedIndices(this.fields, selectedFields);
|
4f438cd9
Renato De Donato
datalets-modifier
|
173
174
175
176
177
|
this.$.select_fields.setSelectFields(selectedIndices);
}, 0);
},
setFilters : function(filters) {
|
256ece27
Renato De Donato
new controllet
|
178
|
this.$.expert.setFilters(filters);
|
4f438cd9
Renato De Donato
datalets-modifier
|
179
180
|
},
|
256ece27
Renato De Donato
new controllet
|
181
182
183
184
185
186
|
setAggregators : function(aggregators) {
this.$.expert.setAggregators(aggregators);
},
_resizeExpertWindow : function(e) {
if(e.detail.show) {
|
89558a41
Renato De Donato
datatype, provide...
|
187
|
this.$.table_container.style.height = "calc(50% - 12px)";
|
256ece27
Renato De Donato
new controllet
|
188
|
this.$.expert_container.style.height = "calc(50% - 12px)";
|
89558a41
Renato De Donato
datatype, provide...
|
189
190
191
|
}
else {
this.$.table_container.style.height = "calc(100% - 72px)";
|
256ece27
Renato De Donato
new controllet
|
192
|
this.$.expert_container.style.height = "48px";
|
89558a41
Renato De Donato
datatype, provide...
|
193
194
195
|
}
this.$.data_table._resize();
|
0af843be
Renato De Donato
filters + alasql
|
196
197
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
198
|
_updateFields : function(e) {
|
256ece27
Renato De Donato
new controllet
|
199
200
201
202
203
|
var selectedFields = e.detail.selectedFields;
this.selectedFields = utility_getSelectedFields(this.fields, selectedFields);
this.$.data_table.setData(this.getData());
this.$.expert.setSelectedFields(this.selectedFields);
|
89558a41
Renato De Donato
datatype, provide...
|
204
|
},
|
0af843be
Renato De Donato
filters + alasql
|
205
|
|
89558a41
Renato De Donato
datatype, provide...
|
206
207
|
_updateFilters : function(e) {
this.filters = e.detail.filters;
|
256ece27
Renato De Donato
new controllet
|
208
209
210
211
212
213
|
this.$.data_table.setData(this.getData());
},
_updateAggregators : function(e) {
this.aggregators = e.detail.aggregators;
this.$.data_table.setData(this.getData());
|
0af843be
Renato De Donato
filters + alasql
|
214
215
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
init : function() {
if(this.dataUrl) {
var that = this;
$.ajax({
url: this.dataUrl,
dataType: "json",
success: function(data){
that.reset();
var f = Object.create(providerFactory);
var provider = f.getProvider(that.dataUrl);
data = provider.selectData(data);
var converter = new DataTypeConverter();
var result = converter.inferJsonDataType(data, ["*"]);
result = converter.cast(result);
that.fields = utility_getFields(result.types);
data = result.dataset;
|
420ea6ab
Renato De Donato
workcicle...
|
236
|
that.data = alasql_QUERY(data, that.fields, null, null, null);
|
89558a41
Renato De Donato
datatype, provide...
|
237
238
|
that.$.select_fields.setFields(that.fields);
|
256ece27
Renato De Donato
new controllet
|
239
240
|
that.$.expert.setFields(that.fields);
// that.$.expert.setSelectedFields(that.selectedFields);
|
89558a41
Renato De Donato
datatype, provide...
|
241
|
|
a1dedcfa
Renato De Donato
worning x gg
|
242
243
244
245
|
that.fire('data-ready', {ready : true});
},
error: function(){
that.fire('data-ready', {ready : false});
|
89558a41
Renato De Donato
datatype, provide...
|
246
247
|
}
});
|
0314f487
Renato De Donato
filters opendatasoft
|
248
|
}
|
0af843be
Renato De Donato
filters + alasql
|
249
|
|
89558a41
Renato De Donato
datatype, provide...
|
250
251
|
else {
this.reset();
|
0af843be
Renato De Donato
filters + alasql
|
252
|
|
89558a41
Renato De Donato
datatype, provide...
|
253
254
255
256
257
|
var converter = new DataTypeConverter();
var result = converter.inferJsonDataType(this.data, ["*"]);
result = converter.cast(result);
this.fields = utility_getFields(result.types);
data = result.dataset;
|
420ea6ab
Renato De Donato
workcicle...
|
258
|
this.data = alasql_QUERY(data, this.fields, null, null, null);
|
89558a41
Renato De Donato
datatype, provide...
|
259
260
|
this.$.select_fields.setFields(this.fields);
|
256ece27
Renato De Donato
new controllet
|
261
262
|
this.$.expert.setFields(this.fields);
// this.$.expert.setSelectedFields(this.selectedFields);
|
89558a41
Renato De Donato
datatype, provide...
|
263
|
}
|
0af843be
Renato De Donato
filters + alasql
|
264
265
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
266
|
reset : function() {
|
89558a41
Renato De Donato
datatype, provide...
|
267
|
this.filters = [];
|
256ece27
Renato De Donato
new controllet
|
268
|
this.aggregators = [];
|
89558a41
Renato De Donato
datatype, provide...
|
269
270
271
|
this.selectedFields = [];
this.$.select_fields.reset();
this.$.data_table.reset();
|
256ece27
Renato De Donato
new controllet
|
272
|
this.$.expert.reset();
|
98d9d8a5
Renato De Donato
filters+groupby
|
273
274
|
},
|
0af843be
Renato De Donato
filters + alasql
|
275
276
|
_resize : function(){
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
|
89558a41
Renato De Donato
datatype, provide...
|
277
278
|
h = h - 64 - 8; //height with page scroller + margin-top
$("#select_data_controllet_container").height(h);
|
0af843be
Renato De Donato
filters + alasql
|
279
280
281
282
283
284
285
|
}
});
</script>
</dom-module>
|