From a649d73a1bd2a9b45eb35d535d40e2454238417c Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 3 Dec 2009 18:10:48 +0100 Subject: little webinterface fixes --- module/web/WebServer.py | 13 ++++++++++++- module/web/static/default/status.js | 4 ++-- module/web/templates/default.tpl | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'module/web') diff --git a/module/web/WebServer.py b/module/web/WebServer.py index 29b0aafe8..3486bf7cb 100644 --- a/module/web/WebServer.py +++ b/module/web/WebServer.py @@ -184,7 +184,7 @@ def queue(): username = request.COOKIES.get('user') - return template('default', page='queue', links=core.get_links(), user=username, status=core_methods.status_server()) + return template('default', page='queue', links=core_methods.get_queue(), user=username, status=core_methods.status_server()) @route('/downloads') def downloads(): @@ -252,6 +252,17 @@ def get_status(): json = '{ "status": "%s", "speed": "%s", "queue": "%s" }' % (status, str(int(data['speed'])), str(data['queue'])) return json +@route('json/addpackage', method='POST') +def add_package(): + response.header['Cache-Control'] = 'no-cache, must-revalidate' + response.content_type = 'application/json' + + if not check_auth(request): + abort(404, "No Access") + + links = request.POST['links'].split('\n') + name = request.POST['name'] + core_methods.add_package(name, links) @route('/json/addlinks', method='POST') def add_links(): diff --git a/module/web/static/default/status.js b/module/web/static/default/status.js index 31a4e0032..3923e80ca 100644 --- a/module/web/static/default/status.js +++ b/module/web/static/default/status.js @@ -39,11 +39,11 @@ window.addEvent('domready', function(){ new Request({ method: 'post', - url: '/json/addlinks', + url: '/json/addpackage', onSuccess: function(){ document.id('linkarea').value = "" } - }).send('links='+document.id('linkarea').value) + }).send('links='+document.id('linkarea').value+"&name="+document.id('pname').value) }) diff --git a/module/web/templates/default.tpl b/module/web/templates/default.tpl index 13be260b6..3f5e8d8e8 100644 --- a/module/web/templates/default.tpl +++ b/module/web/templates/default.tpl @@ -11,7 +11,7 @@ %include header title=header, use_js=js, use_css=['default.css','window.css'], redirect=red -%include window id="addlinks", width=400, caption="Add links", body="", button="Add" +%include window id="addlinks", width=400, caption="Add links", body="", button="Add" @@ -199,9 +199,9 @@ this.morph({'color': '#000'});