From 453c1e55c71a96c9529ecdca1d55278cc41088d6 Mon Sep 17 00:00:00 2001 From: RaNaN <Mast3rRaNaN@hotmail.de> Date: Sat, 18 Jan 2014 18:45:13 +0100 Subject: rewritten download scheduling, improved account manager, db version increased all data will be overwritten --- pyload/web/app/scripts/models/Account.js | 8 +++-- pyload/web/app/scripts/models/ServerStatus.js | 47 -------------------------- pyload/web/app/scripts/models/StatusInfo.js | 48 +++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 50 deletions(-) delete mode 100644 pyload/web/app/scripts/models/ServerStatus.js create mode 100644 pyload/web/app/scripts/models/StatusInfo.js (limited to 'pyload/web/app/scripts/models') diff --git a/pyload/web/app/scripts/models/Account.js b/pyload/web/app/scripts/models/Account.js index 26241d8e3..b9fc40036 100644 --- a/pyload/web/app/scripts/models/Account.js +++ b/pyload/web/app/scripts/models/Account.js @@ -3,9 +3,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', './ConfigIt return Backbone.Model.extend({ - idAttribute: 'loginname', + idAttribute: 'aid', defaults: { + aid: null, plugin: null, loginname: null, owner: -1, @@ -53,14 +54,15 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', './ConfigIt var refresh = _.has(options, 'refresh') && options.refresh; options = App.apiRequest('getAccountInfo', {plugin: this.get('plugin'), - loginname: this.get('loginname'), refresh: refresh}, options); + aid: this.get('aid'), 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); + {aid: this.get('aid'), + plugin: this.get('plugin'), loginname: this.get('loginname'), password: password}, options); return $.ajax(options); }, diff --git a/pyload/web/app/scripts/models/ServerStatus.js b/pyload/web/app/scripts/models/ServerStatus.js deleted file mode 100644 index 59739b41e..000000000 --- a/pyload/web/app/scripts/models/ServerStatus.js +++ /dev/null @@ -1,47 +0,0 @@ -define(['jquery', 'backbone', 'underscore'], - function($, Backbone, _) { - 'use strict'; - - return Backbone.Model.extend({ - - defaults: { - speed: 0, - linkstotal: 0, - linksqueue: 0, - sizetotal: 0, - sizequeue: 0, - notifications: -1, - paused: false, - download: false, - reconnect: false - }, - - // Model Constructor - initialize: function() { - - }, - - fetch: function(options) { - options || (options = {}); - options.url = 'api/getServerStatus'; - - return Backbone.Model.prototype.fetch.call(this, options); - }, - - toJSON: function(options) { - var obj = Backbone.Model.prototype.toJSON.call(this, options); - - obj.linksdone = obj.linkstotal - obj.linksqueue; - obj.sizedone = obj.sizetotal - obj.sizequeue; - if (obj.speed && obj.speed > 0) - obj.eta = Math.round(obj.sizequeue / obj.speed); - else if (obj.sizequeue > 0) - obj.eta = Infinity; - else - obj.eta = 0; - - return obj; - } - - }); - }); \ No newline at end of file diff --git a/pyload/web/app/scripts/models/StatusInfo.js b/pyload/web/app/scripts/models/StatusInfo.js new file mode 100644 index 000000000..8712defa7 --- /dev/null +++ b/pyload/web/app/scripts/models/StatusInfo.js @@ -0,0 +1,48 @@ +define(['jquery', 'backbone', 'underscore'], + function($, Backbone, _) { + 'use strict'; + + return Backbone.Model.extend({ + + defaults: { + speed: 0, + linkstotal: 0, + linksqueue: 0, + sizetotal: 0, + sizequeue: 0, + notifications: -1, + paused: false, + download: false, + reconnect: false, + quota: -1 + }, + + // Model Constructor + initialize: function() { + + }, + + fetch: function(options) { + options || (options = {}); + options.url = 'api/getStatusInfo'; + + return Backbone.Model.prototype.fetch.call(this, options); + }, + + toJSON: function(options) { + var obj = Backbone.Model.prototype.toJSON.call(this, options); + + obj.linksdone = obj.linkstotal - obj.linksqueue; + obj.sizedone = obj.sizetotal - obj.sizequeue; + if (obj.speed && obj.speed > 0) + obj.eta = Math.round(obj.sizequeue / obj.speed); + else if (obj.sizequeue > 0) + obj.eta = Infinity; + else + obj.eta = 0; + + return obj; + } + + }); + }); \ No newline at end of file -- cgit v1.2.3