256ece27
Renato De Donato
new controllet
|
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
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
<link rel="import" href="../../bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="../../bower_components/paper-tabs/paper-tab.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animation.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animatable.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animations.html">
<link rel="import" href="../../bower_components/paper-tooltip/paper-tooltip.html">
<link rel="import" href="../filters-controllet/filters-controllet.html" />
<link rel="import" href="../aggregators-controllet/aggregators-controllet.html" />
<script type="text/javascript" src="../../alasql-utility/alasql.min.js"></script>
<script type="text/javascript" src="../../alasql-utility/alasql-utility.js"></script>
<dom-module id="expert-query-controllet">
<template>
<style is="custom-style">
#expert_container {
display: none;
height: 100%;
width: 100%;
}
#expert_container * {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
}
#expert_container #neon_container {
height: calc(100% - 48px);
width: 100%;
}
#header_open {
display: flex;
/*background: #B6B6B6;*/
/*border: 1px solid #b6b6b6;*/
/*height: 46px;*/
}
#expert_container paper-tabs {
/*height: 46px;*/
width: calc(100% - 48px);
}
#expert_container #query_container {
padding: 28px 8px 0px 8px;
}
#expert_container_close {
height: 48px;
width: 100%;
display: flex;
}
#expert_container_close * {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
}
#expert_container_close #header_close {
height: 24px;
width: calc(100% - 384px);
padding: 12px 0px;
text-align: center;
font-weight: 700;
color: #00BCD4;
background: #FFFFFF;
cursor: pointer;
}
#expert_container_close #space {
width: 192px;
}
paper-tooltip {
--paper-tooltip-background: black;
}
paper-tooltip p {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
margin: 0;
padding: 0;
}
paper-icon-button {
height: 48px;
width: 48px;
padding: 8px;
color: #2196F3;
--paper-icon-button-ink-color: #2196F3;
}
paper-icon-button.disabled{
color: #B6B6B6;
}
paper-icon-button[icon=fullscreen],
paper-icon-button[icon=fullscreen-exit] {
height: 48px;
width: 48px;
padding: 8px;
color: #00BCD4;
--paper-icon-button-ink-color: #00BCD4;
}
paper-icon-button[icon=fullscreen] {
margin-left: 48px;
}
paper-tabs {
background: #B6B6B6;
|
256ece27
Renato De Donato
new controllet
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
</paper-tabs>
<paper-icon-button icon="fullscreen-exit" on-click="_fullscreenExit"></paper-icon-button>
</div>
<neon-animated-pages id="neon_container" selected="{{tabIndex}}" entry-animation="fade-in-animation" exit-animation="fade-out-animation">
<neon-animatable>
<filters-controllet id="filters"></filters-controllet>
</neon-animatable>
<neon-animatable>
<aggregators-controllet id="aggregators"></aggregators-controllet>
</neon-animatable>
<neon-animatable>
<div id="query_container"></div>
</neon-animatable>
</neon-animated-pages>
</paper-material>
</template>
<script>
Polymer({
is : 'expert-query-controllet',
properties : {
tabIndex: {
type: Number,
value: -1
},
fields : {
type : Array,
value : []
},
selectedFields : {
type : Array,
value : []
},
filters : {
type : Array,
value : []
},
aggregators : {
type : Array,
value : []
}
},
listeners: {
'filters-controllet_filters': '_updateFilters',
'aggregators-controllet_aggregators': '_updateAggregators'
},
ready : function() {
},
attached : function() {
this._translate();
},
setFields : function(fields) {
this.fields = fields;
this.$.filters.setFields(fields);
this.$.aggregators.setFields(fields);
},
setSelectedFields : function(selectedFields) {
this.selectedFields = selectedFields;
this.$.filters.setSelectedFields(selectedFields);
this.$.aggregators.setSelectedFields(selectedFields);
this._updateQuery();
},
setFilters : function(filters) {
this.async(function() {
this.$.filters.setFilters(filters);
}, 0);
},
setAggregators : function(aggregators) {
this.async(function() {
this.$.aggregators.setAggregators(aggregators);
}, 0);
},
reset : function() {
this.$.filters.reset();
this.$.aggregators.reset();
this.fields = [];
this.selectedFields = [];
this.filters = [];
this.aggregators = [];
// this.query = "";
},
_translate : function() {
this.$.expert.innerHTML = ln["expert_" + ln["localization"]];
this.$.filtersTab.innerHTML = ln["filters_" + ln["localization"]];
this.$.groupByTab.innerHTML = ln["groupBy_" + ln["localization"]];
this.$.queryTab.innerHTML = ln["query_" + ln["localization"]];
this.$.tooltip_filters.innerHTML = ln["enableFilters_" + ln["localization"]];
this.$.tooltip_aggregators.innerHTML = ln["enableGroupBy_" + ln["localization"]];
},
_fullscreen : function() {
this.$.expert_container_close.style.display = "none";
this.$.expert_container.style.display = "block";
if(this.tabIndex == -1)
this.tabIndex = 0;
this.fire('expert-controllet_show', {show: true});
},
_fullscreenExit : function() {
this.$.expert_container_close.style.display = "flex";
this.$.expert_container.style.display = "none";
this.fire('expert-controllet_show', {show: false});
},
_updateFilters : function(e) {
this.filters = e.detail.filters;
this._updateQuery();
this._disableFiltersIcon(e.detail.filters);
},
_disableFilters : function() {
this.$.filters._disableFilters();
},
_disableFiltersIcon : function(filters) {
var classes = this.$.disable_filters.className;
if (filters.length > 1) {
this.$.disable_filters.className = classes.replace(" disabled", "");
this.$.tooltip_filters.innerHTML = ln["disableFilters_" + ln["localization"]];
}
else if (classes.indexOf("disabled") == -1) {
this.$.disable_filters.className = classes + " disabled";
this.$.tooltip_filters.innerHTML = ln["enableFilters_" + ln["localization"]];
}
},
_updateAggregators : function(e) {
this.aggregators = e.detail.aggregators;
this._updateQuery();
this._disableAggregatorsIcon(e.detail.aggregators);
},
_disableAggregators : function() {
this.$.aggregators._disableAggregators();
},
_disableAggregatorsIcon : function(aggregators) {
var classes = this.$.disable_aggregators.className;
if (aggregators.length > 0) {
this.$.disable_aggregators.className = classes.replace(" disabled", "");
this.$.tooltip_aggregators.innerHTML = ln["disableGroupBy_" + ln["localization"]];
}
else if (classes.indexOf("disabled") == -1) {
this.$.disable_aggregators.className = classes + " disabled";
this.$.tooltip_aggregators.innerHTML = ln["enableGroupBy_" + ln["localization"]];
}
},
_updateQuery : function() {
if(this.selectedFields.length)
this.$.query_container.innerHTML = alasql_QUERY_string(this.selectedFields, this.filters, this.aggregators, null)
.replace('SELECT', '<span style="color:#2196F3; font-weight: 700;">SELECT</span>')
// .replace('FROM ?', '<br><br><span style="color:#2196F3; font-weight: 700;">FROM</span> dataset')
.replace('FROM ?', '')
.replace('WHERE', '<br><br><span style="color:#2196F3; font-weight: 700;">WHERE</span>')
.replace('GROUP BY', '<br><br><span style="color:#2196F3; font-weight: 700;">GROUP BY</span>')
.replace(/\[/g, '')
.replace(/\]/g, '');
else
this.$.query_container.innerHTML = "";
}
});
</script>
</dom-module>
|