Merge pull request #19 from daduke/WiFi-Manager

Wi fi manager
This commit is contained in:
philippe44
2019-09-10 08:11:23 -07:00
committed by GitHub
3 changed files with 47 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
var recovery = 0;
var commandHeader = 'squeezelite -b 500:2000 -d all=info '; var commandHeader = 'squeezelite -b 500:2000 -d all=info ';
// First, checks if it isn't implemented yet. // First, checks if it isn't implemented yet.
@@ -187,6 +188,16 @@ $(document).ready(function(){
selectOutput(this); selectOutput(this);
}); });
if (recovery) {
$("#recoverydiv").hide();
$("#otadiv").show();
$("#command_line").hide();
$("#wifi").hide();
} else {
$("#recoverydiv").show();
$("#otadiv").hide();
}
//first time the page loads: attempt get the connection status and start the wifi scan //first time the page loads: attempt get the connection status and start the wifi scan
refreshAP(); refreshAP();
startCheckStatusInterval(); startCheckStatusInterval();
@@ -304,6 +315,7 @@ function checkStatus(){
//update wait screen //update wait screen
$( "#loading" ).hide(); $( "#loading" ).hide();
$( "#connect-success" ).append("<p>Your IP address now is: " + text(data["ip"]) + "</p>");
$( "#connect-success" ).show(); $( "#connect-success" ).show();
$( "#connect-fail" ).hide(); $( "#connect-fail" ).hide();
} }
@@ -418,6 +430,9 @@ function selectOutput(el) {
if ($(el).attr('id') == 'bt') { if ($(el).attr('id') == 'bt') {
$("#btsinkdiv").show(200); $("#btsinkdiv").show(200);
output = 'bt'; output = 'bt';
} else if ($(el).attr('id') == 'spdif') {
$("#btsinkdiv").hide(200);
output = 'spdif';
} else { } else {
$("#btsinkdiv").hide(200); $("#btsinkdiv").hide(200);
output = 'i2s'; output = 'i2s';
@@ -429,6 +444,8 @@ function generateCommand() {
if (output == 'bt') { if (output == 'bt') {
commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -u m -Z 192000 -r "44100-44100"'; commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -u m -Z 192000 -r "44100-44100"';
} else if (output == 'spdif') {
commandLine += ' -o SPDIF';
} else { } else {
commandLine += ' -o I2S'; commandLine += ' -o I2S';
} }

View File

@@ -158,11 +158,15 @@ function heartbeat()
} }
function handleClick(cb) { function handleClick(cb) {
console.log(cb);
if (cb.id == 'autoexec-cb') {
if (cb.checked) { if (cb.checked) {
$("#autoexec-command").show(200); $("#autoexec-command").show(200);
} else { } else {
$("#autoexec-command").hide(200); $("#autoexec-command").hide(200);
} }
} else if (cb.id == 'autoexec-cb') {
}
} }
</script> </script>
@@ -175,7 +179,7 @@ function handleClick(cb) {
</header> </header>
<h2> <h2>
<div id="autoexec" class="toggle"> <div id="autoexec" class="toggle">
<label>Run automatically at boot <label>Run squeezelite automatically at boot
<input id="autoexec-cb" type="checkbox" checked="checked" onclick='handleClick(this);'/><span class="slider"></span> <input id="autoexec-cb" type="checkbox" checked="checked" onclick='handleClick(this);'/><span class="slider"></span>
</label> </label>
</div> </div>
@@ -184,8 +188,10 @@ function handleClick(cb) {
<div id="autoexec-command"> <div id="autoexec-command">
<div id="audioout" class="toggle-buttons"> <div id="audioout" class="toggle-buttons">
<h2>Audio output</h2> <h2>Audio output</h2>
<input type="radio" id="i2s" name="audio" /> <input type="radio" id="i2s" name="audio" checked='checked' />
<label for="i2s">I2S</label> <label for="i2s">I2S</label>
<input type="radio" id="spdif" name="audio" />
<label for="spdif">SPDIF</label>
<input type="radio" id="bt" name="audio" /> <input type="radio" id="bt" name="audio" />
<label for="bt">Bluetooth</label> <label for="bt">Bluetooth</label>
</div> </div>
@@ -205,14 +211,26 @@ function handleClick(cb) {
<input id="generate-command" type="button" value="Generate" /> <input id="generate-command" type="button" value="Generate" />
</div> </div>
<h2>Command to run</h2> <h2>Squeezelite command to run</h2>
<section id="command-list"> <section id="command-list">
<textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -M esp32</textarea> <textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -M esp32</textarea>
</section> </section>
</div> </div>
<div class="buttons"> <div class="buttons">
<input id="update-command" type="button" value="Update" /> <input id="update-command" type="button" value="Save" />
</div>
</div>
<div id="recoverydiv">
<header><h1>System management</h1></header>
<h2>Check for firmware upgrade</h2>
<div class="buttons">
<input type="button" id="fwcheck" value="Check" onclick='handleClick(this);' />
<p><span id="currentfw">Currently running: 0.1</span> - <span id="latestfw">latest available version: 0.2</span></p>
</div>
<h2>Reboot to recovery system to perform firmware upgrade</h2>
<div class="buttons">
<input type="button" id="recovery" value="Recovery" onclick='handleClick(this);' />
</div> </div>
</div> </div>
<div id="otadiv"> <div id="otadiv">

View File

@@ -22,7 +22,6 @@ button:focus {
outline: none; outline: none;
} }
input[type="button"] { input[type="button"] {
width: 100px;
padding: 5px; padding: 5px;
text-align: center; text-align: center;
display: block; display: block;
@@ -376,3 +375,7 @@ textarea#autoexec1 {
background: #5a9900; background: #5a9900;
box-shadow: none; box-shadow: none;
} }
#otadiv {
display: none;
}