--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/serializers/geostat.js Fri Sep 23 15:43:52 2016 +0200
@@ -0,0 +1,21 @@
+import DS from 'ember-data';
+
+export default DS.Serializer.extend({
+
+ normalizeResponse: function(store, primaryModelClass, payload) {
+ var data = [];
+ Object.keys(payload).forEach(function(key) {
+ data.push({
+ 'id': key,
+ 'type': 'geostat',
+ 'attributes': {
+ 'count': payload[key]
+ }
+ });
+ });
+ return {
+ 'data': data
+ };
+ }
+
+});
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/mirage/fixtures/geostats.js Fri Sep 23 15:43:52 2016 +0200
@@ -0,0 +1,27 @@
+export default [{
+ 'id': "world",
+ areas: [
+ { 'id': "north_america", 'count': 851 },
+ { 'id': "asia", 'count': 403 },
+ { 'id': "europe", 'count': 344 },
+ { 'id': "australia", 'count': 93 },
+ { 'id': "africa", 'count': 77 }
+ ]
+}, {
+ 'id': "europe",
+ areas: [
+ { 'id': "FR", 'count': 77 },
+ { 'id': "GB", 'count': 50 }
+ ]
+}, {
+ 'id' : "FR",
+ areas: [
+ { 'id': "FR-A", 'count': 75 },
+ { 'id': "FR-B", 'count': 60 },
+ { 'id': "FR-C", 'count': 45 },
+ { 'id': "FR-K", 'count': 15 },
+ { 'id': "FR-L", 'count': 13 },
+ { 'id': "FR-M", 'count': 12 }
+ ]
+}];
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/mirage/models/geostat.js Fri Sep 23 15:43:52 2016 +0200
@@ -0,0 +1,4 @@
+import { Model } from 'ember-cli-mirage';
+
+export default Model.extend({
+});
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/mirage/serializers/geostat.js Fri Sep 23 15:43:52 2016 +0200
@@ -0,0 +1,10 @@
+import { JSONAPISerializer } from 'ember-cli-mirage';
+
+import _ from 'lodash/lodash';
+
+export default JSONAPISerializer.extend({
+ serialize(response, request) {
+ var map = response.models.find(map => map.id === request.queryParams['area']);
+ return _(map && map.areas || {}).map((geostat) => { return [geostat.id, geostat.count];}).object().value();
+ }
+});