mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-25 20:25:31 +00:00
json get/set webui_config
This commit is contained in:
parent
adc9902252
commit
0a362757a9
2 changed files with 46 additions and 3 deletions
|
@ -52,7 +52,6 @@ from deluge import component
|
||||||
from utils import dict_cb
|
from utils import dict_cb
|
||||||
from lib import json
|
from lib import json
|
||||||
|
|
||||||
|
|
||||||
def json_response(result, id):
|
def json_response(result, id):
|
||||||
print json.write({
|
print json.write({
|
||||||
"version":"1.1",
|
"version":"1.1",
|
||||||
|
@ -80,7 +79,8 @@ class json_rpc:
|
||||||
* methods : http://dev.deluge-torrent.org/wiki/Development/UiClient#Remoteapi
|
* methods : http://dev.deluge-torrent.org/wiki/Development/UiClient#Remoteapi
|
||||||
"""
|
"""
|
||||||
#extra exposed methods
|
#extra exposed methods
|
||||||
json_exposed = ["update_ui","get_stats","set_torrent_options","system_listMethods"]
|
json_exposed = ["update_ui","get_stats","set_torrent_options","system_listMethods",
|
||||||
|
"get_webui_config","set_webui_config"]
|
||||||
cache = {}
|
cache = {}
|
||||||
torrent_options = ["trackers","max_connections","max_upload_slots","max_upload_speed",
|
torrent_options = ["trackers","max_connections","max_upload_slots","max_upload_speed",
|
||||||
"max_download_speed","file_priorities","prioritize_first_last","auto_managed","stop_at_ratio",
|
"max_download_speed","file_priorities","prioritize_first_last","auto_managed","stop_at_ratio",
|
||||||
|
@ -90,7 +90,6 @@ class json_rpc:
|
||||||
def GET(self):
|
def GET(self):
|
||||||
return json_error("only POST is supported")
|
return json_error("only POST is supported")
|
||||||
|
|
||||||
|
|
||||||
def POST(self , name=None):
|
def POST(self , name=None):
|
||||||
web.header("Content-Type", "application/x-json")
|
web.header("Content-Type", "application/x-json")
|
||||||
ck = cookies()
|
ck = cookies()
|
||||||
|
@ -233,6 +232,20 @@ class json_rpc:
|
||||||
func = getattr(sclient, 'set_torrent_' + option)
|
func = getattr(sclient, 'set_torrent_' + option)
|
||||||
func(torrent_id, value)
|
func(torrent_id, value)
|
||||||
|
|
||||||
|
def get_webui_config(self):
|
||||||
|
return dict([x for x in utils.config.get_config().iteritems() if not x[0].startswith("pwd")])
|
||||||
|
|
||||||
|
def set_webui_config(self, data):
|
||||||
|
utils.validate_config(data)
|
||||||
|
if "pwd" in data:
|
||||||
|
utils.update_pwd(pwd)
|
||||||
|
del data["pwd"]
|
||||||
|
for key, value in data.iteritems():
|
||||||
|
utils.config.set(key, value)
|
||||||
|
utils.config.save()
|
||||||
|
utils.apply_config()
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
component.get("PageManager").register_page("/json/rpc",json_rpc)
|
component.get("PageManager").register_page("/json/rpc",json_rpc)
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,29 @@ function update_ui() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function get_webui_config() {
|
||||||
|
service.get_webui_config({params:[ ],
|
||||||
|
onSuccess:function(data){
|
||||||
|
alert(service.__toJSON(data));
|
||||||
|
},
|
||||||
|
onException:function(errorObj){
|
||||||
|
alert("Error: " + errorObj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function set_webui_config(cfg_dict) {
|
||||||
|
service.set_webui_config({params:[cfg_dict],
|
||||||
|
onSuccess:function(data){
|
||||||
|
alert(service.__toJSON(data));
|
||||||
|
},
|
||||||
|
onException:function(errorObj){
|
||||||
|
alert("Error: " + errorObj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -104,6 +127,13 @@ function update_ui() {
|
||||||
|
|
||||||
<button onclick="update_ui()">update_ui() filter on "Seeding"</button>
|
<button onclick="update_ui()">update_ui() filter on "Seeding"</button>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="torrent_list">
|
<div id="torrent_list">
|
||||||
|
|
||||||
<h1>add+auto-close</h1>
|
<h1>add+auto-close</h1>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue