Commit 0760b53c2e730d2fc162b6ac66d953097e0e5c57

Authored by Renato De Donato
1 parent 1241a415

warning ICONZ

controllets/data-table-controllet/data-table-controllet.html
... ... @@ -43,6 +43,15 @@
43 43 height: 24px;
44 44 width: 24px;
45 45 cursor: pointer;
  46 + /*background: green;*/
  47 + }
  48 +
  49 + paper-icon-button.warning {
  50 + height: 24px;
  51 + width: 24px;
  52 + color: #FFEB3B;
  53 + cursor: help;
  54 + /*background: green;*/
46 55 }
47 56  
48 57 paper-icon-button.order:hover {
... ... @@ -100,6 +109,7 @@
100 109 padding: 12px;
101 110 text-align: center;
102 111 max-width: 224px;
  112 + min-width: 156px;
103 113 overflow: hidden;
104 114 white-space: nowrap;
105 115 text-overflow: ellipsis;
... ... @@ -111,6 +121,18 @@
111 121 color: #FFFFFF;
112 122 font-weight: 700;
113 123 cursor: help;
  124 + line-height: 0px;/*?? or49px su spod iron icon and paper icon icon problem*/
  125 + }
  126 +
  127 + #data_table_container th .th_label {
  128 + display: inline-block;
  129 + height: 24px;
  130 + max-width: calc(100% - 48px - 8px);
  131 + vertical-align: middle;
  132 + /*background: red;*/
  133 + overflow: hidden;
  134 + white-space: nowrap;
  135 + text-overflow: ellipsis;
114 136 }
115 137  
116 138 #data_table_container td {
... ... @@ -185,7 +207,12 @@
185 207  
186 208 <paper-material id="data_table_container" elevation="5">
187 209  
188   - <div id="header"><span id="selected_data"></span></div>
  210 + <div id="header">
  211 + <span id="selected_data"></span>
  212 + <template is="dom-if" if={{hasWarnings}}>
  213 + <paper-icon-button class="warning" icon="warning"></paper-icon-button>
  214 + </template>
  215 + </div>
189 216  
190 217 <paper-tooltip id="tooltip_wornings" for="header" offset="56">
191 218 <template is="dom-repeat" items="{{fields}}">
... ... @@ -202,7 +229,10 @@
202 229 <tr>
203 230 <template is="dom-repeat" items="{{fields}}">
204 231 <th id="id_{{index}}">
205   - {{item.name}}
  232 + <div class="th_label">{{item.name}}</div>
  233 + <template is="dom-if" if={{item.errorsDescription.length}}>
  234 + <paper-icon-button class="warning" icon="warning"></paper-icon-button>
  235 + </template>
206 236 <paper-icon-button id="{{index}}" class="order" on-click="_order" icon="unfold-more"></paper-icon-button>
207 237 </th>
208 238 </template>
... ... @@ -319,7 +349,6 @@
319 349 var result = converter.inferJsonDataType(data, ["*"]);
320 350 result = converter.cast(result);
321 351 this.fields = ArrayUtils.toFieldsArray(result.types);
322   -// console.log(this.fields);
323 352 this.data = result.dataset;
324 353  
325 354 this.filter = "";
... ... @@ -333,11 +362,16 @@
333 362 this.shownNext = Math.min(this.next, this.length);
334 363 this.shownData = this.data.slice(this.prev-1, this.next);
335 364  
336   - this._resize();
  365 + this.hasWarnings = this._hasWarnings();
337 366  
338 367 this.async(function() {
339   - this.$.tooltip_wornings.show();
340   - }, 100);
  368 + if(this.hasWarnings)
  369 + this.$.tooltip_wornings.show();
  370 + else
  371 + this.$.tooltip_wornings.hide();
  372 + }, 1);
  373 +
  374 + this._resize();
341 375 },
342 376  
343 377 reset : function(){
... ... @@ -435,7 +469,6 @@
435 469 },
436 470  
437 471 _sort_by : function(field, reverse, primer){
438   -
439 472 var key = primer ?
440 473 function(x) {return primer(x[field])} :
441 474 function(x) {return x[field]};
... ... @@ -460,6 +493,13 @@
460 493 return "id_" + index;
461 494 },
462 495  
  496 + _hasWarnings: function() {
  497 + for (var i in this.fields)
  498 + if (this.fields[i].errorsDescription.length)
  499 + return true;
  500 + return false;
  501 + },
  502 +
463 503 _isObject: function(item) {
464 504 if(item.value instanceof Array)
465 505 return false;
... ...
controllets/select-data-controllet/select-data-controllet_old.html deleted
1   -<link rel="import" href="../../bower_components/polymer/polymer.html" />
2   -
3   -<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
4   -
5   -<link rel="import" href="../tree-view-controllet/tree-view-controllet.html" />
6   -<link rel="import" href="../multi-table-controllet/multi-table-controllet.html" />
7   -<link rel="import" href="../filters-controllet/filters-controllet.html" />
8   -
9   -<dom-module id="select-data-controllet">
10   -
11   - <style is="custom-style">
12   - .div_container {
13   - display: flex;
14   - flex-direction: row;
15   - }
16   - #material_tree_view {
17   - position: relative;
18   - width: 25%;
19   - min-width: 200px;
20   - height: 100vh;
21   - }
22   - #material_multi_table_filters {
23   - position: relative;
24   - width: 75%;
25   -
26   - margin-left: 64px;
27   - margin-top: 8px;
28   - }
29   -
30   - #div_multi_table {
31   - height: 70%;
32   - width: 100%;
33   - position: relative;
34   - }
35   - #div_filters {
36   - height: 30%;
37   - width: 100%;
38   - position: relative;
39   - }
40   - </style>
41   -
42   - <template>
43   -
44   - <div class="div_container">
45   - <paper-material id="material_tree_view" elevation="5">
46   - <tree-view-controllet id="tree_view" root-name={{rootName}} opened-path={{openedPath}} preselected-fields={{preselectedFields}}></tree-view-controllet>
47   - </paper-material>
48   - <paper-material id="material_multi_table_filters" elevation="5">
49   - <div id="div_multi_table">
50   - <multi-table-controllet id="multi_table" data-url={{dataUrl}}></multi-table-controllet>
51   - </div>
52   - <div id="div_filters">
53   - <filters-controllet id="filters"></filters-controllet>
54   - </div>
55   - </paper-material>
56   - </div>
57   -
58   - </template>
59   -
60   - <script>
61   - Polymer({
62   -
63   - is : 'select-data-controllet',
64   -
65   - properties : {
66   -
67   - rootName : {
68   - type : String,
69   - value : "root"
70   - },
71   -
72   - preselectedFields : {
73   - type : Array,
74   - value : []
75   - },
76   -
77   - openedPath : {
78   - type : String,
79   - value : undefined
80   - },
81   -
82   - dataUrl : {
83   - type : String,
84   - value : undefined,
85   - observer : '_init'
86   - },
87   -
88   - filters : {
89   - type : Array,
90   - value : []
91   - },
92   -
93   - },
94   -
95   - listeners: {
96   - 'tree-view-controllet_selected-fields': '_updateSelectedFields',
97   - 'filters-controllet_filters': '_updateFilters'
98   - },
99   -
100   - ready : function() {
101   - $(this.$.material_tree_view).perfectScrollbar();
102   - },
103   -
104   - attached : function(){
105   - this._resize();
106   - var that = this;
107   - window.addEventListener("resize", function() { that._resize(); });
108   -
109   - if(this.dataletPreset && this.dataletPreset["filters"] != undefined)
110   - this._preselectFilters();
111   - },
112   -
113   - _preselectFilters : function() {
114   - this.async(function() {
115   - this.filters = JSON.parse(this.dataletPreset["filters"]);
116   - this.dataletPreset["filters"] = undefined;
117   - this.$.filters.filters = this.filters;
118   - this.$.multi_table.filters = this.filters;
119   - this._refreshTables();
120   - }, 1);
121   - },
122   -
123   - getFilters : function() {
124   - return this.$.filters.getFilters();
125   - },
126   -
127   - getFields : function() {
128   - return this.$.tree_view.getFields();
129   - },
130   -
131   - getFlatFields : function() {
132   - return this.$.tree_view.getFlatFields();
133   - },
134   -
135   - _init : function() {
136   - var that = this;
137   -
138   - $.ajax({
139   - url: this.dataUrl,
140   - dataType: "json",
141   - success: function(data){
142   - that.rootName = "data";
143   - var data = that._filterJson(data);
144   - that.$.tree_view.setAttribute("json-data", JSON.stringify(data));
145   - that.$.tree_view.selectedFields = [];
146   - that._updateSelectedFields();
147   - that.$.tree_view.ready();
148   - that.filters = [];
149   - that.$.filters.filters = [];
150   - that.$.multi_table.filters = [];
151   - }
152   - });
153   -
154   - this.$.multi_table.ready();
155   - },
156   -
157   - _filterJson : function(data){
158   - //ckan
159   - if(data.result != undefined && data.result.resource_id != undefined) {
160   - this.rootName = "result,records"
161   - return data.result.records;
162   - }
163   - //openDataSoft
164   - else if(data.parameters != undefined && data.parameters.dataset != undefined) {
165   - this.rootName = "records,fields";
166   - return data.records[0].fields;
167   - }
168   - else{
169   - return data;
170   - }
171   - },
172   -
173   - _updateSelectedFields : function() {
174   - var fields = this.$.tree_view.getFields();
175   - this.$.multi_table.setSelectedFields(fields);
176   -
177   - var flatFields = this.$.tree_view.getFlatFields();
178   - this.$.filters.setFields(flatFields);
179   - },
180   -
181   - _updateFilters : function(e) {
182   - this.filters = e.detail.filters;
183   - this.$.multi_table.filters = e.detail.filters;
184   - this._refreshTables();
185   - },
186   -
187   - _refreshTables : function() {
188   - this.$.multi_table.setSelectedFields([]);
189   - this.async(function () {
190   - var fields = this.$.tree_view.getFields();
191   - this.$.multi_table.setSelectedFields(fields);
192   - }, 0);
193   - },
194   -
195   - _resize : function(){
196   - var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
197   - h = h - 64; //height with page scroller
198   - $("#material_tree_view").height(h);
199   - $("#material_multi_table_filters").height(h-8);
200   - }
201   -
202   - });
203   -
204   - </script>
205   -
206   -</dom-module>
207 0 \ No newline at end of file
controllets/select-visualization-controllet/select-datalet-inputs_series_original.html deleted
1   -<link rel="import" href="../../bower_components/polymer/polymer.html" />
2   -
3   -<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
4   -
5   -<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
6   -<link rel="import" href="../../bower_components/paper-menu/paper-menu.html">
7   -<link rel="import" href="../../bower_components/paper-item/paper-item.html">
8   -
9   -<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
10   -<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
11   -<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
12   -
13   -<dom-module id="select-datalet-inputs_series">
14   -
15   - <template>
16   -
17   - <style is="custom-style">
18   - :host {
19   - --paper-dropdown-menu-icon: {
20   - color: #2196F3;
21   - };
22   - }
23   -
24   - #inputs_series_container {
25   - font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
26   - font-size: 16px;
27   -
28   - height: 100%;
29   - width: 258px;
30   - }
31   -
32   - .inputs{
33   - position: relative;
34   - }
35   -
36   - .input_header {
37   - height: 32px;
38   - padding-top: 16px;
39   - text-align: center;
40   - font-weight: 700;
41   - background-color: #B6B6B6;
42   - }
43   -
44   - #expert_container {
45   - display: none;
46   - }
47   -
48   - #expert_header {
49   - height: 32px;
50   - padding-top: 16px;
51   - margin-top: 8px;
52   - text-align: center;
53   - font-weight: 700;
54   - color: #00BCD4;
55   - cursor: pointer;
56   - }
57   -
58   - .info_button {
59   - position: absolute;
60   - top: 18px;
61   - right: 0px;
62   - }
63   -
64   - paper-dropdown-menu {
65   - height: 48px;
66   - width: 210px;;
67   - padding-left: 8px;
68   - padding-bottom: 8px;
69   - --paper-input-container-focus-color: #2196F3;
70   - }
71   -
72   - paper-item.iron-selected {
73   - background-color: #2196F3;
74   - color: #FFFFFF;
75   - }
76   -
77   - paper-icon-button {
78   - color: #2196F3;
79   - --paper-icon-button-ink-color: #2196F3;
80   - margin: 0px;
81   - }
82   - </style>
83   -
84   - <paper-material id="inputs_series_container" elevation="5">
85   -
86   - <div class="input_header"><span id="inputs"></span></div>
87   -
88   - <template is="dom-repeat" items="{{inputs}}" index-as="ddl_index">
89   - <div class="inputs">
90   - <paper-dropdown-menu id={{ddl_index}} label={{_getLabelName(item.name)}}>
91   - <paper-menu class="dropdown-content">
92   - <template is="dom-repeat" items={{fields}}>
93   - <paper-item id={{index}} on-tap="_addInput">{{_fieldName(item)}}</paper-item>
94   - </template>
95   - </paper-menu>
96   - </paper-dropdown-menu>
97   - <div class="info_button">
98   - <paper-icon-button id="{{ddl_index}}" on-click="_setOrders" icon="unfold-more" title=""></paper-icon-button>
99   - </div>
100   - </div>
101   - </template>
102   -
103   - <div id="expert_header" on-click="_showExpertMode"><span id="groupBy"></span></div>
104   -
105   - <div id="expert_container">
106   -
107   - <div class="inputs">
108   - <paper-dropdown-menu id="group_by" disabled>
109   - <paper-menu class="dropdown-content">
110   - <template is="dom-repeat" items={{groupableFields}}>
111   - <paper-item id={{index}} on-tap="_setAggregatorsFields">{{_fieldName(item)}}</paper-item>
112   - </template>
113   - </paper-menu>
114   - </paper-dropdown-menu>
115   - <div class="info_button">
116   - <paper-icon-button id="gb" on-click="_setOrders" icon="unfold-more" title="" disabled></paper-icon-button>
117   - </div>
118   - </div>
119   -
120   - <template is="dom-repeat" items="{{aggregateFields}}" as="field">
121   - <div class="inputs">
122   - <paper-dropdown-menu id="calculate_{{index}}" label="{{_calculateLabel()}}" disabled>
123   - <paper-menu class="dropdown-content">
124   - <template is="dom-repeat" items="{{functions}}">
125   - <paper-item id={{index}} on-tap="_setAggregators">{{_operationName(index)}} : {{_fieldName(field)}}</paper-item>
126   - </template>
127   - </paper-menu>
128   - </paper-dropdown-menu>
129   - </div>
130   - </template>
131   -
132   - </div>
133   -
134   - </paper-material>
135   -
136   -
137   - </template>
138   -
139   - <script>
140   -
141   - Polymer({
142   -
143   - is : 'select-datalet-inputs_series',
144   -
145   - properties : {
146   -
147   - //INPUT
148   - fields : {type : Array, value : []},
149   -
150   - //OUTPUT
151   - selectedFields : {type : Array, value : ["", ""]},
152   - aggregators : {type : Array, value : []},
153   - orders : {type : Array, value : []},
154   -
155   - expert : {
156   - type : Boolean,
157   - value : false
158   - },
159   -
160   - functions : {
161   - type : Array,
162   - value : ["COUNT", "SUM", "MIN", "MAX", "AVG", "FIRST", "LAST"]
163   - },
164   -
165   - inputs : {
166   - type : Array,
167   - value : []
168   - },
169   -
170   - groupableFields : {
171   - type : Array,
172   - value : []
173   - },
174   -
175   - aggregateFields : {
176   - type : Array,
177   - value : [""]
178   - }
179   -
180   - },
181   -
182   - ready : function() {
183   - $(this.$.inputs_series_container).perfectScrollbar();
184   - },
185   -
186   - attached : function() {
187   - this._translate();
188   - },
189   -
190   - _preselectInputs : function(fields, aggregators, orders) {
191   - var ddls = this.$.inputs_series_container.querySelectorAll("paper-dropdown-menu");
192   -
193   -// this.async(function () {
194   - for (var i = 0; i < fields.length; i++) {
195   - var menu = $(ddls[i]).find("paper-menu")[0];
196   - menu.select(i+1);
197   - }
198   - this.selectedFields = this._copy(fields);
199   -// }, 0);
200   - },
201   -
202   - getSelectedFields : function () {
203   - var gb_menu = $(this.$.group_by).find("paper-menu")[0];
204   - var c_menu = $("#calculate_0").find("paper-menu")[0];
205   -
206   - if(gb_menu.selectedItem && c_menu.selectedItem && gb_menu.selectedItem.id != 0) {
207   - var groupByField = this.groupableFields[gb_menu.selected];
208   - if (groupByField != this.selectedFields[0])
209   - return [this.selectedFields[0], groupByField, this.selectedFields[1]];
210   - }
211   - return this.selectedFields;
212   - },
213   -
214   - getAggregators : function () {
215   - return this.aggregators;
216   - },
217   -
218   - getOrders : function () {
219   - return this.orders;
220   - },
221   -
222   - setFields : function(fields) {
223   - var temp = this._copy(fields);
224   - temp.unshift("");
225   -
226   - if (JSON.stringify(this.fields) != JSON.stringify(temp)) {
227   - this.fields = this._copy(temp);
228   - this._reset();
229   - }
230   - },
231   -
232   - setInputs : function(inputs) {
233   - this.inputs = this._copy(inputs);
234   - },
235   -
236   - fireReady : function() {
237   - if(this.selectedFields[0] != "" && this.selectedFields[1] != "")
238   - this.fire('select_visualization_inputs_ready', {isReady: true});
239   - else
240   - this.fire('select_visualization_inputs_ready', {isReady: false});
241   - },
242   -
243   - _reset : function() {
244   - //this.fields = []; --> setFields
245   - //this.inputs = []; --> setInputs
246   - this.selectedFields = ["", ""];
247   - this.aggregators = [];
248   - //this.orders = []; --> _resetOrders
249   - this.expert = true;
250   - this._showExpertMode();//expert --> false
251   - this.groupableFields = [];
252   - this.aggregateFields = [""];
253   -
254   - this.async(function () {
255   - //reset ddl
256   - var ddls = this.$.inputs_series_container.getElementsByTagName("paper-dropdown-menu");
257   - for (var i = 0; i < ddls.length; i++)
258   - $(ddls[i]).find("paper-menu")[0].select(-1);
259   - this.$.group_by.setAttribute("disabled", "");
260   - $("#calculate_0")[0].setAttribute("disabled", "");
261   - //reset orders
262   - this._resetOrders();
263   - }, 1);
264   - },
265   -
266   - _translate : function(){
267   - this.$.inputs.innerHTML = ln["inputs_" + ln["localization"]];
268   - this.$.groupBy.innerHTML = ln["expertGroupBy_" + ln["localization"]];
269   -
270   - this.$.group_by.setAttribute("label", ln["groupBy_" + ln["localization"]]);
271   - },
272   -
273   - _showExpertMode : function() {
274   - if(!this.expert) {
275   - this.$.expert_header.style.color = "#000000";
276   - this.$.expert_header.style.background = "#B6B6B6";
277   - this.$.expert_container.style.display = "block";
278   - }
279   - else {
280   - this.$.expert_header.style.color = "#00BCD4";
281   - this.$.expert_header.style.background = "#FFFFFF";
282   - this.$.expert_container.style.display = "none";
283   - }
284   -
285   - this.expert = !this.expert;
286   - },
287   -
288   - _addInput : function(e){
289   - var selectedFields = this._copy(this.selectedFields);
290   -
291   - var ddl_index = $(e.target).parents("paper-dropdown-menu")[0].id;
292   - var index = e.target.id;
293   - selectedFields[ddl_index] = this.fields[index];
294   -
295   - this.selectedFields = this._copy(selectedFields);
296   -
297   - if(this.selectedFields[0] == "" || this.selectedFields[1] == "") {
298   - this.$.group_by.setAttribute("disabled", "");
299   - $("#calculate_0")[0].setAttribute("disabled", "");
300   -
301   - this.groupableFields = [];
302   - this.aggregateFields = [""];
303   - var menu = $("#calculate_0").find("paper-menu")[0];
304   - menu.select(-1);
305   - }
306   - else {
307   - this.$.group_by.removeAttribute("disabled");
308   - $("#calculate_0")[0].removeAttribute("disabled");
309   -
310   - var groupableFields = [];
311   - for (var i = 0; i < this.fields.length; i++) {
312   - if(this.fields[i] != this.selectedFields[1])
313   - groupableFields.push(this.fields[i]);
314   - }
315   - this.groupableFields = this._copy(groupableFields);
316   - this.aggregateFields = [this.selectedFields[1]];
317   -
318   - this.async(function () {
319   - var menu = $(this.$.group_by).find("paper-menu")[0];
320   - menu.select(-1);
321   - var menu = $("#calculate_0").find("paper-menu")[0];
322   - //var selected = menu.selected;
323   - menu.select(-1);
324   - //menu.select(selected);
325   - }, 0);
326   - }
327   - this._setAggregators();
328   - },
329   -
330   - _setAggregatorsFields : function(){
331   - this.async(function() {
332   - var c_menu = $("#calculate_0").find("paper-menu")[0];
333   - var selected = c_menu.selected > 0 ? c_menu.selected : 0;
334   - c_menu.select(-1);
335   - c_menu.select(selected);
336   -
337   - this._setAggregators();
338   - }, 0);
339   - },
340   -
341   - _setAggregators : function(){
342   - this.async(function() {
343   - this.aggregators = [];
344   -
345   - this._resetOrders();
346   -
347   - $("#gb")[0].setAttribute("disabled", "");
348   -
349   - var gb_menu = $(this.$.group_by).find("paper-menu")[0];
350   - var c_menu = $("#calculate_0").find("paper-menu")[0];
351   -
352   - if(gb_menu.selectedItem && c_menu.selectedItem && gb_menu.selectedItem.id != 0) {
353   - var groupByField = this.groupableFields[gb_menu.selected];
354   - var operationIndex = c_menu.selectedItem.id;
355   -
356   - if (groupByField == this.selectedFields[0]){// X Axis field
357   - this.aggregators.push({"field": groupByField, "operation": "GROUP BY"});
358   - }
359   - else{
360   - $("#gb")[0].removeAttribute("disabled");
361   - this.aggregators.push({"field": this.selectedFields[0], "operation": "GROUP BY"});
362   - this.aggregators.push({"field": groupByField, "operation": "GROUP BY"});
363   - }
364   -
365   - this.aggregators.push({"field": this.selectedFields[1], "operation": this.functions[operationIndex]});
366   - }
367   -
368   - this.fireReady();
369   - }, 0);
370   - },
371   -
372   - _setOrders : function(e){
373   - var t = e.target;
374   - if(t.tagName.indexOf("IRON-ICON") > -1)
375   - t = $(e.target).parents("paper-icon-button")[0];
376   -
377   - var icon = t.getAttribute("icon");
378   - var id = t.getAttribute("id");
379   - var field;
380   -
381   - if(id == "gb"){
382   - var gb_menu = $(this.$.group_by).find("paper-menu")[0];
383   - field = this.groupableFields[gb_menu.selected];
384   - }
385   - else {
386   - field = this.selectedFields[id];
387   - }
388   -
389   - if(icon.indexOf("unfold-more") > -1){
390   - t.setAttribute("icon", "expand-less");
391   - t.setAttribute("title", ln["sortAscending_" + ln["localization"]]);
392   - var orders = this.orders.filter(function (el) { return el.field !== field; });
393   - orders.unshift({"field": field, "operation": "ASC"});
394   - this.orders = this._copy(orders);
395   - }
396   - else if(icon.indexOf("expand-less") > -1){
397   - t.setAttribute("icon", "expand-more");
398   - t.setAttribute("title", ln["sortDescending_" + ln["localization"]]);
399   - var orders = this.orders.filter(function (el) { return el.field !== field; });
400   - orders.unshift({"field": field, "operation": "DESC"});
401   - this.orders = this._copy(orders);
402   - }
403   - else if(icon.indexOf("expand-more") > -1){
404   - t.setAttribute("icon", "unfold-more");
405   - t.setAttribute("title", ln["unsort_" + ln["localization"]]);
406   - var orders = this.orders.filter(function (el) { return el.field !== field; });
407   - this.orders = this._copy(orders);
408   - }
409   -
410   - this.fireReady();
411   - },
412   -
413   - _resetOrders : function(){
414   - var icons = this.$.inputs_series_container.querySelectorAll("paper-icon-button");
415   - for (var i = 0; i < icons.length; i++){
416   - icons[i].setAttribute("icon", "unfold-more");
417   - icons[i].setAttribute("title", ln["unsort_" + ln["localization"]]);
418   - }
419   - this.orders = [];
420   - },
421   -
422   - _fieldName : function(field) {
423   - return field.substring(field.lastIndexOf(",")+1, field.length);
424   - },
425   -
426   - _getLabelName: function(key) {
427   - return ln[key + "_" +ln["localization"]];
428   - },
429   -
430   - _operationName: function(index) {
431   - var key = this.functions[index];
432   - return ln[key + "_" +ln["localization"]];
433   - },
434   -
435   - _calculateLabel: function() {
436   - return ln["calculate" + "_" +ln["localization"]];
437   - },
438   -
439   - _copy : function(o) {
440   - var out, v, key;
441   - out = Array.isArray(o) ? new Array(o.length) : {};
442   - for (key in o) {
443   - v = o[key];
444   - out[key] = (typeof v === "object") ? this._copy(v) : v;
445   - }
446   - return out;
447   - }
448   -
449   - });
450   -
451   - </script>
452   -
453   -</dom-module>
454 0 \ No newline at end of file
controllets/select-visualization-controllet/select-visualization-controllet_old.html deleted
1   -<link rel="import" href="../../bower_components/polymer/polymer.html" />
2   -
3   -<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
4   -
5   -<link rel="import" href="../../bower_components/paper-button/paper-button.html">
6   -
7   -<link rel="import" href="../items-vslider-controllet/items-vslider-controllet.html" />
8   -<link rel="import" href="select-datalet-inputs_series.html" />
9   -<link rel="import" href="select-datalet-inputs.html" />
10   -<link rel="import" href="select-datalet-options.html" />
11   -
12   -<script src="../../../DEEPCLIENT/js/deepClient.js"></script>
13   -
14   -<dom-module id="select-visualization-controllet">
15   -
16   - <template>
17   -
18   - <style is="custom-style">
19   - #select_visualization_container {
20   - display: flex;
21   - font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
22   - font-size: 16px;
23   - margin-top: 8px;
24   - }
25   -
26   - #items_vslider_controllet {
27   - position: relative;
28   - min-width: 172px;
29   - }
30   -
31   - #datalet_selection_inputs {
32   - position: relative;
33   - margin-left: 32px;
34   - min-width: 258px;
35   - }
36   -
37   - #datalet_selection_options {
38   - position: relative;
39   - margin-left: 32px;
40   - min-width: 258px;
41   - }
42   -
43   - #datalet_preview_container {
44   - position: relative;
45   - width: 100%;
46   - margin-left: 32px;
47   - }
48   -
49   - #datalet_selection_datalet {
50   - position: relative;
51   - height: 100vh;
52   - width: 100%;
53   - }
54   -
55   - #datalet_selection_datalet_placeholder {
56   - padding: 16px;
57   - }
58   -
59   - .input_header {
60   - height: 32px;
61   - padding-top: 16px;
62   - text-align: center;
63   - font-weight: 700;
64   - background-color: #B6B6B6;
65   - }
66   -
67   - paper-button {
68   - position: absolute;
69   - bottom: 16px;
70   - right: 11px;
71   -
72   - height: 48px;
73   - width: 172px;
74   - background-color: #00BCD4;
75   - color: white;
76   - font-weight: 700;
77   - padding: 16px;
78   - }
79   -
80   - paper-button:hover {
81   - background-color: #00AABF;
82   -
83   - box-shadow: 0px 8px 12px #888;
84   - -webkit-box-shadow: 0px 8px 12px #888;
85   - -moz-box-shadow: 0px 8px 12px #888;
86   - }
87   -
88   - paper-button[disabled] {
89   - background-color: #B6B6B6;
90   - }
91   - </style>
92   -
93   - <iron-ajax id="selectedDatalet_request" on-response="_handleSelectedDatalet"></iron-ajax>
94   -
95   - <div id="select_visualization_container">
96   -
97   - <div id="items_vslider_controllet">
98   - <items-vslider-controllet id="vslider" datalets-list-url={{dataletsListUrl}} preselected-datalet={{preselectedDatalet}}></items-vslider-controllet>
99   - </div>
100   -
101   - <div id="datalet_selection_inputs">
102   - <template is="dom-if" if="{{_checkType(type, 'multiseries')}}">
103   - <select-datalet-inputs_series id="inputs_series"></select-datalet-inputs_series>
104   - </template>
105   - <template is="dom-if" if="{{_checkType(type, 'default')}}">
106   - <select-datalet-inputs id="inputs"></select-datalet-inputs>
107   - </template>
108   - <template is="dom-if" if="{{_checkType(type, '')}}">
109   - <select-datalet-inputs></select-datalet-inputs>
110   - </template>
111   - </div>
112   -
113   - <div id="datalet_selection_options">
114   - <select-datalet-options id="options"></select-datalet-options>
115   - </div>
116   -
117   - <div id="datalet_preview_container">
118   -
119   - <paper-material id="datalet_selection_datalet" elevation="5">
120   - <div class="input_header"><span id="dataletPreview"></span></div>
121   - <div id="datalet_selection_datalet_placeholder"></div>
122   - </paper-material>
123   -
124   - <paper-button id="add_button" disabled raised on-click="_addDatalet"></paper-button>
125   -
126   - </div>
127   -
128   - </div>
129   -
130   - </template>
131   -
132   - <script>
133   -
134   - Polymer({
135   -
136   - is : 'select-visualization-controllet',
137   -
138   - properties : {
139   -
140   - deepUrl : {
141   - type : String,
142   - value : undefined
143   - },
144   -
145   - dataletsListUrl : {
146   - type : String,
147   - value : undefined
148   - },
149   -
150   - selectedDatalet : {
151   - type : String,
152   - value : undefined
153   - },
154   -
155   - preselectedDatalet : {
156   - type : String,
157   - value : undefined
158   - },
159   -
160   - type : {
161   - type : String,
162   - value : ""
163   - },
164   -
165   - filters : {
166   - type : Array,
167   - value : []
168   - },
169   -
170   - fields : {
171   - type : Array,
172   - value : []
173   - },
174   -
175   - selectedFields : {
176   - type : Array,
177   - value : []
178   - },
179   -
180   - dataletPreset : {
181   - type : Object,
182   - value : []
183   - },
184   -
185   - dataUrl : {
186   - type : String,
187   - value : undefined
188   - },
189   -
190   - params:{
191   - type: Object,
192   - value: undefined
193   - },
194   -
195   - data : {
196   - type : Object,
197   - value : undefined
198   - },
199   -
200   - },
201   -
202   - listeners: {
203   -// 'select-fields-controllet_selected-fields': '_updateFields',
204   -// 'filters-controllet_filters': '_updateFilters',
205   - 'items-vslider-controllet_selected-datalet': '_selectDatalet',
206   - 'select_visualization_inputs_ready': '_loadDatalet',
207   - 'select_visualization_options_changed': '_tryLoadDatalet'
208   - },
209   -
210   - ready : function() {
211   - this._resize();
212   -
213   - $(this.$.datalet_selection_datalet).perfectScrollbar();
214   -
215   -// this.params = {'data-url' : this.dataUrl};//not here
216   - },
217   -
218   - attached : function() {
219   - this._resize();
220   - var that = this;
221   - window.addEventListener("resize", function() { that._resize(); });
222   -
223   - this._translate();
224   - },
225   -
226   - setFilters : function(filters) {
227   - this.filters = this._copy(filters);
228   - },
229   -
230   - setFields : function(fields) {
231   -// if (this.fields.length > 0 && JSON.stringify(this.fields) != JSON.stringify(fields))
232   -// this.init();
233   -
234   - this.fields = this._copy(fields);
235   -
236   - var inputs = this._getInputs();
237   - if (inputs)
238   - inputs.setFields(this.fields);
239   - },
240   -
241   - setData : function(data) {
242   - this.data = this._copy(data);
243   - },
244   -
245   - init : function() {
246   - this.$.vslider._reset();
247   - },
248   -
249   - show : function() {//show --> preselect
250   -// if(this.preselectedDatalet)
251   - if(this.dataletPreset)
252   - this._preselectDatalet();
253   -
254   -// if (this.$.datalet_selection_datalet_placeholder.innerHTML == "") {
255   -// var inputs = this._getInputs();
256   -// inputs.fireReady();
257   -// }
258   - },
259   -
260   - _translate : function(){
261   - if(this.preselectedDatalet)
262   - this.$.add_button.innerHTML = ln["modifyDatalet_" + ln["localization"]];
263   - else
264   - this.$.add_button.innerHTML = ln["addDatalet_" + ln["localization"]];
265   -
266   - this.$.dataletPreview.innerHTML = ln["dataletPreview_" + ln["localization"]];
267   - },
268   -
269   - _selectDatalet : function(e){
270   -
271   - this.$.add_button.setAttribute("disabled", "true");
272   -
273   - this.selectedDatalet = e.detail.datalet;
274   -
275   - this.$.datalet_selection_datalet_placeholder.innerHTML = "";
276   -
277   - if(!this.selectedDatalet){
278   - this.type = "";
279   - this.$.options.setOptions([]);
280   - }
281   - else{
282   - this.$.selectedDatalet_request.url = this.deepUrl + e.detail.datalet + "-datalet";
283   - this.$.selectedDatalet_request.generateRequest();
284   - }
285   - },
286   -
287   - _handleSelectedDatalet : function(e){
288   -
289   - if(this.type != e.detail.response.type) {
290   -
291   - this.type = e.detail.response.type;
292   -
293   - this.async(function () {
294   - var inputs = this._getInputs();
295   - inputs.setFields(this.fields);
296   - inputs.setInputs(e.detail.response.idm.inputs.input);// Cannot read property '0' of undefined
297   - }, 0);
298   -
299   - this.$.options.setOptions(e.detail.response.idm.inputs.layouts.input);
300   - }
301   - else {
302   - this.$.options.checkOptions(e.detail.response.idm.inputs.layouts.input);
303   - }
304   -
305   - this.async(function () {
306   - var inputs = this._getInputs();
307   - inputs.fireReady();
308   - }, 0);
309   -
310   -// this.async(function () {
311   -// if(this.preselectedDatalet)
312   -// this._preselectDatalet();
313   -// }, 1);
314   - },
315   -
316   - _preselectDatalet : function() {
317   - this.$.vslider._preselectDatalet();
318   -
319   - this.async(function () {
320   - this.$.options._preselectOptions(this.dataletPreset);
321   - }, 100);
322   -
323   - this.async(function () {
324   - var inputs = this._getInputs();
325   - inputs._preselectInputs(this.fields, this.dataletPreset["aggregators"], this.dataletPreset["orders"]);
326   - this.dataletPreset = undefined;
327   - }, 200);
328   - },
329   -
330   - _tryLoadDatalet : function(){
331   - var inputs = this._getInputs();
332   - inputs.fireReady();
333   - },
334   -
335   - _loadDatalet : function(e){
336   - if(!e.detail.isReady) {
337   - this.$.datalet_selection_datalet_placeholder.innerHTML = "";
338   - return;
339   - }
340   -
341   - var inputs = this._getInputs();
342   -
343   - this.selectedFields = inputs.getSelectedFields();
344   -
345   - this.params = {'data-url' : this.dataUrl};//??????????????????
346   -// this.params = {};
347   -
348   - this.params["filters"] = JSON.stringify(this.filters);
349   - this.params["aggregators"] = JSON.stringify(inputs.getAggregators());
350   - this.params["orders"] = JSON.stringify(inputs.getOrders());
351   -
352   - this.params["export_menu"] = "0";
353   -
354   - var params = this.$.options.getParams();
355   - for (var key in params) { this.params[key] = params[key]; }
356   -
357   - var data = alasql_complexSelectData(this.data, this.selectedFields, this.filters, inputs.getAggregators(), inputs.getOrders());
358   - data = transformData(data, this.selectedFields, true);
359   - this.params["data"] = JSON.stringify(data).replace(/'/g, "&#39;");
360   -
361   - var dataletParams ={
362   - component: this.selectedDatalet+"-datalet",
363   - fields: this.selectedFields,
364   - params: this.params,
365   - placeHolder: this.$.datalet_selection_datalet_placeholder,
366   - };
367   -
368   - ComponentService.deep_url = this.deepUrl;
369   - ComponentService.getComponent(dataletParams);
370   -
371   - this.$.add_button.removeAttribute("disabled");
372   - },
373   -
374   - _addDatalet : function(){
375   - delete this.params["export_menu"];
376   -
377   - var data = {
378   - dataUrl: this.dataUrl,
379   - datalet: this.selectedDatalet+"-datalet",
380   - fields: this.selectedFields,
381   - params: this.params,
382   - staticData: JSON.stringify(this.$.datalet_selection_datalet_placeholder.children[1].behavior.data)
383   - }
384   -
385   - this.fire('data-sevc-controllet.dataletCreated', {data : data});
386   - },
387   -
388   - _checkType: function(type, check){
389   - if (type == "multiseries" || type == "")
390   - return (type == check);
391   - else if(check == "default")
392   - return true;
393   - return false;
394   - },
395   -
396   - _getInputs : function(){
397   - if(this.type == "multiseries")
398   - return this.$$("#inputs_series")
399   - return this.$$("#inputs");
400   - },
401   -
402   - _copy : function(o) {
403   - var out, v, key;
404   - out = Array.isArray(o) ? new Array(o.length) : {};
405   - for (key in o) {
406   - v = o[key];
407   - out[key] = (typeof v === "object") ? this._copy(v) : v;
408   - }
409   - return out;
410   - },
411   -
412   - _resize : function(){
413   - var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
414   - h = h - 64 - 8; //height with page scroller
415   -
416   - $("#items_vslider_controllet").height(h);//vslider controllet
417   - $("#datalet_selection_inputs").height(h);
418   - $("#datalet_selection_options").height(h);
419   -
420   - $("#datalet_selection_datalet").height(h);
421   - }
422   -
423   - });
424   -
425   - </script>
426   -
427   -</dom-module>
428 0 \ No newline at end of file
datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior_old.js deleted
1   -/*
2   -@license
3   - The MIT License (MIT)
4   -
5   - Copyright (c) 2015 Dipartimento di Informatica - Universit� di Salerno - Italy
6   -
7   - Permission is hereby granted, free of charge, to any person obtaining a copy
8   - of this software and associated documentation files (the "Software"), to deal
9   - in the Software without restriction, including without limitation the rights
10   - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11   - copies of the Software, and to permit persons to whom the Software is
12   - furnished to do so, subject to the following conditions:
13   -
14   - The above copyright notice and this permission notice shall be included in
15   - all copies or substantial portions of the Software.
16   -
17   - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18   - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19   - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20   - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21   - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22   - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23   - THE SOFTWARE.
24   -*/
25   -
26   -/**
27   - * Developed by :
28   - * ROUTE-TO-PA Project - grant No 645860. - www.routetopa.eu
29   - *
30   -*/
31   -
32   -
33   -var AjaxJsonAlasqlBehavior = {
34   -
35   - properties: {
36   -
37   - /**
38   - * It contains the json data from async xhr call returned from core-ajax core component
39   - *
40   - * @attribute json_results
41   - * @type object
42   - * @default 'null'.
43   - */
44   - json_results: {
45   - type: Object,
46   - value: {}
47   - }
48   -
49   - },
50   -
51   - /**
52   - * Make an AJAX call to the dataset URL
53   - *
54   - * @method requestData
55   - */
56   - requestData: function(){
57   -
58   - var comp = this;
59   -
60   - $.ajax({
61   - url: this._component.dataUrl,
62   - dataType: "json",
63   - success: function(e){
64   - comp.handleResponse(e);
65   - }
66   - });
67   - },
68   -
69   - /**
70   - * Called when core-ajax component receive the json data from called url.
71   - *
72   - * @method handleResponse
73   - */
74   - handleResponse: function(e) {
75   - this.properties.json_results.value = e;
76   - this.runWorkcycle();
77   - },
78   -
79   - /**
80   - * selectData built a JSONPATH query based on the user selected fields then extract data from the JSON response.
81   - * This method built an objects <name, data> for every user selected field and push it into the data array.
82   - *
83   - * @method selectData
84   - */
85   - selectData : function() {
86   - var jsonData = [this.properties.json_results.value];
87   -
88   - this._component.fields = JSON.parse(this._component.fields);
89   -
90   - var filters = JSON.parse(this._component.getAttribute("filters"));
91   - var aggregators = JSON.parse(this._component.getAttribute("aggregators"));
92   - var orders = JSON.parse(this._component.getAttribute("orders"));
93   -
94   - //preview my space
95   - if(filters && filters[0] && filters[0].constructor == Array){
96   - filters = filters[0];
97   - aggregators = aggregators[0];
98   - orders = orders[0];
99   - }
100   -
101   - var provider = this._getProvider(this._component.fields[0]);
102   -
103   - var path = this._path(this._component.fields[0], provider);
104   -
105   - var fields = [];
106   - for (var i=0; i < this._component.fields.length; i++)
107   - fields.push(this._fieldName(this._component.fields[i], provider));
108   -
109   - //WHERE
110   - var where = "";
111   - if(filters && filters.length) {
112   -
113   - for (var i=0; i < filters.length; i++)
114   - filters[i]["field"] = this._fieldName(filters[i]["field"], provider);
115   -
116   - where = "WHERE ";
117   - for (var i=0; i < filters.length; i++) {
118   - if(filters[i]["operation"] == "contains")
119   - where += filters[i]["field"] + " like '%" + filters[i]["value"] + "%' AND ";
120   - else if(filters[i]["operation"] == "start")
121   - where += filters[i]["field"] + " like '" + filters[i]["value"] + "%' AND ";
122   - else if(filters[i]["operation"] == "ends")
123   - where += filters[i]["field"] + " like '%" + filters[i]["value"] + "' AND ";
124   - else
125   - where += filters[i]["field"] + " " + filters[i]["operation"] + " " + filters[i]["value"] + " AND ";
126   - }
127   - where = where.slice(0, -5);
128   - }
129   -
130   - provider="";
131   -
132   - //ORDER BY
133   - var orderBy = "";
134   - if(orders && orders.length) {
135   -
136   - for (var i=0; i < orders.length; i++)
137   - orders[i]["field"] = this._fieldName(orders[i]["field"], provider);
138   -
139   - orderBy = "ORDER BY ";
140   - for (var i = 0; i < orders.length; i++)
141   - orderBy += orders[i]["field"] + " " + orders[i]["operation"] + ", ";
142   - orderBy = orderBy.slice(0, -2);
143   - }
144   -
145   - //SELECT
146   - var select = "SELECT ";
147   - for (var i = 0; i < fields.length; i++)
148   - select += fields[i] + " as " + this._fieldName(this._component.fields[i], "") + ", ";
149   - select = select.slice(0, -2);
150   -
151   - var pureSelect = select;
152   -
153   - /**/
154   - var res = alasql("SELECT "+ path +" FROM ?", [jsonData]);
155   - var records = res[0][path];
156   - var obj = alasql(pureSelect + " FROM ?", [records]);
157   - //console.log(obj);
158   -
159   - var select = "SELECT ";
160   - for (var i = 0; i < fields.length; i++) {
161   - var key = Object.keys(obj[0])[i];
162   - var v = obj[0][key];
163   - if (!isNaN(v))
164   - select += fields[i] + "::NUMBER as " + this._fieldName(this._component.fields[i], "") + ", ";
165   - else
166   - select += fields[i] + " as " + this._fieldName(this._component.fields[i], "") + ", ";
167   -
168   - //omg!
169   - //var key2 = "["+key+"]";
170   - //if(fields[0].indexOf("->") > -1)
171   - // key2 = "fields->["+key+"]";
172   - //if (!isNaN(v))
173   - // select += key2 + "::NUMBER as " + this._fieldName(key, "") + ", ";
174   - //else
175   - // select += key2 + " as " + this._fieldName(key, "") + ", ";
176   - }
177   - select = select.slice(0, -2);
178   -
179   - var pureSelect = select;
180   - /**/
181   -
182   - //GROUP BY
183   - var groupBy = "";
184   - if(aggregators && aggregators.length) {
185   -
186   - for (var i=0; i < aggregators.length; i++)
187   - aggregators[i]["field"] = this._fieldName(aggregators[i]["field"], provider);
188   -
189   - groupBy = "GROUP BY " + aggregators[0]["field"];
190   - select = "SELECT " + aggregators[0]["field"];
191   - for (var i = 1; i < aggregators.length; i++)
192   - select += ", " + aggregators[i]["operation"] + "(" + aggregators[i]["field"] + ") as " + aggregators[i]["field"];
193   - }
194   -
195   - //QUERY
196   - console.log('SELECT '+ path +' FROM ?');
197   - var res = alasql("SELECT "+ path +" FROM ?", [jsonData]);
198   -
199   - var records = res[0][path];
200   -
201   - //console.log(select + ' FROM ? ' + where + ' ' + groupBy + ' ' + orderBy + '');
202   - //var obj = alasql(select + " FROM ? " + where + " " + groupBy + " " + orderBy + "", [records]);
203   -
204   - console.log(pureSelect + ' FROM ? ' + where);
205   - var obj = alasql(pureSelect + " FROM ? " + where, [records]);
206   -
207   - if (groupBy != "") {
208   - console.log(select + ' FROM ? ' + groupBy + ' ' + orderBy + '');
209   - var obj = alasql(select + " FROM ? " + groupBy + " " + orderBy + "", [obj]);
210   - }
211   -
212   - //multiserie test
213   - //var query = "SELECT [preteur], [annee] as [annee], SUM([capital_restant_du]) as [capital_restant_du] FROM ? GROUP BY [preteur], [annee]"
214   - //var obj = alasql(query, [obj]);
215   - //console.log(obj);
216   - //this.data = obj;
217   -
218   -
219   - //PUSH DATA
220   - if(!obj || obj.length == 0)
221   - this.data = []
222   - else
223   - this._pushData(obj);
224   -
225   - this._deleteWaitImage();
226   - },
227   -
228   - _pushData : function(obj) {
229   - this.data = [];
230   -
231   - for (var key in Object.keys(obj[0])){
232   -
233   - var name = Object.keys(obj[0])[key];
234   - var data = [];
235   - var value;
236   -
237   - for (var i in obj) {
238   - data.push(obj[i][name]);
239   - //value = obj[i][name];
240   - //if(!isNaN(value) && value != "")
241   - // value = parseFloat(obj[i][name]);
242   - //data.push(value);
243   - }
244   -
245   - this.data.push({
246   - name: name,
247   - data: data
248   - });
249   - }
250   - },
251   -
252   - _getProvider : function(field) {
253   - if(field.indexOf("result,records") > -1)
254   - return "ckan";
255   - else if(field.indexOf("records,fields") > -1)
256   - return "openDataSoft";
257   - else
258   - return "provider";
259   - },
260   -
261   - _fieldName : function(field, provider) {
262   - if(provider.indexOf("ckan") > -1) {
263   - return "[" + field.substring(field.lastIndexOf(",") + 1, field.length) + "]";
264   - }
265   - else if(provider.indexOf("openDataSoft") > -1) {
266   - return "fields->["+field.substring(field.lastIndexOf(",")+1, field.length)+"]";
267   - }
268   - else {
269   - return "["+field.substring(field.lastIndexOf(",")+1, field.length)+"]";
270   - }
271   - },
272   -
273   - _path : function(field, provider) {
274   - if(provider.indexOf("ckan") > -1) {
275   - return "result->records"
276   - }
277   - else if(provider.indexOf("openDataSoft") > -1) {
278   - return "records";
279   - }
280   - else {
281   - return field.substring(0, field.lastIndexOf(",")).replace(",", "->");
282   - }
283   - },
284   -
285   - /**
286   - * Delete a image after loading a datalet
287   - */
288   - _deleteWaitImage : function() {
289   - $("img[src$='spin.svg']").remove();
290   - }
291   -
292   -};
293 0 \ No newline at end of file
datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior_old2.js deleted
1   -/*
2   -@license
3   - The MIT License (MIT)
4   -
5   - Copyright (c) 2015 Dipartimento di Informatica - Universit� di Salerno - Italy
6   -
7   - Permission is hereby granted, free of charge, to any person obtaining a copy
8   - of this software and associated documentation files (the "Software"), to deal
9   - in the Software without restriction, including without limitation the rights
10   - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11   - copies of the Software, and to permit persons to whom the Software is
12   - furnished to do so, subject to the following conditions:
13   -
14   - The above copyright notice and this permission notice shall be included in
15   - all copies or substantial portions of the Software.
16   -
17   - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18   - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19   - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20   - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21   - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22   - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23   - THE SOFTWARE.
24   -*/
25   -
26   -/**
27   - * Developed by :
28   - * ROUTE-TO-PA Project - grant No 645860. - www.routetopa.eu
29   - *
30   -*/
31   -
32   -
33   -var AjaxJsonAlasqlBehavior = {
34   -
35   - properties: {
36   -
37   - /**
38   - * It contains the json data from async xhr call returned from core-ajax core component
39   - *
40   - * @attribute json_results
41   - * @type object
42   - * @default 'null'.
43   - */
44   - json_results: {
45   - type: Object,
46   - value: {}
47   - }
48   -
49   - },
50   -
51   - /**
52   - * Make an AJAX call to the dataset URL
53   - *
54   - * @method requestData
55   - */
56   - requestData: function(){
57   -
58   - var comp = this;
59   -
60   - $.ajax({
61   - url: this._component.dataUrl,
62   - dataType: "json",
63   - success: function(e){
64   - comp.handleResponse(e);
65   - }
66   - });
67   - },
68   -
69   - /**
70   - * Called when core-ajax component receive the json data from called url.
71   - *
72   - * @method handleResponse
73   - */
74   - handleResponse: function(e) {
75   - this.properties.json_results.value = e;
76   - this.runWorkcycle();
77   - },
78   -
79   - /**
80   - * selectData built a JSONPATH query based on the user selected fields then extract data from the JSON response.
81   - * This method built an objects <name, data> for every user selected field and push it into the data array.
82   - *
83   - * @method selectData
84   - */
85   - selectData : function() {
86   - this._component.fields = JSON.parse(this._component.fields);
87   - var provider = this._getProvider(this._component.fields[0]);
88   -
89   - var filters = JSON.parse(this._component.getAttribute("filters"));
90   - var aggregators = JSON.parse(this._component.getAttribute("aggregators"));
91   - var orders = JSON.parse(this._component.getAttribute("orders"));
92   -
93   - //preview my space
94   - if(filters && filters[0] && filters[0].constructor == Array){
95   - filters = filters[0];
96   - aggregators = aggregators[0];
97   - orders = orders[0];
98   - }
99   -
100   - var fields = [];
101   - for (var i=0; i < this._component.fields.length; i++)
102   - fields.push(this._fieldName(this._component.fields[i], provider));
103   -
104   - //if(aggregators)
105   - // for (var i=0; i < aggregators.length; i++)
106   - // aggregators[i]["field"] = this._fieldName(aggregators[i]["field"], provider);
107   -
108   - //var jsonData = [this.properties.json_results.value];
109   -
110   - //jsdatachecker
111   - var _converter = new DataTypeConverter();
112   - var path2 = this._arrayPath(provider);
113   - var processingResult = _converter.inferJsonDataType(this.properties.json_results.value, path2);
114   - var processingResults = _converter.convert(processingResult);
115   - var jsonData = [processingResults.dataset];
116   -
117   - //WHERE
118   - var where = "";
119   - if(filters && filters.length) {
120   -
121   - for (var i=0; i < filters.length; i++)
122   - filters[i]["field"] = this._fieldName(filters[i]["field"], provider);
123   -
124   - where = "WHERE ";
125   - for (var i=0; i < filters.length; i++) {
126   - if(filters[i]["operation"] == "contains")
127   - where += filters[i]["field"] + " like '%" + filters[i]["value"] + "%' AND ";
128   - else if(filters[i]["operation"] == "start")
129   - where += filters[i]["field"] + " like '" + filters[i]["value"] + "%' AND ";
130   - else if(filters[i]["operation"] == "ends")
131   - where += filters[i]["field"] + " like '%" + filters[i]["value"] + "' AND ";
132   - else
133   - where += filters[i]["field"] + " " + filters[i]["operation"] + " " + filters[i]["value"] + " AND ";
134   - }
135   - where = where.slice(0, -5);
136   - }
137   -
138   - //ORDER BY
139   - var orderBy = "";
140   - if(orders && orders.length) {
141   -
142   - for (var i=0; i < orders.length; i++)
143   - orders[i]["field"] = this._fieldName(orders[i]["field"], "");
144   -
145   - orderBy = "ORDER BY ";
146   - for (var i = 0; i < orders.length; i++)
147   - orderBy += orders[i]["field"] + " " + orders[i]["operation"] + ", ";
148   - orderBy = orderBy.slice(0, -2);
149   - }
150   -
151   - //SELECT
152   - var pureSelect = "SELECT ";
153   - for (var i = 0; i < fields.length; i++)
154   - pureSelect += fields[i] + " as " + this._fieldName(this._component.fields[i], "") + ", ";
155   - pureSelect = pureSelect.slice(0, -2);
156   -
157   - //GROUP BY
158   - //var groupBy = "";
159   - //if(aggregators && aggregators.length) {
160   - //
161   - // for (var i=0; i < aggregators.length; i++)
162   - // aggregators[i]["field"] = this._fieldName(aggregators[i]["field"], provider);
163   - //
164   - // groupBy = "GROUP BY " + aggregators[0]["field"];
165   - // select = "SELECT " + aggregators[0]["field"];
166   - // for (var i = 1; i < aggregators.length; i++)
167   - // select += ", " + aggregators[i]["operation"] + "(" + aggregators[i]["field"] + ") as " + aggregators[i]["field"];
168   - //}
169   -
170   - //var groupBy = "";
171   - //if(aggregators && aggregators.length) {
172   - //
173   - // groupBy = "GROUP BY " + this._fieldName(aggregators[0]["field"], "");
174   - // select = "SELECT " + this._fieldName(aggregators[0]["field"], provider) + " as " + this._fieldName(aggregators[0]["field"], "");
175   - // for (var i = 1; i < aggregators.length; i++)
176   - // select += ", " + aggregators[i]["operation"] + "(" + this._fieldName(aggregators[i]["field"], provider) + ") as " + this._fieldName(aggregators[i]["field"], "");
177   - //}
178   -
179   - //GROUP BY
180   - var groupBy = "";
181   - if(aggregators && aggregators.length) {
182   -
183   - for (var i=0; i < aggregators.length; i++)
184   - aggregators[i]["field"] = this._fieldName(aggregators[i]["field"], "");
185   -
186   - groupBy = "GROUP BY " + aggregators[0]["field"];
187   - var select = "SELECT " + aggregators[0]["field"];
188   - for (var i = 1; i < aggregators.length; i++)
189   - select += ", " + aggregators[i]["operation"] + "(" + aggregators[i]["field"] + ") as " + aggregators[i]["field"];
190   - }
191   -
192   - //QUERY
193   - var path = this._path(this._component.fields[0], provider);
194   -
195   - console.log('SELECT '+ path +' FROM ?');
196   - var res = alasql("SELECT "+ path +" FROM ?", [jsonData]);
197   -
198   - var records = res[0][path];
199   -
200   - //console.log(select + ' FROM ? ' + where + ' ' + groupBy + ' ' + orderBy + '');
201   - //var obj = alasql(select + " FROM ? " + where + " " + groupBy + " " + orderBy + "", [records]);
202   -
203   - console.log(pureSelect + ' FROM ? ' + where);
204   - var obj = alasql(pureSelect + " FROM ? " + where, [records]);
205   -
206   - if (groupBy != "") {
207   - console.log(select + ' FROM ? ' + groupBy + ' ' + orderBy + '');
208   - obj = alasql(select + " FROM ? " + groupBy + " " + orderBy + "", [obj]);
209   - }
210   -
211   - //TEST
212   - //var query = "SELECT [preteur], [annee] as [annee], SUM([capital_restant_du]) as [capital_restant_du] FROM ? GROUP BY [preteur], [annee]"
213   - //var obj = alasql(query, [obj]);
214   - //console.log(obj);
215   - //this.data = obj;
216   -
217   - //PUSH DATA
218   - if(!obj || obj.length == 0)
219   - this.data = []
220   - else
221   - this._pushData(obj, fields);
222   -
223   - this._deleteWaitImage();
224   - },
225   -
226   - _pushData : function(obj, keys) {
227   - this.data = [];
228   -
229   - if (typeof keys == 'undefined')
230   - keys = Object.keys(obj[0]);
231   -
232   - for (var key in keys){
233   -
234   - var name = keys[key].replace(/(\[|\]|fields->)/g, "");
235   - var data = [];
236   -
237   - for (var i in obj) {
238   - data.push(obj[i][name]);
239   - }
240   -
241   - this.data.push({
242   - name: name,
243