From b8027504de12e4960a02cc40bad6b689604327da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Anders=20Betn=C3=A9r?=
Date: Wed, 10 May 2006 17:37:29 +0000
Subject: [PATCH] All config options on config.html are defined in config.xml
and the option values are fetched with /xml-rpc?method=config
---
admin-root/config.html | 107 ++-----------------------
admin-root/config.js | 117 ++++++++++++++++++++++++++--
admin-root/config.xml | 172 +++++++++++++++++++++++++++++++++++++++++
admin-root/hdr.html | 1 +
4 files changed, 290 insertions(+), 107 deletions(-)
create mode 100644 admin-root/config.xml
diff --git a/admin-root/config.html b/admin-root/config.html
index a6c73208..1e36c96c 100644
--- a/admin-root/config.html
+++ b/admin-root/config.html
@@ -13,6 +13,13 @@ input {
select {
font: icon;
}
+#config_path {
+ float: left;
+ width: 11em;
+ font:icon;
+ padding-top: .3em;
+ padding-left: 1em;
+}
Configuration
@@ -24,105 +31,7 @@ running server. The server must be restarted for these values to
take effect.-->
This is work in progress. no changes saved, some fields not updated, some not even in mt-daapd.conf
-
@include ftr.html@
diff --git a/admin-root/config.js b/admin-root/config.js
index fce298af..0b14a854 100644
--- a/admin-root/config.js
+++ b/admin-root/config.js
@@ -8,20 +8,121 @@ function init() {
}
var Config = {
+ layout: '',
+ configPath: '',
+ configOptionValues: '',
init: function () {
- new Ajax.Request('/xml-rpc?method=stats',{method: 'get',onComplete: Config.updateStatus});
- new Ajax.Request('/xml-rpc?method=config',{method: 'get',onComplete: Config.showConfig});
+ new Ajax.Request('/config.xml',{method: 'get',onComplete: Config.storeConfigLayout});
},
- showConfig: function (request) {
- $A(request.responseXML.getElementsByTagName('general')[0].childNodes).each(function (el) {
- $(el.nodeName).value = Element.textContent(el);
- });
+ storeConfigLayout: function (request) {
+ Config.layout = request.responseXML;
+ new Ajax.Request('/xml-rpc?method=stats',{method: 'get',onComplete: Config.updateStatus});
},
updateStatus: function (request) {
- $('config_path').appendChild(document.createTextNode(
- Element.textContent(request.responseXML.getElementsByTagName('config_path')[0])));
+ Config.configPath = Element.textContent(request.responseXML.getElementsByTagName('config_path')[0]);
+// $('config_path').appendChild(document.createTextNode(
+
+// );
+ new Ajax.Request('/xml-rpc?method=config',{method: 'get',onComplete: Config.showConfig});
+ },
+ showConfig: function (request) {
+ Config.configOptionValues = request.responseXML;
+ var sections = $A(Config.layout.getElementsByTagName('section'));
+ sections.each(function (section) {
+ var head = document.createElement('div');
+ head.className= 'naviheader';
+ head.appendChild(document.createTextNode(section.getAttribute('name')));
+ var body = document.createElement('div');
+ body.className = 'navibox';
+ if ('Server' == section.getAttribute('name')) {
+ body.appendChild(Builder.node('span',{id:'config_path'},'Config File'));
+ body.appendChild(document.createTextNode(Config.configPath));
+ body.appendChild(Builder.node('br'));
+ body.appendChild(Builder.node('div',{style: 'clear: both;'}));
+ }
+ $A(section.getElementsByTagName('item')).each(function (item) {
+ body.appendChild(Config._buildItem(item));
+ });
+ $('theform').appendChild(head);
+ $('theform').appendChild(body);
+ });
+ },
+ _getConfigOptionValue: function(id) {
+ var value = Config.configOptionValues.getElementsByTagName(id);
+ if (value.length > 0) {
+ return Element.textContent(value[0]);
+ } else {
+ return '';
+ }
+ },
+ _buildItem: function(item) {
+
+ var ret;
+ var itemId = item.getAttribute('id');
+ switch(Element.textContent(item.getElementsByTagName('type')[0])) {
+ case 'short_text':
+ ret = BuildElement.input(itemId,
+ Element.textContent(item.getElementsByTagName('name')[0]),
+ Config._getConfigOptionValue(itemId),20,
+ Element.textContent(item.getElementsByTagName('short_description')[0]),
+ '');
+ break;
+ case 'long_text':
+ ret = BuildElement.input(itemId,
+ Element.textContent(item.getElementsByTagName('name')[0]),
+ Config._getConfigOptionValue(itemId),80,
+ Element.textContent(item.getElementsByTagName('short_description')[0]),
+ '');
+ break;
+ case 'select':
+ ret = BuildElement.select(itemId,
+ Element.textContent(item.getElementsByTagName('name')[0]),
+ item.getElementsByTagName('option'),
+ Config._getConfigOptionValue(itemId),
+ Element.textContent(item.getElementsByTagName('short_description')[0])
+ );
+ break;
+ }
+ return ret;
}
}
+var BuildElement = {
+ input: function(id,displayName,value,size,short_description,long_description) {
+
+ var frag = document.createDocumentFragment();
+ var label = document.createElement('label');
+
+ label.setAttribute('for',id);
+ label.appendChild(document.createTextNode(displayName));
+ frag.appendChild(label);
+
+ frag.appendChild(Builder.node('input',{id:id,name:id,className: 'text',
+ value: value,size: size}));
+ frag.appendChild(document.createTextNode('\u00a0'));
+ frag.appendChild(document.createTextNode(short_description));
+ frag.appendChild(Builder.node('br'));
+ return frag;
+ },
+ select: function(id,displayName,options,value,short_description,long_description) {
+ var frag = document.createDocumentFragment();
+ var label = document.createElement('label');
+ label.setAttribute('for',id);
+ label.appendChild(document.createTextNode(displayName));
+ frag.appendChild(label);
+
+ var select = Builder.node('select',{id: id,name: id, size: 1});
+ $A(options).each(function (option) {
+ select.appendChild(Builder.node('option',{value: option.getAttribute('value')},
+ Element.textContent(option)));
+ });
+ frag.appendChild(select);
+ frag.appendChild(document.createTextNode('\u00a0'));
+ frag.appendChild(document.createTextNode(short_description));
+ frag.appendChild(Builder.node('br'));
+ return frag;
+ }
+
+}
Object.extend(Element, {
removeChildren: function(element) {
while(element.hasChildNodes()) {
diff --git a/admin-root/config.xml b/admin-root/config.xml
new file mode 100644
index 00000000..b1afda96
--- /dev/null
+++ b/admin-root/config.xml
@@ -0,0 +1,172 @@
+
+
+
+
+ Server Name
+
+ The name iTunes and other daap clients should see
+
+
+ This is both the name of the server as advertised via
+ rendezvous, and the name of the database exported via
+ DAAP. Also know as "What shows up in iTunes".
+
+ short_text
+
+
+ Web Root
+
+ long_text
+
+
+ Port
+
+ The port the server should run at; default is 3689
+
+ short_text
+
+
+ Logfile
+
+ long_text
+
+
+ Run As
+
+ short_text
+
+
+ Admin password
+
+ The password for this administration interface.
+
+ short_text
+
+
+ MP3 Password
+
+ The password clients need to access this server.
+
+ short_text
+
+
+ Compress
+
+ Should browsing data be compressed on the way to the client?
+
+ select
+
+
+ 0
+
+
+ Debug Level
+
+ Possible values are 0 to 9, 9 being the most detailed debug level.
+
+ select
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ MP3 Directory
+
+ long_text
+
+
+ Extensions
+
+ short_text
+
+
+ Playlist File
+
+ long_text
+
+
+ Process .m3u Files
+
+ Should m3u files be processed as playlists?
+
+ select
+
+
+ 0
+
+
+ Compilation Directories
+
+ long_text
+
+
+ Art Filename
+
+ long_text
+
+
+
+
+
+ Database Type
+
+ select
+
+
+ sqlite
+
+
+ Database Directory
+
+ long_text
+
+
+ Scan Type
+
+ select
+
+
+
+ 2
+
+
+ Rescan Interval
+
+ How often should mt-daapd look for new files? In seconds.
+
+ short_text
+
+
+ Always Scan
+
+ select
+
+
+ 0
+
+
+
+
+
+ SSC Program
+
+ long_text
+
+
+ SSC Codec Types
+
+ long_text
+
+
+
\ No newline at end of file
diff --git a/admin-root/hdr.html b/admin-root/hdr.html
index 184c7253..dc6d2a56 100644
--- a/admin-root/hdr.html
+++ b/admin-root/hdr.html
@@ -6,6 +6,7 @@
@ispage config.html::@
@ispage config.html::@
+ @ispage config.html::@
@ispage config.html::@
@ispage status.html::@
@ispage status.html::@