Skip to content

Instantly share code, notes, and snippets.

@superlou
Last active January 1, 2016 04:19
Show Gist options
  • Save superlou/8091238 to your computer and use it in GitHub Desktop.
Save superlou/8091238 to your computer and use it in GitHub Desktop.
Resolving into ember from jQuery
{
"referral_link":"https://db.tt/2iEFmHsw",
"display_name":"Louis Simons",
"uid":23040725,
"country":"US",
"quota_info":{
"datastores":0,
"shared":31745173,
"quota":5100273664,
"normal":438654772
},
"email":"lousimons@gmail.com"
}
OurMemories.DropboxStore = DS.Model.extend({
token: DS.attr('string'),
user: DS.belongsTo('user'),
isAuthorized: function() {
if (this.get('token')) {
return true;
} else {
return false;
}
}.property('token'),
accountInfo: function() {
// todo Refactor this into https://github.com/instructure/ic-ajax
var account_info_url = '/dropbox_stores/' + this.id + '/account_info.json';
var requestPromise = new Ember.RSVP.Promise(function(resolve, reject) {
$.getJSON(account_info_url, resolve).fail(reject);
});
return requestPromise;
}.property('token')
});
OurMemories.DropboxStoreController = Ember.ObjectController.extend({
init: function() {
self = this;
this.store.find('dropboxStore').then(function(data) {
self.set('content', data.objectAt(0));
});
},
usedSpace: function() {
return this.get('accountInfo.quota_info.normal');
}.property('accountInfo'),
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment