summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
Diffstat (limited to 'module/web')
-rw-r--r--module/web/json_app.py29
-rw-r--r--module/web/media/js/settings.coffee4
-rw-r--r--module/web/media/js/settings.js2
-rw-r--r--module/web/pyload_app.py11
-rw-r--r--module/web/templates/default/settings_item.html14
5 files changed, 22 insertions, 38 deletions
diff --git a/module/web/json_app.py b/module/web/json_app.py
index f3626405c..196c9e36d 100644
--- a/module/web/json_app.py
+++ b/module/web/json_app.py
@@ -232,38 +232,23 @@ def set_captcha():
return {'captcha': False}
-@route("/json/load_config/:category/:section")
+@route("/json/load_config/:section")
@login_required("SETTINGS")
-def load_config(category, section):
- conf = None
- if category == "general":
- conf = PYLOAD.getConfigDict()
- elif category == "plugin":
- conf = PYLOAD.getPluginConfigDict()
+def load_config(section):
+ data = PYLOAD.configureSection(section)
+ return render_to_response("settings_item.html", {"section": data})
- for key, option in conf[section].iteritems():
- if key in ("desc","outline"): continue
- if ";" in option["type"]:
- option["list"] = option["type"].split(";")
-
- option["value"] = decode(option["value"])
-
- return render_to_response("settings_item.html", {"skey": section, "section": conf[section]})
-
-
-@route("/json/save_config/:category", method="POST")
+@route("/json/save_config", method="POST")
@login_required("SETTINGS")
-def save_config(category):
+def save_config():
for key, value in request.POST.iteritems():
try:
section, option = key.split("|")
except:
continue
- if category == "general": category = "core"
-
- PYLOAD.setConfigValue(section, option, decode(value), category)
+ PYLOAD.setConfigValue(section, option, decode(value))
@route("/json/add_account", method="POST")
diff --git a/module/web/media/js/settings.coffee b/module/web/media/js/settings.coffee
index 9205233e3..04d352dae 100644
--- a/module/web/media/js/settings.coffee
+++ b/module/web/media/js/settings.coffee
@@ -51,7 +51,7 @@ class SettingsUI
new Request({
"method" : "get"
- "url" : "/json/load_config/#{category}/#{section}"
+ "url" : "/json/load_config/#{section}"
"onSuccess": (data) =>
target.set "html", data
target.reveal()
@@ -65,7 +65,7 @@ class SettingsUI
form.set "send", {
"method": "post"
- "url": "/json/save_config/#{category}"
+ "url": "/json/save_config"
"onSuccess" : ->
root.notify.alert '{{ _("Settings saved.")}}', {
'className': 'success'
diff --git a/module/web/media/js/settings.js b/module/web/media/js/settings.js
index 9191fac72..3604c38b0 100644
--- a/module/web/media/js/settings.js
+++ b/module/web/media/js/settings.js
@@ -1,3 +1,3 @@
{% autoescape true %}
-var SettingsUI,root;var __bind=function(a,b){return function(){return a.apply(b,arguments)}};root=this;window.addEvent("domready",function(){root.accountDialog=new MooDialog({destroyOnHide:false});root.accountDialog.setContent($("account_box"));new TinyTab($$("#toptabs li a"),$$("#tabs-body > span"));$$("ul.nav").each(function(a){return new MooDropMenu(a,{onOpen:function(b){return b.fade("in")},onClose:function(b){return b.fade("out")},onInitialize:function(b){return b.fade("hide").set("tween",{duration:500})}})});return new SettingsUI()});SettingsUI=(function(){function a(){var c,e,b,d;this.menu=$$("#general-menu li");this.menu.append($$("#plugin-menu li"));this.name=$("tabsback");this.general=$("general_form_content");this.plugin=$("plugin_form_content");d=this.menu;for(e=0,b=d.length;e<b;e++){c=d[e];c.addEvent("click",this.menuClick.bind(this))}$("general|submit").addEvent("click",this.configSubmit.bind(this));$("plugin|submit").addEvent("click",this.configSubmit.bind(this));$("account_add").addEvent("click",function(f){root.accountDialog.open();return f.stop()});$("account_reset").addEvent("click",function(f){return root.accountDialog.close()});$("account_add_button").addEvent("click",this.addAccount.bind(this));$("account_submit").addEvent("click",this.submitAccounts.bind(this))}a.prototype.menuClick=function(h){var c,b,g,f,d;d=h.target.get("id").split("|"),c=d[0],g=d[1];b=h.target.get("text");f=c==="general"?this.general:this.plugin;f.dissolve();return new Request({method:"get",url:"/json/load_config/"+c+"/"+g,onSuccess:__bind(function(e){f.set("html",e);f.reveal();return this.name.set("text",b)},this)}).send()};a.prototype.configSubmit=function(d){var c,b;c=d.target.get("id").split("|")[0];b=$(""+c+"_form");b.set("send",{method:"post",url:"/json/save_config/"+c,onSuccess:function(){return root.notify.alert('{{ _("Settings saved.")}}',{className:"success"})},onFailure:function(){return root.notify.alert('{{ _("Error occured.")}}',{className:"error"})}});b.send();return d.stop()};a.prototype.addAccount=function(c){var b;b=$("add_account_form");b.set("send",{method:"post",onSuccess:function(){return window.location.reload()},onFailure:function(){return root.notify.alert('{{_("Error occured.")}}',{className:"error"})}});b.send();return c.stop()};a.prototype.submitAccounts=function(c){var b;b=$("account_form");b.set("send",{method:"post",onSuccess:function(){return window.location.reload()},onFailure:function(){return root.notify.alert('{{ _("Error occured.") }}',{className:"error"})}});b.send();return c.stop()};return a})();
+var SettingsUI,root;var __bind=function(a,b){return function(){return a.apply(b,arguments)}};root=this;window.addEvent("domready",function(){root.accountDialog=new MooDialog({destroyOnHide:false});root.accountDialog.setContent($("account_box"));new TinyTab($$("#toptabs li a"),$$("#tabs-body > span"));$$("ul.nav").each(function(a){return new MooDropMenu(a,{onOpen:function(b){return b.fade("in")},onClose:function(b){return b.fade("out")},onInitialize:function(b){return b.fade("hide").set("tween",{duration:500})}})});return new SettingsUI()});SettingsUI=(function(){function a(){var c,e,b,d;this.menu=$$("#general-menu li");this.menu.append($$("#plugin-menu li"));this.name=$("tabsback");this.general=$("general_form_content");this.plugin=$("plugin_form_content");d=this.menu;for(e=0,b=d.length;e<b;e++){c=d[e];c.addEvent("click",this.menuClick.bind(this))}$("general|submit").addEvent("click",this.configSubmit.bind(this));$("plugin|submit").addEvent("click",this.configSubmit.bind(this));$("account_add").addEvent("click",function(f){root.accountDialog.open();return f.stop()});$("account_reset").addEvent("click",function(f){return root.accountDialog.close()});$("account_add_button").addEvent("click",this.addAccount.bind(this));$("account_submit").addEvent("click",this.submitAccounts.bind(this))}a.prototype.menuClick=function(h){var c,b,g,f,d;d=h.target.get("id").split("|"),c=d[0],g=d[1];b=h.target.get("text");f=c==="general"?this.general:this.plugin;f.dissolve();return new Request({method:"get",url:"/json/load_config/"+g,onSuccess:__bind(function(e){f.set("html",e);f.reveal();return this.name.set("text",b)},this)}).send()};a.prototype.configSubmit=function(d){var c,b;c=d.target.get("id").split("|")[0];b=$(""+c+"_form");b.set("send",{method:"post",url:"/json/save_config",onSuccess:function(){return root.notify.alert('{{ _("Settings saved.")}}',{className:"success"})},onFailure:function(){return root.notify.alert('{{ _("Error occured.")}}',{className:"error"})}});b.send();return d.stop()};a.prototype.addAccount=function(c){var b;b=$("add_account_form");b.set("send",{method:"post",onSuccess:function(){return window.location.reload()},onFailure:function(){return root.notify.alert('{{_("Error occured.")}}',{className:"error"})}});b.send();return c.stop()};a.prototype.submitAccounts=function(c){var b;b=$("account_form");b.set("send",{method:"post",onSuccess:function(){return window.location.reload()},onFailure:function(){return root.notify.alert('{{ _("Error occured.") }}',{className:"error"})}});b.send();return c.stop()};return a})();
{% endautoescape %} \ No newline at end of file
diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py
index df4a4b3d4..5e6d18584 100644
--- a/module/web/pyload_app.py
+++ b/module/web/pyload_app.py
@@ -241,17 +241,16 @@ def get_download(path):
@route("/settings")
@login_required('SETTINGS')
def config():
- conf = PYLOAD.getConfig()
- plugin = PYLOAD.getPluginConfig()
+ conf = PYLOAD.getConfigPointer()
conf_menu = []
plugin_menu = []
- for entry in sorted(conf.keys()):
- conf_menu.append((entry, conf[entry].description))
+ for section, data in conf.getBaseSections():
+ conf_menu.append((section, data.name))
- for entry in sorted(plugin.keys()):
- plugin_menu.append((entry, plugin[entry].description))
+ for section, data in conf.getPluginSections():
+ plugin_menu.append((section, data.name))
accs = PYLOAD.getAccounts(False)
diff --git a/module/web/templates/default/settings_item.html b/module/web/templates/default/settings_item.html
index 813383343..b81ba1b95 100644
--- a/module/web/templates/default/settings_item.html
+++ b/module/web/templates/default/settings_item.html
@@ -1,12 +1,13 @@
<table class="settable">
{% if section.outline %}
- <tr><th colspan="2">{{ section.outline }}</th></tr>
+ <tr><th colspan="2">{{ section.description }}</th></tr>
{% endif %}
- {% for okey, option in section.iteritems() %}
- {% if okey not in ("desc","outline") %}
+ {% for option in section.items %}
+ {% set okey = option.name %}
+ {% set skey = section.name %}
<tr>
- <td><label for="{{skey}}|{{okey}}"
- style="color:#424242;">{{ option.desc }}:</label></td>
+ <td><label for="{{section.name}}|{{option.name}}"
+ style="color:#424242;">{{ option.long_name }}:</label></td>
<td>
{% if option.type == "bool" %}
<select id="{{skey}}|{{okey}}" name="{{skey}}|{{okey}}">
@@ -17,7 +18,7 @@
</select>
{% elif ";" in option.type %}
<select id="{{skey}}|{{okey}}" name="{{skey}}|{{okey}}">
- {% for entry in option.list %}
+ {% for entry in option.type.split(";") %}
<option {% if option.value == entry %}
selected="selected" {% endif %}>{{ entry }}</option>
{% endfor %}
@@ -43,6 +44,5 @@
{% endif %}
</td>
</tr>
- {% endif %}
{% endfor %}
</table> \ No newline at end of file