cms/app-client/app/adapters/application.js
author ymh <ymh.work@gmail.com>
Tue, 20 Mar 2018 15:02:40 +0100
changeset 573 25f3d28f51b2
parent 467 762fc0eb4946
permissions -rw-r--r--
Added tag 0.0.25 for changeset 190ae1dee68d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
126
e87a340711a4 improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents: 123
diff changeset
     1
import RESTAdapter from 'ember-data/adapters/rest';
e87a340711a4 improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents: 123
diff changeset
     2
import ENV from 'app-client/config/environment';
91
acfeddc7821d rename "sound" to "document"
nowmad@nowmads-macbook-pro.local
parents: 90
diff changeset
     3
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
     4
const TYPE_PATH_MAP = {
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
     5
    transcript: 'transcript',
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
     6
    geostat: 'stats/geostats',
393
5ef3bfef0bff add colors to visu chrono
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
     7
    datestat: 'stats/datestats',
424
feb0d3e0fef9 add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents: 393
diff changeset
     8
    dateminmax: 'stats/dateminmax',
465
9df336529b2f make filter and theme visualisatiion change on filter modification
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
     9
    theme: 'stats/themes',
467
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 465
diff changeset
    10
    discourse: 'stats/discourses',
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 465
diff changeset
    11
    language: 'stats/languages'
306
3fccf43160a7 Some more changes linked to the change of api organization + some jshint error cleaning
ymh <ymh.work@gmail.com>
parents: 305
diff changeset
    12
};
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
    13
126
e87a340711a4 improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents: 123
diff changeset
    14
export default RESTAdapter.extend({
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    15
319
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    16
    namespace: (ENV.APP.backRootURL || ENV.rootURL).replace(/\/$/,"")+'/api/v1',
126
e87a340711a4 improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents: 123
diff changeset
    17
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    18
    buildURL: function(modelName, id) {
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    19
        if(modelName === 'transcript') {
319
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    20
            return this.urlPrefix() + '/documents/' + encodeURIComponent(encodeURIComponent(id)) + '/' + modelName;
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    21
        } else if (modelName === 'document' && id) {
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    22
            return this.urlPrefix() + '/documents/' + encodeURIComponent(encodeURIComponent(id)) ;
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    23
        }
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    24
        return this._super(...arguments);
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    25
    },
42
7d091abf82fd add application adapter to simulate REST, using fixtures
nowmad@nowmads-macbook-pro.local
parents:
diff changeset
    26
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    27
    pathForType: function(modelName) {
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 261
diff changeset
    28
        return TYPE_PATH_MAP[modelName] || this._super(...arguments);
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    29
    }
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 126
diff changeset
    30
261
02e2396bcbbc Migrate to ember 2.7 + correct jquery null context error + declare shim for popcorn (instead of silencing the JSHint error)
ymh <ymh.work@gmail.com>
parents: 245
diff changeset
    31
});