json:get_webui_templates

This commit is contained in:
Martijn Voncken 2008-07-25 17:29:10 +00:00
parent 4cc5ccd0b8
commit e84e090c8e
2 changed files with 20 additions and 4 deletions

View File

@ -46,11 +46,13 @@ from web import webapi
import page_decorators as deco
from web import cookies, setcookie as w_setcookie
import utils
from render import render
from utils import dict_cb
from lib import json
from deluge.ui.client import sclient,aclient
from deluge.log import LOG as log
from deluge import component
from utils import dict_cb
from lib import json
def json_response(result, id):
print json.write({
@ -80,13 +82,12 @@ class json_rpc:
"""
#extra exposed methods
json_exposed = ["update_ui","get_stats","set_torrent_options","system_listMethods",
"get_webui_config","set_webui_config"]
"get_webui_config","set_webui_config","get_webui_templates"]
cache = {}
torrent_options = ["trackers","max_connections","max_upload_slots","max_upload_speed",
"max_download_speed","file_priorities","prioritize_first_last","auto_managed","stop_at_ratio",
"stop_ratio","remove_at_ratio"]
def GET(self):
return json_error("only POST is supported")
@ -245,6 +246,10 @@ class json_rpc:
utils.config.save()
utils.apply_config()
def get_webui_templates(self):
return render.get_templates()
def register():
component.get("PageManager").register_page("/json/rpc",json_rpc)

View File

@ -109,6 +109,16 @@ function set_webui_config(cfg_dict) {
});
};
function get_webui_templates() {
service.get_webui_templates({params:[ ],
onSuccess:function(data){
alert(service.__toJSON(data));
},
onException:function(errorObj){
alert("Error: " + errorObj);
}
});
};
</script>
@ -131,6 +141,7 @@ function set_webui_config(cfg_dict) {
<button onclick="set_webui_config({'button_style':1})">set_webui_config({'button_style':1})</button>
<button onclick="set_webui_config({'button_style':2})">set_webui_config({'button_style':2})</button>
<button onclick="get_webui_config()">get_webui_config()</button>
<button onclick="get_webui_templates()">get_webui_templates()</button>