ember-ajax

Fixes #37
Fixes #38
This commit is contained in:
Matthew Dillon 2015-11-12 13:32:41 -07:00
parent e54c6fcb2f
commit b12ff0eb20
7 changed files with 34 additions and 51 deletions

View file

@ -1,10 +1,10 @@
import Ember from 'ember';
import ajaxRequest from '../../../../utils/ajax-request';
const { Route, $: { isEmptyObject }, inject: { service } } = Ember;
export default Route.extend({
session: service(),
ajax: service(),
queryParams: {
strain_ids: {
@ -33,12 +33,7 @@ export default Route.extend({
compare.set('selectedStrains', params.strain_ids);
compare.set('selectedCharacteristics', params.characteristic_ids);
const url = `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/compare`;
const options = {
method: 'GET',
data: params,
};
return ajaxRequest(url, options, this.get('session'));
return this.get('ajax').request('/compare', { data: params })
},
setupController: function(controller, model) {

View file

@ -1,24 +1,17 @@
import Ember from 'ember';
import ajaxRequest from '../../../../utils/ajax-request';
const { Controller, inject: { service } } = Ember;
export default Controller.extend({
session: service(),
ajax: service(),
currentUser: service('session-account'),
actions: {
save: function(password) {
const url = `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/users/password`;
const id = this.get('currentUser.account.id');
const options = {
method: 'POST',
data: {
id: id,
password: password,
},
};
ajaxRequest(url, options, this.get('session'));
const data = { id: id, password: password };
this.get('ajax').post('/users/password', { data: data });
this.transitionToRoute('protected.users.show', id);
this.get('flashMessages').information('Your password has been changed.');
},