Commit 4f438cd9661a48ca806a7df781fad96a9a87aa0f

Authored by Renato De Donato
1 parent 8c43b0b4

datalets-modifier

controllets/data-sevc-controllet/co-datalets-creator-controllet.html
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 18
19 <neon-animatable> 19 <neon-animatable>
20 20
21 - <select-data-controllet id="select_data" data-url={{dataUrl}} data={{data}}></select-data-controllet> 21 + <select-data-controllet id="select_data"></select-data-controllet>
22 22
23 </neon-animatable> 23 </neon-animatable>
24 24
@@ -76,6 +76,7 @@ @@ -76,6 +76,7 @@
76 ready : function(){ 76 ready : function(){
77 ln["localization"] = this.localization; 77 ln["localization"] = this.localization;
78 78
  79 + this.$.select_data.data = this.data;
79 this.$.select_data.dataUrl = this.dataUrl; 80 this.$.select_data.dataUrl = this.dataUrl;
80 this.$.select_data.init(); 81 this.$.select_data.init();
81 this.$.select_visualization.dataUrl = this.dataUrl; 82 this.$.select_visualization.dataUrl = this.dataUrl;
controllets/data-sevc-controllet/datalets-modifier-controllet.html
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <link rel="import" href="../select-data-controllet/select-data-controllet.html" /> 10 <link rel="import" href="../select-data-controllet/select-data-controllet.html" />
11 <link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" /> 11 <link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" />
12 12
13 -<dom-module id="data-sevc-controllet"> 13 +<dom-module id="datalets-modifier-controllet">
14 14
15 <template> 15 <template>
16 16
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 36
37 Polymer({ 37 Polymer({
38 38
39 - is : 'data-sevc-controllet', 39 + is : 'datalets-modifier-controllet',
40 40
41 listeners : { 41 listeners : {
42 'page-slider-controllet_selected' : '_updateSlider', 42 'page-slider-controllet_selected' : '_updateSlider',
controllets/datalets-modifier-controllet/datalets-modifier-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="datalets-modifier-controllet">
  14 +
  15 + <template>
  16 +
  17 + <page-slider-controllet id="slider">
  18 +
  19 + <neon-animatable>
  20 +
  21 + <select-data-controllet id="select_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}} data-url={{dataUrl}} preselected-datalet={{selectedDatalet}} datalet-preset={{dataletPreset}}></select-visualization-controllet>
  28 +
  29 + </neon-animatable>
  30 +
  31 + </page-slider-controllet>
  32 +
  33 + </template>
  34 +
  35 + <script>
  36 +
  37 + Polymer({
  38 +
  39 + is : 'datalets-modifier-controllet',
  40 +
  41 + listeners : {
  42 + 'page-slider-controllet_selected' : '_updateSlider',
  43 + 'select-fields-controllet_selected-fields' : '_allowThirdStep',
  44 + 'filters-controllet_filters': '_allowThirdStep',
  45 + 'data-ready': '_preselect'
  46 + },
  47 +
  48 + properties : {
  49 +
  50 + dataUrl : {
  51 + type : String,
  52 + value : undefined
  53 + },
  54 +
  55 + deepUrl : {
  56 + type : String,
  57 + value : undefined
  58 + },
  59 +
  60 + dataletsListUrl : {
  61 + type : String ,
  62 + value : undefined
  63 + },
  64 +
  65 + selectedDatalet : {
  66 + type : String,
  67 + value : undefined
  68 + },
  69 +
  70 + selectedFields : {
  71 + type : Array,
  72 + value : []
  73 + },
  74 +
  75 + dataletPreset : {
  76 + type : Object,
  77 + value : []
  78 + },
  79 +
  80 + localization : {
  81 + type : String,
  82 + value : "en"
  83 + }
  84 +
  85 + },
  86 +
  87 + ready : function(){
  88 + ln["localization"] = this.localization;
  89 +
  90 + this.$.select_data.dataUrl = this.dataletPreset["data-url"];
  91 + this.$.select_data.init();
  92 + this.$.select_visualization.dataUrl = this.dataletPreset["data-url"];
  93 + this.$.select_visualization.init();
  94 + },
  95 +
  96 + _preselect : function(){
  97 + this.$.select_data.setSelectedFields(this.selectedFields);
  98 + this.$.select_data.setFilters(JSON.parse(this.dataletPreset["filters"]));
  99 + },
  100 +
  101 + _updateSlider : function(e){
  102 + switch (e.detail.selected) {
  103 + case 0:
  104 + this.$.slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]);
  105 +
  106 + this.$.slider.chevronLeft("invisible");
  107 + this.$.slider.chevronRight(false);
  108 +
  109 + if(this.$.slider.getPrevSelected() == 1)
  110 + this.$.slider.chevronRight(true);
  111 + break;
  112 + case 1:
  113 + this.$.slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]);
  114 +
  115 + this.$.slider.chevronLeft(true);
  116 + this.$.slider.chevronRight("invisible");
  117 +
  118 + /**/this.$.select_visualization.show();//resize
  119 + }
  120 + },
  121 +
  122 + _allowThirdStep : function(){
  123 + this.$.slider.chevronRight(false);
  124 + var fields = this.$.select_data.getSelectedFields();
  125 + var filters = this.$.select_data.getFilters();
  126 + var data = this.$.select_data.getData();
  127 + if(fields.length > 0) {
  128 + this.$.select_visualization.init();
  129 + this.$.select_visualization.setFields(fields);
  130 + this.$.select_visualization.setFilters(filters);
  131 + this.$.select_visualization.setData(data);
  132 + this.$.slider.chevronRight(true);
  133 + }
  134 + }
  135 +
  136 + });
  137 +
  138 + </script>
  139 +
  140 +</dom-module>
0 \ No newline at end of file 141 \ No newline at end of file
controllets/providers-utility-controllet/providers-utility-controllet.html
@@ -22,12 +22,21 @@ @@ -22,12 +22,21 @@
22 }; 22 };
23 23
24 utility_getSelectedFields = function(fields, indices) { 24 utility_getSelectedFields = function(fields, indices) {
25 - selectedFileds = []; 25 + var selectedFileds = [];
26 for (var i = 0; i < indices.length; i++) 26 for (var i = 0; i < indices.length; i++)
27 selectedFileds.push(fields[indices[i]]); 27 selectedFileds.push(fields[indices[i]]);
28 return selectedFileds; 28 return selectedFileds;
29 }; 29 };
30 30
  31 + utility_getSelectedIndices = function(fields, selectedFileds) {
  32 + console.log("we");
  33 + var selectedIndices = [];
  34 + for (var i = 0; i < fields.length; i++)
  35 + if($.inArray(fields[i], selectedFileds) > -1)
  36 + selectedIndices.push(i);
  37 + return selectedIndices;
  38 + };
  39 +
31 // utility_getResourceUrl = function(url) { 40 // utility_getResourceUrl = function(url) {
32 // //CKAN 41 // //CKAN
33 // var strDatasetPos = url.indexOf('/dataset/'); 42 // var strDatasetPos = url.indexOf('/dataset/');
controllets/select-data-controllet/select-data-controllet.html
@@ -133,6 +133,21 @@ @@ -133,6 +133,21 @@
133 return this.data; 133 return this.data;
134 }, 134 },
135 135
  136 + setSelectedFields : function(selectedFields) {
  137 + this.async(function() {
  138 + var selectedIndices = utility_getSelectedIndices(this.fields, selectedFields);
  139 +
  140 + console.log(selectedIndices);
  141 + this.$.select_fields.setSelectFields(selectedIndices);
  142 + }, 0);
  143 + },
  144 +
  145 + setFilters : function(filters) {
  146 + this.async(function() {
  147 + this.$.filters.setFilters(filters);
  148 + }, 0);
  149 + },
  150 +
136 _resizeFilters : function() { 151 _resizeFilters : function() {
137 if(!this.showFilter) { 152 if(!this.showFilter) {
138 this.$.table_container.style.height = "calc(50% - 12px)"; 153 this.$.table_container.style.height = "calc(50% - 12px)";
@@ -186,9 +201,8 @@ @@ -186,9 +201,8 @@
186 201
187 that.$.select_fields.setFields(that.fields); 202 that.$.select_fields.setFields(that.fields);
188 that.$.filters.setFields(that.fields); 203 that.$.filters.setFields(that.fields);
189 -// that.$.data_table.setData(data);  
190 204
191 - that._preselect(); 205 + that.fire('data-ready');
192 } 206 }
193 }); 207 });
194 } 208 }
@@ -205,15 +219,10 @@ @@ -205,15 +219,10 @@
205 219
206 this.$.select_fields.setFields(this.fields); 220 this.$.select_fields.setFields(this.fields);
207 this.$.filters.setFields(this.fields); 221 this.$.filters.setFields(this.fields);
208 -// this.$.data_table.setData(data);  
209 -  
210 - this._preselect();  
211 } 222 }
212 }, 223 },
213 224
214 reset : function() { 225 reset : function() {
215 -// this.dataUrl = undefined;  
216 -// this.data = undefined;  
217 this.filters = []; 226 this.filters = [];
218 this.selectedFields = []; 227 this.selectedFields = [];
219 this.$.select_fields.reset(); 228 this.$.select_fields.reset();
@@ -221,15 +230,6 @@ @@ -221,15 +230,6 @@
221 this.$.filters.reset(); 230 this.$.filters.reset();
222 }, 231 },
223 232
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);  
230 - }, 0);  
231 - },  
232 -  
233 _resize : function(){ 233 _resize : function(){
234 var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16; 234 var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16;
235 h = h - 64 - 8; //height with page scroller + margin-top 235 h = h - 64 - 8; //height with page scroller + margin-top
controllets/select-dataset-controllet/ortelio-controllet.html
@@ -506,15 +506,15 @@ @@ -506,15 +506,15 @@
506 506
507 var url = this.$.list.selectedItem.resource_url; 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 -// } 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 // 518 //
519 // // Check if OPENDATASOFT 519 // // Check if OPENDATASOFT
520 // var strExploreDatasetPos = url.indexOf('/explore/dataset/'); 520 // var strExploreDatasetPos = url.indexOf('/explore/dataset/');