diff options
Diffstat (limited to 'pyload/web')
-rw-r--r-- | pyload/web/app/scripts/models/Package.js | 20 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/dashboard/dashboardView.js | 11 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/dashboard/packageView.js | 5 | ||||
-rw-r--r-- | pyload/web/app/styles/default/dashboard.less | 4 | ||||
-rw-r--r-- | pyload/web/app/templates/default/dashboard/package.html | 8 | ||||
-rw-r--r-- | pyload/web/cnl_app.py | 27 |
6 files changed, 57 insertions, 18 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( diff --git a/pyload/web/app/scripts/views/dashboard/dashboardView.js b/pyload/web/app/scripts/views/dashboard/dashboardView.js index d98e28fe3..6a263bf03 100644 --- a/pyload/web/app/scripts/views/dashboard/dashboardView.js +++ b/pyload/web/app/scripts/views/dashboard/dashboardView.js @@ -28,10 +28,8 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', 'col var self = this; // When package is added we reload the data - this.listenTo(App.vent, 'package:added', function() { - console.log('Package tree caught, package:added event'); - self.tree.fetch(); - }); + this.listenTo(App.vent, 'package:added', _.bind(this.fetch, this)); + this.listenTo(App.vent, 'package:inserted', _.bind(this.fetch, this)); this.listenTo(App.vent, 'file:updated', _.bind(this.fileUpdated, this)); @@ -59,6 +57,11 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', 'col this.$('.input').select2({tags: ['a', 'b', 'sdf']}); }, + fetch: function() { + console.log('Fetching package tree'); + this.tree.fetch(); + }, + update: function() { console.log('Update package list'); diff --git a/pyload/web/app/scripts/views/dashboard/packageView.js b/pyload/web/app/scripts/views/dashboard/packageView.js index 1bb250f27..243ebac9b 100644 --- a/pyload/web/app/scripts/views/dashboard/packageView.js +++ b/pyload/web/app/scripts/views/dashboard/packageView.js @@ -11,6 +11,7 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashb events: { 'click .package-name, .btn-open': 'open', 'click .icon-refresh': 'restart', + 'click .toggle-paused': 'pause', 'click .select': 'select', 'click .icon-chevron-down': 'loadMenu', 'click .btn-delete': 'deleteItem', @@ -68,6 +69,10 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore', 'hbs!tpl/dashb App.dashboard.openPackage(this.model); }, + pause: function(e) { + this.model.togglePaused(); + }, + select: function(e) { e.preventDefault(); var checked = this.$('.select').hasClass('icon-check'); diff --git a/pyload/web/app/styles/default/dashboard.less b/pyload/web/app/styles/default/dashboard.less index 336070737..1e9f21fec 100644 --- a/pyload/web/app/styles/default/dashboard.less +++ b/pyload/web/app/styles/default/dashboard.less @@ -85,6 +85,10 @@ .package-frame { background-color: @light; + &.paused { + .stripes(fade(@yellowLightest, 90%), @light); + } + } } diff --git a/pyload/web/app/templates/default/dashboard/package.html b/pyload/web/app/templates/default/dashboard/package.html index cde0dda6e..bc8314494 100644 --- a/pyload/web/app/templates/default/dashboard/package.html +++ b/pyload/web/app/templates/default/dashboard/package.html @@ -7,14 +7,18 @@ {{ name }} </span> - <div class="package-frame"> + <div class="package-frame{{#if paused}} paused{{/if}}"> <div class="tag-area"> <!--<span class="badge badge-success"><i class="icon-tag"></i>video</span>--> <!--<span class="badge badge-success badge-ghost"><i class="icon-tag"></i> Add Tag</span>--> </div> <div class="package-indicator"> <i class="icon-plus-sign btn-move" data-toggle="tooltip" title="Move files here"></i> - <i class="icon-pause" data-toggle="tooltip" title="Pause Package"></i> + {{#if paused}} + <i class="icon-play toggle-paused" data-toggle="tooltip" title="Unpause Package"></i> + {{else}} + <i class="icon-pause toggle-paused" data-toggle="tooltip" title="Pause Package"></i> + {{/if}} <i class="icon-refresh" data-toggle="tooltip" title="Restart Package"></i> {{#if shared }} <i class="icon-eye-open" data-toggle="tooltip" title="Package is public"></i> diff --git a/pyload/web/cnl_app.py b/pyload/web/cnl_app.py index d8311d90f..a3917b052 100644 --- a/pyload/web/cnl_app.py +++ b/pyload/web/cnl_app.py @@ -5,6 +5,7 @@ import re from urllib import unquote from base64 import standard_b64decode from binascii import unhexlify +from traceback import print_exc from pyload.utils.fs import safe_filename @@ -16,6 +17,10 @@ try: except: pass +def generate_and_add(urls, paused): + packs = PYLOAD.generatePackages(urls) + for name, urls in packs.iteritems(): + PYLOAD.addPackage(name, urls, paused=paused) def local_check(function): def _view(*args, **kwargs): @@ -42,9 +47,9 @@ def add(request): urls = filter(lambda x: x != "", request.POST['urls'].split("\n")) if package: - PYLOAD.addPackage(package, urls, 0) + PYLOAD.addPackage(package, urls, paused=True) else: - PYLOAD.generateAndAddPackages(urls, 0) + generate_and_add(urls, True) return "" @@ -61,7 +66,7 @@ def addcrypted(): dlc_file.close() try: - PYLOAD.addPackage(package, [dlc_path], 0) + PYLOAD.addPackage(package, [dlc_path], paused=True) except: return HTTPError() else: @@ -108,11 +113,12 @@ def addcrypted2(): try: if package: - PYLOAD.addPackage(package, result, 0) + PYLOAD.addPackage(package, result, paused=True) else: - PYLOAD.generateAndAddPackages(result, 0) + generate_and_add(result, True) except: - return "failed can't add" + print_exc() + return "failed" else: return "success\r\n" @@ -125,16 +131,17 @@ def flashgot(): if request.environ['HTTP_REFERER'] != "http://localhost:9666/flashgot" and request.environ['HTTP_REFERER'] != "http://127.0.0.1:9666/flashgot": return HTTPError() - autostart = int(request.forms.get('autostart', 0)) + autostart = bool(int(request.forms.get('autostart', 0))) package = request.forms.get('package', None) urls = filter(lambda x: x != "", request.forms['urls'].split("\n")) + + # TODO: folder? folder = request.forms.get('dir', None) if package: - PYLOAD.addPackage(package, urls, autostart) + PYLOAD.addPackage(package, urls, paused=autostart) else: - PYLOAD.generateAndAddPackages(urls, autostart) - + generate_and_add(urls, autostart) return "" @route("/crossdomain.xml") |