All config options on config.html are defined in config.xml and the

option values are fetched with /xml-rpc?method=config
This commit is contained in:
Anders Betnér 2006-05-10 17:37:29 +00:00
parent b780bac291
commit b8027504de
4 changed files with 290 additions and 107 deletions

View File

@ -13,6 +13,13 @@ input {
select {
font: icon;
}
#config_path {
float: left;
width: 11em;
font:icon;
padding-top: .3em;
padding-left: 1em;
}
</style>
<h1>Configuration</h1>
@ -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</p>
<form method="get" action="#">
<div class="naviheader">Server</div>
<div class="navibox">
<span style="float: left; width: 11em; font:icon;padding-top: .3em; padding-left: 1em;">Config File</span>
<span id="config_path"></span><br />
<div style="clear: both;"></div>
<label for="servername">Server Name</label>
<input class="text" type="text" id="servername" value="" />
&nbsp;the name iTunes and other daap clients should see.<br />
<label for="web_root">Web Root</label>
<input class="text" type="text" id="web_root" size="80" value="" /><br />
<label for="port">Port</label>
<input class="text" type="text" id="port" value="" />
&nbsp;The port the server should run at; default is 3689.<br />
<label for="logfile">Logfile</label>
<input class="text" type="text" id="logfile" size="80" value="" /><br />
<label for="runas">Run As</label>
<input class="text" type="text" id="runas" value="" /><br />
<label for="admin_pw">Admin Password</label>
<input class="text" type="text" id="admin_pw" value="" />
&nbsp;The password for this administration interface.<br />
<label for="password">MP3 Password</label>
<input class="text" type="text" id="password" value="" />
&nbsp;The password clients need to access this server.<br />
<label for="compress">Compress</label>
<select id="compress" size="1">
<option value="1">Yes</option>
<option value="0" selected="selected">No</option>
</select>
&nbsp;Should browsing data be compressed on the way to the client?<br />
<label for="debug">Debug Level</label>
<select id="debug" size="1">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
&nbsp;Possible values are 0 to 9, 9 being the most detailed debug level.<br />
</div>
<div class="naviheader">Music Files</div>
<div class="navibox">
<label for="mp3_dir">MP3 Directory</label>
<input class="text" type="text" id="mp3_dir" size="80" value="" /><br />
<label for="extensions">Extensions</label>
<input class="text" type="text" id="extensions" size="80" value="" /><br />
<label for="playlist">Playlist File</label>
<input class="text" type="text" id="playlist" size="80" value="" /><br />
<label for="process_m3u">Process .m3u Files</label>
<select id="process_m3u" size="1">
<option value="1">Yes</option>
<option value="0" selected="selected">No</option>
</select>
Should m3u files be processed as playlists?<br />
<label for="compdirs">Compilation Directories</label>
<input class="text" type="text" id="compdirs" size="80" value="" /><br />
<label for="art_filename">Art Filename</label>
<input class="text" type="text" id="art_filename" size="80" value="" /><br />
</div>
<div class="naviheader">Database</div>
<div class="navibox">
<label for="db_type">Database Type</label>
<select id="db_type" size="1">
<option value="sqlite">sqlite</option>
<option value="sqlite3">sqlite3</option>
</select><br />
<label for="db_parms">Database Directory</label>
<input class="text" type="text" id="db_parms" size="80" value="" /><br />
<label for="scan_type">Scan Type</label>
<select id="scan_type" size="1">
<option value="0">0 - Normal</option>
<option value="1">1 - Aggressive</option>
<option value="2">2 - Painfully aggressive</option>
</select><br />
<label for="rescan">Rescan Interval</label>
<input class="text" type="text" id="rescan" value="" />
&nbsp;How often should mt-daapd look for new files? In seconds.<br />
<label for="always">Always Scan</label>
<select id="always" size="1">
<option value="1">Yes</option>
<option value="0" selected="selected">No</option>
</select><br />
</div>
<div class="naviheader">Transcoding</div>
<div class="navibox">
<label for="ssc_prog">SSC prog</label>
<input class="text" type="text" id="ssc_prog" size="80" value="" /><br />
<label for="ssc_codectypes">SSC codec types</label>
<input class="text" type="text" id="ssc_codectypes" size="80" value="" /><br />
</div>
<form id="theform" method="get" action="#">
</form>
@include ftr.html@

View File

@ -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()) {

172
admin-root/config.xml Normal file
View File

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
<section name="Server">
<item id="servername">
<name>Server Name</name>
<short_description>
The name iTunes and other daap clients should see
</short_description>
<long_description>
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".
</long_description>
<type>short_text</type>
</item>
<item id="web_root">
<name>Web Root</name>
<short_description></short_description>
<type>long_text</type>
</item>
<item id="port">
<name>Port</name>
<short_description>
The port the server should run at; default is 3689
</short_description>
<type>short_text</type>
</item>
<item id="logfile">
<name>Logfile</name>
<short_description></short_description>
<type>long_text</type>
</item>
<item id="runas">
<name>Run As</name>
<short_description></short_description>
<type>short_text</type>
</item>
<item id="admin_pw">
<name>Admin password</name>
<short_description>
The password for this administration interface.
</short_description>
<type>short_text</type>
</item>
<item id="password">
<name>MP3 Password</name>
<short_description>
The password clients need to access this server.
</short_description>
<type>short_text</type>
</item>
<item id="compress">
<name>Compress</name>
<short_description>
Should browsing data be compressed on the way to the client?
</short_description>
<type>select</type>
<option value="0">No</option>
<option value="1">Yes</option>
<default_value>0</default_value>
</item>
<item id="debug">
<name>Debug Level</name>
<short_description>
Possible values are 0 to 9, 9 being the most detailed debug level.
</short_description>
<type>select</type>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<default_value>0</default_value>
</item>
</section>
<section name="Music Files">
<item id="mp3_dir">
<name>MP3 Directory</name>
<short_description></short_description>
<type>long_text</type>
</item>
<item id="extensions">
<name>Extensions</name>
<short_description></short_description>
<type>short_text</type>
</item>
<item id="playlist">
<name>Playlist File</name>
<short_description></short_description>
<type>long_text</type>
</item>
<item id="process_m3u">
<name>Process .m3u Files</name>
<short_description>
Should m3u files be processed as playlists?
</short_description>
<type>select</type>
<option value="0">No</option>
<option value="1">Yes</option>
<default_value>0</default_value>
</item>
<item id="compdirs">
<name>Compilation Directories</name>
<short_description></short_description>
<type>long_text</type>
</item>
<item id="art_filename">
<name>Art Filename</name>
<short_description></short_description>
<type>long_text</type>
</item>
</section>
<section name="Database">
<item id="db_type">
<name>Database Type</name>
<short_description></short_description>
<type>select</type>
<option value="sqlite">sqlite</option>
<option value="sqlite3">sqlite3</option>
<default_value>sqlite</default_value>
</item>
<item id="db_parms">
<name>Database Directory</name>
<short_description></short_description>
<type>long_text</type>
</item>
<item id="scan_type">
<name>Scan Type</name>
<short_description></short_description>
<type>select</type>
<option value="0">0 - Normal</option>
<option value="1">1 - Aggressive</option>
<option value="2">2 - Painfully aggressive</option>
<default_value>2</default_value>
</item>
<item id="rescan_interval">
<name>Rescan Interval</name>
<short_description>
How often should mt-daapd look for new files? In seconds.
</short_description>
<type>short_text</type>
</item>
<item id="always_scan">
<name>Always Scan</name>
<short_description></short_description>
<type>select</type>
<option value="0">No</option>
<option value="1">Yes</option>
<default_value>0</default_value>
</item>
</section>
<section name="Transcoding">
<item id="ssc_prog">
<name>SSC Program</name>
<short_description></short_description>
<type>long_text</type>
</item>
<item id="ssc_codectypes">
<name>SSC Codec Types</name>
<short_description></short_description>
<type>long_text</type>
</item>
</section>
</config>

View File

@ -6,6 +6,7 @@
<link rel="stylesheet" type="text/css" href="mt-daapd.css" />
@ispage config.html:<script type="text/javascript" src="lib-js/prototype.js"></script>:@
@ispage config.html:<script type="text/javascript" src="lib-js/script.aculo.us/effects.js"></script>:@
@ispage config.html:<script type="text/javascript" src="lib-js/script.aculo.us/builder.js"></script>:@
@ispage config.html:<script type="text/javascript" src="config.js"></script>:@
@ispage status.html:<script type="text/javascript" src="lib-js/prototype.js"></script>:@
@ispage status.html:<script type="text/javascript" src="lib-js/script.aculo.us/effects.js"></script>:@