# HG changeset patch # User Chloe Laisne # Date 1473093947 -7200 # Node ID 53a6985443f869a47f67af62506d3b8b487713b4 # Parent a719b2dcea346cf8a97f2d421e13fbc96aa236af geostats endpoint + mapvar diff -r a719b2dcea34 -r 53a6985443f8 cms/app-client/app/components/visu-carto.js --- a/cms/app-client/app/components/visu-carto.js Mon Aug 29 20:01:13 2016 +0200 +++ b/cms/app-client/app/components/visu-carto.js Mon Sep 05 18:45:47 2016 +0200 @@ -3,6 +3,10 @@ export default Ember.Component.extend({ + continentsMapVar: AmCharts.maps.continentsLow, + countriesMapVar: AmCharts.maps.worldLow, + franceMapVar: AmCharts.maps.france2016Low, + filter: Ember.inject.service(), locationObserver: Ember.observer('filter.location', function() { if(!this.get('filter').get('location')) { @@ -10,12 +14,55 @@ } }), + geostats: [], + observerGeostats: Ember.observer('geostats', function() { + //console.log(this.get('geostats')); + }), + didInsertElement: function(){ this.$('#mapdiv').height(Ember.$('.corpus-app-container').height()); this.createAmMap(); }, createAmMap: function() { + var self = this; + + var france2016LowAreas = []; + this.get('franceMapVar')['svg']['g']['path'].forEach(function(area) { + france2016LowAreas.push({ + 'id': area.id, + 'passZoomValuesToTarget': false, + 'autoZoom': false, + 'selectable': true + }) + }); + + var continentsLowAreas = []; + this.get('continentsMapVar')['svg']['g']['path'].forEach(function(area) { + var object = { + 'id': area.id, + 'linkToObject': { + 'mapVar': self.get('countriesMapVar'), + 'getAreasFromMap': true + }, + 'passZoomValuesToTarget': true, + 'autoZoom': true + }; + if(area.id === 'europe') { + object['linkToObject']['areas'] = [{ + 'id': 'FR', + 'linkToObject': { + 'mapVar': self.get('franceMapVar'), + 'getAreasFromMap': true, + 'areas': france2016LowAreas + }, + 'autoZoom': true, + 'selectable': true + }]; + } + continentsLowAreas.push(object); + }); + this.set('map', AmCharts.makeChart('mapdiv', { 'type': 'map', 'fontFamily': 'sans-serif', @@ -38,148 +85,8 @@ }, 'dataProvider': { - 'map': 'continentsLow', - 'areas': [{ - 'id':'south_america', - 'linkToObject': { - 'map': 'worldLow', - 'getAreasFromMap': true - }, - 'passZoomValuesToTarget': true, - 'autoZoom': true - }, - { - 'id':'north_america', - 'linkToObject': { - 'map': 'worldLow', - 'getAreasFromMap': true - }, - 'passZoomValuesToTarget': true, - 'autoZoom': true - }, - { - 'id':'asia', - 'linkToObject': { - 'map': 'worldLow', - 'getAreasFromMap': true - }, - 'passZoomValuesToTarget': true, - 'autoZoom': true - }, - { - 'id':'europe', - 'linkToObject': { - 'map': 'worldLow', - 'getAreasFromMap': true, - 'areas': [{ - 'id': 'FR', - 'linkToObject': { - 'map': 'france2016Low', - 'getAreasFromMap': true, - 'areas': [{ - 'id': 'FR-A', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-B', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-C', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-D', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-E', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-F', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-G', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-H', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-I', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-J', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-K', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-L', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }, - { - 'id': 'FR-M', - 'passZoomValuesToTarget': false, - 'autoZoom': false, - 'selectable': true - }] - }, - 'autoZoom': true, - 'selectable': true - }] - }, - 'passZoomValuesToTarget': true, - 'autoZoom': true - }, - { - 'id':'australia', - 'linkToObject': { - 'map': 'worldLow', - 'getAreasFromMap': true - }, - 'passZoomValuesToTarget': true, - 'autoZoom': true - }, - { - 'id':'africa', - 'linkToObject': { - 'map': 'worldLow', - 'getAreasFromMap': true - }, - 'passZoomValuesToTarget': true, - 'autoZoom': true - }] + 'mapVar': this.get('continentsMapVar'), + 'areas': continentsLowAreas }, listeners: [{ @@ -195,6 +102,10 @@ clickMapObject: function(event) { this.get('filter').set('location', event.mapObject.title); + + /*this.get('geostats').forEach( function (geostat) { + console.log('geostat', geostat.get('id'), geostat.get('count')); + });*/ }, homeButtonClicked: function(event) { diff -r a719b2dcea34 -r 53a6985443f8 cms/app-client/app/routes/tabs/carto.js --- a/cms/app-client/app/routes/tabs/carto.js Mon Aug 29 20:01:13 2016 +0200 +++ b/cms/app-client/app/routes/tabs/carto.js Mon Sep 05 18:45:47 2016 +0200 @@ -1,4 +1,9 @@ import Ember from 'ember'; export default Ember.Route.extend({ + + model: function() { + return this.store.query('geostat', { 'areas': 'FR-A,FR-B,FR-C,FR-D,FR-E' }); + } + }); diff -r a719b2dcea34 -r 53a6985443f8 cms/app-client/app/templates/tabs/carto.hbs --- a/cms/app-client/app/templates/tabs/carto.hbs Mon Aug 29 20:01:13 2016 +0200 +++ b/cms/app-client/app/templates/tabs/carto.hbs Mon Sep 05 18:45:47 2016 +0200 @@ -1,3 +1,3 @@
- {{ visu-carto documents=model }} + {{ visu-carto geostats=model }}
\ No newline at end of file diff -r a719b2dcea34 -r 53a6985443f8 cms/app-client/mirage/config.js --- a/cms/app-client/mirage/config.js Mon Aug 29 20:01:13 2016 +0200 +++ b/cms/app-client/mirage/config.js Mon Sep 05 18:45:47 2016 +0200 @@ -32,6 +32,14 @@ this.get('/languages'); + this.get('/geostats', function(db, request) { + if(request.queryParams.areas) { + return db.areas.find(request.queryParams.areas.split(',')); + } else { + return []; + } + }); + this.get('/themes'); this.get('/discourses'); diff -r a719b2dcea34 -r 53a6985443f8 cms/app-client/mirage/serializers/language.js --- a/cms/app-client/mirage/serializers/language.js Mon Aug 29 20:01:13 2016 +0200 +++ b/cms/app-client/mirage/serializers/language.js Mon Sep 05 18:45:47 2016 +0200 @@ -2,7 +2,6 @@ import _ from 'lodash/lodash'; - export default JSONAPISerializer.extend({ serialize(response) { return _(response.models).map((lang) => { return [lang.id, lang.count];}).object().value();