Commit 89558a416e35b2af0a2c60cf45564fcb8ac1f85d
1 parent
1a26bccd
datatype, provider mod
Showing
20 changed files
with
1230 additions
and
707 deletions
alasql-utility/alasql-utility.js
1 | -/** | |
2 | - * Created by renato on 31/05/16. | |
3 | - */ | |
1 | +function alasql_selectData (data, fields, filters) { | |
2 | + if(fields.length == 0) | |
3 | + return []; | |
4 | + | |
5 | + var _fields = _addParenthesis(fields); | |
6 | + | |
7 | + var select = _alasql_SELECT(_fields); | |
8 | + | |
9 | + var where = ""; | |
10 | + if(filters && filters.length) { | |
11 | + var _filters = _copy(filters); | |
12 | + where = _alasql_WHERE(_filters); | |
13 | + } | |
14 | + | |
15 | + var query = select + " FROM ?" + where; | |
16 | + | |
17 | + return alasql(query, [data]); | |
18 | +} | |
19 | + | |
20 | +function alasql_complexSelectData (data, fields, filters, aggregators, orders) { | |
21 | + if(fields.length == 0) | |
22 | + return []; | |
23 | + | |
24 | + var _fields = _addParenthesis(fields); | |
25 | + | |
26 | + var select = _alasql_SELECT(_fields); | |
27 | + | |
28 | + var where = ""; | |
29 | + if(filters && filters.length) { | |
30 | + var _filters = _copy(filters); | |
31 | + where = _alasql_WHERE(_filters); | |
32 | + } | |
33 | + | |
34 | + var orderBy = ""; | |
35 | + if(orders && orders.length) { | |
36 | + var _orders = _copy(orders); | |
37 | + orderBy = _alasql_ORDERBY(_orders); | |
38 | + } | |
39 | + | |
40 | + var groupBy = ""; | |
41 | + if(aggregators && aggregators.length) { | |
42 | + var _aggregators = _copy(aggregators); | |
43 | + groupBy = _alasql_GROUPBY(_aggregators); | |
44 | + select = groupBy[0]; | |
45 | + groupBy = groupBy[1]; | |
46 | + } | |
47 | + | |
48 | + var query = select + " FROM ?" + where + " " + groupBy + " " + orderBy; | |
49 | + | |
50 | + return alasql(query, [data]); | |
51 | +} | |
52 | + | |
53 | +function _alasql_SELECT (fields) { | |
54 | + | |
55 | + var select = "SELECT "; | |
56 | + | |
57 | + if(fields[0] == "*") | |
58 | + return select += "*"; | |
59 | + | |
60 | + for (var i = 0; i < fields.length; i++) | |
61 | + select += fields[i] + ", "; | |
62 | + return select.slice(0, -2); | |
63 | +} | |
64 | + | |
65 | +function _alasql_WHERE (filters) { | |
66 | + var where = " WHERE "; | |
67 | + var logicalOperator; | |
68 | + | |
69 | + /*DEPRECATED*/if(filters[0].logicalOperator == undefined) { | |
70 | + logicalOperator = "AND" | |
71 | + } | |
72 | + else { | |
73 | + logicalOperator = filters[0].logicalOperator; | |
74 | + filters = filters.slice(1); | |
75 | + } | |
76 | + | |
77 | + for (var i=0; i < filters.length; i++) | |
78 | + filters[i]["field"] = _normalizeField(filters[i]["field"]); | |
79 | + | |
80 | + for (var i=0; i < filters.length; i++) { | |
81 | + if(filters[i]["operation"] == "contains") | |
82 | + where += filters[i]["field"] + " like '%" + filters[i]["value"] + "%' " + logicalOperator + " "; | |
83 | + else if(filters[i]["operation"] == "not contains") | |
84 | + where += filters[i]["field"] + " not like '%" + filters[i]["value"] + "%' " + logicalOperator + " "; | |
85 | + else if(filters[i]["operation"] == "start") | |
86 | + where += filters[i]["field"] + " like '" + filters[i]["value"] + "%' " + logicalOperator + " "; | |
87 | + else if(filters[i]["operation"] == "ends") | |
88 | + where += filters[i]["field"] + " like '%" + filters[i]["value"] + "' " + logicalOperator + " "; | |
89 | + else | |
90 | + where += filters[i]["field"] + " " + filters[i]["operation"] + " " + filters[i]["value"] + " " + logicalOperator + " "; | |
91 | + } | |
92 | + | |
93 | + return where.slice(0, -4); | |
94 | +} | |
95 | + | |
96 | +function _alasql_GROUPBY (aggregators) { | |
97 | + for (var i=0; i < aggregators.length; i++) | |
98 | + aggregators[i]["field"] = _normalizeField(aggregators[i]["field"]); | |
99 | + | |
100 | + var select = "SELECT "; | |
101 | + var groupBy = "GROUP BY "; | |
102 | + | |
103 | + for (var i = 0; i < aggregators.length; i++) { | |
104 | + if(aggregators[i]["operation"] == "GROUP BY") { | |
105 | + select += aggregators[i]["field"] + ", "; | |
106 | + groupBy += aggregators[i]["field"] + ", "; | |
107 | + } | |
108 | + else | |
109 | + select += aggregators[i]["operation"] + "(" + aggregators[i]["field"] + ") as " + aggregators[i]["field"] + ", "; | |
110 | + } | |
111 | + | |
112 | + return [select.slice(0, -2), groupBy.slice(0, -2)]; | |
113 | +} | |
114 | + | |
115 | +function _alasql_ORDERBY (orders) { | |
116 | + for (var i=0; i < orders.length; i++) | |
117 | + orders[i]["field"] = _normalizeField(orders[i]["field"]); | |
118 | + | |
119 | + var orderBy = "ORDER BY "; | |
120 | + | |
121 | + for (var i = 0; i < orders.length; i++) | |
122 | + orderBy += orders[i]["field"] + " " + orders[i]["operation"] + ", "; | |
123 | + | |
124 | + return orderBy.slice(0, -2); | |
125 | +} | |
126 | + | |
127 | +function _addParenthesis (fields) { | |
128 | + var result = []; | |
129 | + | |
130 | + for (var i=0; i < fields.length; i++) | |
131 | + result.push(_normalizeField(fields[i])); | |
132 | + | |
133 | + return result; | |
134 | +} | |
135 | + | |
136 | +function _normalizeField (field) { | |
137 | + /*DEPRECATED*/return "[" + field.substring(field.lastIndexOf(",") + 1, field.length) + "]"; | |
138 | + //return "[" + field + "]"; | |
139 | +} | |
140 | + | |
141 | +function transformData (data, fields, truncate) { | |
142 | + if(!data || data.length == 0) | |
143 | + return []; | |
144 | + | |
145 | + /*DEPRECATED*/for (var i=0; i < fields.length; i++) | |
146 | + fields[i] = fields[i].substring(fields[i].lastIndexOf(",") + 1, fields[i].length); | |
147 | + | |
148 | + var tData = []; | |
149 | + | |
150 | + for (var i in fields){ | |
151 | + | |
152 | + var field = fields[i]; | |
153 | + var values = []; | |
154 | + | |
155 | + for (var i in data) { | |
156 | + var v = data[i][field]; | |
157 | + if(truncate) | |
158 | + if(!isNaN(v) && v % 1 != 0) | |
159 | + v = Math.floor(v * 100) / 100; | |
160 | + values.push(v); | |
161 | + } | |
162 | + | |
163 | + tData.push({ | |
164 | + name: field, | |
165 | + data: values | |
166 | + }); | |
167 | + } | |
168 | + | |
169 | + return tData; | |
170 | +}; | |
171 | + | |
172 | +function _copy (o) { | |
173 | + var out, v, key; | |
174 | + out = Array.isArray(o) ? new Array(o.length) : {}; | |
175 | + for (key in o) { | |
176 | + v = o[key]; | |
177 | + out[key] = (typeof v === "object") ? this._copy(v) : v; | |
178 | + } | |
179 | + return out; | |
180 | +} | |
4 | 181 | \ No newline at end of file | ... | ... |
controllets/data-sevc-controllet/co-datalets-creator-controllet.html
0 โ 100755
1 | +<script src="../shared_js/perfect-scrollbar/js/min/perfect-scrollbar.jquery.min.js"></script> | |
2 | +<link rel="stylesheet" href="../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css"> | |
3 | + | |
4 | +<script src="../../locales/controllet_ln.js"></script> | |
5 | + | |
6 | +<link rel="import" href="../../bower_components/polymer/polymer.html"> | |
7 | + | |
8 | +<link rel="import" href="../page-slider-controllet/page-slider-controllet.html"> | |
9 | + | |
10 | +<link rel="import" href="../select-data-controllet/select-data-controllet.html" /> | |
11 | +<link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" /> | |
12 | + | |
13 | +<dom-module id="co-datalets-creator-controllet"> | |
14 | + | |
15 | + <template> | |
16 | + | |
17 | + <page-slider-controllet id="slider"> | |
18 | + | |
19 | + <neon-animatable> | |
20 | + | |
21 | + <select-data-controllet id="select_data" data-url={{dataUrl}} data={{data}}></select-data-controllet> | |
22 | + | |
23 | + </neon-animatable> | |
24 | + | |
25 | + <neon-animatable> | |
26 | + | |
27 | + <select-visualization-controllet id="select_visualization" deep-url={{deepUrl}} datalets-list-url={{dataletsListUrl}}></select-visualization-controllet> | |
28 | + | |
29 | + </neon-animatable> | |
30 | + | |
31 | + </page-slider-controllet> | |
32 | + | |
33 | + </template> | |
34 | + | |
35 | + <script> | |
36 | + | |
37 | + Polymer({ | |
38 | + | |
39 | + is : 'co-datalets-creator-controllet', | |
40 | + | |
41 | + listeners : { | |
42 | + 'page-slider-controllet_selected' : '_updateSlider', | |
43 | + 'dataset-selection-controllet_data-url' : '_allowSecondStep', | |
44 | + 'select-fields-controllet_selected-fields' : '_allowThirdStep', | |
45 | + 'filters-controllet_filters': '_allowThirdStep' | |
46 | + }, | |
47 | + | |
48 | + properties : { | |
49 | + | |
50 | + dataUrl : { | |
51 | + type : String, | |
52 | + value : undefined | |
53 | + }, | |
54 | + | |
55 | + data : { | |
56 | + type : Array, | |
57 | + value : [] | |
58 | + }, | |
59 | + | |
60 | + deepUrl : { | |
61 | + type : String, | |
62 | + value : undefined | |
63 | + }, | |
64 | + | |
65 | + dataletsListUrl : { | |
66 | + type : String , | |
67 | + value : undefined | |
68 | + }, | |
69 | + | |
70 | + localization : { | |
71 | + type : String, | |
72 | + value : "en" | |
73 | + } | |
74 | + | |
75 | + }, | |
76 | + | |
77 | + ready : function(){ | |
78 | + ln["localization"] = this.localization; | |
79 | + | |
80 | + this.$.select_data.init(); | |
81 | + }, | |
82 | + | |
83 | + _updateSlider : function(e){ | |
84 | + switch (e.detail.selected) { | |
85 | + case 0: | |
86 | + this.$.slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]); | |
87 | + | |
88 | + this.$.slider.chevronLeft("invisible"); | |
89 | + this.$.slider.chevronRight(false); | |
90 | + | |
91 | + if(this.$.slider.getPrevSelected() == 2) | |
92 | + this.$.slider.chevronRight(true); | |
93 | + break; | |
94 | + case 1: | |
95 | + this.$.slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]); | |
96 | + | |
97 | + this.$.slider.chevronLeft(true); | |
98 | + this.$.slider.chevronRight("invisible"); | |
99 | + } | |
100 | + }, | |
101 | + | |
102 | + _allowThirdStep : function(){ | |
103 | + this.$.slider.chevronRight(false); | |
104 | + var fields = this.$.select_data.getSelectedFields(); | |
105 | + var filters = this.$.select_data.getFilters(); | |
106 | + var data = this.$.select_data.getData(); | |
107 | + if(fields.length > 0) { | |
108 | + this.$.select_visualization.init(); | |
109 | + this.$.select_visualization.setFields(fields); | |
110 | + this.$.select_visualization.setFilters(filters); | |
111 | + this.$.select_visualization.setData(data); | |
112 | + this.$.slider.chevronRight(true); | |
113 | + } | |
114 | + } | |
115 | + | |
116 | + }); | |
117 | + | |
118 | + </script> | |
119 | + | |
120 | +</dom-module> | |
0 | 121 | \ No newline at end of file | ... | ... |
controllets/data-sevc-controllet/data-sevc-controllet.html
... | ... | @@ -7,13 +7,10 @@ |
7 | 7 | |
8 | 8 | <link rel="import" href="../page-slider-controllet/page-slider-controllet.html"> |
9 | 9 | |
10 | -<!--<link rel="import" href="../dataset-selection-controllet/dataset-selection-controllet.html">--> | |
11 | 10 | <link rel="import" href="../select-dataset-controllet/select-dataset-controllet.html"> |
12 | 11 | <link rel="import" href="../select-data-controllet/select-data-controllet.html" /> |
13 | 12 | <link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" /> |
14 | 13 | |
15 | - | |
16 | - | |
17 | 14 | <dom-module id="data-sevc-controllet"> |
18 | 15 | |
19 | 16 | <template> |
... | ... | @@ -22,22 +19,19 @@ |
22 | 19 | |
23 | 20 | <neon-animatable> |
24 | 21 | |
25 | - <template is="dom-if" if={{!modify}}> | |
26 | - <!--<dataset-selection-controllet id="select_dataset" data={{data}} datasets={{datasets}} suggested-datasets={{suggestedDatasets}}></dataset-selection-controllet>--> | |
27 | - <select-dataset-controllet id="select_dataset" data={{data}} datasets={{datasets}} suggested-datasets={{suggestedDatasets}}></select-dataset-controllet> | |
28 | - </template> | |
22 | + <select-dataset-controllet id="select_dataset" datasets={{datasets}} suggested-datasets={{suggestedDatasets}}></select-dataset-controllet> | |
29 | 23 | |
30 | 24 | </neon-animatable> |
31 | 25 | |
32 | 26 | <neon-animatable> |
33 | 27 | |
34 | - <select-data-controllet id="select_data" data-url={{dataUrl}} preselected-fields={{selectedFields}} datalet-preset="{{dataletPreset}}"></select-data-controllet> | |
28 | + <select-data-controllet id="select_data"></select-data-controllet> | |
35 | 29 | |
36 | 30 | </neon-animatable> |
37 | 31 | |
38 | 32 | <neon-animatable> |
39 | 33 | |
40 | - <select-visualization-controllet id="select_visualization" deep-url={{deepUrl}} datalets-list-url={{dataletsListUrl}} data-url={{dataUrl}} preselected-datalet={{selectedDatalet}} datalet-preset={{dataletPreset}}></select-visualization-controllet> | |
34 | + <select-visualization-controllet id="select_visualization" deep-url={{deepUrl}} datalets-list-url={{dataletsListUrl}}></select-visualization-controllet> | |
41 | 35 | |
42 | 36 | </neon-animatable> |
43 | 37 | |
... | ... | @@ -54,23 +48,14 @@ |
54 | 48 | listeners : { |
55 | 49 | 'page-slider-controllet_selected' : '_updateSlider', |
56 | 50 | 'dataset-selection-controllet_data-url' : '_allowSecondStep', |
57 | - 'tree-view-controllet_selected-fields' : '_allowThirdStep' | |
51 | + 'select-fields-controllet_selected-fields' : '_allowThirdStep', | |
52 | + 'filters-controllet_filters': '_allowThirdStep' | |
58 | 53 | }, |
59 | 54 | |
60 | 55 | properties : { |
61 | 56 | |
62 | - deepUrl : { | |
63 | - type : String, | |
64 | - value : undefined | |
65 | - }, | |
66 | - | |
67 | - dataletsListUrl : { | |
68 | - type : String , | |
69 | - value : undefined | |
70 | - }, | |
71 | - | |
72 | 57 | datasets : { |
73 | - type : Array, | |
58 | + type : Object, | |
74 | 59 | value : undefined |
75 | 60 | }, |
76 | 61 | |
... | ... | @@ -79,36 +64,16 @@ |
79 | 64 | value : undefined |
80 | 65 | }, |
81 | 66 | |
82 | - dataUrl : { | |
83 | - type : String, | |
84 | - value : undefined | |
85 | - }, | |
86 | - | |
87 | - jsonData : { | |
88 | - type : Object, | |
67 | + deepUrl : { | |
68 | + type : String, | |
89 | 69 | value : undefined |
90 | 70 | }, |
91 | 71 | |
92 | - modify : { | |
93 | - type : Boolean, | |
94 | - value : false | |
95 | - }, | |
96 | - | |
97 | - selectedDatalet : { | |
98 | - type : String, | |
72 | + dataletsListUrl : { | |
73 | + type : String , | |
99 | 74 | value : undefined |
100 | 75 | }, |
101 | 76 | |
102 | - selectedFields : { | |
103 | - type : Array, | |
104 | - value : [] | |
105 | - }, | |
106 | - | |
107 | - dataletPreset : { | |
108 | - type : Object, | |
109 | - value : [] | |
110 | - }, | |
111 | - | |
112 | 77 | localization : { |
113 | 78 | type : String, |
114 | 79 | value : "en" |
... | ... | @@ -117,86 +82,79 @@ |
117 | 82 | }, |
118 | 83 | |
119 | 84 | ready : function(){ |
120 | - if(this.selectedDatalet){ | |
121 | - this.modify = true; | |
122 | - this.$.slider.selected = 1; | |
123 | - this.dataUrl = this.dataletPreset["data-url"]; | |
124 | - } | |
125 | 85 | ln["localization"] = this.localization; |
126 | 86 | }, |
127 | 87 | |
128 | 88 | _updateSlider : function(e){ |
129 | 89 | switch (e.detail.selected) { |
130 | 90 | case 0: |
131 | - slider.setTitle(ln["slide1Title_" + this.localization], ln["slide1Subtitle_" + this.localization]); | |
132 | - slider.chevronLeft("invisible"); | |
133 | - slider.chevronRight(false); | |
134 | - if(slider.getPrevSelected() == 1) | |
135 | - slider.chevronRight(true); | |
91 | + this.$.slider.setTitle(ln["slide1Title_" + this.localization], ln["slide1Subtitle_" + this.localization]); | |
92 | + | |
93 | + this.$.slider.chevronLeft("invisible"); | |
94 | + this.$.slider.chevronRight(false); | |
95 | + | |
96 | + if(this.$.slider.getPrevSelected() == 1) | |
97 | + this.$.slider.chevronRight(true); | |
136 | 98 | break; |
137 | 99 | case 1: |
138 | - slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]); | |
139 | - if(this.modify){ | |
140 | - slider.chevronLeft("invisible"); | |
141 | - } | |
142 | - else{ | |
143 | - slider.chevronLeft(true); | |
144 | - } | |
145 | - slider.chevronRight(false); | |
146 | - this._allowThirdStep({detail: {fields: select_data.getFlatFields()}}); | |
147 | - if(this.modify){ | |
148 | - this.$.select_visualization.setFields(select_data.getFlatFields()); | |
149 | - this.$.select_visualization.setFilters(select_data.getFilters()); | |
150 | - } | |
100 | + this.$.slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]); | |
101 | + | |
102 | + this.$.slider.chevronLeft(true); | |
103 | + this.$.slider.chevronRight(false); | |
104 | + | |
105 | + if(this.$.slider.getPrevSelected() == 2) | |
106 | + this.$.slider.chevronRight(true); | |
151 | 107 | break; |
152 | 108 | case 2: |
153 | - slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]); | |
154 | - slider.chevronLeft(true); | |
155 | - slider.chevronRight("invisible"); | |
156 | - | |
157 | - this.$.select_visualization.setFields(select_data.getFlatFields()); | |
158 | - this.$.select_visualization.setFilters(select_data.getFilters()); | |
159 | - if(this.modify) { | |
160 | - this.$.select_visualization.show();//resize | |
161 | - } | |
109 | + this.$.slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]); | |
110 | + | |
111 | + this.$.slider.chevronLeft(true); | |
112 | + this.$.slider.chevronRight("invisible"); | |
162 | 113 | } |
163 | 114 | }, |
164 | 115 | |
165 | 116 | _allowSecondStep : function(e){ |
166 | 117 | if(e.detail.url == "") { |
167 | - slider.chevronRight(false); | |
168 | - select_dataset.$.selected_url.invalid = false; | |
118 | + this.$.slider.chevronRight(false); | |
119 | + this.$.select_dataset.$.selected_url.invalid = false; | |
169 | 120 | return; |
170 | 121 | } |
171 | 122 | |
172 | - this.dataUrl = e.detail.url; | |
123 | + var that = this; | |
173 | 124 | |
174 | 125 | $.ajax({ |
175 | 126 | url: e.detail.url, |
176 | 127 | dataType: "json", |
177 | - success: function(data){ | |
178 | -// this.dataUrl = e.detail.url | |
179 | -// this.jsonData = JSON.stringify(data); | |
180 | - slider.chevronRight(true); | |
181 | - select_dataset.$.selected_url.invalid = false; | |
128 | + success: function(){ | |
129 | + that.$.select_dataset.$.selected_url.invalid = false; | |
130 | + var f = Object.create(providerFactory); | |
131 | + var provider = f.getProvider(e.detail.url); | |
132 | + var dataUrl = provider.addLimit(e.detail.url); | |
133 | + that.$.select_data.dataUrl = dataUrl; | |
134 | + that.$.select_data.init(); | |
135 | + that.$.select_visualization.dataUrl = dataUrl; | |
136 | + that.$.select_visualization.init(); | |
137 | + that.$.slider.chevronRight(true); | |
182 | 138 | }, |
183 | 139 | error: function(){ |
184 | -// this.jsonData = undefined; | |
185 | - slider.chevronRight(false); | |
186 | - select_dataset.$.selected_url.invalid = true; | |
140 | + that.$.slider.chevronRight(false); | |
141 | + that.$.select_dataset.$.selected_url.invalid = true; | |
187 | 142 | } |
188 | 143 | }); |
189 | - | |
190 | - this.$.select_visualization.reset(); | |
191 | 144 | }, |
192 | 145 | |
193 | - _allowThirdStep : function(e){ | |
194 | - if(e.detail.fields.length > 0) | |
195 | - slider.chevronRight(true); | |
196 | - else | |
197 | - slider.chevronRight(false); | |
198 | - | |
199 | - //this.$.select_visualization.reset(); | |
146 | + _allowThirdStep : function(){ | |
147 | + this.$.slider.chevronRight(false); | |
148 | + var fields = this.$.select_data.getSelectedFields(); | |
149 | + var filters = this.$.select_data.getFilters(); | |
150 | + var data = this.$.select_data.getData(); | |
151 | + if(fields.length > 0) { | |
152 | + this.$.select_visualization.init(); | |
153 | + this.$.select_visualization.setFields(fields); | |
154 | + this.$.select_visualization.setFilters(filters); | |
155 | + this.$.select_visualization.setData(data); | |
156 | + this.$.slider.chevronRight(true); | |
157 | + } | |
200 | 158 | } |
201 | 159 | |
202 | 160 | }); | ... | ... |
controllets/data-sevc-controllet/demo/index.html
... | ... | @@ -10,14 +10,20 @@ |
10 | 10 | <link rel="stylesheet" href="../../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css"> |
11 | 11 | |
12 | 12 | <link rel="import" href="../data-sevc-controllet.html" /> |
13 | + <link rel="import" href="../co-datalets-creator-controllet.html" /> | |
13 | 14 | </head> |
14 | 15 | |
15 | 16 | <body> |
16 | 17 | |
17 | - <data-sevc-controllet localization="en" id="dsc" deep-url="http://172.16.15.77/DEEalerProvider/DEEP/" datalets-list-url="http://172.16.15.77/DEEalerProvider/DEEP/datalets-list" | |
18 | - datasets='{"result":{"providers":{"1":{"title":"CKAN","api_url":"http:\/\/ckan.routetopa.eu","image_hash":"11","id":"1"}},"datasets":[{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 2","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b056c5e6-76af-4526-a35d-7dee664fb6ee\/download\/isislab.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) ROUTE-TO-PA Dissemination","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/818c2edb-0cb7-4288-b340-e4dd1933d817\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) ROUTE-TO-PA Dissemination - dl","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/fd8c4d6f-315d-4aa0-b7bd-4fdde7bf641b\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) dissemination of ROUTE-TO-PA project","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/b0ef6017-8c64-4e11-8046-7e51a8561856\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"test dissemination with link","resource_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","url":"http:\/\/ckan.routetopa.eu\/dataset\/ba5054af-7561-4f99-9504-76ea004a1e85\/resource\/4cc2349d-bf7b-4bbe-a7ca-db5312bb6c94\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Dissemination activity of the first year","resource_name":"Dissemination activity of the first year (2015)","url":"http:\/\/ckan.routetopa.eu\/dataset\/61f07087-210a-4c35-9606-2aafe183633b\/resource\/5f9d8d8b-1c41-45f7-9dbb-61b9a7bcd076\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"City of the Hague Municipality","package_name":"Test 3- Buurten","resource_name":"Test Buurten - 3","url":"http:\/\/ckan.routetopa.eu\/dataset\/1248d447-2901-4beb-91ae-c2f249fd8a99\/resource\/1fdbc765-8945-4271-8dce-9c7eba45a67d\/download\/Test-3-Compare.csv","metas":"{\"organization\":\"City of the Hague Municipality\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"}]}}' | |
19 | - suggested-datasets='[{"resource_name":"SUGGESTED 1","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"},{"resource_name":"SUGGESTED 2","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"},{"resource_name":"SUGGESTED 3","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"}]' | |
20 | - ></data-sevc-controllet> | |
18 | + <!--<data-sevc-controllet deep-url="http://172.16.15.38/DEEalerProvider/DEEP/"--> | |
19 | + <!--datalets-list-url="http://172.16.15.38/DEEalerProvider/DEEP/datalets-list"--> | |
20 | + <!--datasets='{"result":{"providers":{"1":{"title":"CKAN","api_url":"http:\/\/ckan.routetopa.eu","image_hash":"11","id":"1"}},"datasets":[{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 1","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b3d3d9ff-291e-47ca-a0d2-a15deef81737\/download\/isislab2.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"Dublin","package_name":"isislab DATA","resource_name":"Resource 2","url":"http:\/\/ckan.routetopa.eu\/dataset\/566c2867-ea89-45a2-bd7a-30ae82606007\/resource\/b056c5e6-76af-4526-a35d-7dee664fb6ee\/download\/isislab.csv","metas":"{\"organization\":\"Dublin\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) ROUTE-TO-PA Dissemination","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/818c2edb-0cb7-4288-b340-e4dd1933d817\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) ROUTE-TO-PA Dissemination - dl","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/fd8c4d6f-315d-4aa0-b7bd-4fdde7bf641b\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","resource_name":"First year (2015) dissemination of ROUTE-TO-PA project","url":"http:\/\/ckan.routetopa.eu\/dataset\/d81d451d-8b3d-47f4-b57f-e295e8f51da0\/resource\/b0ef6017-8c64-4e11-8046-7e51a8561856\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link-Upd.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"test dissemination with link","resource_name":"Year 1 Dissemination of the ROUTE-TO-PA project (2015)","url":"http:\/\/ckan.routetopa.eu\/dataset\/ba5054af-7561-4f99-9504-76ea004a1e85\/resource\/4cc2349d-bf7b-4bbe-a7ca-db5312bb6c94\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New---Link.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"ROUTE-TO-PA","package_name":"Dissemination activity of the first year","resource_name":"Dissemination activity of the first year (2015)","url":"http:\/\/ckan.routetopa.eu\/dataset\/61f07087-210a-4c35-9606-2aafe183633b\/resource\/5f9d8d8b-1c41-45f7-9dbb-61b9a7bcd076\/download\/ROUTE-TO-PA-Individual-Dissemination-Activity-Report-Form-Responses-New.csv","metas":"{\"organization\":\"ROUTE-TO-PA\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"},{"w":1,"provider_name":"p:1","organization_name":"City of the Hague Municipality","package_name":"Test 3- Buurten","resource_name":"Test Buurten - 3","url":"http:\/\/ckan.routetopa.eu\/dataset\/1248d447-2901-4beb-91ae-c2f249fd8a99\/resource\/1fdbc765-8945-4271-8dce-9c7eba45a67d\/download\/Test-3-Compare.csv","metas":"{\"organization\":\"City of the Hague Municipality\",\"description\":\"\",\"format\":\"\",\"last_modified\":\"\",\"name\":\"\",\"created\":\"\"}"}]}}'--> | |
21 | + <!--suggested-datasets='[{"resource_name":"SUGGESTED 1","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"},{"resource_name":"SUGGESTED 2","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"},{"resource_name":"SUGGESTED 3","url":"noUrl.csv","metas":"{\"description\":\"noDescriione\"}"}]'--> | |
22 | + <!--</data-sevc-controllet>--> | |
23 | + | |
24 | + <co-datalets-creator-controllet data='[{"a":"0", "b":"1"},{"a":"2", "b":"3"}]' deep-url="http://172.16.15.38/DEEalerProvider/DEEP/" | |
25 | + datalets-list-url="http://172.16.15.38/DEEalerProvider/DEEP/datalets-list" | |
26 | + </co-datalets-creator-controllet> | |
21 | 27 | |
22 | 28 | </body> |
23 | 29 | ... | ... |
controllets/filters-controllet/demo/index.html
... | ... | @@ -19,11 +19,11 @@ |
19 | 19 | |
20 | 20 | .container { |
21 | 21 | height: 400px; |
22 | - width: 50%; | |
22 | + width: 1200px; | |
23 | 23 | /*width: 400px;*/ |
24 | 24 | position: relative; |
25 | 25 | top: 100px; |
26 | - left:25%; | |
26 | + left:300px; | |
27 | 27 | } |
28 | 28 | |
29 | 29 | </style> |
... | ... | @@ -41,7 +41,8 @@ |
41 | 41 | |
42 | 42 | filters_controllet.setFields(fields); |
43 | 43 | |
44 | - filters_controllet.filters = [{field: "Lat", operation: "<=", value: "16"}, {field: "Long", operation: "!=", value: "32"}, {field: "Sbiricos", operation: "!=", value: "12AAA32+DAO"}]; | |
44 | + filters_controllet.filters = [{logicalOperator: "OR"}, {field: "Lat", operation: "<=", value: "16"}, {field: "Long", operation: "!=", value: "32"}, {field: "Sbiricos", operation: "!=", value: "12AAA32+DAO"}]; | |
45 | +// filters_controllet.logicalOperator = "or"; | |
45 | 46 | |
46 | 47 | var filters = filters_controllet.getFilters(); |
47 | 48 | ... | ... |
controllets/filters-controllet/filters-controllet.html
1 | 1 | <link rel="import" href="../../bower_components/polymer/polymer.html" /> |
2 | 2 | |
3 | +<link rel="import" href="../../bower_components/paper-material/paper-material.html" /> | |
4 | + | |
3 | 5 | <link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html"> |
4 | 6 | <link rel="import" href="../../bower_components/paper-menu/paper-menu.html"> |
5 | 7 | <link rel="import" href="../../bower_components/paper-item/paper-item.html"> |
... | ... | @@ -8,150 +10,216 @@ |
8 | 10 | <link rel="import" href="../../bower_components/iron-icons/iron-icons.html"> |
9 | 11 | <link rel="import" href="../../bower_components/iron-icon/iron-icon.html"> |
10 | 12 | |
13 | +<link rel="import" href="../../bower_components/paper-button/paper-button.html"> | |
14 | + | |
11 | 15 | <dom-module id="filters-controllet"> |
12 | 16 | |
13 | 17 | <template> |
14 | 18 | |
15 | 19 | <style is="custom-style"> |
16 | 20 | |
17 | - :host { | |
18 | - --paper-dropdown-menu-icon: { | |
19 | - color: #2196F3; | |
20 | - }; | |
21 | - } | |
22 | - | |
23 | 21 | #filters_container { |
24 | - height: 100%; | |
22 | + height: 48px; | |
25 | 23 | width: 100%; |
24 | + } | |
26 | 25 | |
26 | + #filters_container * { | |
27 | 27 | font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif; |
28 | 28 | font-size: 16px; |
29 | + line-height: 24px; | |
29 | 30 | } |
30 | 31 | |
31 | - #filters_panel { | |
32 | - display: none; | |
33 | - position: relative; | |
34 | - height: calc(100% - 48px); | |
35 | - } | |
36 | - | |
37 | - .filters_header { | |
32 | + #filters_container #header { | |
38 | 33 | height: 32px; |
39 | 34 | padding-top: 16px; |
40 | 35 | text-align: center; |
41 | 36 | font-weight: 700; |
42 | 37 | |
38 | + background: #FFFFFF; | |
43 | 39 | color: #00BCD4; |
44 | 40 | cursor: pointer; |
45 | 41 | } |
46 | 42 | |
43 | + #filters_container #header.hide{ | |
44 | + color: #00BCD4; | |
45 | + background: #FFFFFF; | |
46 | + } | |
47 | + | |
48 | + /*#filters_container #header.hide:hover{*/ | |
49 | + /*}*/ | |
50 | + | |
51 | + #filters_container #header.show{ | |
52 | + color: #000000; | |
53 | + background: #B6B6B6; | |
54 | + } | |
55 | + | |
56 | + #filters_container #panel { | |
57 | + display: none; | |
58 | + position: relative; | |
59 | + height: calc(100% - 48px); | |
60 | + background: #FFFFFF; | |
61 | + } | |
62 | + | |
47 | 63 | paper-dropdown-menu { |
48 | - height: 48px; | |
49 | - width: 248px;; | |
64 | + width: 100%; | |
50 | 65 | --paper-input-container-focus-color: #2196F3; |
51 | 66 | } |
52 | 67 | |
68 | + :host { | |
69 | + --paper-dropdown-menu-icon: { | |
70 | + color: #2196F3; | |
71 | + }; | |
72 | + } | |
73 | + | |
74 | + paper-item { | |
75 | + min-width: 128px; | |
76 | + } | |
77 | + | |
53 | 78 | paper-item.iron-selected { |
54 | 79 | background-color: #2196F3; |
55 | 80 | color: #FFFFFF; |
56 | 81 | } |
57 | 82 | |
83 | + paper-input { | |
84 | + width: 100%; | |
85 | + --paper-input-container-focus-color: #2196F3; | |
86 | + } | |
87 | + | |
88 | + paper-button { | |
89 | + margin: 0px; | |
90 | + height: 44px; | |
91 | + color: #FFFFFF; | |
92 | + background: #2196F3; | |
93 | + font-weight: 700; | |
94 | + } | |
95 | + | |
96 | + paper-button:hover { | |
97 | + box-shadow: 0px 8px 12px #888; | |
98 | + -webkit-box-shadow: 0px 8px 12px #888; | |
99 | + -moz-box-shadow: 0px 8px 12px #888; | |
100 | + } | |
101 | + | |
58 | 102 | paper-icon-button { |
103 | + padding: 4px; | |
104 | + } | |
105 | + | |
106 | + paper-icon-button.add { | |
59 | 107 | color: #2196F3; |
60 | 108 | --paper-icon-button-ink-color: #2196F3; |
61 | - margin: 0px; | |
62 | 109 | } |
63 | 110 | |
64 | 111 | paper-icon-button.cancel { |
65 | 112 | color: #F44336; |
66 | 113 | --paper-icon-button-ink-color: #F44336; |
67 | - margin-bottom: -6px; | |
68 | - margin-left: -8px; | |
69 | 114 | } |
70 | - paper-icon-button.add { | |
71 | - margin-bottom: -6px; | |
72 | - margin-left: -8px; | |
115 | + | |
116 | + #filters_container .row { | |
117 | + display: flex; | |
118 | + height: 60px; | |
119 | + width: 100%; | |
73 | 120 | } |
74 | 121 | |
75 | - paper-input { | |
122 | + #filters_container .ddl_container { | |
123 | + display: flex; | |
124 | + height: 60px; | |
125 | + width: 25%; | |
126 | + padding: 0px 8px; | |
127 | + } | |
128 | + | |
129 | + #filters_container .add_container { | |
130 | + height: 40px; | |
131 | + width: 40px; | |
132 | + padding: 10px 0px; | |
133 | + } | |
134 | + | |
135 | + #filters_container .andOr_container { | |
76 | 136 | display: inline-block; |
77 | - height: 48px; | |
78 | - width: 248px; | |
79 | - --paper-input-container-focus-color: #2196F3; | |
137 | + height: 44px; | |
138 | + width: calc(100% - 40px); | |
139 | + padding: 8px 0px; | |
140 | + text-align: right; | |
80 | 141 | } |
81 | 142 | |
82 | - td { | |
143 | + #filters_container .row2 { | |
144 | + display: flex; | |
83 | 145 | height: 48px; |
84 | - padding: 0px; | |
85 | - padding-bottom: 4px; | |
86 | - margin: 0px; | |
87 | - width: 248px; | |
88 | - border-bottom: 1px solid #2196F3; | |
89 | - vertical-align: bottom; | |
146 | + width: 100%; | |
90 | 147 | } |
91 | 148 | |
92 | - th { | |
93 | - height: 48px; | |
94 | - padding: 0px; | |
95 | - margin: 0px; | |
96 | - vertical-align: bottom; | |
97 | - text-align: left ; | |
149 | + #filters_container .row2 .highlighted { | |
150 | + color: #2196F3; | |
151 | + font-weight: 700; | |
152 | + } | |
153 | + | |
154 | + #filters_container .filter { | |
155 | + height: 24px; | |
156 | + width: calc(75% - 16px); | |
157 | + padding: 12px 8px; | |
98 | 158 | } |
99 | 159 | |
100 | - .filters_cell_button { | |
101 | - width: 24px; | |
102 | - border-bottom: none; | |
160 | + #filters_container .remove_container { | |
161 | + height: 40px; | |
162 | + width: 40px; | |
163 | + padding: 4px 8px; | |
164 | + | |
103 | 165 | } |
104 | 166 | |
105 | 167 | </style> |
106 | 168 | |
107 | - <div id="filters_container"> | |
108 | - | |
109 | - <div id="filters_header" class="filters_header" on-click="_showFiltersPanel"><span id="filters"><span id="addFilters"></span></span></div> | |
110 | - | |
111 | - <div id="filters_panel"> | |
112 | - | |
113 | - <table cellspacing="12px"> | |
114 | - <tr> | |
115 | - <th> | |
116 | - <paper-dropdown-menu id="filter_field" label="Field"> | |
117 | - <paper-menu id="filter_field_menu" class="dropdown-content"> | |
118 | - <template is="dom-repeat" items={{fields}}> | |
119 | - <paper-item id={{index}}>{{_fieldName(item)}}</paper-item> | |
120 | - <!--on-tap=""--> | |
121 | - </template> | |
122 | - </paper-menu> | |
123 | - </paper-dropdown-menu> | |
124 | - </th> | |
125 | - <th> | |
126 | - <paper-dropdown-menu id="filter_operation" label="Operation"> | |
127 | - <paper-menu id="filter_operation_menu" class="dropdown-content"> | |
128 | - <template is="dom-repeat" items={{operations}}> | |
129 | - <paper-item id={{index}}>{{_getOperationlName(item)}}</paper-item> | |
130 | - </template> | |
131 | - </paper-menu> | |
132 | - </paper-dropdown-menu> | |
133 | - </th> | |
134 | - <th> | |
135 | - <paper-input id="filter_value" label="Value" class="base_input" maxlength="32" auto-validate pattern="^[.:,;+-_ a-zA-Z0-9]*" error-message="Invalid value!"></paper-input> | |
136 | - <!--"^[_a-zA-Z0-9]*"--> | |
137 | - </th> | |
138 | - <th class="filters_cell_button"> | |
169 | + <paper-material id="filters_container" elevation="5"> | |
170 | + | |
171 | + <div id="header" class="hide" on-click="_showFiltersPanel"><span id="filters"><span id="addFilters"></span></span></div> | |
172 | + | |
173 | + <div id="panel"> | |
174 | + | |
175 | + <div class="row"> | |
176 | + <div class="ddl_container"> | |
177 | + <paper-dropdown-menu id="filter_field" label="Field"> | |
178 | + <paper-menu id="filter_field_menu" class="dropdown-content"> | |
179 | + <template is="dom-repeat" items={{fields}}> | |
180 | + <paper-item id={{index}}>{{_fieldName(item)}}</paper-item> | |
181 | + </template> | |
182 | + </paper-menu> | |
183 | + </paper-dropdown-menu> | |
184 | + </div> | |
185 | + <div class="ddl_container"> | |
186 | + <paper-dropdown-menu id="filter_operation" label="Operation"> | |
187 | + <paper-menu id="filter_operation_menu" class="dropdown-content"> | |
188 | + <template is="dom-repeat" items={{operations}}> | |
189 | + <paper-item id={{index}}>{{_getOperationlName(item)}}</paper-item> | |
190 | + </template> | |
191 | + </paper-menu> | |
192 | + </paper-dropdown-menu> | |
193 | + </div> | |
194 | + <div class="ddl_container"> | |
195 | + <paper-input id="filter_value" label="Value" class="base_input" maxlength="32" auto-validate pattern="^[.:,;+-_ a-zA-Z0-9]*" error-message="Invalid value!"></paper-input> | |
196 | + </div> | |
197 | + <div class="ddl_container"> | |
198 | + <div class="add_container"> | |
139 | 199 | <paper-icon-button on-click="_addFilter" icon="add-circle" class="add"></paper-icon-button> |
140 | - </th> | |
141 | - </tr> | |
142 | - <template is="dom-repeat" items={{filters}}> | |
143 | - <tr> | |
144 | - <td>{{item.field}}</td> | |
145 | - <td>{{item.operation}}</td> | |
146 | - <td class="filters_cell_value">{{item.value}}</td> | |
147 | - <td class="filters_cell_button"><paper-icon-button on-click="_deleteFilter" icon="cancel" class="cancel"></paper-icon-button></td> | |
148 | - </tr> | |
200 | + </div> | |
201 | + <div class="andOr_container"> | |
202 | + <paper-button raised on-click="_changeLogicalOperator"><span id="andOr">{{logicalOperator}}</span></paper-button> | |
203 | + </div> | |
204 | + </div> | |
205 | + </div> | |
206 | + | |
207 | + <template is="dom-repeat" items={{filters}}> | |
208 | + <template is="dom-if" if="{{index}}"><!--excludes logicalOperator--> | |
209 | + <div class="row2"> | |
210 | + <div class="filter"> | |
211 | + {{item.field}} <span class="highlighted">{{item.operation}}</span> "{{item.value}}" <span class="highlighted">{{_getLogicalOperator(index)}}</span> | |
212 | + </div> | |
213 | + <div class="remove_container"> | |
214 | + <paper-icon-button on-click="_deleteFilter" icon="cancel" class="cancel"></paper-icon-button> | |
215 | + </div> | |
216 | + </div> | |
149 | 217 | </template> |
150 | - </table> | |
218 | + </template> | |
151 | 219 | |
152 | 220 | </div> |
153 | 221 | |
154 | - </div> | |
222 | + </paper-material> | |
155 | 223 | |
156 | 224 | </template> |
157 | 225 | |
... | ... | @@ -175,7 +243,7 @@ |
175 | 243 | |
176 | 244 | filters : { |
177 | 245 | type : Array, |
178 | - value : [] | |
246 | + value : [{logicalOperator: "AND"}] | |
179 | 247 | }, |
180 | 248 | |
181 | 249 | show : { |
... | ... | @@ -186,21 +254,37 @@ |
186 | 254 | }, |
187 | 255 | |
188 | 256 | ready : function() { |
189 | - $(this.$.filters_panel).perfectScrollbar(); | |
257 | + $(this.$.panel).perfectScrollbar(); | |
258 | +// this._showFiltersPanel(); | |
190 | 259 | }, |
191 | 260 | |
192 | 261 | attached : function() { |
262 | + this.logicalOperator = this.filters[0].logicalOperator; | |
263 | + | |
193 | 264 | this._translate(); |
194 | 265 | }, |
195 | 266 | |
196 | 267 | setFields : function(fields) { |
197 | - this.fields = this._copy(fields); | |
268 | +// this.fields = this._copy(fields); | |
269 | + this.fields = fields.slice(); | |
270 | + this.fields = fields; | |
271 | + }, | |
272 | + | |
273 | + setFilters : function(filters) { | |
274 | + this.filters = filters.slice(); | |
275 | + this.logicalOperator = this.filters[0].logicalOperator; | |
276 | + this._fire(); | |
198 | 277 | }, |
199 | 278 | |
200 | 279 | getFilters : function() { |
201 | 280 | return this.filters; |
202 | 281 | }, |
203 | 282 | |
283 | + reset : function() { | |
284 | + this.fields = []; | |
285 | + this.filters = [{logicalOperator: "AND"}]; | |
286 | + }, | |
287 | + | |
204 | 288 | _translate : function() { |
205 | 289 | this.$.addFilters.innerHTML = ln["expertAddFilters_" + ln["localization"]]; |
206 | 290 | this.$.filter_field.setAttribute("label", ln["filterField_" + ln["localization"]]); |
... | ... | @@ -213,20 +297,34 @@ |
213 | 297 | }, |
214 | 298 | |
215 | 299 | _showFiltersPanel : function() { |
300 | +// ? filter class hiddend & hover: | |
301 | + | |
216 | 302 | if(!this.show) { |
217 | - this.$.filters_header.style.color = "#000000"; | |
218 | - this.$.filters_header.style.background = "#B6B6B6"; | |
219 | - this.$.filters_panel.style.display = "block"; | |
303 | + this.$.filters_container.style.height = "100%"; | |
304 | + $(this.$.header).removeClass("hide"); | |
305 | + $(this.$.header).addClass("show"); | |
306 | + this.$.panel.style.display = "block"; | |
307 | + | |
220 | 308 | } |
221 | 309 | else { |
222 | - this.$.filters_header.style.color = "#00BCD4"; | |
223 | - this.$.filters_header.style.background = "#FFFFFF"; | |
224 | - this.$.filters_panel.style.display = "none"; | |
310 | + this.$.filters_container.style.height = "48px"; | |
311 | + $(this.$.header).removeClass("show"); | |
312 | + $(this.$.header).addClass("hide"); | |
313 | + this.$.panel.style.display = "none"; | |
225 | 314 | } |
226 | 315 | |
316 | + this.fire('filters-controllet_show', {show: this.show}); | |
317 | + | |
227 | 318 | this.show = !this.show; |
228 | 319 | }, |
229 | 320 | |
321 | + _fire : function() { | |
322 | + if (this.filters.length > 1) | |
323 | + this.fire('filters-controllet_filters', {filters: this.filters}); | |
324 | + else | |
325 | + this.fire('filters-controllet_filters', {filters: []}); | |
326 | + }, | |
327 | + | |
230 | 328 | _addFilter : function() { |
231 | 329 | if (this.$.filter_field.selectedItem && this.$.filter_operation_menu.selectedItem && this.$.filter_value.value != "" && !this.$.filter_value.invalid) { |
232 | 330 | var field = this.$.filter_field.value; |
... | ... | @@ -235,26 +333,34 @@ |
235 | 333 | // var operation = this.$.filter_operation.value; |
236 | 334 | var value = this.$.filter_value.value; |
237 | 335 | |
238 | - var filters = this.filters; | |
239 | - filters.push({"field": field, "operation": operation, "value": value}); | |
240 | - this.filters = this._copy(filters); | |
336 | +// var filters = this.filters; | |
337 | +// filters.push({"field": field, "operation": operation, "value": value}); | |
338 | +// this.filters = filters; | |
339 | + | |
340 | + this.filters.push({"field": field, "operation": operation, "value": value}); | |
241 | 341 | |
242 | 342 | this.$.filter_field_menu.select(-1); |
243 | 343 | this.$.filter_operation_menu.select(-1); |
244 | 344 | this.$.filter_value.value = ""; |
245 | 345 | |
246 | - this.fire('filters-controllet_filters', {filters: this.filters}); | |
346 | + this._fire(); | |
347 | + | |
348 | + this._renderFilters(); | |
247 | 349 | } |
248 | 350 | }, |
249 | 351 | |
250 | 352 | _deleteFilter : function(e) { |
251 | 353 | var index = e.model.index; |
252 | 354 | |
253 | - var filters = this.filters; | |
254 | - filters.splice(index, 1); | |
255 | - this.filters = this._copy(filters); | |
355 | +// var filters = this.filters; | |
356 | +// filters.splice(index, 1); | |
357 | +// this.filters = this._copy(filters); | |
358 | + | |
359 | + this.filters.splice(index, 1); | |
360 | + | |
361 | + this._fire(); | |
256 | 362 | |
257 | - this.fire('filters-controllet_filters', {filters: this.filters}); | |
363 | + this._renderFilters(); | |
258 | 364 | }, |
259 | 365 | |
260 | 366 | _getOperationlName: function(operation) { |
... | ... | @@ -269,15 +375,54 @@ |
269 | 375 | return operation; |
270 | 376 | }, |
271 | 377 | |
272 | - _copy : function(o) { | |
273 | - var out, v, key; | |
274 | - out = Array.isArray(o) ? [] : {}; | |
275 | - for (key in o) { | |
276 | - v = o[key]; | |
277 | - out[key] = (typeof v === "object") ? this._copy(v) : v; | |
278 | - } | |
279 | - return out; | |
280 | - } | |
378 | +// _changeLogicalOperator : function() { | |
379 | +// if(this.logicalOperator == "AND") | |
380 | +// this.logicalOperator = "OR"; | |
381 | +// else | |
382 | +// this.logicalOperator = "AND"; | |
383 | +// | |
384 | +// this._fire(); | |
385 | +// | |
386 | +// this._renderFilters(); | |
387 | +// }, | |
388 | + | |
389 | + _changeLogicalOperator : function() { | |
390 | + if(this.logicalOperator == "AND") | |
391 | + this.logicalOperator = "OR"; | |
392 | + else | |
393 | + this.logicalOperator = "AND"; | |
394 | + | |
395 | + this.filters[0] = {logicalOperator: this.logicalOperator} | |
396 | + | |
397 | + this._fire(); | |
398 | + | |
399 | + this._renderFilters(); | |
400 | + }, | |
401 | + | |
402 | + _renderFilters : function() { | |
403 | + var filters = this.filters.slice(); | |
404 | + this.filters = []; | |
405 | + this.async(function() { | |
406 | + this.filters = filters; | |
407 | + }, 0); | |
408 | + }, | |
409 | + | |
410 | + _getLogicalOperator : function(index) { | |
411 | + if(index == this.filters.length -1) | |
412 | + return ""; | |
413 | + else | |
414 | + return this.filters[0].logicalOperator; | |
415 | + }, | |
416 | + | |
417 | +// _copy : function(o) { | |
418 | +// var out, v, key; | |
419 | +// out = Array.isArray(o) ? [] : {}; | |
420 | +// for (key in o) { | |
421 | +// v = o[key]; | |
422 | +// out[key] = (typeof v === "object") ? this._copy(v) : v; | |
423 | +// } | |
424 | +// return out; | |
425 | +// } | |
281 | 426 | |
282 | 427 | }); |
283 | 428 | ... | ... |
controllets/paper-card-controllet/paper-card-controllet.html
... | ... | @@ -36,12 +36,15 @@ |
36 | 36 | #paper_card_container .legend { |
37 | 37 | position: relative; |
38 | 38 | bottom: 48px; |
39 | - height: 32px; | |
40 | - padding: 16px 0px 0px 8px; | |
39 | + height: 16px; | |
40 | + padding: 16px 8px; | |
41 | 41 | background-color: rgba(0, 0, 0, 0.8); |
42 | 42 | color: white; |
43 | 43 | font-weight: 700; |
44 | - word-wrap: break-word; | |
44 | + /*word-wrap: break-word;*/ | |
45 | + overflow: hidden; | |
46 | + white-space: nowrap; | |
47 | + text-overflow: ellipsis; | |
45 | 48 | } |
46 | 49 | |
47 | 50 | #paper_card_container .footer { |
... | ... | @@ -51,8 +54,10 @@ |
51 | 54 | bottom: 48px; |
52 | 55 | padding: 4px; |
53 | 56 | font-size: 12px; |
54 | - word-wrap: break-word; | |
57 | + /*word-wrap: break-word;*/ | |
55 | 58 | overflow: hidden; |
59 | + white-space: nowrap; | |
60 | + text-overflow: ellipsis; | |
56 | 61 | } |
57 | 62 | |
58 | 63 | paper-fab { |
... | ... | @@ -62,7 +67,7 @@ |
62 | 67 | } |
63 | 68 | |
64 | 69 | paper-fab.open { |
65 | - bottom: -20px; | |
70 | + bottom: 40px; | |
66 | 71 | right: 8px; |
67 | 72 | } |
68 | 73 | |
... | ... | @@ -122,31 +127,23 @@ |
122 | 127 | <content></content> |
123 | 128 | </div> |
124 | 129 | |
125 | - <div class="legend"> | |
126 | - | |
130 | + <div class="legend" title="{{cardTitle}}"> | |
127 | 131 | {{cardTitle}} |
132 | + </div> | |
128 | 133 | |
129 | - <template is="dom-if" if="{{checkType(cardType, 'link')}}"> | |
130 | - | |
131 | - <paper-fab id="card_open_link" class="open" mini icon="link" on-click="_handleOpenClick"></paper-fab> | |
132 | - | |
133 | - </template> | |
134 | - | |
135 | - <template is="dom-if" if="{{checkType(cardType, 'text')}}"> | |
136 | - | |
137 | - <paper-fab id="card_open_text" class="open" mini icon="text-format" on-click="_handleOpenClick"></paper-fab> | |
138 | - | |
139 | - </template> | |
140 | - | |
141 | - <template is="dom-if" if="{{checkType(cardType, 'datalet')}}"> | |
142 | - | |
143 | - <paper-fab id="card_open_datalet" class="open" mini icon="assessment" on-click="_handleOpenClick"></paper-fab> | |
134 | + <template is="dom-if" if="{{checkType(cardType, 'link')}}"> | |
135 | + <paper-fab id="card_open_link" class="open" mini icon="link" on-click="_handleOpenClick"></paper-fab> | |
136 | + </template> | |
144 | 137 | |
145 | - </template> | |
138 | + <template is="dom-if" if="{{checkType(cardType, 'text')}}"> | |
139 | + <paper-fab id="card_open_text" class="open" mini icon="text-format" on-click="_handleOpenClick"></paper-fab> | |
140 | + </template> | |
146 | 141 | |
147 | - </div> | |
142 | + <template is="dom-if" if="{{checkType(cardType, 'datalet')}}"> | |
143 | + <paper-fab id="card_open_datalet" class="open" mini icon="assessment" on-click="_handleOpenClick"></paper-fab> | |
144 | + </template> | |
148 | 145 | |
149 | - <div class="footer"> | |
146 | + <div class="footer" title="{{comment}}"> | |
150 | 147 | {{comment}} |
151 | 148 | </div> |
152 | 149 | ... | ... |
controllets/providers-utility-controllet/ckan.js
1 | -//function _path() { | |
2 | -// return "result->records" | |
3 | -//} | |
4 | -// | |
5 | -//function _arrayPath() { | |
6 | -// return ["result", "records", "*"]; | |
7 | -//} | |
8 | - | |
9 | -function ckan_Provider (url) { | |
10 | - this.url = url; | |
11 | - this.path = "result->records"; | |
1 | +function ckan_Provider () { //--> dataUrl inutile | |
2 | + //this.dataUrl = dataUrl; | |
3 | + //this.path = "result->records"; | |
4 | + //this.arrayPath = ["result", "records", "*"]; | |
12 | 5 | } |
13 | 6 | |
14 | -ckan_Provider.prototype.getData = function() { | |
15 | - console.log("ckan"); | |
16 | - return 'ckan'; | |
17 | -}; | |
18 | 7 | \ No newline at end of file |
8 | +ckan_Provider.prototype.selectData = function(data) { | |
9 | + return data.result.records; | |
10 | +}; | |
11 | + | |
12 | +ckan_Provider.prototype.addLimit = function(url) { | |
13 | + if(url.indexOf("&limit=") > -1) | |
14 | + return url; | |
15 | + return url + "&limit=99999"; | |
16 | +}; | |
17 | + | |
18 | +//ckan_Provider.prototype.getFields = function(data) { | |
19 | +// var fields = []; | |
20 | +// for (var key in data.result.records[0]) | |
21 | +// fields.push(key); | |
22 | +// return fields; | |
23 | +//}; | |
24 | + | |
25 | +//ckan_Provider.prototype.requestData = function() { | |
26 | +// var that = this; | |
27 | +// | |
28 | +// $.ajax({ | |
29 | +// url: this.dataUrl, | |
30 | +// dataType: "json", | |
31 | +// success: function(data){ | |
32 | +// that.data = data.result.records; | |
33 | +// } | |
34 | +// }); | |
35 | +//}; | |
19 | 36 | \ No newline at end of file | ... | ... |
controllets/providers-utility-controllet/generic.js
controllets/providers-utility-controllet/openDataSoft.js
1 | -function openDataSoft_Provider (url) { | |
2 | - this.url = url; | |
3 | - this.path = "result->records"; | |
4 | -} | |
1 | +function openDataSoft_Provider () {} | |
5 | 2 | |
6 | -openDataSoft_Provider.prototype.getData = function() { | |
7 | - return 'openDataSoft'; | |
8 | -}; | |
9 | 3 | \ No newline at end of file |
4 | +openDataSoft_Provider.prototype.selectData = function(data) { | |
5 | + var selectedData = []; | |
6 | + for(var i=0; i<data.records.length; i++) | |
7 | + selectedData.push(data.records[i].fields); | |
8 | + return selectedData; | |
9 | +}; | |
10 | + | |
11 | +openDataSoft_Provider.prototype.addLimit = function(url) { | |
12 | + if(url.indexOf("&rows=") > -1) | |
13 | + return url; | |
14 | + return url + "&rows=10000"; | |
15 | +}; | |
16 | + | |
17 | +//openDataSoft_Provider.prototype.getFields = function(data) { | |
18 | +// var fields = []; | |
19 | +// for (var key in data.records[0].fields) | |
20 | +// fields.push(key); | |
21 | +// return fields; | |
22 | +//}; | |
10 | 23 | \ No newline at end of file | ... | ... |
controllets/providers-utility-controllet/providers-utility-controllet.html
1 | -<!DOCTYPE html> | |
2 | -<html lang="en"> | |
3 | -<head> | |
4 | - <meta charset="UTF-8"> | |
5 | - <title></title> | |
6 | -</head> | |
7 | -<body> | |
8 | - | |
9 | -</body> | |
10 | -</html> | |
11 | 1 | \ No newline at end of file |
2 | +<link rel="import" href="../../bower_components/polymer/polymer.html" /> | |
3 | + | |
4 | +<script src="ckan.js"></script> | |
5 | +<script src="openDataSoft.js"></script> | |
6 | +<script src="generic.js"></script> | |
7 | + | |
8 | +<script> | |
9 | + var providerFactory = { | |
10 | + getProvider: function(dataUrl) { | |
11 | + if (dataUrl.indexOf("datastore_search?resource_id") > -1) | |
12 | + return new ckan_Provider(); | |
13 | + else if (dataUrl.indexOf("search?dataset") > -1) | |
14 | + return new openDataSoft_Provider(); | |
15 | + else | |
16 | + return generic_Provider(); | |
17 | + } | |
18 | + }; | |
19 | + | |
20 | + //jsdatachecker | |
21 | + utility_getFields = function(types) { | |
22 | + return Object.keys(types).map(function(key) { return key; }); | |
23 | + }; | |
24 | + | |
25 | + utility_getSelectedFields = function(fields, indices) { | |
26 | + selectedFileds = []; | |
27 | + for (var i = 0; i < indices.length; i++) | |
28 | + selectedFileds.push(fields[indices[i]]); | |
29 | + return selectedFileds; | |
30 | + }; | |
31 | + | |
32 | + // utility_getResourceUrl = function(url) { | |
33 | + // //CKAN | |
34 | + // var strDatasetPos = url.indexOf('/dataset/'); | |
35 | + // var strResourcePos = url.indexOf('/resource/'); | |
36 | + // if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) { | |
37 | + // var urlSegment1 = url.substring(0, strDatasetPos); | |
38 | + // var urlResourceEnd = url.indexOf('/', strResourcePos + 10); | |
39 | + // var resourceId = url.substring(strResourcePos + 10, urlResourceEnd); | |
40 | + // return urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId; | |
41 | + // } | |
42 | + // //OPENDATASOFT | |
43 | + // var strExploreDatasetPos = url.indexOf('/explore/dataset/'); | |
44 | + // if (strExploreDatasetPos >= 0) { | |
45 | + // var urlSegment1 = url.substring(0, strExploreDatasetPos); | |
46 | + // var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/'); | |
47 | + // var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length); | |
48 | + // return urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId; | |
49 | + // } | |
50 | + // return ""; | |
51 | + // }; | |
52 | +</script> | |
53 | + | |
54 | +<dom-module id="providers-utility-controllet"> | |
55 | + | |
56 | + <template></template> | |
57 | + | |
58 | + <script> | |
59 | + Polymer({ | |
60 | + is : 'providers-utility-controllet', | |
61 | + }); | |
62 | + </script> | |
63 | + | |
64 | +</dom-module> | |
12 | 65 | \ No newline at end of file | ... | ... |
controllets/select-data-controllet/demo/index.html
... | ... | @@ -15,28 +15,21 @@ |
15 | 15 | |
16 | 16 | <body> |
17 | 17 | |
18 | - <!--<select-data-controllet id="tvmt" root-name="data" opened-path="records,geometry" preselected-fields='["nhits", "records,datasetid", "records,recordid"]' data-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5"></select-data-controllet>--> | |
19 | - <!--<select-data-controllet id="tvmt" root-name="data" data-url="https://data.issy.com/api/records/1.0/search?dataset=flux-rss-des-offres-demplois-a-issy-les-moulineaux&sort=published&facet=published&refine.published=2015%2F10"></select-data-controllet>--> | |
20 | - <select-data-controllet id="tvmt" root-name="data" data-url="https://data.issy.com/api/records/1.0/search/?dataset=repartitiondeladetteparpreteursau3112n-feuille1&rows=56&sort=-annee"></select-data-controllet> | |
21 | - <!--<select-data-controllet id="tvmt" root-name="data" data-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5"></select-data-controllet>--> | |
18 | + <select-data-controllet id="sd" data-url="https://data.issy.com/api/records/1.0/search?dataset=repartitiondeladetteparpreteursau3112n-feuille1"></select-data-controllet> | |
19 | + <!--<select-data-controllet id="sd" data-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=642ceea8-711e-4124-b450-0d23010c44e6"></select-data-controllet>--> | |
22 | 20 | |
23 | 21 | <script> |
24 | 22 | ln["localization"] = "en"; |
25 | - var tvmt = document.getElementById('tvmt'); | |
23 | + var sd = document.getElementById('sd'); | |
24 | + sd._init(); | |
26 | 25 | |
27 | - tvmt.addEventListener("tree-view-controllet_selected-fields", function (e) { | |
26 | +// tvmt.addEventListener("tree-view-controllet_selected-fields", function (e) { | |
28 | 27 | // console.log(tvmt.getFlatFields()); |
29 | 28 | // console.log(tvmt.getFields()); |
30 | - }); | |
29 | +// }); | |
31 | 30 | |
32 | 31 | </script> |
33 | 32 | |
34 | 33 | </body> |
35 | 34 | |
36 | -</html> | |
37 | - | |
38 | -<!--urls:--> | |
39 | -<!--http://dati.lazio.it/catalog/api/action/datastore_search?resource_id=114baf3d-6d4f-42ff-b4af-481beef59ae1--> | |
40 | -<!--url: 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5',--> | |
41 | -<!--url: 'https://data.issy.com/api/records/1.0/search?dataset=liste-des-restaurants-a-issy-les-moulineaux&sort=type&facet=type&facet=terrasse',--> | |
42 | -<!--url: 'https://data.issy.com/api/records/1.0/search?dataset=flux-rss-des-offres-demplois-a-issy-les-moulineaux&sort=published&facet=published&refine.published=2015',--> | |
43 | 35 | \ No newline at end of file |
36 | +</html> | |
44 | 37 | \ No newline at end of file | ... | ... |
controllets/select-data-controllet/select-data-controllet.html
1 | 1 | <link rel="import" href="../../bower_components/polymer/polymer.html" /> |
2 | 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" /> | |
3 | +<link rel="import" href="../select-fields-controllet/select-fields-controllet.html" /> | |
4 | +<link rel="import" href="../data-table-controllet/data-table-controllet.html" /> | |
7 | 5 | <link rel="import" href="../filters-controllet/filters-controllet.html" /> |
8 | 6 | |
7 | +<link rel="import" href="../providers-utility-controllet/providers-utility-controllet.html" /> | |
8 | + | |
9 | +<script type="text/javascript" src="../../alasql-utility/alasql.min.js"></script> | |
10 | +<script type="text/javascript" src="../../alasql-utility/alasql-utility.js"></script> | |
11 | + | |
12 | +<script type="text/javascript" src="../../bower_components/JSDataChecker/jsdatachecker.min.js"></script> | |
13 | + | |
9 | 14 | <dom-module id="select-data-controllet"> |
10 | 15 | |
11 | 16 | <style is="custom-style"> |
12 | - .div_container { | |
17 | + | |
18 | + #select_data_controllet_container { | |
13 | 19 | display: flex; |
14 | 20 | flex-direction: row; |
21 | + margin-top: 8px; | |
15 | 22 | } |
16 | - #material_tree_view { | |
17 | - position: relative; | |
18 | - width: 25%; | |
19 | - min-width: 200px; | |
20 | - height: 100vh; | |
23 | + | |
24 | + #select_data_controllet_container * { | |
25 | + font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
26 | + font-size: 16px; | |
27 | + line-height: 24px; | |
21 | 28 | } |
22 | - #material_multi_table_filters { | |
23 | - position: relative; | |
24 | - width: 75%; | |
25 | 29 | |
26 | - margin-left: 64px; | |
27 | - margin-top: 8px; | |
30 | + #select_data_controllet_container #fields_container { | |
31 | + height: 100%; | |
32 | + width: 20%; | |
33 | + min-width: 192px; | |
34 | + } | |
35 | + | |
36 | + #select_data_controllet_container #right_container { | |
37 | + height: 100%; | |
38 | + width: calc(80% - 24px); | |
39 | + margin-left: 24px; | |
28 | 40 | } |
29 | 41 | |
30 | - #div_multi_table { | |
31 | - height: 70%; | |
42 | + #select_data_controllet_container #table_container { | |
43 | + height: calc(100% - 72px); | |
32 | 44 | width: 100%; |
33 | - position: relative; | |
34 | 45 | } |
35 | - #div_filters { | |
36 | - height: 30%; | |
46 | + | |
47 | + #select_data_controllet_container #filters_container { | |
48 | + height: 48px; | |
37 | 49 | width: 100%; |
38 | - position: relative; | |
50 | + margin-top: 24px; | |
39 | 51 | } |
52 | + | |
40 | 53 | </style> |
41 | 54 | |
42 | 55 | <template> |
43 | 56 | |
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> | |
57 | + <providers-utility-controllet></providers-utility-controllet> | |
58 | + | |
59 | + <div id="select_data_controllet_container"> | |
60 | + <div id="fields_container"> | |
61 | + <select-fields-controllet id="select_fields"></select-fields-controllet> | |
62 | + </div> | |
63 | + <div id="right_container"> | |
64 | + <div id="table_container"> | |
65 | + <data-table-controllet id="data_table"></data-table-controllet> | |
51 | 66 | </div> |
52 | - <div id="div_filters"> | |
67 | + <div id="filters_container"> | |
53 | 68 | <filters-controllet id="filters"></filters-controllet> |
54 | 69 | </div> |
55 | - </paper-material> | |
70 | + </div> | |
56 | 71 | </div> |
57 | 72 | |
73 | + | |
58 | 74 | </template> |
59 | 75 | |
60 | 76 | <script> |
... | ... | @@ -64,139 +80,160 @@ |
64 | 80 | |
65 | 81 | properties : { |
66 | 82 | |
67 | - rootName : { | |
83 | + dataUrl : { | |
68 | 84 | type : String, |
69 | - value : "root" | |
70 | - }, | |
71 | - | |
72 | - preselectedFields : { | |
73 | - type : Array, | |
74 | - value : [] | |
85 | + value : undefined | |
86 | +// observer : '_init' | |
75 | 87 | }, |
76 | 88 | |
77 | - openedPath : { | |
78 | - type : String, | |
89 | + data : { | |
90 | + type : Object, | |
79 | 91 | value : undefined |
80 | 92 | }, |
81 | 93 | |
82 | - dataUrl : { | |
83 | - type : String, | |
84 | - value : undefined, | |
85 | - observer : '_init' | |
94 | + filters : { | |
95 | + type : Array, | |
96 | + value : [] | |
97 | +// value : [{logicalOperator: "OR"}, {field: "annee", operation: "=", value: "2014"}, {field: "annee", operation: "=", value: "2015"}] | |
86 | 98 | }, |
87 | 99 | |
88 | - filters : { | |
100 | + selectedFields : { | |
89 | 101 | type : Array, |
90 | 102 | value : [] |
91 | - }, | |
103 | +// value : [0,2,4] | |
104 | + } | |
92 | 105 | |
93 | 106 | }, |
94 | 107 | |
95 | 108 | listeners: { |
96 | - 'tree-view-controllet_selected-fields': '_updateSelectedFields', | |
109 | + 'filters-controllet_show': '_resizeFilters', | |
110 | + 'select-fields-controllet_selected-fields': '_updateFields', | |
97 | 111 | 'filters-controllet_filters': '_updateFilters' |
98 | 112 | }, |
99 | 113 | |
100 | 114 | ready : function() { |
101 | - $(this.$.material_tree_view).perfectScrollbar(); | |
115 | + this.showFilter = false; | |
102 | 116 | }, |
103 | 117 | |
104 | 118 | attached : function(){ |
105 | 119 | this._resize(); |
106 | 120 | var that = this; |
107 | 121 | window.addEventListener("resize", function() { that._resize(); }); |
108 | - | |
109 | - if(this.dataletPreset && this.dataletPreset["filters"] != undefined) | |
110 | - this._preselectFilters(); | |
111 | 122 | }, |
112 | 123 | |
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); | |
124 | + getSelectedFields : function() { | |
125 | + return utility_getSelectedFields(this.fields, this.selectedFields);; | |
121 | 126 | }, |
122 | 127 | |
123 | 128 | getFilters : function() { |
124 | - return this.$.filters.getFilters(); | |
129 | + return this.filters; | |
125 | 130 | }, |
126 | 131 | |
127 | - getFields : function() { | |
128 | - return this.$.tree_view.getFields(); | |
132 | + getData : function() { | |
133 | + return this.data; | |
129 | 134 | }, |
130 | 135 | |
131 | - getFlatFields : function() { | |
132 | - return this.$.tree_view.getFlatFields(); | |
136 | + _resizeFilters : function() { | |
137 | + if(!this.showFilter) { | |
138 | + this.$.table_container.style.height = "calc(50% - 12px)"; | |
139 | + this.$.filters_container.style.height = "calc(50% - 12px)"; | |
140 | + } | |
141 | + else { | |
142 | + this.$.table_container.style.height = "calc(100% - 72px)"; | |
143 | + this.$.filters_container.style.height = "48px"; | |
144 | + } | |
145 | + | |
146 | + this.$.data_table._resize(); | |
147 | + | |
148 | + this.showFilter = !this.showFilter; | |
133 | 149 | }, |
134 | 150 | |
135 | - _init : function() { | |
136 | - var that = this; | |
151 | + _updateFields : function(e) { | |
152 | + this.selectedFields = e.detail.selectedFields; | |
153 | + var fields = utility_getSelectedFields(this.fields, this.selectedFields); | |
154 | + var data = alasql_selectData(this.data, fields, this.filters); | |
155 | + this.$.data_table.setData(data); | |
156 | + }, | |
137 | 157 | |
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(); | |
158 | + _updateFilters : function(e) { | |
159 | + this.filters = e.detail.filters; | |
160 | + var fields = utility_getSelectedFields(this.fields, this.selectedFields); | |
161 | + var data = alasql_selectData(this.data, fields, this.filters); | |
162 | + this.$.data_table.setData(data); | |
155 | 163 | }, |
156 | 164 | |
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; | |
165 | + init : function() { | |
166 | + if(this.dataUrl) { | |
167 | + | |
168 | + var that = this; | |
169 | + | |
170 | + $.ajax({ | |
171 | + url: this.dataUrl, | |
172 | + dataType: "json", | |
173 | + success: function(data){ | |
174 | + that.reset(); | |
175 | + | |
176 | + var f = Object.create(providerFactory); | |
177 | + var provider = f.getProvider(that.dataUrl); | |
178 | + data = provider.selectData(data); | |
179 | + | |
180 | + var converter = new DataTypeConverter(); | |
181 | + var result = converter.inferJsonDataType(data, ["*"]); | |
182 | + result = converter.cast(result); | |
183 | + that.fields = utility_getFields(result.types); | |
184 | + data = result.dataset; | |
185 | + that.data = alasql_selectData(data, that.fields); | |
186 | + | |
187 | + that.$.select_fields.setFields(that.fields); | |
188 | + that.$.filters.setFields(that.fields); | |
189 | +// that.$.data_table.setData(data); | |
190 | + | |
191 | + that._preselect(); | |
192 | + } | |
193 | + }); | |
170 | 194 | } |
171 | - }, | |
172 | 195 | |
173 | - _updateSelectedFields : function() { | |
174 | - var fields = this.$.tree_view.getFields(); | |
175 | - this.$.multi_table.setSelectedFields(fields); | |
196 | + else { | |
197 | + this.reset(); | |
176 | 198 | |
177 | - var flatFields = this.$.tree_view.getFlatFields(); | |
178 | - this.$.filters.setFields(flatFields); | |
199 | + var converter = new DataTypeConverter(); | |
200 | + var result = converter.inferJsonDataType(this.data, ["*"]); | |
201 | + result = converter.cast(result); | |
202 | + this.fields = utility_getFields(result.types); | |
203 | + data = result.dataset; | |
204 | + this.data = alasql_selectData(data, this.fields); | |
205 | + | |
206 | + this.$.select_fields.setFields(this.fields); | |
207 | + this.$.filters.setFields(this.fields); | |
208 | +// this.$.data_table.setData(data); | |
209 | + | |
210 | + this._preselect(); | |
211 | + } | |
179 | 212 | }, |
180 | 213 | |
181 | - _updateFilters : function(e) { | |
182 | - this.filters = e.detail.filters; | |
183 | - this.$.multi_table.filters = e.detail.filters; | |
184 | - this._refreshTables(); | |
214 | + reset : function() { | |
215 | +// this.dataUrl = undefined; | |
216 | +// this.data = undefined; | |
217 | + this.filters = []; | |
218 | + this.selectedFields = []; | |
219 | + this.$.select_fields.reset(); | |
220 | + this.$.data_table.reset(); | |
221 | + this.$.filters.reset(); | |
185 | 222 | }, |
186 | 223 | |
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); | |
224 | + _preselect : function() { | |
225 | + this.async(function() { | |
226 | + if(this.filters.length > 1) | |
227 | + this.$.filters.setFilters(this.filters); | |
228 | + if(this.selectedFields.length > 0) | |
229 | + this.$.select_fields.setSelectFields(this.selectedFields); | |
192 | 230 | }, 0); |
193 | 231 | }, |
194 | 232 | |
195 | 233 | _resize : function(){ |
196 | 234 | 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); | |
235 | + h = h - 64 - 8; //height with page scroller + margin-top | |
236 | + $("#select_data_controllet_container").height(h); | |
200 | 237 | } |
201 | 238 | |
202 | 239 | }); | ... | ... |
controllets/select-dataset-controllet/ortelio-controllet.html
... | ... | @@ -506,26 +506,26 @@ |
506 | 506 | |
507 | 507 | var url = this.$.list.selectedItem.resource_url; |
508 | 508 | |
509 | - // Check if CKAN | |
510 | - var strDatasetPos = url.indexOf('/dataset/'); | |
511 | - var strResourcePos = (strDatasetPos >= 0) ? url.indexOf('/resource/') : -1; | |
512 | - if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) { | |
513 | - var urlSegment1 = url.substring(0, strDatasetPos); | |
514 | - var urlResourceEnd = url.indexOf('/', strResourcePos + 10); | |
515 | - var resourceId = url.substring(strResourcePos + 10, urlResourceEnd); | |
516 | - url = urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId; | |
517 | - } | |
518 | - | |
519 | - // Check if OPENDATASOFT | |
520 | - var strExploreDatasetPos = url.indexOf('/explore/dataset/'); | |
521 | - if (strExploreDatasetPos >= 0) { | |
522 | - var urlSegment1 = url.substring(0, strExploreDatasetPos); | |
523 | - var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/'); | |
524 | - var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length); | |
525 | - url = urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId; | |
526 | - } | |
527 | - | |
528 | - url = this._addlimitUrl(url); | |
509 | +// // Check if CKAN | |
510 | +// var strDatasetPos = url.indexOf('/dataset/'); | |
511 | +// var strResourcePos = (strDatasetPos >= 0) ? url.indexOf('/resource/') : -1; | |
512 | +// if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) { | |
513 | +// var urlSegment1 = url.substring(0, strDatasetPos); | |
514 | +// var urlResourceEnd = url.indexOf('/', strResourcePos + 10); | |
515 | +// var resourceId = url.substring(strResourcePos + 10, urlResourceEnd); | |
516 | +// url = urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId; | |
517 | +// } | |
518 | +// | |
519 | +// // Check if OPENDATASOFT | |
520 | +// var strExploreDatasetPos = url.indexOf('/explore/dataset/'); | |
521 | +// if (strExploreDatasetPos >= 0) { | |
522 | +// var urlSegment1 = url.substring(0, strExploreDatasetPos); | |
523 | +// var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/'); | |
524 | +// var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length); | |
525 | +// url = urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId; | |
526 | +// } | |
527 | + | |
528 | +// url = this._addlimitUrl(url); | |
529 | 529 | |
530 | 530 | this.fire("datasetexplorer-datalet_data-url", { url: url });//change event name |
531 | 531 | } |
... | ... | @@ -536,18 +536,18 @@ |
536 | 536 | }, 0); |
537 | 537 | }, |
538 | 538 | |
539 | - _addlimitUrl : function(url){ | |
540 | - //CKAN --> action no limit | |
541 | - if((url.indexOf("api/action") > -1) && !(url.indexOf("limit") > -1)) | |
542 | - { | |
543 | - url += "&limit=99999"; | |
544 | - } | |
545 | - //OpenDataSoft --> action no limit | |
546 | - if((url.indexOf("api/records") > -1) && !(url.indexOf("rows") > -1)){ | |
547 | - url += "&rows=10000"; | |
548 | - } | |
549 | - return url; | |
550 | - } | |
539 | +// _addlimitUrl : function(url){ | |
540 | +// //CKAN --> action no limit | |
541 | +// if((url.indexOf("api/action") > -1) && !(url.indexOf("limit") > -1)) | |
542 | +// { | |
543 | +// url += "&limit=99999"; | |
544 | +// } | |
545 | +// //OpenDataSoft --> action no limit | |
546 | +// if((url.indexOf("api/records") > -1) && !(url.indexOf("rows") > -1)){ | |
547 | +// url += "&rows=10000"; | |
548 | +// } | |
549 | +// return url; | |
550 | +// } | |
551 | 551 | }); |
552 | 552 | }); |
553 | 553 | </script> | ... | ... |
controllets/select-dataset-controllet/select-dataset-controllet.html
... | ... | @@ -33,6 +33,7 @@ |
33 | 33 | |
34 | 34 | <link rel="import" href="../../bower_components/paper-checkbox/paper-checkbox.html"> |
35 | 35 | |
36 | +<link rel="import" href="../providers-utility-controllet/providers-utility-controllet.html"> | |
36 | 37 | <link rel="import" href="ortelio-controllet.html"> |
37 | 38 | <link rel="import" href="../../datalets/datasetexplorer-datalet/datasetexplorer-datalet.html"> |
38 | 39 | |
... | ... | @@ -740,28 +741,32 @@ |
740 | 741 | html += "<b>" + i + ":</b> " + metas[i] + "<br>"; |
741 | 742 | this.$.info.innerHTML = html; |
742 | 743 | |
743 | - var url = this.$.list.selectedItem.url; | |
744 | - | |
745 | - // Check if CKAN | |
746 | - var strDatasetPos = url.indexOf('/dataset/'); | |
747 | - var strResourcePos = (strDatasetPos >= 0) ? url.indexOf('/resource/') : -1; | |
748 | - if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) { | |
749 | - var urlSegment1 = url.substring(0, strDatasetPos); | |
750 | - var urlResourceEnd = url.indexOf('/', strResourcePos + 10); | |
751 | - var resourceId = url.substring(strResourcePos + 10, urlResourceEnd); | |
752 | - url = urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId; | |
753 | - } | |
754 | - | |
755 | - // Check if OPENDATASOFT | |
756 | - var strExploreDatasetPos = url.indexOf('/explore/dataset/'); | |
757 | - if (strExploreDatasetPos >= 0) { | |
758 | - var urlSegment1 = url.substring(0, strExploreDatasetPos); | |
759 | - var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/'); | |
760 | - var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length); | |
761 | - url = urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId; | |
762 | - } | |
763 | - | |
764 | - this.dataUrl = this._addlimitUrl(url); | |
744 | + this.dataUrl = this.$.list.selectedItem.url; | |
745 | +// var url = this.$.list.selectedItem.url; | |
746 | + | |
747 | +// url = utility_getResourceUrl(url); | |
748 | + | |
749 | +// // Check if CKAN | |
750 | +// var strDatasetPos = url.indexOf('/dataset/'); | |
751 | +// var strResourcePos = (strDatasetPos >= 0) ? url.indexOf('/resource/') : -1; | |
752 | +// if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) { | |
753 | +// var urlSegment1 = url.substring(0, strDatasetPos); | |
754 | +// var urlResourceEnd = url.indexOf('/', strResourcePos + 10); | |
755 | +// var resourceId = url.substring(strResourcePos + 10, urlResourceEnd); | |
756 | +// url = urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId; | |
757 | +// } | |
758 | +// | |
759 | +// // Check if OPENDATASOFT | |
760 | +// var strExploreDatasetPos = url.indexOf('/explore/dataset/'); | |
761 | +// if (strExploreDatasetPos >= 0) { | |
762 | +// var urlSegment1 = url.substring(0, strExploreDatasetPos); | |
763 | +// var datasetEnd = url.indexOf(strExploreDatasetPos + 17, '/'); | |
764 | +// var datasetId = url.substring(strExploreDatasetPos + 17, datasetEnd >= 0 ? datasetEnd : url.length); | |
765 | +// url = urlSegment1 + '/api/records/1.0/search?dataset=' + datasetId; | |
766 | +// } | |
767 | + | |
768 | +// this.dataUrl = this._addlimitUrl(url); | |
769 | +// this.dataUrl = url; | |
765 | 770 | } |
766 | 771 | else { |
767 | 772 | this.dataUrl = ""; |
... | ... | @@ -771,25 +776,26 @@ |
771 | 776 | }, |
772 | 777 | |
773 | 778 | _selectDataUrl_treeMap : function(e) { |
774 | - this.dataUrl = this._addlimitUrl(e.detail.url); | |
779 | +// this.dataUrl = this._addlimitUrl(e.detail.url); | |
780 | + this.dataUrl = e.detail.url; | |
775 | 781 | }, |
776 | 782 | |
777 | 783 | _fireDataUrl : function(){ |
778 | 784 | this.fire('dataset-selection-controllet_data-url', {url: this.dataUrl}); |
779 | 785 | }, |
780 | 786 | |
781 | - _addlimitUrl : function(url){ | |
782 | - //CKAN --> action no limit | |
783 | - if((url.indexOf("api/action") > -1) && !(url.indexOf("limit") > -1)) | |
784 | - { | |
785 | - url += "&limit=99999"; | |
786 | - } | |
787 | - //OpenDataSoft --> action no limit | |
788 | - if((url.indexOf("api/records") > -1) && !(url.indexOf("rows") > -1)){ | |
789 | - url += "&rows=10000"; | |
790 | - } | |
791 | - return url; | |
792 | - }, | |
787 | +// _addlimitUrl : function(url){ | |
788 | +// //CKAN --> action no limit | |
789 | +// if((url.indexOf("api/action") > -1) && !(url.indexOf("limit") > -1)) | |
790 | +// { | |
791 | +// url += "&limit=99999"; | |
792 | +// } | |
793 | +// //OpenDataSoft --> action no limit | |
794 | +// if((url.indexOf("api/records") > -1) && !(url.indexOf("rows") > -1)){ | |
795 | +// url += "&rows=10000"; | |
796 | +// } | |
797 | +// return url; | |
798 | +// }, | |
793 | 799 | |
794 | 800 | _resize : function(){ |
795 | 801 | var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16; | ... | ... |
controllets/select-fields-controllet/demo/index.html
1 | 1 | <html> |
2 | 2 | |
3 | 3 | <head> |
4 | + <script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> | |
5 | + | |
4 | 6 | <script src="../../shared_js/jquery-1.11.2.min.js"></script> |
5 | 7 | |
6 | - <script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> | |
8 | + <script src="../../shared_js/perfect-scrollbar/js/min/perfect-scrollbar.jquery.min.js"></script> | |
9 | + <link rel="stylesheet" href="../../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css"> | |
10 | + | |
11 | + <script src="../../../locales/controllet_ln.js"></script> | |
7 | 12 | |
8 | - <link rel="import" href="../tree-view-controllet.html" /> | |
13 | + <link rel="import" href="../select-fields-controllet.html" /> | |
9 | 14 | </head> |
10 | 15 | |
11 | 16 | <body> |
... | ... | @@ -15,65 +20,27 @@ |
15 | 20 | display: flex; |
16 | 21 | flex-direction: row; |
17 | 22 | } |
18 | - #tree_container { | |
23 | + #select_fields_container { | |
24 | + height: 600px; | |
19 | 25 | width: 300px; |
20 | - } | |
21 | - #fields_container { | |
22 | 26 | margin-left: 100px; |
23 | 27 | } |
28 | + | |
24 | 29 | </style> |
25 | 30 | |
26 | 31 | <div class="container"> |
27 | - | |
28 | - <div id="tree_container"> | |
29 | - | |
30 | - <!--<tree-view-controllet id="tree" root-name="data" opened-path="records,geometry" preselected-fields='["records,datasetid", "records,recordid", "nhits"]'></tree-view-controllet>--> | |
31 | - <tree-view-controllet id="tree" root-name="create-datalet-controllet"></tree-view-controllet> | |
32 | - | |
33 | - </div> | |
34 | - | |
35 | - <div id="fields_container"> | |
36 | - <h3>Selected fields:</h3> | |
37 | - <p id="fields"> </p> | |
32 | + <div id="select_fields_container"> | |
33 | + <select-fields-controllet fields='["pippo", "pluto", "paperino", "pippo", "pluto", "paperino"]' preselected-fields="[0,2]"></select-fields-controllet> | |
38 | 34 | </div> |
39 | - | |
40 | 35 | </div> |
41 | 36 | |
42 | - | |
43 | 37 | <script> |
38 | + ln["localization"] = "en"; | |
44 | 39 | |
45 | - var json = {"select-dataset-controllet": "s", "select-data-controllet": {"tree-view-controllet": "", "multi-table-controllet": "", "filters-controllet": ""}, "select-visualization-controllet": {"items-vslider-controllet": ""}}; | |
46 | - var tree = document.getElementById('tree'); | |
47 | - tree.setAttribute("json-data", JSON.stringify(json)); | |
48 | - tree.ready(); | |
49 | - | |
50 | -// var tree = document.getElementById('tree'); | |
51 | - var fields = document.getElementById('fields'); | |
52 | -// | |
53 | -// $.ajax({ | |
54 | -// url: 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=c3b52992-ba61-4a73-a637-0f2e1ca26aab', | |
55 | -// dataType: "json", | |
56 | -// success: function(data){ | |
57 | -// tree.setAttribute("json-data", JSON.stringify(data)); | |
58 | -// tree.ready();//chrome | |
59 | -// } | |
60 | -// }); | |
61 | -// | |
62 | -// tree.addEventListener("tree-view-controllet_selected-fields", function (e) { | |
63 | -// fields.innerHTML = e.detail.fields; | |
64 | -//// console.log(tree.getFlatFields()); | |
65 | -//// console.log(tree.getFields());//firefox console.log does not recognize associative array? | |
66 | -// }); | |
40 | + document.addEventListener("select-fields-controllet_selected-fields", function (e) { | |
41 | + console.log(e.detail.selectedFields); | |
42 | + }); | |
67 | 43 | |
68 | 44 | </script> |
69 | 45 | |
70 | -</body> | |
71 | - | |
72 | -</html> | |
73 | - | |
74 | -<!--urls:--> | |
75 | -<!--https://yperdiavgeia.gr/analytics/counts/source:Decision/query:linux/method:count_organization.json--> | |
76 | -<!--http://dati.lazio.it/catalog/api/action/datastore_search?resource_id=114baf3d-6d4f-42ff-b4af-481beef59ae1--> | |
77 | -<!--url: 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5',--> | |
78 | -<!--url: 'https://data.issy.com/api/records/1.0/search?dataset=liste-des-restaurants-a-issy-les-moulineaux&sort=type&facet=type&facet=terrasse',--> | |
79 | -<!--url: 'https://data.issy.com/api/records/1.0/search?dataset=flux-rss-des-offres-demplois-a-issy-les-moulineaux&sort=published&facet=published&refine.published=2015',--> | |
80 | 46 | \ No newline at end of file |
47 | +</body> | |
81 | 48 | \ No newline at end of file | ... | ... |
controllets/select-fields-controllet/select-fields-controllet.html
0 โ 100644
1 | +<link rel="import" href="../../bower_components/polymer/polymer.html" /> | |
2 | + | |
3 | +<link rel="import" href="../../bower_components/paper-material/paper-material.html" /> | |
4 | +<link rel="import" href="../../bower_components/paper-menu/paper-menu.html"> | |
5 | +<link rel="import" href="../../bower_components/paper-item/paper-item.html"> | |
6 | + | |
7 | +<dom-module id="select-fields-controllet"> | |
8 | + | |
9 | + <style is="custom-style"> | |
10 | + | |
11 | + #select_fields_controllet_container { | |
12 | + height: 100%; | |
13 | + width: 100%; | |
14 | + } | |
15 | + | |
16 | + #select_fields_controllet_container * { | |
17 | + font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
18 | + font-size: 16px; | |
19 | + line-height: 24px; | |
20 | + } | |
21 | + | |
22 | + #select_fields_controllet_container #header { | |
23 | + background: #B6B6B6; | |
24 | + height: 24px; | |
25 | + padding: 12px; | |
26 | + text-align: center; | |
27 | + font-weight: 700; | |
28 | + cursor: pointer; | |
29 | + } | |
30 | + | |
31 | + #select_fields_controllet_container #menu_container { | |
32 | + position: relative; | |
33 | + height: calc(100% - 48px); | |
34 | + width: 100%; | |
35 | + } | |
36 | + | |
37 | + paper-menu { | |
38 | + padding: 0px; | |
39 | + } | |
40 | + | |
41 | + paper-item { | |
42 | + cursor: pointer; | |
43 | + color: #000000; | |
44 | + margin: 4px; | |
45 | + } | |
46 | + | |
47 | + paper-item.iron-selected { | |
48 | + background: #2196F3; | |
49 | + color: #FFFFFF; | |
50 | + } | |
51 | + | |
52 | + paper-item:focus:before { | |
53 | + opacity: 0 !important; | |
54 | + background: white; | |
55 | + } | |
56 | + | |
57 | + paper-item:focus:after { | |
58 | + opacity: 0 !important; | |
59 | + background: white; | |
60 | + } | |
61 | + | |
62 | + paper-item:hover:not(.iron-selected) { | |
63 | + background-color: rgba(0, 0, 0, 0.12); | |
64 | + } | |
65 | + | |
66 | + </style> | |
67 | + | |
68 | + <template> | |
69 | + | |
70 | + <paper-material id="select_fields_controllet_container" elevation="5"> | |
71 | + | |
72 | + <div id="header" on-click="_invertSelection"><span id="fields"></span></div> | |
73 | + <div id="menu_container"> | |
74 | + <paper-menu id="menu" multi> | |
75 | + <template is="dom-repeat" items="{{fields}}"> | |
76 | + <paper-item>{{item}}</paper-item> | |
77 | + </template> | |
78 | + </paper-menu> | |
79 | + </div> | |
80 | + | |
81 | + </paper-material> | |
82 | + | |
83 | + </template> | |
84 | + | |
85 | + <script> | |
86 | + Polymer({ | |
87 | + | |
88 | + is : 'select-fields-controllet', | |
89 | + | |
90 | + properties : { | |
91 | + | |
92 | + fields : { | |
93 | + type : Array, | |
94 | + value : [] | |
95 | + }, | |
96 | + | |
97 | +// preselectedFields : { | |
98 | +// type : Array, | |
99 | +// value : [] | |
100 | +// } | |
101 | + }, | |
102 | + | |
103 | + listeners: { | |
104 | + 'iron-activate': '_fireSelectedFields' | |
105 | + }, | |
106 | + | |
107 | + ready : function() { | |
108 | + $(this.$.menu_container).perfectScrollbar(); | |
109 | + }, | |
110 | + | |
111 | + attached : function() { | |
112 | + this._translate(); | |
113 | + | |
114 | +// if (this.preselectedFields.length > 0) | |
115 | +// this._preselectFields(); | |
116 | + }, | |
117 | + | |
118 | + setFields : function(fields) { | |
119 | + this.fields = fields; | |
120 | + }, | |
121 | + | |
122 | + setSelectFields : function(selectFields) { | |
123 | + for(var i=0; i<selectFields.length; i++) | |
124 | + this.$.menu.select(selectFields[i]); | |
125 | + this._fireSelectedFields(); | |
126 | + }, | |
127 | + | |
128 | + reset: function() { | |
129 | + this.$.menu.selectedValues = []; | |
130 | + this.setFields([]); | |
131 | + }, | |
132 | + | |
133 | + _translate : function() { | |
134 | + this.$.fields.innerHTML = ln["fields_" + ln["localization"]]; | |
135 | + }, | |
136 | + | |
137 | +// _preselectFields : function() { | |
138 | +// for(var i=0; i<this.preselectedFields.length; i++) | |
139 | +// this.$.menu.select(this.preselectedFields[i]); | |
140 | +// this._fireSelectedFields(); | |
141 | +// }, | |
142 | + | |
143 | + _fireSelectedFields : function() { | |
144 | + this.debounce('_fireSelectedFields', function () { | |
145 | + this.fire('select-fields-controllet_selected-fields', {selectedFields: this.$.menu.selectedValues}); | |
146 | + }, 300); | |
147 | + }, | |
148 | + | |
149 | + _invertSelection : function() { | |
150 | +// for(var i=this.fields.length-1; i>=0; i--) | |
151 | + for(var i=0; i<this.fields.length; i++) | |
152 | + this.$.menu.select(i); | |
153 | + | |
154 | + $(this.$.menu_container).animate({ scrollTop: 0}, 0); | |
155 | + | |
156 | + this._fireSelectedFields(); | |
157 | + } | |
158 | + | |
159 | + }); | |
160 | + | |
161 | + </script> | |
162 | + | |
163 | +</dom-module> | |
0 | 164 | \ No newline at end of file | ... | ... |
controllets/select-visualization-controllet/select-visualization-controllet.html
... | ... | @@ -190,14 +190,21 @@ |
190 | 190 | params:{ |
191 | 191 | type: Object, |
192 | 192 | value: undefined |
193 | - } | |
193 | + }, | |
194 | + | |
195 | + data : { | |
196 | + type : Object, | |
197 | + value : undefined | |
198 | + }, | |
194 | 199 | |
195 | 200 | }, |
196 | 201 | |
197 | 202 | listeners: { |
203 | +// 'select-fields-controllet_selected-fields': '_updateFields', | |
204 | +// 'filters-controllet_filters': '_updateFilters', | |
198 | 205 | 'items-vslider-controllet_selected-datalet': '_selectDatalet', |
199 | 206 | 'select_visualization_inputs_ready': '_loadDatalet', |
200 | - 'select_visualization_options_changed': '_tryLoadDatalet', | |
207 | + 'select_visualization_options_changed': '_tryLoadDatalet' | |
201 | 208 | }, |
202 | 209 | |
203 | 210 | ready : function() { |
... | ... | @@ -221,8 +228,8 @@ |
221 | 228 | }, |
222 | 229 | |
223 | 230 | setFields : function(fields) { |
224 | - if (this.fields.length > 0 && JSON.stringify(this.fields) != JSON.stringify(fields)) | |
225 | - this.reset(); | |
231 | +// if (this.fields.length > 0 && JSON.stringify(this.fields) != JSON.stringify(fields)) | |
232 | +// this.init(); | |
226 | 233 | |
227 | 234 | this.fields = this._copy(fields); |
228 | 235 | |
... | ... | @@ -231,7 +238,11 @@ |
231 | 238 | inputs.setFields(this.fields); |
232 | 239 | }, |
233 | 240 | |
234 | - reset : function() { | |
241 | + setData : function(data) { | |
242 | + this.data = this._copy(data); | |
243 | + }, | |
244 | + | |
245 | + init : function() { | |
235 | 246 | this.$.vslider._reset(); |
236 | 247 | }, |
237 | 248 | |
... | ... | @@ -342,11 +353,15 @@ |
342 | 353 | var params = this.$.options.getParams(); |
343 | 354 | for (var key in params) { this.params[key] = params[key]; } |
344 | 355 | |
356 | + var data = alasql_complexSelectData(this.data, this.selectedFields, this.filters, inputs.getAggregators(), inputs.getOrders()); | |
357 | + data = transformData(data, this.selectedFields, true); | |
358 | + this.params["data"] = JSON.stringify(data); | |
359 | + | |
345 | 360 | var dataletParams ={ |
346 | - component : this.selectedDatalet+"-datalet", | |
347 | - params : this.params, | |
348 | - fields : this.selectedFields, | |
349 | - placeHolder : this.$.datalet_selection_datalet_placeholder | |
361 | + component: this.selectedDatalet+"-datalet", | |
362 | + params: this.params, | |
363 | + fields: this.selectedFields, | |
364 | + placeHolder: this.$.datalet_selection_datalet_placeholder, | |
350 | 365 | }; |
351 | 366 | |
352 | 367 | ComponentService.deep_url = this.deepUrl; |
... | ... | @@ -359,11 +374,11 @@ |
359 | 374 | delete this.params["export_menu"]; |
360 | 375 | |
361 | 376 | var data = { |
362 | - dataUrl : this.dataUrl, | |
363 | - params : this.params, | |
364 | - fields : this.selectedFields, | |
365 | - datalet : this.selectedDatalet+"-datalet", | |
366 | - staticData : JSON.stringify(this.$.datalet_selection_datalet_placeholder.children[1].behavior.data) | |
377 | + dataUrl: this.dataUrl, | |
378 | + params: this.params, | |
379 | + fields: this.selectedFields, | |
380 | + datalet: this.selectedDatalet+"-datalet", | |
381 | + staticData: JSON.stringify(this.$.datalet_selection_datalet_placeholder.children[1].behavior.data) | |
367 | 382 | } |
368 | 383 | |
369 | 384 | this.fire('data-sevc-controllet.dataletCreated', {data : data}); | ... | ... |
datalets/base-ajax-json-alasql-datalet/base-ajax-json-alasql-datalet.html
... | ... | @@ -29,7 +29,12 @@ |
29 | 29 | --> |
30 | 30 | |
31 | 31 | <link rel="import" href="../base-datalet/base-datalet.html"> |
32 | -<script type="text/javascript" src="../../bower_components/jsdatachecker/jsdatachecker.min.js"></script> | |
32 | +<link rel="import" href="../../controllets/providers-utility-controllet/providers-utility-controllet.html" /> | |
33 | + | |
34 | +<script type="text/javascript" src="../../alasql-utility/alasql.min.js"></script> | |
35 | +<script type="text/javascript" src="../../alasql-utility/alasql-utility.js"></script> | |
36 | + | |
37 | +<script type="text/javascript" src="../../bower_components/JSDataChecker/jsdatachecker.min.js"></script> | |
33 | 38 | |
34 | 39 | <!-- |
35 | 40 | The `base-ajax-json-jsonpath-datalet` extend the base component and define the mechanism to access and select data. |
... | ... | @@ -52,6 +57,9 @@ Example : |
52 | 57 | --> |
53 | 58 | |
54 | 59 | <dom-module id="base-ajax-json-alasql-datalet"> |
60 | + | |
61 | + <providers-utility-controllet></providers-utility-controllet> | |
62 | + | |
55 | 63 | <template> |
56 | 64 | <base-datalet data-url="{{dataUrl}}" fields="{{fields}}" data="{{data}}" title="{{title}}" description="{{description}}" export_menu="{{export_menu}}"></base-datalet> |
57 | 65 | </template> | ... | ... |
datalets/base-ajax-json-alasql-datalet/static/js/AjaxJsonAlasqlBehavior.js
... | ... | @@ -83,8 +83,7 @@ var AjaxJsonAlasqlBehavior = { |
83 | 83 | * @method selectData |
84 | 84 | */ |
85 | 85 | selectData : function() { |
86 | - this._component.fields = JSON.parse(this._component.fields); | |
87 | - var provider = this._getProvider(this._component.fields[0]); | |
86 | + var fields = this._component.fields = JSON.parse(this._component.fields); | |
88 | 87 | |
89 | 88 | var filters = JSON.parse(this._component.getAttribute("filters")); |
90 | 89 | var aggregators = JSON.parse(this._component.getAttribute("aggregators")); |
... | ... | @@ -97,181 +96,23 @@ var AjaxJsonAlasqlBehavior = { |
97 | 96 | orders = orders[0]; |
98 | 97 | } |
99 | 98 | |
100 | - var fields = []; | |
101 | - for (var i=0; i < this._component.fields.length; i++) | |
102 | - fields.push(this._fieldName(this._component.fields[i], provider)); | |
99 | + var f = Object.create(providerFactory); | |
100 | + var provider = f.getProvider(this._component.dataUrl); | |
101 | + var data = provider.selectData(this.properties.json_results.value); | |
103 | 102 | |
104 | - //jsdatachecker | |
105 | - var _converter = new DataTypeConverter(); | |
106 | - var path2 = this._arrayPath(provider); | |
107 | - var processingResult = _converter.inferJsonDataType(this.properties.json_results.value, path2); | |
108 | - var processingResults = _converter.convert(processingResult); | |
109 | - var jsonData = [processingResults.dataset]; | |
103 | + var converter = new DataTypeConverter(); | |
104 | + var result = converter.inferJsonDataType(data, ["*"]); | |
105 | + result = converter.cast(result); | |
106 | + data = result.dataset; | |
110 | 107 | |
111 | - //WHERE | |
112 | - var where = ""; | |
113 | - if(filters && filters.length) { | |
108 | + //data = alasql_selectData(data, fields, filters); | |
109 | + data = alasql_complexSelectData(data, fields, filters, aggregators, orders); | |
114 | 110 | |
115 | - for (var i=0; i < filters.length; i++) | |
116 | - filters[i]["field"] = this._fieldName(filters[i]["field"], provider); | |
117 | - | |
118 | - where = "WHERE "; | |
119 | - for (var i=0; i < filters.length; i++) { | |
120 | - if(filters[i]["operation"] == "contains") | |
121 | - where += filters[i]["field"] + " like '%" + filters[i]["value"] + "%' AND "; | |
122 | - else if(filters[i]["operation"] == "not contains") | |
123 | - where += filters[i]["field"] + " not like '%" + filters[i]["value"] + "%' AND "; | |
124 | - else if(filters[i]["operation"] == "start") | |
125 | - where += filters[i]["field"] + " like '" + filters[i]["value"] + "%' AND "; | |
126 | - else if(filters[i]["operation"] == "ends") | |
127 | - where += filters[i]["field"] + " like '%" + filters[i]["value"] + "' AND "; | |
128 | - else | |
129 | - where += filters[i]["field"] + " " + filters[i]["operation"] + " " + filters[i]["value"] + " AND "; | |
130 | - } | |
131 | - where = where.slice(0, -5); | |
132 | - } | |
133 | - | |
134 | - //ORDER BY | |
135 | - var orderBy = ""; | |
136 | - if(orders && orders.length) { | |
137 | - | |
138 | - for (var i=0; i < orders.length; i++) | |
139 | - orders[i]["field"] = this._fieldName(orders[i]["field"], ""); | |
140 | - | |
141 | - orderBy = "ORDER BY "; | |
142 | - for (var i = 0; i < orders.length; i++) | |
143 | - orderBy += orders[i]["field"] + " " + orders[i]["operation"] + ", "; | |
144 | - orderBy = orderBy.slice(0, -2); | |
145 | - } | |
146 | - | |
147 | - //SELECT | |
148 | - var pureSelect = "SELECT "; | |
149 | - for (var i = 0; i < fields.length; i++) | |
150 | - pureSelect += fields[i] + " as " + this._fieldName(this._component.fields[i], "") + ", "; | |
151 | - pureSelect = pureSelect.slice(0, -2); | |
152 | - | |
153 | - //GROUP BY | |
154 | - var groupBy = ""; | |
155 | - var select = ""; | |
156 | - if(aggregators && aggregators.length) { | |
157 | - | |
158 | - for (var i=0; i < aggregators.length; i++) | |
159 | - aggregators[i]["field"] = this._fieldName(aggregators[i]["field"], ""); | |
160 | - | |
161 | - groupBy = "GROUP BY " + aggregators[0]["field"]; | |
162 | - select = "SELECT " + aggregators[0]["field"]; | |
163 | - for (var i = 1; i < aggregators.length; i++) | |
164 | - select += ", " + aggregators[i]["operation"] + "(" + aggregators[i]["field"] + ") as " + aggregators[i]["field"]; | |
165 | - | |
166 | - if(aggregators[1] && aggregators[1]["operation"] == "GROUP BY") { | |
167 | - groupBy = "GROUP BY " + aggregators[0]["field"] + ", " + aggregators[1]["field"]; | |
168 | - select = "SELECT " + aggregators[0]["field"] + ", " + aggregators[1]["field"]; | |
169 | - for (var i = 2; i < aggregators.length; i++) | |
170 | - select += ", " + aggregators[i]["operation"] + "(" + aggregators[i]["field"] + ") as " + aggregators[i]["field"]; | |
171 | - } | |
172 | - } | |
173 | - | |
174 | - //QUERY | |
175 | - var path = this._path(this._component.fields[0], provider); | |
176 | - var query; | |
177 | - | |
178 | - query = "SELECT "+ path +" FROM ?"; | |
179 | - //console.log(query); | |
180 | - var res = alasql(query, [jsonData]); | |
181 | - | |
182 | - var records = res[0][path]; | |
183 | - | |
184 | - query = pureSelect + " FROM ? " + where + " " + orderBy; | |
185 | - //console.log(query); | |
186 | - var obj = alasql(query, [records]); | |
187 | - | |
188 | - if (groupBy != "") { | |
189 | - query = select + " FROM ? " + groupBy + " " + orderBy; | |
190 | - //console.log(query); | |
191 | - obj = alasql(query, [obj]); | |
192 | - } | |
193 | - | |
194 | - //PUSH DATA | |
195 | - if(!obj || obj.length == 0) | |
196 | - this.data = [] | |
197 | - else | |
198 | - this._pushData(obj, fields); | |
111 | + this.data = transformData(data, fields, true); | |
199 | 112 | |
200 | 113 | this._deleteWaitImage(); |
201 | 114 | }, |
202 | 115 | |
203 | - _pushData : function(obj, keys) { | |
204 | - this.data = []; | |
205 | - | |
206 | - if (typeof keys == 'undefined') | |
207 | - keys = Object.keys(obj[0]); | |
208 | - | |
209 | - for (var key in keys){ | |
210 | - | |
211 | - var name = keys[key].replace(/(\[|\]|fields->)/g, ""); | |
212 | - var data = []; | |
213 | - | |
214 | - for (var i in obj) { | |
215 | - var v = obj[i][name]; | |
216 | - if(!isNaN(v) && v % 1 != 0) | |
217 | - v = Math.floor(v * 100) / 100; | |
218 | - data.push(v); | |
219 | - | |
220 | - //data.push(obj[i][name]); | |
221 | - } | |
222 | - | |
223 | - this.data.push({ | |
224 | - name: name, | |
225 | - data: data | |
226 | - }); | |
227 | - } | |
228 | - }, | |
229 | - | |
230 | - _getProvider : function(field) { | |
231 | - if(field.indexOf("result,records") > -1) | |
232 | - return "ckan"; | |
233 | - else if(field.indexOf("records,fields") > -1) | |
234 | - return "openDataSoft"; | |
235 | - else | |
236 | - return "provider"; | |
237 | - }, | |
238 | - | |
239 | - _fieldName : function(field, provider) { | |
240 | - if(provider.indexOf("ckan") > -1) { | |
241 | - return "[" + field.substring(field.lastIndexOf(",") + 1, field.length) + "]"; | |
242 | - } | |
243 | - else if(provider.indexOf("openDataSoft") > -1) { | |
244 | - return "fields->[" + field.substring(field.lastIndexOf(",") + 1, field.length)+ "]"; | |
245 | - } | |
246 | - else { | |
247 | - return "[" + field.substring(field.lastIndexOf(",") + 1, field.length) + "]"; | |
248 | - } | |
249 | - }, | |
250 | - | |
251 | - _path : function(field, provider) { | |
252 | - if(provider.indexOf("ckan") > -1) { | |
253 | - return "result->records" | |
254 | - } | |
255 | - else if(provider.indexOf("openDataSoft") > -1) { | |
256 | - return "records"; | |
257 | - } | |
258 | - else { | |
259 | - return field.substring(0, field.lastIndexOf(",")).replace(",", "->"); | |
260 | - } | |
261 | - }, | |
262 | - | |
263 | - _arrayPath : function(provider) { | |
264 | - if(provider.indexOf("ckan") > -1) { | |
265 | - return ["result", "records", "*"]; | |
266 | - } | |
267 | - else if(provider.indexOf("openDataSoft") > -1) { | |
268 | - return ["records", "fields", "*"]; | |
269 | - } | |
270 | - else { | |
271 | - return ["*"]; | |
272 | - } | |
273 | - }, | |
274 | - | |
275 | 116 | /** |
276 | 117 | * Delete a image after loading a datalet |
277 | 118 | */ | ... | ... |