From 8d842efb12ee7db88505e3078b626855e55aa4bf Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 17 Jan 2010 18:31:52 +0100 Subject: some fixes, closed #62 ?? --- module/web/ajax/urls.py | 1 + module/web/ajax/views.py | 8 +++++++- module/web/templates/default/base.html | 26 ++++++++++++++++++++------ module/web/templates/default/queue.html | 13 +++++++++++++ 4 files changed, 41 insertions(+), 7 deletions(-) (limited to 'module/web') diff --git a/module/web/ajax/urls.py b/module/web/ajax/urls.py index 4decc27b1..7d63ef5a6 100644 --- a/module/web/ajax/urls.py +++ b/module/web/ajax/urls.py @@ -18,6 +18,7 @@ urlpatterns = patterns('ajax', (r'^queue$', 'views.queue'), (r'^pause$', 'views.pause'), (r'^unpause$', 'views.unpause'), + (r'^cancel$', 'views.cancel'), (r'^packages$', 'views.packages'), (r'^package/(\d+)$', 'views.package'), (r'^link/(\d+)$', 'views.link'), diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py index ea092745f..4f136cef9 100644 --- a/module/web/ajax/views.py +++ b/module/web/ajax/views.py @@ -30,7 +30,7 @@ class JsonResponse(HttpResponse): object, indent=2, cls=json.DjangoJSONEncoder, ensure_ascii=False) super(JsonResponse, self).__init__( - content, content_type='application/json') #@TODO uncomment + content)#, content_type='application/json') #@TODO uncomment self['Cache-Control'] = 'no-cache, must-revalidate' @@ -117,6 +117,12 @@ def unpause(request): return HttpResponseServerError() +@permission('pyload.can_change_status') +def cancel(request): + try: + return JsonResponse(settings.PYLOAD.stop_downloads()) + except: + return HttpResponseServerError() @permission('pyload.can_see_dl') def packages(request): diff --git a/module/web/templates/default/base.html b/module/web/templates/default/base.html index 0cebeb5d8..692a951bc 100644 --- a/module/web/templates/default/base.html +++ b/module/web/templates/default/base.html @@ -45,6 +45,20 @@ document.addEvent("domready", function(){ limit: 30000 }) + $('action_play').addEvent('click', function(){ + new Request({method: 'get', url: 'json/unpause'}).send(); + }); + + + $('action_cancel').addEvent('click', function(){ + new Request({method: 'get', url: 'json/cancel'}).send(); + }); + + + $('action_stop').addEvent('click', function(){ + new Request({method: 'get', url: 'json/pause'}).send(); + }); + jsonStatus.startTimer(); }); @@ -58,8 +72,8 @@ document.addEvent("domready", function(){ function LoadJsonToContent(data) { $("speed").set('text', Math.round(data.speed*100)/100); - $("aktiv").set('text', data.queue); - $("queue").set('text', data.total); + $("aktiv").set('text', data.activ); + $("aktiv_from").set('text', data.queue); } function show(){ add_bg.set('opacity', 0); @@ -147,9 +161,9 @@ function AddBox() {% if perms.pyload.can_change_status %} {% endif %} @@ -157,7 +171,7 @@ function AddBox() {% if perms.pyload.can_see_dl %}
{% endif %} diff --git a/module/web/templates/default/queue.html b/module/web/templates/default/queue.html index e9c1baa92..bc306730e 100644 --- a/module/web/templates/default/queue.html +++ b/module/web/templates/default/queue.html @@ -28,4 +28,17 @@ {% endfor %}