--- a/cms/app-client/app/components/discourses-component.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/components/discourses-component.js Tue Nov 08 01:22:56 2016 +0100
@@ -2,8 +2,7 @@
import d3 from 'd3';
import ENV from 'app-client/config/environment';
import _ from 'lodash/lodash';
-
-
+import URI from 'urijs';
export default Ember.Component.extend({
@@ -25,8 +24,9 @@
didRender: function() {
var self = this;
var baseURL = (ENV.APP.backRootURL || ENV.rootURL).replace(/\/$/,"")+'/api/v1/stats';
+ var url = URI(baseURL+"/stats/discourses").search(this.get('filter').get('queryParamsValuesURI'));
- d3.json(baseURL + "/discourses", function(data) {
+ d3.json(url.href(), function(data) {
var discourses = data['discourses'];
var array = Object.keys(discourses).map(function (key) { return discourses[key].count; });
var oldMin = Math.min(...array),
--- a/cms/app-client/app/components/visu-chrono-year.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/components/visu-chrono-year.js Tue Nov 08 01:22:56 2016 +0100
@@ -24,7 +24,7 @@
if(this.get('isDisabled')) {
return false;
}
- return this.get('colors').getPerceptiveLuminance(this.get('backgroundColor')) >= 0.5;
+ return this.get('colors').getPerceptiveLuminance(backgroundColor) >= 0.5;
}),
backgroundColor: Ember.computed('count', 'maxCount', 'minCount', function() {
--- a/cms/app-client/app/components/visu-langues.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/components/visu-langues.js Tue Nov 08 01:22:56 2016 +0100
@@ -2,6 +2,7 @@
import d3 from 'd3';
import ENV from 'app-client/config/environment';
import _ from 'lodash/lodash';
+import URI from 'urijs';
export default Ember.Component.extend({
@@ -17,8 +18,9 @@
didInsertElement: function(){
var self = this;
var baseurl = (ENV.APP.backRootURL || ENV.rootURL).replace(/\/$/,"")+'/api/v1';
+ var url = URI(baseurl+"/stats/languages").search(this.get('filter').get('queryParamsValuesURI'));
- d3.json(baseurl+"/stats/languages", function(data) {
+ d3.json(url.href(), function(data) {
var margin = { top: 30, right: 0, bottom: 0, left: 0 };
var width = Ember.$('#' + self.get('elementId')).width();
var height = Ember.$('#' + self.get('elementId')).height() - margin.top - margin.bottom;
--- a/cms/app-client/app/controllers/application.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/controllers/application.js Tue Nov 08 01:22:56 2016 +0100
@@ -5,28 +5,40 @@
player: Ember.inject.service(),
filter: Ember.inject.service(),
+ constants: Ember.inject.service(),
+ page: 1,
+ limit: Ember.computed(function() {
+ return this.get('constants').DOCUMENTS_PAGINATION_PERPAGE;
+ }),
playerVideoscreenObserver: Ember.observer('player.videoscreen', function() {
Ember.$('body').toggleClass('videoscreen', this.get('player').get('videoscreen'));
}),
- // queryParams: ['location', 'date', 'notice', 'language', 'discourse', 'theme'],
- // queryParams: Ember.computed('filter.queryParams', 'notice', function() {
- // const queryParamsList = this.get('filter').get('queryParams');
- // return _.merge(queryParamsList, {'notice' : this.get('notice')});
- // }),
queryParams : Ember.computed('filter.queryParams', function() {
var res = _.clone(this.get('filter').get('queryParams'));
res.push('notice');
+ res.push('page');
return res;
}),
- location: Ember.computed.alias('filter.location'),
- date: Ember.computed.alias('filter.date'),
- language: Ember.computed.alias('filter.language'),
- discourse: Ember.computed.alias('filter.discourse'),
- theme: Ember.computed.alias('filter.theme'),
+ // this has to be done because queryParameters can not be computed properties...
+ // Of course, we rather had computed properties.
+ // c.f. : https://github.com/emberjs/ember.js/issues/11592
+ date: null,
+ discourse: null,
+ language: null,
+ location: null,
+ theme: null,
+
+ languageObserver: Ember.observer('language', 'date', 'date.[]', 'discourse', 'discourse.[]', 'location', 'theme', 'theme.[]', function() {
+ this.get('filter').setProperties(this.getProperties('language', 'date', 'discourse', 'theme', 'location'));
+ }),
+ filterObserver: Ember.observer('filter', 'filter.language', 'filter.date', 'filter.date.[]', 'filter.discourse', 'filter.discourse.[]', 'filter.location', 'filter.theme', 'filter.theme.[]', function() {
+ this.set('language', this.get('filter').get('language'));
+ this.setProperties(this.get('filter').getProperties('language', 'date', 'discourse', 'theme', 'location'));
+ }),
itemObserver: Ember.observer('player.item', function() {
var self = this;
@@ -62,21 +74,23 @@
init: function() {
this._super(...arguments);
this.get('player');
+ this.get('filter');
},
actions: {
- changeDocument: function(docDirection){
- var direction = (docDirection === "next") ? 1 : -1;
- var currentObject = this.get("filteredDocuments").findBy('id', this.get("currentItem").get('id'));
- if ( currentObject !== 'undefined'){
- var index = this.get("filteredDocuments").indexOf(currentObject);
- if ( typeof(this.get("filteredDocuments").objectAt(index+direction)) !== 'undefined'){
- return this.set('currentId', this.get("filteredDocuments").objectAt(index+direction).id);
- }
+ setPageQueryparams: function(type) {
+ var page = this.get('page');
+ if(type === 'previous') {
+ page = page - 1;
+ } else if(type === 'next') {
+ page = page + 1;
}
- return this.set('currentId', this.get('filteredDocuments').get('firstObject').id);
+ this.propertyWillChange('page');
+ this.set('page', page);
+ this.propertyDidChange('page');
},
+
play: function(item){
this.set("currentId", item.id);
}
--- a/cms/app-client/app/controllers/tabs/chrono.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/controllers/tabs/chrono.js Tue Nov 08 01:22:56 2016 +0100
@@ -1,4 +1,5 @@
import Ember from 'ember';
export default Ember.Controller.extend({
+
});
--- a/cms/app-client/app/routes/application.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/routes/application.js Tue Nov 08 01:22:56 2016 +0100
@@ -1,36 +1,23 @@
import Ember from 'ember';
import _ from 'lodash/lodash';
+import RSVP from 'rsvp';
+import ENV from 'app-client/config/environment';
+import URI from 'urijs';
export default Ember.Route.extend({
filter: Ember.inject.service(),
- page: 1,
- limit: 10,
+ constants: Ember.inject.service(),
- documents: [],
- model: Ember.observer('page', function() {
- var self = this;
- var promise = this.store.query('document', {
- page: this.get('page'),
- perpage: this.get('limit')
- });
- promise.then(function(value) {
- if(self.controller) {
- self.controller.set('page', self.get('page'));
- self.controller.set('documents', self.get('documents'));
- }
- self.set('documents', value);
- });
+ model: Ember.observer('page', function(params) {
+ var filterQueryArgs = _.clone(this.get('filter').get('queryParamsValues'));
+ var promise = this.store.query('document', _.merge(filterQueryArgs, {
+ page: params['page'],
+ perpage: this.get('constants').DOCUMENTS_PAGINATION_PERPAGE
+ }));
return promise;
}),
- setupController: function(controller) {
- this._super(...arguments);
- controller.set('page', this.get('page'));
- controller.set('limit', this.get('limit'));
- controller.set('documents', this.get('documents'));
- },
-
/**
Serializes value of the query parameter based on defaultValueType
@method serializeQueryParam
@@ -61,33 +48,51 @@
return this._super(value, urlKey, defaultValueType);
},
+ beforeModel: function(transition) {
+ new RSVP.Promise((resolve) => {
+ // succeed
+ this.get('filter').setProperties(transition['queryParams']);
+ resolve();
+ });
+ return this._super(...arguments);
+ },
+
+ queryParams: Ember.computed('filter', function() {
+ var res = this.get('filter').getRouteQueryParams();
+ res['page'] = { refreshModel: true };
+ res['notice'] = { refreshModel: false };
+ return res;
+ }),
actions: {
- setPageQueryparams: function(type) {
- var page = this.get('page');
- if(type === 'previous') {
- page = page - 1;
- } else if(type === 'next') {
- page = page + 1;
- }
- this.propertyWillChange('page');
- this.set('page', page);
- this.propertyDidChange('page');
- },
-
-
- willTransition: function() {
- // Prevent navigation from removing query parameters
- this.transitionTo({ queryParams: this.controller.get('queryParams') });
- },
-
didTransition: function() {
// Append body classname depending on the route
Ember.$('body').removeClass((this.controller.get('currentPath') || '').replace(/\//g, '-').dasherize());
Ember.run.once(this, function() {
Ember.$('body').addClass((this.controller.get('currentPath') ||'').replace(/\//g, '-').dasherize());
});
+ // change external navigations links
+ if(ENV.APP.navigationLinksSelector) {
+ return new RSVP.Promise((resolve) => {
+ setTimeout(() => {
+ let hash = window.location.hash;
+ if(!hash) {
+ return true;
+ }
+ let uriHash = URI(hash.substr(1));
+ Ember.$(ENV.APP.navigationLinksSelector).each((i, l) => {
+ let uri = URI(Ember.$(l).prop('href'));
+ if(uri.fragment()) {
+ let urifragment = URI(uri.fragment()).search(uriHash.search());
+ Ember.$(l).prop('href', uri.fragment(urifragment.href()).href());
+ }
+ });
+ resolve(true);
+ }, 10);
+ });
+ }
+ return true;
}
}
--- a/cms/app-client/app/routes/tabs/carto.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/routes/tabs/carto.js Tue Nov 08 01:22:56 2016 +0100
@@ -1,9 +1,11 @@
import Ember from 'ember';
+import _ from 'lodash/lodash';
export default Ember.Route.extend({
constants: Ember.inject.service(),
player: Ember.inject.service(),
+ filter: Ember.inject.service(),
modelQueryParam: '',
@@ -14,10 +16,11 @@
},
model: function() {
- return this.store.query('geostat', {
+ var filterQueryParams = _.clone(this.get('filter').get('queryParamsValues'));
+ return this.store.query('geostat', _.merge(filterQueryParams, {
'area': this.get('modelQueryParam'),
'details': 1
- });
+ }));
},
activate: function() {
--- a/cms/app-client/app/routes/tabs/chrono.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/routes/tabs/chrono.js Tue Nov 08 01:22:56 2016 +0100
@@ -3,12 +3,14 @@
export default Ember.Route.extend({
- player: Ember.inject.service(),
+ player: Ember.inject.service(),
+ filter: Ember.inject.service(),
model: function() {
+ console.log('model chrono', this.get('filter').get('queryParamsValues'));
return RSVP.hash({
- range: [1948, 2015],
- datestats: this.get('store').findAll('datestat')
+ range: [1948, 2015], // TODO: make it dynamic
+ datestats: this.get('store').query('datestat', this.get('filter').get('queryParamsValues'))
});
},
--- a/cms/app-client/app/routes/tabs/discours.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/routes/tabs/discours.js Tue Nov 08 01:22:56 2016 +0100
@@ -2,10 +2,10 @@
export default Ember.Route.extend({
- player: Ember.inject.service(),
-
- activate: function() {
+ player: Ember.inject.service(),
+
+ activate: function() {
this.get('player').set('window', false);
}
-});
\ No newline at end of file
+});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/routes/tabs/language.js Tue Nov 08 01:22:56 2016 +0100
@@ -0,0 +1,11 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+
+ player: Ember.inject.service(),
+
+ activate: function() {
+ this.get('player').set('window', false);
+ }
+
+});
--- a/cms/app-client/app/routes/tabs/thematiques.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/routes/tabs/thematiques.js Tue Nov 08 01:22:56 2016 +0100
@@ -1,8 +1,10 @@
import Ember from 'ember';
+import _ from 'lodash/lodash';
export default Ember.Route.extend({
player: Ember.inject.service(),
+ filter: Ember.inject.service(),
index: 0,
limit: 40,
@@ -12,11 +14,12 @@
model: Ember.observer('index', function() {
var self = this;
- var promise = this.store.query('theme', {
+ var filterQueryParams = _.clone(this.get('filter').get('queryParamsValues'));
+ var promise = this.store.query('theme', _.merge(filterQueryParams, {
'limit': this.get('limit'),
'index': this.get('index'),
'sort': this.get('sort')
- });
+ }));
promise.then(function(value) {
if (self.get('themes').length) {
value = self.get('themes').pushObjects(value.get('content'));
@@ -57,7 +60,7 @@
this.set('index', 0);
}
}
-
+
}
});
--- a/cms/app-client/app/services/colors.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/services/colors.js Tue Nov 08 01:22:56 2016 +0100
@@ -9,12 +9,12 @@
return s(v).hex();
}
-export function shade(d) {
+export function shade(v, vmin, vmax) {
var aColor = chroma(LINEAR_COLOR_START).rgb();
var aSolidColor = chroma(LINEAR_COLOR_END).rgb();
var aFillColor = [];
for(var i = 0; i < 3; i++) {
- aFillColor.push((d.count - dMin) * (aSolidColor[i] - aColor[i]) / (dMax - dMin) + aColor[i]);
+ aFillColor.push((v - vmin) * (aSolidColor[i] - aColor[i]) / (vmax - vmin) + aColor[i]);
}
return chroma.rgb(aFillColor).hex();
}
--- a/cms/app-client/app/services/constants.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/services/constants.js Tue Nov 08 01:22:56 2016 +0100
@@ -1,5 +1,8 @@
import Ember from 'ember';
+
+const DOCUMENTS_PAGINATION_PERPAGE = 10;
+
const GEONAMES = {
'world': '6295630',
'france': '3017382'
@@ -319,5 +322,6 @@
KEY_CODES: KEY_CODES,
VIAF_BASE_URL: "http://viaf.org/viaf/",
LEXVO_BASE_URL: "http://lexvo.org/id/iso639-3/",
- LANGUAGES_TREEMAP: LANGUAGES_TREEMAP
+ LANGUAGES_TREEMAP: LANGUAGES_TREEMAP,
+ DOCUMENTS_PAGINATION_PERPAGE : DOCUMENTS_PAGINATION_PERPAGE
});
--- a/cms/app-client/app/services/filter.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/services/filter.js Tue Nov 08 01:22:56 2016 +0100
@@ -13,8 +13,39 @@
queryParams: FILTER_QUERY_PARAMS,
+ getRouteQueryParams: function(exclude) {
+ return _.reduce(FILTER_QUERY_PARAMS, function(res, f) {
+ if(f !== exclude) {
+ res[f] = {
+ refreshModel: true
+ };
+ }
+ return res;
+ }, {});
+ },
+
+ getControllerQueryParams: function(exclude) {
+ return _.filter(FILTER_QUERY_PARAMS, function(f) { return f !== exclude; });
+ },
+
queryParamsValues: Ember.computed('date', 'discourse', 'language', 'location', 'theme', function() {
- return this.getProperties(FILTER_QUERY_PARAMS);
+ return _.reduce(this.getProperties(FILTER_QUERY_PARAMS), function(res, v, k) {
+ if(v) {
+ res[k] = v;
+ }
+ return res;
+ }, {});
+ }),
+ queryParamsValuesURI: Ember.computed('date', 'discourse', 'language', 'location', 'theme', function() {
+ return _.reduce(this.getProperties(FILTER_QUERY_PARAMS), function(res, v, k) {
+ if(v) {
+ if(k === "date" || k === "discourse" || k === "theme" ) {
+ k = k + "[]";
+ }
+ res[k] = v;
+ }
+ return res;
+ }, {});
}),
removeFilter: function(filter, value) {
switch(filter) {
--- a/cms/app-client/app/templates/application.hbs Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/app/templates/application.hbs Tue Nov 08 01:22:56 2016 +0100
@@ -1,4 +1,4 @@
-{{player-component action="changeDocument" document=currentItem}}
+{{player-component document=currentItem}}
<div class="corpus-window">
@@ -19,7 +19,7 @@
<div class="corpus-app-wrapper">
{{ filter-component }}
- {{ playlist-component model=documents page=page limit=limit pageAction='setPageQueryparams' }}
+ {{ playlist-component model=model page=page limit=limit pageAction='setPageQueryparams' }}
</div>
</div>
\ No newline at end of file
--- a/cms/app-client/bower.json Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/bower.json Tue Nov 08 01:22:56 2016 +0100
@@ -14,6 +14,7 @@
"Faker": "~3.1.0",
"store": "https://github.com/marcuswestin/store.js.git#v1.3.20",
"popcorn-js": "popcornjs#^1.5.11",
- "chroma-js": "gka/chroma.js#master"
+ "chroma-js": "gka/chroma.js#master",
+ "urijs": "^1.18.2"
}
}
--- a/cms/app-client/config/environment.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/config/environment.js Tue Nov 08 01:22:56 2016 +0100
@@ -15,6 +15,7 @@
},
APP: {
backRootURL: '/corpus/',
+ navigationLinksSelector: '.sub-menu > a',
// Here you can pass flags/options to your application instance
// when it is created
}
--- a/cms/app-client/ember-cli-build.js Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/app-client/ember-cli-build.js Tue Nov 08 01:22:56 2016 +0100
@@ -33,6 +33,10 @@
app.import('vendor/data/maps/worldLow.js');
app.import('vendor/data/maps/continentsLow.js');
app.import('vendor/data/maps/france2016Low.js');
+ app.import({
+ development: 'bower_components/urijs/src/URI.js',
+ production: 'bower_components/urijs/src/URI.min.js'
+ });
//shims
app.import('vendor/shims/ammaps.js', {
@@ -50,7 +54,11 @@
'chroma': ['defaults']
}
});
-
+ app.import('vendor/shims/urijs.js', {
+ exports: {
+ 'urijs': [ 'default' ]
+ }
+ });
return app.toTree();
};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/vendor/shims/urijs.js Tue Nov 08 01:22:56 2016 +0100
@@ -0,0 +1,9 @@
+(function() {
+ function vendorModule() {
+ 'use strict';
+
+ return { 'default': self['URI'] };
+ }
+
+ define('urijs', [], vendorModule);
+})();
--- a/cms/corpus_module/corpus.module.tmpl Sun Nov 06 03:44:16 2016 +0100
+++ b/cms/corpus_module/corpus.module.tmpl Tue Nov 08 01:22:56 2016 +0100
@@ -117,6 +117,7 @@
),
"APP" => array(
"backRootURL" => "/".CORPUS_BACK_URL."/",
+ "navigationLinksSelector" => ".corpus-app-sub-menu",
"name" => "app-client",
"version" => CORPUS_APP_VERSION
),
--- a/common/corpus-common-addon/addon/components/doc-language.js Sun Nov 06 03:44:16 2016 +0100
+++ b/common/corpus-common-addon/addon/components/doc-language.js Tue Nov 08 01:22:56 2016 +0100
@@ -10,7 +10,9 @@
_resolveLexvoIds: Ember.on('init', Ember.observer('url', function() {
this.get('lexvoResolver').getName(this.get('url')).then(function(str) {
+ if (!(this.get('isDestroyed') || this.get('isDestroying'))) {
this.set('resolvedName', str);
+ }
}.bind(this));
})),
--- a/common/corpus-common-addon/addon/components/doc-location.js Sun Nov 06 03:44:16 2016 +0100
+++ b/common/corpus-common-addon/addon/components/doc-location.js Tue Nov 08 01:22:56 2016 +0100
@@ -11,7 +11,9 @@
_resolveGeonamesIds: Ember.on('init', Ember.observer('url', function () {
this.get('geonamesResolver').getLabel(this.get('url'))
.then(function (str) {
- this.set('resolvedLabel', str);
+ if (!(this.get('isDestroyed') || this.get('isDestroying'))) {
+ this.set('resolvedLabel', str);
+ }
}.bind(this));
})),
--- a/common/corpus-common-addon/addon/components/doc-subject.js Sun Nov 06 03:44:16 2016 +0100
+++ b/common/corpus-common-addon/addon/components/doc-subject.js Tue Nov 08 01:22:56 2016 +0100
@@ -10,7 +10,9 @@
_resolveBnfIds: Ember.on('init', Ember.observer('url', function() {
this.get('bnfResolver').getLabel(this.get('url')).then(function(str) {
+ if (!(this.get('isDestroyed') || this.get('isDestroying'))) {
this.set('resolvedLabel', str);
+ }
}.bind(this));
})),