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" />
|
0af843be
Renato De Donato
filters + alasql
|
5
6
|
<link rel="import" href="../filters-controllet/filters-controllet.html" />
|
89558a41
Renato De Donato
datatype, provide...
|
7
8
9
10
11
12
13
|
<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>
<script type="text/javascript" src="../../bower_components/JSDataChecker/jsdatachecker.min.js"></script>
|
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
47
48
|
#select_data_controllet_container #filters_container {
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>
|
89558a41
Renato De Donato
datatype, provide...
|
67
|
<div id="filters_container">
|
0af843be
Renato De Donato
filters + alasql
|
68
69
|
<filters-controllet id="filters"></filters-controllet>
</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
86
|
value : undefined
// observer : '_init'
|
0af843be
Renato De Donato
filters + alasql
|
87
88
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
89
90
|
data : {
type : Object,
|
0af843be
Renato De Donato
filters + alasql
|
91
92
93
|
value : undefined
},
|
89558a41
Renato De Donato
datatype, provide...
|
94
95
96
97
|
filters : {
type : Array,
value : []
// value : [{logicalOperator: "OR"}, {field: "annee", operation: "=", value: "2014"}, {field: "annee", operation: "=", value: "2015"}]
|
98d9d8a5
Renato De Donato
filters+groupby
|
98
99
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
100
|
selectedFields : {
|
98d9d8a5
Renato De Donato
filters+groupby
|
101
|
type : Array,
|
a53fbbed
Renato De Donato
select-dataset ne...
|
102
|
value : []
|
89558a41
Renato De Donato
datatype, provide...
|
103
104
|
// value : [0,2,4]
}
|
0af843be
Renato De Donato
filters + alasql
|
105
106
107
108
|
},
listeners: {
|
89558a41
Renato De Donato
datatype, provide...
|
109
110
|
'filters-controllet_show': '_resizeFilters',
'select-fields-controllet_selected-fields': '_updateFields',
|
98d9d8a5
Renato De Donato
filters+groupby
|
111
|
'filters-controllet_filters': '_updateFilters'
|
0af843be
Renato De Donato
filters + alasql
|
112
113
114
|
},
ready : function() {
|
89558a41
Renato De Donato
datatype, provide...
|
115
|
this.showFilter = false;
|
0af843be
Renato De Donato
filters + alasql
|
116
117
118
119
120
121
|
},
attached : function(){
this._resize();
var that = this;
window.addEventListener("resize", function() { that._resize(); });
|
a53fbbed
Renato De Donato
select-dataset ne...
|
122
123
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
124
125
|
getSelectedFields : function() {
return utility_getSelectedFields(this.fields, this.selectedFields);;
|
0af843be
Renato De Donato
filters + alasql
|
126
127
|
},
|
98d9d8a5
Renato De Donato
filters+groupby
|
128
|
getFilters : function() {
|
89558a41
Renato De Donato
datatype, provide...
|
129
|
return this.filters;
|
98d9d8a5
Renato De Donato
filters+groupby
|
130
131
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
132
|
getData : function() {
|
0f4f5f1b
Renato De Donato
new datalets mult...
|
133
134
135
136
137
138
139
140
141
|
//return datatable.getData
//this.fields = "*"
var data = alasql_selectData(this.data, this.fields, this.filters);
var converter = new DataTypeConverter();
var result = converter.inferJsonDataType(data, ["*"]);
result = converter.cast(result);
data = result.dataset;
return data;
|
0af843be
Renato De Donato
filters + alasql
|
142
143
|
},
|
4f438cd9
Renato De Donato
datalets-modifier
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
setSelectedFields : function(selectedFields) {
this.async(function() {
var selectedIndices = utility_getSelectedIndices(this.fields, selectedFields);
console.log(selectedIndices);
this.$.select_fields.setSelectFields(selectedIndices);
}, 0);
},
setFilters : function(filters) {
this.async(function() {
this.$.filters.setFilters(filters);
}, 0);
},
|
89558a41
Renato De Donato
datatype, provide...
|
159
160
161
162
163
164
165
166
167
168
169
170
171
|
_resizeFilters : function() {
if(!this.showFilter) {
this.$.table_container.style.height = "calc(50% - 12px)";
this.$.filters_container.style.height = "calc(50% - 12px)";
}
else {
this.$.table_container.style.height = "calc(100% - 72px)";
this.$.filters_container.style.height = "48px";
}
this.$.data_table._resize();
this.showFilter = !this.showFilter;
|
0af843be
Renato De Donato
filters + alasql
|
172
173
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
174
175
176
177
178
179
|
_updateFields : function(e) {
this.selectedFields = e.detail.selectedFields;
var fields = utility_getSelectedFields(this.fields, this.selectedFields);
var data = alasql_selectData(this.data, fields, this.filters);
this.$.data_table.setData(data);
},
|
0af843be
Renato De Donato
filters + alasql
|
180
|
|
89558a41
Renato De Donato
datatype, provide...
|
181
182
183
184
185
|
_updateFilters : function(e) {
this.filters = e.detail.filters;
var fields = utility_getSelectedFields(this.fields, this.selectedFields);
var data = alasql_selectData(this.data, fields, this.filters);
this.$.data_table.setData(data);
|
0af843be
Renato De Donato
filters + alasql
|
186
187
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
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;
that.data = alasql_selectData(data, that.fields);
that.$.select_fields.setFields(that.fields);
that.$.filters.setFields(that.fields);
|
89558a41
Renato De Donato
datatype, provide...
|
212
|
|
a1dedcfa
Renato De Donato
worning x gg
|
213
214
215
216
|
that.fire('data-ready', {ready : true});
},
error: function(){
that.fire('data-ready', {ready : false});
|
89558a41
Renato De Donato
datatype, provide...
|
217
218
|
}
});
|
0314f487
Renato De Donato
filters opendatasoft
|
219
|
}
|
0af843be
Renato De Donato
filters + alasql
|
220
|
|
89558a41
Renato De Donato
datatype, provide...
|
221
222
|
else {
this.reset();
|
0af843be
Renato De Donato
filters + alasql
|
223
|
|
89558a41
Renato De Donato
datatype, provide...
|
224
225
226
227
228
229
230
231
232
|
var converter = new DataTypeConverter();
var result = converter.inferJsonDataType(this.data, ["*"]);
result = converter.cast(result);
this.fields = utility_getFields(result.types);
data = result.dataset;
this.data = alasql_selectData(data, this.fields);
this.$.select_fields.setFields(this.fields);
this.$.filters.setFields(this.fields);
|
89558a41
Renato De Donato
datatype, provide...
|
233
|
}
|
0af843be
Renato De Donato
filters + alasql
|
234
235
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
236
|
reset : function() {
|
89558a41
Renato De Donato
datatype, provide...
|
237
238
239
240
241
|
this.filters = [];
this.selectedFields = [];
this.$.select_fields.reset();
this.$.data_table.reset();
this.$.filters.reset();
|
98d9d8a5
Renato De Donato
filters+groupby
|
242
243
|
},
|
0af843be
Renato De Donato
filters + alasql
|
244
245
|
_resize : function(){
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
|
89558a41
Renato De Donato
datatype, provide...
|
246
247
|
h = h - 64 - 8; //height with page scroller + margin-top
$("#select_data_controllet_container").height(h);
|
0af843be
Renato De Donato
filters + alasql
|
248
249
250
251
252
253
254
|
}
});
</script>
</dom-module>
|