diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-08-11 20:36:10 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-08-11 20:36:10 +0200 |
commit | 080643e89af62013d70bb574cd54cf4876628515 (patch) | |
tree | e79e3bebe9175da613c4a339fc4ac3fa172ecced /pyload/web/app/scripts/models/Account.js | |
parent | another try to fix broken accounts (diff) | |
download | pyload-080643e89af62013d70bb574cd54cf4876628515.tar.xz |
improved account list
Diffstat (limited to 'pyload/web/app/scripts/models/Account.js')
-rw-r--r-- | pyload/web/app/scripts/models/Account.js | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/pyload/web/app/scripts/models/Account.js b/pyload/web/app/scripts/models/Account.js index 9cfc1c0c1..e2cc4f9ec 100644 --- a/pyload/web/app/scripts/models/Account.js +++ b/pyload/web/app/scripts/models/Account.js @@ -5,7 +5,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], function($ // TODO // generated, not submitted - idAttribute: 'user', + idAttribute: 'loginname', defaults: { plugin: null, @@ -30,8 +30,31 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], function($ }, - save: function(options) { - options = App.apiRequest('updateAccountInfo', {account: this.toJSON()}, options); + fetch: function(options) { + var refresh = _.has(options, 'refresh') && options.refresh; + options = App.apiRequest('getAccountInfo', + {plugin: this.get('plugin'), + loginname: this.get('loginname'), refresh: refresh}, options); + + return Backbone.Model.prototype.fetch.call(this, options); + }, + + setPassword: function(password, options) { + options = App.apiRequest('updateAccount', + {plugin: this.get('plugin'), loginname: this.get('loginname'), password: password}, options); + + return $.ajax(options); + }, + + save: function() { + // On success wait 1sec and trigger event to reload info + var options = App.apiRequest('updateAccountInfo', {account: this.toJSON()}, { + success: function() { + _.delay(function() { + App.vent.trigger('accounts:updated'); + }, 1000); + } + }); return $.ajax(options); }, |