summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/models/Package.js
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web/app/scripts/models/Package.js')
-rw-r--r--pyload/web/app/scripts/models/Package.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/pyload/web/app/scripts/models/Package.js b/pyload/web/app/scripts/models/Package.js
index a34ec1c69..555d5b7d6 100644
--- a/pyload/web/app/scripts/models/Package.js
+++ b/pyload/web/app/scripts/models/Package.js
@@ -1,5 +1,5 @@
-define(['jquery', 'backbone', 'underscore', 'app', 'collections/FileList', 'require'],
- function($, Backbone, _, App, FileList, require) {
+define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collections/FileList', 'require'],
+ function($, Backbone, _, App, Api, FileList, require) {
'use strict';
return Backbone.Model.extend({
@@ -36,6 +36,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/FileList', 'requ
toJSON: function(options) {
var obj = Backbone.Model.prototype.toJSON.call(this, options);
obj.percent = Math.round(obj.stats.linksdone * 100 / obj.stats.linkstotal);
+ obj.paused = obj.status === Api.PackageStatus.Paused;
return obj;
},
@@ -64,6 +65,21 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/FileList', 'requ
// TODO
},
+ togglePaused: function() {
+ var self = this;
+ var paused = this.get('status') === Api.PackageStatus.Paused;
+
+ $.ajax(App.apiRequest('setPackagePaused', {
+ pid: this.get('pid'),
+ paused: !paused
+ }, {
+ success: function(data) {
+ console.log('New package status', data);
+ self.set('status', data);
+ }
+ }));
+ },
+
destroy: function(options) {
// TODO: Not working when using data?, array seems to break it
options = App.apiRequest(