From dffdfa56c644f2bc967eaaff2a76c2fbcfe4ed07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Betn=C3=A9r?= Date: Thu, 18 May 2006 18:48:53 +0000 Subject: [PATCH] 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 --- admin-root/config.html | 9 +++++-- admin-root/config.js | 56 ++++++++++++++++++++++++++++++++++++++---- admin-root/config.xml | 5 ---- admin-root/hdr.html | 3 +-- 4 files changed, 59 insertions(+), 14 deletions(-) diff --git a/admin-root/config.html b/admin-root/config.html index 254d217f..c1581c7c 100644 --- a/admin-root/config.html +++ b/admin-root/config.html @@ -27,6 +27,11 @@ select { padding-left: 1.5em; margin-bottom: .5em; } +#config_not_writable_warning { + background-color: yellow; + padding: 1em; + border: 1px solid #8CACBB; +}

Configuration

@@ -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 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 3a479097..8cbbff4c 100644 --- a/admin-root/config.js +++ b/admin-root/config.js @@ -1,14 +1,39 @@ 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 // I could have put it below Config = ... but I want all window.load events // at the start of the file + function init() { Config.init(); Event.observe($('button_save'),'click',saveForm); } var ConfigXML = { 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) { return this.config[section][id]; }, @@ -59,6 +84,7 @@ var Config = { }, updateStatus: function (request) { 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( // ); @@ -84,7 +110,27 @@ var Config = { }); $('theform').appendChild(head); $('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) { if (multiple) { @@ -257,9 +303,9 @@ function saved(req) { function saveForm() { var getString = []; $A($('theform').getElementsByTagName('input')).each(function (input,i) { - if ((i > 10) && (i < 17)) { - getString.push(Form.Element.serialize(input.id)); - } + if (input.value != '') { + getString.push(Form.Element.serialize(input.id)); + } }); getString = getString.join('&'); new Ajax.Request('/xml-rpc?method=updateconfig&'+getString,{method: 'get', diff --git a/admin-root/config.xml b/admin-root/config.xml index 666d997a..81f2b5eb 100644 --- a/admin-root/config.xml +++ b/admin-root/config.xml @@ -112,11 +112,6 @@ long_text_multiple Add compilation directory - - Art Filename - - long_text -
diff --git a/admin-root/hdr.html b/admin-root/hdr.html index dc6d2a56..e87c6f95 100644 --- a/admin-root/hdr.html +++ b/admin-root/hdr.html @@ -5,8 +5,7 @@ @ispage config.html::@ - @ispage config.html::@ - @ispage config.html::@ + @ispage config.html::@ @ispage config.html::@ @ispage status.html::@ @ispage status.html::@