93ba7167
Renato De Donato
filters bug fix + ln
|
1
2
3
4
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
|
93ba7167
Renato De Donato
filters bug fix + ln
|
5
6
|
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
|
93ba7167
Renato De Donato
filters bug fix + ln
|
7
|
<link rel="import" href="../items-vslider-controllet/items-vslider-controllet.html" />
|
256ece27
Renato De Donato
new controllet
|
8
9
10
11
|
<link rel="import" href="../select-inputs-controllet/select-inputs-controllet.html" />
<link rel="import" href="../datalet-preview-controllet/datalet-preview-controllet.html" />
<script type="text/javascript" src="../../bower_components/jsdatachecker/jsdatachecker.min.js"></script>
|
93ba7167
Renato De Donato
filters bug fix + ln
|
12
13
14
|
<script src="../../../DEEPCLIENT/js/deepClient.js"></script>
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
15
|
<dom-module id="select-visualization-controllet">
|
93ba7167
Renato De Donato
filters bug fix + ln
|
16
17
18
19
|
<template>
<style is="custom-style">
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
20
|
#select_visualization_container {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
21
|
display: flex;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
22
23
24
|
margin-top: 8px;
}
|
256ece27
Renato De Donato
new controllet
|
25
26
27
28
|
#select_visualization_container * {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
29
30
|
}
|
256ece27
Renato De Donato
new controllet
|
31
|
#items_vslider_container {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
32
|
position: relative;
|
256ece27
Renato De Donato
new controllet
|
33
|
width: 172px;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
34
35
|
}
|
256ece27
Renato De Donato
new controllet
|
36
|
#select_inputs_container {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
37
|
position: relative;
|
256ece27
Renato De Donato
new controllet
|
38
|
width: calc(50% - 12px - 172px - 24px);
|
93ba7167
Renato De Donato
filters bug fix + ln
|
39
|
min-width: 258px;
|
256ece27
Renato De Donato
new controllet
|
40
|
margin-left: 24px;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
41
42
|
}
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
43
|
#datalet_preview_container {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
44
|
position: relative;
|
256ece27
Renato De Donato
new controllet
|
45
46
|
width: calc(50% - 12px);
margin-left: 24px;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
47
48
|
}
|
256ece27
Renato De Donato
new controllet
|
49
50
51
52
53
|
/*#datalet_placeholder {*/
/*width: calc(100% - 32px);*/
/*height: calc(100% - 48px - 32px);*/
/*padding: 16px;*/
/*}*/
|
93ba7167
Renato De Donato
filters bug fix + ln
|
54
|
|
256ece27
Renato De Donato
new controllet
|
55
56
57
58
59
60
61
|
/*.header {*/
/*height: 24px;*/
/*padding: 12px;*/
/*text-align: center;*/
/*font-weight: 700;*/
/*background-color: #B6B6B6;*/
/*}*/
|
93ba7167
Renato De Donato
filters bug fix + ln
|
62
|
|
93ba7167
Renato De Donato
filters bug fix + ln
|
63
64
|
paper-button {
position: absolute;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
65
66
|
height: 48px;
width: 172px;
|
256ece27
Renato De Donato
new controllet
|
67
68
69
|
padding: 12px;
background: #00BCD4;
color: #FFFFFF;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
70
|
font-weight: 700;
|
256ece27
Renato De Donato
new controllet
|
71
72
73
74
75
76
|
/*bottom: 16px;*/
/*right: 11px;*/
top: -56px;
right: 0;
margin: 0 16px;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
77
78
79
80
81
82
83
84
85
86
87
88
89
|
}
paper-button:hover {
background-color: #00AABF;
box-shadow: 0px 8px 12px #888;
-webkit-box-shadow: 0px 8px 12px #888;
-moz-box-shadow: 0px 8px 12px #888;
}
paper-button[disabled] {
background-color: #B6B6B6;
}
|
93ba7167
Renato De Donato
filters bug fix + ln
|
90
91
92
93
|
</style>
<iron-ajax id="selectedDatalet_request" on-response="_handleSelectedDatalet"></iron-ajax>
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
94
|
<div id="select_visualization_container">
|
93ba7167
Renato De Donato
filters bug fix + ln
|
95
|
|
256ece27
Renato De Donato
new controllet
|
96
97
|
<div id="items_vslider_container">
<items-vslider-controllet id="vslider" datalets-list-url="{{dataletsListUrl}}"></items-vslider-controllet>
|
93ba7167
Renato De Donato
filters bug fix + ln
|
98
99
|
</div>
|
256ece27
Renato De Donato
new controllet
|
100
101
|
<div id="select_inputs_container">
<select-inputs-controllet id="inputs"></select-inputs-controllet>
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
102
|
</div>
|
93ba7167
Renato De Donato
filters bug fix + ln
|
103
|
|
256ece27
Renato De Donato
new controllet
|
104
105
|
<div id="datalet_preview_container">
<datalet-preview-controllet id="preview" deep-url="{{deepUrl}}" datalets-list-url="{{dataletsListUrl}}"></datalet-preview-controllet>
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
106
|
</div>
|
93ba7167
Renato De Donato
filters bug fix + ln
|
107
|
|
256ece27
Renato De Donato
new controllet
|
108
|
<paper-button id="add_button" disabled raised on-click="_addDatalet"></paper-button>
|
93ba7167
Renato De Donato
filters bug fix + ln
|
109
|
|
256ece27
Renato De Donato
new controllet
|
110
111
|
<!--<paper-material id="datalet_preview_container" elevation="5">-->
<!--<div class="header"><span id="dataletPreview"></span></div>-->
|
93ba7167
Renato De Donato
filters bug fix + ln
|
112
|
|
256ece27
Renato De Donato
new controllet
|
113
|
<!--<div id="datalet_placeholder"></div>-->
|
93ba7167
Renato De Donato
filters bug fix + ln
|
114
|
|
256ece27
Renato De Donato
new controllet
|
115
|
<!--</paper-material>-->
|
93ba7167
Renato De Donato
filters bug fix + ln
|
116
|
|
93ba7167
Renato De Donato
filters bug fix + ln
|
117
118
119
120
121
122
123
124
|
</div>
</template>
<script>
Polymer({
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
125
|
is : 'select-visualization-controllet',
|
93ba7167
Renato De Donato
filters bug fix + ln
|
126
127
128
129
130
131
132
133
134
135
136
137
138
|
properties : {
deepUrl : {
type : String,
value : undefined
},
dataletsListUrl : {
type : String,
value : undefined
},
|
256ece27
Renato De Donato
new controllet
|
139
|
dataUrl : {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
140
141
142
143
|
type : String,
value : undefined
},
|
256ece27
Renato De Donato
new controllet
|
144
145
|
data : {
type : Object,
|
93ba7167
Renato De Donato
filters bug fix + ln
|
146
147
148
|
value : undefined
},
|
256ece27
Renato De Donato
new controllet
|
149
|
selectedFields : {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
150
151
152
153
|
type : Array,
value : []
},
|
256ece27
Renato De Donato
new controllet
|
154
|
filters : {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
155
156
157
158
|
type : Array,
value : []
},
|
256ece27
Renato De Donato
new controllet
|
159
|
aggregators : {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
160
161
162
163
|
type : Array,
value : []
},
|
256ece27
Renato De Donato
new controllet
|
164
165
166
167
|
// orders : {
// type : Array,
// value : []
// },
|
93ba7167
Renato De Donato
filters bug fix + ln
|
168
|
|
256ece27
Renato De Donato
new controllet
|
169
|
selectedDatalet : {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
170
171
172
173
|
type : String,
value : undefined
},
|
256ece27
Renato De Donato
new controllet
|
174
175
176
|
dataletType : {
type : String,
value : undefined
|
89558a41
Renato De Donato
datatype, provide...
|
177
178
|
},
|
256ece27
Renato De Donato
new controllet
|
179
180
|
preselectedDatalet : {
type : String,
|
89558a41
Renato De Donato
datatype, provide...
|
181
182
|
value : undefined
},
|
93ba7167
Renato De Donato
filters bug fix + ln
|
183
|
|
256ece27
Renato De Donato
new controllet
|
184
185
186
187
188
|
dataletPreset : {
type : Object,
value : []
}
|
93ba7167
Renato De Donato
filters bug fix + ln
|
189
190
191
|
},
listeners: {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
192
|
'items-vslider-controllet_selected-datalet': '_selectDatalet',
|
256ece27
Renato De Donato
new controllet
|
193
|
'select-inputs_isReady': '_loadDatalet'
|
93ba7167
Renato De Donato
filters bug fix + ln
|
194
195
196
|
},
ready : function() {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
197
198
199
200
201
202
203
204
205
206
207
|
},
attached : function() {
this._resize();
var that = this;
window.addEventListener("resize", function() { that._resize(); });
this._translate();
},
setFilters : function(filters) {
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
208
|
this.filters = this._copy(filters);
|
93ba7167
Renato De Donato
filters bug fix + ln
|
209
210
|
},
|
256ece27
Renato De Donato
new controllet
|
211
212
213
|
setAggregators : function(aggregators) {
this.aggregators = this._copy(aggregators);
},
|
a53fbbed
Renato De Donato
select-dataset ne...
|
214
|
|
256ece27
Renato De Donato
new controllet
|
215
216
217
|
// setOrders : function(orders) {
// this.orders = this._copy(orders);
// },
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
218
|
|
256ece27
Renato De Donato
new controllet
|
219
220
|
setSelectedFields : function(selectedFields) {
this.selectedFields = this._copy(selectedFields);
|
93ba7167
Renato De Donato
filters bug fix + ln
|
221
222
|
},
|
89558a41
Renato De Donato
datatype, provide...
|
223
224
|
setData : function(data) {
this.data = this._copy(data);
|
89558a41
Renato De Donato
datatype, provide...
|
225
|
|
256ece27
Renato De Donato
new controllet
|
226
227
228
229
230
|
var converter = new DataTypeConverter();
var result = converter.inferJsonDataType(data, ["*"]);
result = converter.cast(result);
this.$.inputs.setFields(ArrayUtils.toFieldsArray(result.types));
this.$.vslider.setEnabledDatalets(ArrayUtils.toFieldsArray(result.types));
|
a53fbbed
Renato De Donato
select-dataset ne...
|
231
232
|
},
|
256ece27
Renato De Donato
new controllet
|
233
234
235
|
init : function() {
if(this.selectedDatalet !== undefined)
this.$.vslider.reset();// fire _selectDatalet undefined
|
93ba7167
Renato De Donato
filters bug fix + ln
|
236
237
238
|
},
_translate : function(){
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
239
240
241
242
|
if(this.preselectedDatalet)
this.$.add_button.innerHTML = ln["modifyDatalet_" + ln["localization"]];
else
this.$.add_button.innerHTML = ln["addDatalet_" + ln["localization"]];
|
93ba7167
Renato De Donato
filters bug fix + ln
|
243
244
245
|
},
_selectDatalet : function(e){
|
93ba7167
Renato De Donato
filters bug fix + ln
|
246
247
|
this.selectedDatalet = e.detail.datalet;
|
256ece27
Renato De Donato
new controllet
|
248
249
250
|
this.$.add_button.setAttribute("disabled", "true");
this.$.preview.eraseDatalet();
this.$.preview.eraseInfo();
|
93ba7167
Renato De Donato
filters bug fix + ln
|
251
|
|
256ece27
Renato De Donato
new controllet
|
252
|
if(this.selectedDatalet) {
|
93ba7167
Renato De Donato
filters bug fix + ln
|
253
254
|
this.$.selectedDatalet_request.url = this.deepUrl + e.detail.datalet + "-datalet";
this.$.selectedDatalet_request.generateRequest();
|
93ba7167
Renato De Donato
filters bug fix + ln
|
255
|
}
|
256ece27
Renato De Donato
new controllet
|
256
257
258
259
|
else {
this.dataletType = undefined;
this.$.inputs._reset();
}
|
93ba7167
Renato De Donato
filters bug fix + ln
|
260
261
|
},
|
93ba7167
Renato De Donato
filters bug fix + ln
|
262
|
_handleSelectedDatalet : function(e){
|
256ece27
Renato De Donato
new controllet
|
263
|
this.$.preview.loadInfo(e.detail.response);
|
93ba7167
Renato De Donato
filters bug fix + ln
|
264
|
|
256ece27
Renato De Donato
new controllet
|
265
266
267
|
if(this.dataletType != e.detail.response.type) {
this.dataletType = e.detail.response.type;
this.$.inputs.setInputs(e.detail.response.idm);
|
93ba7167
Renato De Donato
filters bug fix + ln
|
268
269
|
}
else {
|
256ece27
Renato De Donato
new controllet
|
270
|
this.$.inputs._fire();
|
93ba7167
Renato De Donato
filters bug fix + ln
|
271
|
}
|
93ba7167
Renato De Donato
filters bug fix + ln
|
272
273
|
},
|
256ece27
Renato De Donato
new controllet
|
274
275
276
277
278
279
280
281
|
preselect : function() {
if(this.preselectedDatalet) {
this.$.vslider.preselectDatalet(this.preselectedDatalet);
this.async(function () {
this.$.inputs._preselectInputs(this.dataletPreset);
this.preselectedDatalet = undefined;
}, 100);
}
|
93ba7167
Renato De Donato
filters bug fix + ln
|
282
283
|
},
|
9819a403
Renato De Donato
bubble scatter tr...
|
284
285
|
_loadDatalet : function(e){
if(!e.detail.isReady) {
|
256ece27
Renato De Donato
new controllet
|
286
|
this.$.preview.eraseDatalet();
|
9819a403
Renato De Donato
bubble scatter tr...
|
287
288
289
|
return;
}
|
256ece27
Renato De Donato
new controllet
|
290
|
this.params = {'data-url' : this.dataUrl};/*???*/
|
a53fbbed
Renato De Donato
select-dataset ne...
|
291
|
|
256ece27
Renato De Donato
new controllet
|
292
|
// this.selectedFields = ["pippi", "baudo"];
|
0f4f5f1b
Renato De Donato
new datalets mult...
|
293
|
|
256ece27
Renato De Donato
new controllet
|
294
|
this.params["selectedfields"] = JSON.stringify(this.$.inputs.getSelectedInputs());
|
93ba7167
Renato De Donato
filters bug fix + ln
|
295
|
this.params["filters"] = JSON.stringify(this.filters);
|
256ece27
Renato De Donato
new controllet
|
296
297
|
this.params["aggregators"] = JSON.stringify(this.aggregators);
this.params["orders"] = JSON.stringify(this.$.inputs.getOrders());
|
93ba7167
Renato De Donato
filters bug fix + ln
|
298
|
|
382b55e7
Renato De Donato
ortelio
|
299
300
|
this.params["export_menu"] = "0";
|
256ece27
Renato De Donato
new controllet
|
301
|
var params = this.$.inputs.getSelectedOptions();
|
fb05b400
Renato De Donato
controllet 2.0, n...
|
302
|
for (var key in params) { this.params[key] = params[key]; }
|
93ba7167
Renato De Donato
filters bug fix + ln
|
303
|
|
0f4f5f1b
Renato De Donato
new datalets mult...
|
304
|
//use cache
|
256ece27
Renato De Donato
new controllet
|
305
306
307
308
309
|
var selectedFields = this.$.inputs.getSelectedInputs();
var fields = [];
for (var i=0; i < selectedFields.length; i++)
if (selectedFields[i])
fields.push(selectedFields[i].value);
|
166db682
Renato De Donato
converter 3 times :(
|
310
311
|
var converter = new DataTypeConverter();
|
256ece27
Renato De Donato
new controllet
|
312
313
|
var data = alasql_QUERY(this.data, fields, null, null, this.$.inputs.getOrders());
|
166db682
Renato De Donato
converter 3 times :(
|
314
315
316
317
|
var result = converter.inferJsonDataType(data, ["*"]);
result = converter.cast(result);
data = result.dataset;
|
256ece27
Renato De Donato
new controllet
|
318
|
data = alasql_transformData(data, fields, true);
|
166db682
Renato De Donato
converter 3 times :(
|
319
|
|
38197df0
Renato De Donato
use cache preview...
|
320
321
|
this.params["data"] = JSON.stringify(data).replace(/'/g, "'");
//
|
89558a41
Renato De Donato
datatype, provide...
|
322
|
|
93ba7167
Renato De Donato
filters bug fix + ln
|
323
|
var dataletParams ={
|
89558a41
Renato De Donato
datatype, provide...
|
324
|
component: this.selectedDatalet+"-datalet",
|
89558a41
Renato De Donato
datatype, provide...
|
325
|
fields: this.selectedFields,
|
256ece27
Renato De Donato
new controllet
|
326
327
|
params: this.params
// placeHolder: this.$.datalet_placeholder
|
93ba7167
Renato De Donato
filters bug fix + ln
|
328
329
|
};
|
256ece27
Renato De Donato
new controllet
|
330
331
332
333
|
// ComponentService.deep_url = this.deepUrl;
// ComponentService.getComponent(dataletParams);
this.$.preview.loadDatalet(dataletParams);
|
93ba7167
Renato De Donato
filters bug fix + ln
|
334
335
336
337
338
|
this.$.add_button.removeAttribute("disabled");
},
_addDatalet : function(){
|
256ece27
Renato De Donato
new controllet
|
339
340
|
var staticData = this.params["data"];
|
8c43b0b4
Renato De Donato
remove cache on a...
|
341
|
delete this.params["data"];
|
256ece27
Renato De Donato
new controllet
|
342
|
delete this.params["export_menu"];
|
9124e8df
Renato De Donato
export_menu bug fix
|
343
|
|
93ba7167
Renato De Donato
filters bug fix + ln
|
344
|
var data = {
|
89558a41
Renato De Donato
datatype, provide...
|
345
|
dataUrl: this.dataUrl,
|
89558a41
Renato De Donato
datatype, provide...
|
346
|
datalet: this.selectedDatalet+"-datalet",
|
4cbf1380
Renato De Donato
preview cache
|
347
348
|
fields: this.selectedFields,
params: this.params,
|
256ece27
Renato De Donato
new controllet
|
349
|
staticData: staticData
|
93ba7167
Renato De Donato
filters bug fix + ln
|
350
351
352
|
}
this.fire('data-sevc-controllet.dataletCreated', {data : data});
|
93ba7167
Renato De Donato
filters bug fix + ln
|
353
354
|
},
|
93ba7167
Renato De Donato
filters bug fix + ln
|
355
356
357
358
359
360
361
362
363
364
|
_copy : function(o) {
var out, v, key;
out = Array.isArray(o) ? new Array(o.length) : {};
for (key in o) {
v = o[key];
out[key] = (typeof v === "object") ? this._copy(v) : v;
}
return out;
},
|
93ba7167
Renato De Donato
filters bug fix + ln
|
365
366
367
368
|
_resize : function(){
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
h = h - 64 - 8; //height with page scroller
|
256ece27
Renato De Donato
new controllet
|
369
370
371
|
$("#items_vslider_container").height(h);
$("#select_inputs_container").height(h);
$("#datalet_preview_container").height(h);
|
93ba7167
Renato De Donato
filters bug fix + ln
|
372
373
374
375
376
377
378
|
}
});
</script>
</dom-module>
|