Commit 89558a416e35b2af0a2c60cf45564fcb8ac1f85d

Authored by Renato De Donato
1 parent 1a26bccd

datatype, provider mod

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-&#45;&#45;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-&#45;&#45;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-&#45;&#45;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-&#45;&#45;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}}&nbsp;&nbsp;&nbsp;<span class="highlighted">{{item.operation}}</span>&nbsp;&nbsp;&nbsp;"{{item.value}}"&nbsp;&nbsp;&nbsp;<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
1   -/**
2   - * Created by renato on 25/05/16.
3   - */
  1 +function generic_Provider () {}
  2 +
  3 +generic_Provider.prototype.selectData = function(data) {
  4 + return data;
  5 +};
  6 +
  7 +generic_Provider.prototype.addLimit = function(url) {
  8 + return url;
  9 +};
4 10 \ No newline at end of file
... ...
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 +