summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/models/ServerStatus.js
diff options
context:
space:
mode:
Diffstat (limited to 'module/web/static/js/models/ServerStatus.js')
-rw-r--r--module/web/static/js/models/ServerStatus.js81
1 files changed, 40 insertions, 41 deletions
diff --git a/module/web/static/js/models/ServerStatus.js b/module/web/static/js/models/ServerStatus.js
index 2430a9ffd..9242bdf95 100644
--- a/module/web/static/js/models/ServerStatus.js
+++ b/module/web/static/js/models/ServerStatus.js
@@ -1,47 +1,46 @@
define(['jquery', 'backbone', 'underscore'],
function($, Backbone, _) {
- return Backbone.Model.extend({
+ 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.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;
- defaults: {
- speed: 0,
- files: null,
- notifications: -1,
- paused: false,
- download: false,
- reconnect: false
- },
-
- // Model Constructor
- initialize: function() {
-
- },
-
- fetch: function() {
- 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);
-
- // stats are not available
- if (obj.files === null)
return obj;
+ }
- obj.files.linksleft = obj.files.linkstotal - obj.files.linksdone;
- obj.files.sizeleft = obj.files.sizetotal - obj.files.sizedone;
- if (obj.speed && obj.speed > 0)
- obj.files.eta = Math.round(obj.files.sizeleft / obj.speed);
- else if (obj.files.sizeleft > 0)
- obj.files.eta = Infinity;
- else
- obj.files.eta = 0;
-
- return obj;
- }
-
- });
-}); \ No newline at end of file
+ });
+ }); \ No newline at end of file