Commit 35c4a6d817970c36d47b88670c055b0c05633f2e
1 parent
1c6559d7
Datasets providers compatimilityupdate, leafletjs update
Showing
3 changed files
with
30 additions
and
89 deletions
controllets/data-sevc-controllet/data-sevc-controllet.html
... | ... | @@ -58,7 +58,7 @@ Example: |
58 | 58 | |
59 | 59 | <data-sevc-controllet deep-url="http://192.168.214.128/DEEalerProvider/DEEP/" |
60 | 60 | datalets-list-url="http://192.168.214.128/DEEalerProvider/DEEP/datalets-list" |
61 | - organization="2" > | |
61 | + datasets='{[{name : 'dataset1', url : dataset1Urls}, ... , {name : 'datasetN', url : datasetNUrls}]' > | |
62 | 62 | </data-sevc-controllet> |
63 | 63 | |
64 | 64 | |
... | ... | @@ -313,7 +313,7 @@ Example: |
313 | 313 | <paper-dropdown-menu id="datasets-sources" label="Available datasets"> |
314 | 314 | <paper-menu class="dropdown-content"> |
315 | 315 | <template is="dom-repeat" items="{{datasets}}" as="dataset" index-as="index"> |
316 | - <paper-item id="{{index}}" on-tap="_datasourceSelected">{{dataset}}</paper-item> | |
316 | + <paper-item id="{{index}}" on-tap="_datasourceSelected">{{dataset.name}}</paper-item> | |
317 | 317 | </template> |
318 | 318 | </paper-menu> |
319 | 319 | </paper-dropdown-menu> |
... | ... | @@ -424,60 +424,6 @@ Example: |
424 | 424 | |
425 | 425 | <script> |
426 | 426 | |
427 | - var datasetsPrato = { | |
428 | - names:[ | |
429 | - 'Consuntivo entrate 2009', | |
430 | - 'Consuntivo entrate 2010', | |
431 | - 'Consuntivo entrate 2011', | |
432 | - 'Consuntivo entrate 2012', | |
433 | - 'Consuntivo entrate 2014' | |
434 | - ], | |
435 | - urls: [ | |
436 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=07843fc3-07e1-4c66-9be4-fed43ca4a26f&limit=10000', | |
437 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=48a4db73-d3d4-4639-bbc2-9c797d0e6cda&limit=10000', | |
438 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=a14cc2fb-0c24-48d7-9370-834045797d89&limit=10000', | |
439 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=fb32fcb6-5e44-4e52-b132-01c6540ddbee&limit=10000', | |
440 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=0cb600fc-19ad-4aaf-9794-1e6ea851840a&limit=10000' | |
441 | - ] | |
442 | - } | |
443 | - | |
444 | - var datasetsGroeningen = { | |
445 | - names:[ | |
446 | - 'Vestigingen register gemeente Groningen', | |
447 | - 'Woonruimte gemeente Groningen' | |
448 | - ], | |
449 | - urls: [ | |
450 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=ba554c1f-02a7-4d76-b449-fb9daa1f8bfd&limit=10000', | |
451 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=af7b3916-4347-469a-8354-3c2d559bd92f&limit=10000' | |
452 | - ] | |
453 | - } | |
454 | - | |
455 | - var datasetsDublin = { | |
456 | - names:[ | |
457 | - 'SDCC Traffic Cameras', | |
458 | - 'Derelict Site Register', | |
459 | - 'Dublin City Council Commencement Notices', | |
460 | - 'Dublin City Council Planning Applications', | |
461 | - 'Dun Laoghaire-Rathdown County Council Planning Application 2008-2014', | |
462 | - 'Fingal Council Planning Applications for last 7 years', | |
463 | - 'Planning Register', | |
464 | - 'Fingal Development Plan 2011-2017 Record of Protected Structures' | |
465 | - ], | |
466 | - urls: [ | |
467 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=10000', | |
468 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=fcbee83e-3d3d-4303-a568-24dd33d02adc&limit=10000', | |
469 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=ee00de68-f2e4-482f-a003-3c0561351075&limit=10000', | |
470 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=2f4a9d44-b52f-4c8b-a5db-d8f4a676d81e&limit=10000', | |
471 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=c479f061-9638-489d-ac55-0c68765548ff&limit=10000', | |
472 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=d29a477a-4734-43ef-8002-048c8640d441&limit=10000', | |
473 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=2b23f32d-e27e-4eef-af1e-27e05103df7d&limit=10000', | |
474 | - 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=5ea813bc-fdf9-4edb-b3b1-0142b593d5c6&limit=10000', | |
475 | - ] | |
476 | - } | |
477 | - | |
478 | - var AvailableDatasets = [datasetsPrato, datasetsGroeningen, datasetsDublin] | |
479 | - | |
480 | - | |
481 | 427 | Polymer({ |
482 | 428 | |
483 | 429 | is : 'data-sevc-controllet', |
... | ... | @@ -544,7 +490,7 @@ Example: |
544 | 490 | */ |
545 | 491 | dataUrl : { |
546 | 492 | type : String, |
547 | - value : "",/*"http://demo.ckan.org/api/action/datastore_search?resource_id=8324a4c9-66d6-47bf-a898-94237cc39b9f&limit=50",*/ | |
493 | + value : "", | |
548 | 494 | observer : '_dataUrlChanged' |
549 | 495 | }, |
550 | 496 | /** |
... | ... | @@ -559,17 +505,6 @@ Example: |
559 | 505 | value : "" |
560 | 506 | }, |
561 | 507 | /** |
562 | - * It represents the organization related to datesets available for the user. It will be set at runtime based on the country of the user | |
563 | - * | |
564 | - * @attribute organization | |
565 | - * @type Number | |
566 | - * @default 2 | |
567 | - */ | |
568 | - organization : { | |
569 | - type : Number, | |
570 | - value : 2 | |
571 | - }, | |
572 | - /** | |
573 | 508 | * It's used to store the list of datalets returned from DEEP |
574 | 509 | * |
575 | 510 | * @attribute datalets_list |
... | ... | @@ -623,19 +558,7 @@ Example: |
623 | 558 | datasets : |
624 | 559 | { |
625 | 560 | type : Array, |
626 | - value : AvailableDatasets[0].names | |
627 | - }, | |
628 | - /** | |
629 | - * It's used to store the datasets urls | |
630 | - * | |
631 | - * @attribute datasets | |
632 | - * @type Array | |
633 | - * @default empty | |
634 | - */ | |
635 | - datasets_urls : | |
636 | - { | |
637 | - type : Array, | |
638 | - value :AvailableDatasets[0].urls | |
561 | + value : [] | |
639 | 562 | } |
640 | 563 | |
641 | 564 | }, |
... | ... | @@ -650,9 +573,6 @@ Example: |
650 | 573 | |
651 | 574 | ready : function(){ |
652 | 575 | |
653 | - this.datasets = AvailableDatasets[this.organization].names; | |
654 | - this.datasets_urls = AvailableDatasets[this.organization].urls; | |
655 | - | |
656 | 576 | $(this.$.fields_placeholder).perfectScrollbar(); |
657 | 577 | $(this.$.selected_fields_main_container).perfectScrollbar(); |
658 | 578 | $(this.$.idm_fields_main_container).perfectScrollbar(); |
... | ... | @@ -790,7 +710,7 @@ Example: |
790 | 710 | */ |
791 | 711 | _datasourceSelected : function(e){ |
792 | 712 | |
793 | - this.$.data_url.value = this.datasets_urls[parseInt(e.target.id)]; | |
713 | + this.$.data_url.value = this.datasets[parseInt(e.target.id)].url; | |
794 | 714 | }, |
795 | 715 | /** |
796 | 716 | * Callback related to data url change | ... | ... |
datalets/base-ajax-json-jsonpath-datalet/static/js/AjaxJsonJsonPathBehavior.js
... | ... | @@ -68,6 +68,21 @@ var AjaxJsonJsonPathBehavior = { |
68 | 68 | this.properties.json_results.value = e; |
69 | 69 | this.runWorkcycle(); |
70 | 70 | }, |
71 | + /** | |
72 | + * Check if input field(passed as an array of separated value that mach with field path in received object) is an array of objet. | |
73 | + * The field is checked on current json object retrieved from the async request. | |
74 | + * | |
75 | + * @param field | |
76 | + */ | |
77 | + isFieldArray : function(field){ | |
78 | + if(field.length == 0) return false; | |
79 | + var obj = this.properties.json_results.value[field[0]]; | |
80 | + for(var i=1; i < field.length; i++){ | |
81 | + obj = (obj.constructor == Array) ? obj[0][field[i]] : obj[field[i]]; | |
82 | + } | |
83 | + | |
84 | + return (obj.constructor === Array && obj[0].constructor == Object) ? true : false; | |
85 | + }, | |
71 | 86 | |
72 | 87 | /** |
73 | 88 | * selectData built a JSONPATH query based on the user selected fields then extract data from the JSON response. |
... | ... | @@ -83,10 +98,12 @@ var AjaxJsonJsonPathBehavior = { |
83 | 98 | for(var i=0;i < this._component.fields.length; i++){ |
84 | 99 | var query = "$"; |
85 | 100 | var query_elements = this._component.fields[i].split(','); |
86 | - for(var j=0; j < query_elements.length - 1;j++){ | |
101 | + for(var j=0; j < query_elements.length;j++){ | |
87 | 102 | query += "['" + query_elements[j] + "']"; |
103 | + if(this.isFieldArray(query_elements.slice(0,j+1))){ | |
104 | + query += "[*]"; | |
105 | + } | |
88 | 106 | } |
89 | - query += "[*]" + "['" + query_elements[query_elements.length - 1] + "']"; | |
90 | 107 | this.data.push({name : query_elements[query_elements.length - 1], data : jsonPath(this.properties.json_results.value, query)}); |
91 | 108 | } |
92 | 109 | } | ... | ... |
datalets/leafletjs-datalet/leafletjs-datalet.html
... | ... | @@ -69,11 +69,15 @@ Example: |
69 | 69 | presentData: function(){ |
70 | 70 | |
71 | 71 | var coordinates = []; |
72 | - //var keys = Object.keys(this.properties.data.value[0]); | |
72 | + var isArray = (this.data[0].data[0].constructor === Array) ? true : false; | |
73 | 73 | |
74 | 74 | for(var i=0; i<this.data[0].data.length; i++) |
75 | 75 | { |
76 | - coordinates.push([parseFloat(this.data[0].data[i]), parseFloat(this.data[1].data[i])]); | |
76 | + if(isArray) | |
77 | + coordinates.push([parseFloat(this.data[0].data[i][0]), parseFloat(this.data[0].data[i][1])]); | |
78 | + else | |
79 | + coordinates.push([parseFloat(this.data[0].data[i]), parseFloat(this.data[1].data[i])]); | |
80 | + | |
77 | 81 | var marker = L.marker([coordinates[i][0], coordinates[i][1]]).addTo(this._component.map); |
78 | 82 | |
79 | 83 | if(this.data[2]) | ... | ... |