Added warning if mt-daapd.conf not writable

Switch order of save cancel buttons when on a Mac
Disable save button (will write a script to enable it as 
soon as something changes on the page)
Removed art_filename from config.xml
This commit is contained in:
Anders Betnér 2006-05-18 18:48:53 +00:00
parent 3eef14e1cf
commit dffdfa56c6
4 changed files with 59 additions and 14 deletions

View File

@ -27,6 +27,11 @@ select {
padding-left: 1.5em; padding-left: 1.5em;
margin-bottom: .5em; margin-bottom: .5em;
} }
#config_not_writable_warning {
background-color: yellow;
padding: 1em;
border: 1px solid #8CACBB;
}
</style> </style>
<h1>Configuration</h1> <h1>Configuration</h1>
@ -37,8 +42,8 @@ make changes to these settings, they will not be reflected in the
running server. The server must be restarted for these values to running server. The server must be restarted for these values to
take effect.--> take effect.-->
This is work in progress. no changes saved, some fields not updated, some not even in mt-daapd.conf</p> This is work in progress. no changes saved, some fields not updated, some not even in mt-daapd.conf</p>
<button id="button_save">Save</button><button id="button_cancel">Cancel</button> <div id="config_not_writable_warning" style="display: none;">Your config file is not writable, you can not change anything using this webpage</div>
<form id="theform" method="get" action="#"> <form id="theform" method="get" action="#">
</form> </form>
<div id="buttons"></div>
@include ftr.html@ @include ftr.html@

View File

@ -1,14 +1,39 @@
Event.observe(window,'load',init); Event.observe(window,'load',init);
//###TODO
//Check if writable
//Disable/enable save/cancel
//swap buttons if navigator.platform == mac
/* platform = window.navigator.platform.toLowerCase();
if (platform.indexOf('win') != -1)
navigator.OS = 'win';
else if (platform.indexOf('mac') != -1)
navigator.OS = 'mac';
else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
navigator.OS = 'nix';*/
//Inform user if server restart needed
//config.xml: Add browse file/dir button, add multiple, add textbox size?
//
// Config isn't defined until after the Event.observe above // Config isn't defined until after the Event.observe above
// I could have put it below Config = ... but I want all window.load events // I could have put it below Config = ... but I want all window.load events
// at the start of the file // at the start of the file
function init() { function init() {
Config.init(); Config.init();
Event.observe($('button_save'),'click',saveForm); Event.observe($('button_save'),'click',saveForm);
} }
var ConfigXML = { var ConfigXML = {
config: [], config: [],
getOptionFromElementName: function (name) {
var id = name.replace(/.*:/,'');
return Try.these(
function () {ConfigXml.config['Server'][id];},
function () {ConfigXml.config['Music_Files'][id];},
function () {ConfigXml.config['Database'][id];},
function () {ConfigXml.config['Plugins'][id];},
function () {ConfigXml.config['Transcoding'][id];}
);
},
getOption: function (section,id) { getOption: function (section,id) {
return this.config[section][id]; return this.config[section][id];
}, },
@ -59,6 +84,7 @@ var Config = {
}, },
updateStatus: function (request) { updateStatus: function (request) {
Config.configPath = Element.textContent(request.responseXML.getElementsByTagName('config_path')[0]); Config.configPath = Element.textContent(request.responseXML.getElementsByTagName('config_path')[0]);
Config.isWritable = Element.textContent(request.responseXML.getElementsByTagName('writable_config')[0]) == '1';
// $('config_path').appendChild(document.createTextNode( // $('config_path').appendChild(document.createTextNode(
// ); // );
@ -84,7 +110,27 @@ var Config = {
}); });
$('theform').appendChild(head); $('theform').appendChild(head);
$('theform').appendChild(body); $('theform').appendChild(body);
}); });
if (!Config.isWritable) {
Effect.Appear('config_not_writable_warning');
} else {
// Create save and cancel buttons
var save = Builder.node('button',{id: 'button_save', disabled: 'disabled'},'Save');
var cancel = Builder.node('button',{id: 'button_cancel'},'Cancel');
var spacer = document.createTextNode('\u00a0\u00a0');
var buttons = $('buttons');
if (navigator.platform.indexOf('mac') != -1) {
// We're on mac
buttons.appendChild(cancel);
buttons.appendChild(spacer);
buttons.appendChild(save);
} else {
// What about all them unix variants?
buttons.appendChild(save);
buttons.appendChild(spacer);
buttons.appendChild(cancel);
}
}
}, },
_getConfigOptionValue: function(id,multiple) { _getConfigOptionValue: function(id,multiple) {
if (multiple) { if (multiple) {
@ -257,9 +303,9 @@ function saved(req) {
function saveForm() { function saveForm() {
var getString = []; var getString = [];
$A($('theform').getElementsByTagName('input')).each(function (input,i) { $A($('theform').getElementsByTagName('input')).each(function (input,i) {
if ((i > 10) && (i < 17)) { if (input.value != '') {
getString.push(Form.Element.serialize(input.id)); getString.push(Form.Element.serialize(input.id));
} }
}); });
getString = getString.join('&'); getString = getString.join('&');
new Ajax.Request('/xml-rpc?method=updateconfig&'+getString,{method: 'get', new Ajax.Request('/xml-rpc?method=updateconfig&'+getString,{method: 'get',

View File

@ -112,11 +112,6 @@
<type>long_text_multiple</type> <type>long_text_multiple</type>
<add_item_text>Add compilation directory</add_item_text> <add_item_text>Add compilation directory</add_item_text>
</item> </item>
<item id="art_filename" config_section="general">
<name>Art Filename</name>
<short_description></short_description>
<type>long_text</type>
</item>
</section> </section>
<section name="Database"> <section name="Database">

View File

@ -5,8 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="mt-daapd.css" /> <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/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/scriptaculous.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 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/prototype.js"></script>:@
@ispage status.html:<script type="text/javascript" src="lib-js/script.aculo.us/effects.js"></script>:@ @ispage status.html:<script type="text/javascript" src="lib-js/script.aculo.us/effects.js"></script>:@