diff --git a/general/package/wifibroadcast-ng/www/index.html b/general/package/wifibroadcast-ng/www/index.html index 988287bc..820af70b 100644 --- a/general/package/wifibroadcast-ng/www/index.html +++ b/general/package/wifibroadcast-ng/www/index.html @@ -78,12 +78,12 @@
- +
- Stream +
@@ -233,73 +233,58 @@ }); } - function populateFormFields() { - const populate = (data, formPrefix) => { - Object.keys(data).forEach((section) => { - Object.keys(data[section]).forEach((key) => { - const field = document.querySelector(`[name="${formPrefix}.${section}.${key}"]`); - if (field) { + function syncForm(data, formPrefix, mode) { + Object.keys(data).forEach((section) => { + Object.keys(data[section]).forEach((key) => { + const field = document.querySelector(`[name="${formPrefix}.${section}.${key}"]`); + if (field) { + if (mode === "setup") { field.value = data[section][key]; - } - }); - }); - }; - - if (configData.majestic) { - populate(configData.majestic, 'majestic'); - } - if (configData.wfb) { - populate(configData.wfb, 'wfb'); - } - } - - function updateData() { - const update = (data, formPrefix) => { - Object.keys(data).forEach((section) => { - Object.keys(data[section]).forEach((key) => { - const field = document.querySelector(`[name="${formPrefix}.${section}.${key}"]`); - if (field) { + } else if (mode === "update") { data[section][key] = field.value; } - }); + } }); - }; - - update(configData.majestic, 'majestic'); - update(configData.wfb, 'wfb'); + }); } - document.getElementById('apply-majestic-button').addEventListener('click', () => { + function executeDelay(button, command) { + button.disabled = true; + runCommand(command); + setTimeout(() => { + button.disabled = false; + location.reload(); + }, 1000); + } + + document.getElementById('apply-majestic-button').addEventListener('click', function() { if (configData.majestic) { - updateData(); + syncForm(configData.majestic, 'majestic', "update"); uploadYAML(configData.majestic, '/etc/majestic.yaml'); - runCommand('killall -1 majestic'); - setTimeout(() => location.reload(), 1000); + executeDelay(this, 'killall -1 majestic'); } }); - document.getElementById('apply-wfb-button').addEventListener('click', () => { + document.getElementById('apply-wfb-button').addEventListener('click', function() { if (configData.wfb) { - updateData(); + syncForm(configData.wfb, 'wfb', "update"); uploadYAML(configData.wfb, '/etc/wfb.yaml'); - runCommand('wifibroadcast restart'); - setTimeout(() => location.reload(), 1000); + executeDelay(this, 'wifibroadcast restart'); } }); - document.getElementById('reset-button').addEventListener('click', () => { - runCommand('wifibroadcast reset'); - setTimeout(() => location.reload(), 1000); + document.getElementById('reset-button').addEventListener('click', function() { + executeDelay(this, 'wifibroadcast reset'); }); loadYAML('/etc/majestic.yaml', (data) => { configData.majestic = data; - populateFormFields(); + syncForm(configData.majestic, 'majestic', "setup"); }); loadYAML('/etc/wfb.yaml', (data) => { configData.wfb = data; - populateFormFields(); + syncForm(configData.wfb, 'wfb', "setup"); }); diff --git a/general/package/wifibroadcast-ng/www/stream.svg b/general/package/wifibroadcast-ng/www/stream.svg new file mode 100644 index 00000000..28d8d4cb --- /dev/null +++ b/general/package/wifibroadcast-ng/www/stream.svg @@ -0,0 +1,4 @@ + + + +