Add CSV download for compare (change backing service, too)
This commit is contained in:
parent
7c194447f7
commit
da4ebc9b29
3 changed files with 34 additions and 32 deletions
|
@ -1,4 +1,5 @@
|
|||
import Ember from 'ember';
|
||||
import ajaxRequest from '../../../../utils/ajax-request';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
queryParams: {
|
||||
|
@ -12,16 +13,35 @@ export default Ember.Route.extend({
|
|||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
if (Ember.$.isEmptyObject(transition.queryParams)) {
|
||||
if (Ember.$.isEmptyObject(transition.queryParams.strain_ids) ||
|
||||
Ember.$.isEmptyObject(transition.queryParams.characteristic_ids)) {
|
||||
this.transitionTo('protected.compare');
|
||||
}
|
||||
},
|
||||
|
||||
model: function(params) {
|
||||
if (params.strain_ids === '' || params.characteristic_ids === '') {
|
||||
this.transitionTo('protected.compare');
|
||||
}
|
||||
|
||||
let compare = this.controllerFor('protected.compare');
|
||||
compare.set('selectedStrains', params.strain_ids);
|
||||
compare.set('selectedCharacteristics', params.characteristic_ids);
|
||||
return this.store.query('measurement', params);
|
||||
|
||||
let url = `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/compare`;
|
||||
let options = {
|
||||
method: 'GET',
|
||||
data: params,
|
||||
};
|
||||
return ajaxRequest(url, options);
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
model.forEach((m, i) => {
|
||||
let c = this.store.peekRecord('characteristic', m[0]);
|
||||
model[i][0] = c.get('characteristicName');
|
||||
});
|
||||
controller.set('model', model);
|
||||
},
|
||||
|
||||
});
|
||||
|
|
Reference in a new issue