mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 04:24:27 +00:00
json get/set webui_config
This commit is contained in:
parent
adc9902252
commit
0a362757a9
@ -52,7 +52,6 @@ from deluge import component
|
||||
from utils import dict_cb
|
||||
from lib import json
|
||||
|
||||
|
||||
def json_response(result, id):
|
||||
print json.write({
|
||||
"version":"1.1",
|
||||
@ -80,7 +79,8 @@ class json_rpc:
|
||||
* methods : http://dev.deluge-torrent.org/wiki/Development/UiClient#Remoteapi
|
||||
"""
|
||||
#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 = {}
|
||||
torrent_options = ["trackers","max_connections","max_upload_slots","max_upload_speed",
|
||||
"max_download_speed","file_priorities","prioritize_first_last","auto_managed","stop_at_ratio",
|
||||
@ -90,7 +90,6 @@ class json_rpc:
|
||||
def GET(self):
|
||||
return json_error("only POST is supported")
|
||||
|
||||
|
||||
def POST(self , name=None):
|
||||
web.header("Content-Type", "application/x-json")
|
||||
ck = cookies()
|
||||
@ -233,6 +232,20 @@ class json_rpc:
|
||||
func = getattr(sclient, 'set_torrent_' + option)
|
||||
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():
|
||||
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>
|
||||
|
||||
@ -104,6 +127,13 @@ function update_ui() {
|
||||
|
||||
<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">
|
||||
|
||||
<h1>add+auto-close</h1>
|
||||
|
Loading…
x
Reference in New Issue
Block a user