mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-27 12:50:49 +03:00
More OTA fix, restore UI from previous commit
This commit is contained in:
@@ -11,7 +11,8 @@ if (!String.prototype.format) {
|
||||
};
|
||||
}
|
||||
|
||||
var recovery = false;
|
||||
var releaseURL = 'https://api.github.com/repos/sle118/squeezelite-esp32/releases';
|
||||
var recovery = true;
|
||||
var enableTimers = true;
|
||||
var commandHeader = 'squeezelite -b 500:2000 -d all=info ';
|
||||
|
||||
@@ -24,6 +25,7 @@ var StatusIntervalActive = false;
|
||||
var ConfigIntervalActive = false;
|
||||
var RefreshAPIIntervalActive = false;
|
||||
|
||||
var output = '';
|
||||
//TODO check
|
||||
var to = 0, set_int = 0;
|
||||
|
||||
@@ -65,7 +67,7 @@ function RepeatCheckConfigInterval(){
|
||||
|
||||
function RepeatRefreshAPInterval(){
|
||||
if(RefreshAPIIntervalActive)
|
||||
startRefreshAPInterval()
|
||||
startRefreshAPInterval();
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
@@ -175,18 +177,110 @@ $(document).ready(function(){
|
||||
$( "#wifi" ).slideDown( "fast", function() {})
|
||||
});
|
||||
|
||||
$("#update-command").click(function() {
|
||||
updateAutoexec();
|
||||
$("#autoexec-cb").on("click", function() {
|
||||
autoexec = (this.checked)?1:0;
|
||||
$.ajax({
|
||||
url: '/config.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: { "X-Custom-autoexec": autoexec },
|
||||
data: { 'timestamp': Date.now() }
|
||||
});
|
||||
console.log('sent config JSON with headers:', autoexec);
|
||||
});
|
||||
|
||||
$("#save-autoexec1").on("click", function() {
|
||||
autoexec1 = $("#autoexec1").val();
|
||||
|
||||
$.ajax({
|
||||
url: '/config.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: { "X-Custom-autoexec1": autoexec1 },
|
||||
data: { 'timestamp': Date.now() }
|
||||
});
|
||||
console.log('sent config JSON with headers:', autoexec1);
|
||||
});
|
||||
|
||||
$("#recovery").on("click", function() {
|
||||
$.ajax({
|
||||
url: '/recovery.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
data: { 'timestamp': Date.now()}
|
||||
});
|
||||
});
|
||||
|
||||
$("#reboot").on("click", function() {
|
||||
$.ajax({
|
||||
url: '/reboot.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
data: { 'timestamp': Date.now()}
|
||||
});
|
||||
});
|
||||
|
||||
$("#generate-command").on("click", function() {
|
||||
var commandLine = commandHeader + '-n ' + $("#player").val();
|
||||
|
||||
if (output == 'bt') {
|
||||
commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -Z 192000';
|
||||
} else if (output == 'spdif') {
|
||||
commandLine += ' -o SPDIF -R -Z 192000';
|
||||
} else {
|
||||
commandLine += ' -o I2S';
|
||||
}
|
||||
if ($("#optional").val() != '') {
|
||||
commandLine += ' ' + $("#optional").val();
|
||||
}
|
||||
$("#autoexec1").val(commandLine);
|
||||
});
|
||||
|
||||
$("#generate-command").click(function() {
|
||||
generateCommand();
|
||||
});
|
||||
|
||||
$('[name=audio]').click(function(){
|
||||
selectOutput(this);
|
||||
$('[name=audio]').on("click", function(){
|
||||
if (this.id == 'bt') {
|
||||
$("#btsinkdiv").show(200);
|
||||
output = 'bt';
|
||||
} else if (this.id == 'spdif') {
|
||||
$("#btsinkdiv").hide(200);
|
||||
output = 'spdif';
|
||||
} else {
|
||||
$("#btsinkdiv").hide(200);
|
||||
output = 'i2s';
|
||||
}
|
||||
});
|
||||
|
||||
$('#fwcheck').on("click", function(){
|
||||
$("#releaseTable").html("");
|
||||
$.getJSON(releaseURL, function(data) {
|
||||
data.forEach(function(release) {
|
||||
var url = '';
|
||||
release.assets.forEach(function(asset) {
|
||||
if (asset.name.match(/\.bin$/)) {
|
||||
url = asset.browser_download_url;
|
||||
}
|
||||
});
|
||||
var [ver, idf, cfg, branch] = release.name.split('-');
|
||||
$("#releaseTable").append(
|
||||
"<tr>"+
|
||||
"<td>"+ver+"</td>"+
|
||||
"<td>"+idf+"</td>"+
|
||||
"<td>"+cfg+"</td>"+
|
||||
"<td>"+branch+"</td>"+
|
||||
"<td><input id='generate-command' type='button' class='btn btn-success' value='Select' data-url='"+url+"' onclick='setURL(this);' /></td>"+
|
||||
"</tr>"
|
||||
);
|
||||
});
|
||||
})
|
||||
.fail(function() {
|
||||
alert("failed to fetch release history!");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//first time the page loads: attempt to get the connection status and start the wifi scan
|
||||
refreshAP();
|
||||
getConfig();
|
||||
@@ -196,6 +290,20 @@ $(document).ready(function(){
|
||||
startRefreshAPInterval();
|
||||
});
|
||||
|
||||
function setURL(button) {
|
||||
var url = button.dataset.url;
|
||||
$.ajax({
|
||||
url: '/config.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: { "X-Custom-fwurl": url },
|
||||
data: { 'timestamp': Date.now() }
|
||||
});
|
||||
$('[data-url^="http"]').addClass("btn-success").removeClass("btn-danger");
|
||||
$('[data-url="'+url+'"]').addClass("btn-danger").removeClass("btn-success");
|
||||
}
|
||||
|
||||
function performConnect(conntype){
|
||||
//stop the status refresh. This prevents a race condition where a status
|
||||
//request would be refreshed with wrong ip info from a previous connection
|
||||
@@ -240,8 +348,6 @@ function performConnect(conntype){
|
||||
startRefreshAPInterval();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function rssiToIcon(rssi){
|
||||
if(rssi >= -60){
|
||||
return 'w0';
|
||||
@@ -367,16 +473,16 @@ function getConfig() {
|
||||
} else {
|
||||
console.log('turn off autoexec');
|
||||
$("#autoexec-cb")[0].checked=false;
|
||||
$("#autoexec-command").hide(200);
|
||||
}
|
||||
}
|
||||
if (data.hasOwnProperty('recovery')) {
|
||||
if (data["recovery"] === 1) {
|
||||
recovery = true;
|
||||
$("#tab-wifi").removeClass("active show");
|
||||
$("#tab-system").addClass("active show");
|
||||
$("#navbar").hide();
|
||||
$("#recoverydiv").hide();
|
||||
$("#otadiv").show();
|
||||
$("#command_line").hide();
|
||||
$("#wifi").hide();
|
||||
} else {
|
||||
recovery = false;
|
||||
$("#recoverydiv").show();
|
||||
@@ -399,77 +505,8 @@ function getConfig() {
|
||||
});
|
||||
}
|
||||
|
||||
function updateAutoexec(){
|
||||
autoexec = ($("#autoexec-cb")[0].checked)?1:0;
|
||||
autoexec1 = $("#autoexec1").val();
|
||||
|
||||
$.ajax({
|
||||
url: '/config.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
headers: { "X-Custom-autoexec": autoexec, "X-Custom-autoexec1": autoexec1 },
|
||||
data: { 'timestamp': Date.now() }
|
||||
});
|
||||
console.log('sent config JSON with headers:', autoexec, autoexec1);
|
||||
}
|
||||
|
||||
var output = '';
|
||||
function selectOutput(el) {
|
||||
if ($(el).attr('id') == 'bt') {
|
||||
$("#btsinkdiv").show(200);
|
||||
output = 'bt';
|
||||
} else if ($(el).attr('id') == 'spdif') {
|
||||
$("#btsinkdiv").hide(200);
|
||||
output = 'spdif';
|
||||
} else {
|
||||
$("#btsinkdiv").hide(200);
|
||||
output = 'i2s';
|
||||
}
|
||||
}
|
||||
|
||||
function generateCommand() {
|
||||
var commandLine = commandHeader + '-n ' + $("#player").val();
|
||||
|
||||
if (output == 'bt') {
|
||||
commandLine += ' -o "BT -n \'' + $("#btsink").val() + '\'" -R -Z 192000';
|
||||
} else if (output == 'spdif') {
|
||||
commandLine += ' -o SPDIF -R -Z 192000';
|
||||
} else {
|
||||
commandLine += ' -o I2S';
|
||||
}
|
||||
if ($("#optional").val() != '') {
|
||||
commandLine += ' ' + $("#optional").val();
|
||||
}
|
||||
$("#autoexec1").val(commandLine);
|
||||
}
|
||||
|
||||
function handleClick(item) {
|
||||
console.log(item);
|
||||
if (item.id == 'autoexec-cb') {
|
||||
if (item.checked) {
|
||||
$("#autoexec-command").show(200);
|
||||
} else {
|
||||
$("#autoexec-command").hide(200);
|
||||
}
|
||||
} else if (item.id == 'recovery') {
|
||||
$.ajax({
|
||||
url: '/recovery.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
data: { 'timestamp': Date.now()}
|
||||
});
|
||||
} else if (item.id == 'reboot') {
|
||||
$.ajax({
|
||||
url: '/reboot.json',
|
||||
dataType: 'json',
|
||||
method: 'POST',
|
||||
cache: false,
|
||||
data: { 'timestamp': Date.now()}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//TODO daduke check
|
||||
function file_change() {
|
||||
|
||||
@@ -4,24 +4,26 @@
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<link rel="stylesheet" href="/test/bootstrap.min.css"> <!-- TODO delete -->
|
||||
<link rel="stylesheet" href="/bootstrap.css">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<script src="/jquery.js"></script>
|
||||
<script src="/bootstrap.js"></script>
|
||||
<script src="/popper.js"></script>
|
||||
<script src="/code.js"></script>
|
||||
|
||||
<!-- TODO delete -->
|
||||
<link rel="stylesheet" href="/test/bootstrap.min.css">
|
||||
<script src="/test/jquery.min.js"></script>
|
||||
<script src="/test/bootstrap.min.js"></script>
|
||||
<script src="/test/popper.min.js"></script>
|
||||
|
||||
<script src="/code.js"></script>
|
||||
|
||||
|
||||
<title>esp32-wifi-manager</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ul class="nav nav-tabs">
|
||||
<ul id="navbar" class="nav nav-tabs">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#tab-wifi">WiFi</a>
|
||||
</li>
|
||||
@@ -31,6 +33,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#tab-audio">Audio + LMS</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#tab-gpio">GPIO</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#tab-system">System</a>
|
||||
</li>
|
||||
@@ -67,8 +72,8 @@
|
||||
<input id="manual_pwd" type="password" placeholder="Password" value="">
|
||||
</section>
|
||||
<div class="buttons">
|
||||
<input id="manual_join" type="button" value="Join" data-connect="manual" />
|
||||
<input id="manual_cancel" type="button" value="Cancel"/>
|
||||
<input id="manual_join" type="button" class="btn btn-success" value="Join" data-connect="manual" />
|
||||
<input id="manual_cancel" type="button" class="btn btn-danger" value="Cancel"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -81,8 +86,8 @@
|
||||
<input id="pwd" type="password" placeholder="Password" value="">
|
||||
</section>
|
||||
<div class="buttons">
|
||||
<input id="join" type="button" value="Join" />
|
||||
<input id="cancel" type="button" value="Cancel"/>
|
||||
<input id="join" type="button" class="btn btn-success" value="Join" />
|
||||
<input id="cancel" type="button" class="btn btn-danger" value="Cancel"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -105,7 +110,7 @@
|
||||
</div>
|
||||
</section>
|
||||
<div class="buttons">
|
||||
<input id="ok-connect" type="button" value="OK" class="ctr" />
|
||||
<input id="ok-connect" type="button" value="OK" class="btn btn-success" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -117,7 +122,7 @@
|
||||
<h2></h2>
|
||||
<section>
|
||||
<div class="buttons">
|
||||
<input id="disconnect" type="button" value="Disconnect" class="ctr"/>
|
||||
<input id="disconnect" type="button" value="Disconnect" class="btn btn-danger"/>
|
||||
</div>
|
||||
</section>
|
||||
<h2>IP Address</h2>
|
||||
@@ -127,15 +132,15 @@
|
||||
<div class="ape">Default Gateway:<div id="gw" class="fr"></div></div>
|
||||
</section>
|
||||
<div class="buttons">
|
||||
<input id="ok-details" type="button" value="OK" class="ctr" />
|
||||
<input id="ok-details" type="button" value="Back" class="btn btn-success" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="diag-disconnect" class="diag-box">
|
||||
<div class="diag-box-win">
|
||||
<p>Are you sure you would like to disconnect from this wifi?</p>
|
||||
<div class="buttons">
|
||||
<input id="no-disconnect" type="button" value="No" />
|
||||
<input id="yes-disconnect" type="button" value="Yes" />
|
||||
<input id="no-disconnect" type="button" value="No" class="btn btn-success" />
|
||||
<input id="yes-disconnect" type="button" value="Yes" class="btn btn-danger" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -143,71 +148,92 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="tab-startup">
|
||||
<h2>Run squeezelite automatically at boot</h2>
|
||||
<div id="autoexec" class="toggle">
|
||||
<label>
|
||||
<input id="autoexec-cb" type="checkbox" checked="checked" onclick='handleClick(this);'/><span class="slider"></span>
|
||||
</label>
|
||||
<h1>Run squeezelite automatically at boot</h1>
|
||||
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="autoexec-cb" checked="checked">
|
||||
<label class="custom-control-label" for="autoexec-cb"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="tab-audio">
|
||||
<div id="autoexec-command">
|
||||
<div id="audioout" class="toggle-buttons">
|
||||
<h2>Audio output</h2>
|
||||
<input type="radio" id="i2s" name="audio" checked='checked' />
|
||||
<label for="i2s">I2S</label>
|
||||
<input type="radio" id="spdif" name="audio" />
|
||||
<label for="spdif">SPDIF</label>
|
||||
<input type="radio" id="bt" name="audio" />
|
||||
<label for="bt">Bluetooth</label>
|
||||
<div id="audioout">
|
||||
<h1>Audio output</h1>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="i2s" name="audio" class="custom-control-input" checked='checked' />
|
||||
<label for="i2s" class="custom-control-label">I2S</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="spdif" name="audio" class="custom-control-input" />
|
||||
<label for="spdif" class="custom-control-label">SPDIF</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input type="radio" id="bt" name="audio" class="custom-control-input" />
|
||||
<label for="bt" class="custom-control-label">Bluetooth</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="btsinkdiv">
|
||||
<input id="btsink" type="text" value="BT sink name" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Player name</h2>
|
||||
<input id="player" type="text" value="squeezelite" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Optional setting (e.g. for LMS IP address)</h2>
|
||||
<input id="optional" type="text" value="" placeholder="-s 192.168.0.1" />
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
<input id="generate-command" type="button" value="Generate" />
|
||||
</div>
|
||||
|
||||
<h2>Squeezelite command to run</h2>
|
||||
<section id="command-list">
|
||||
<textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -M esp32</textarea>
|
||||
</section>
|
||||
</div>
|
||||
<div id="btsinkdiv">
|
||||
<input id="btsink" type="text" value="BT sink name" />
|
||||
</div>
|
||||
<div>
|
||||
<h1>Player name</h1>
|
||||
<input id="player" type="text" value="squeezelite" />
|
||||
</div>
|
||||
<div>
|
||||
<h1>Optional setting (e.g. for LMS IP address)</h1>
|
||||
<input id="optional" type="text" value="" placeholder="-s 192.168.0.1" />
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
<input id="generate-command" type="button" class="btn btn-success" value="Generate" />
|
||||
</div>
|
||||
|
||||
<h1>Squeezelite command to run</h1>
|
||||
<section id="command-list">
|
||||
<textarea id="autoexec1" maxlength="120">squeezelite -o I2S -b 500:2000 -d all=info -M esp32</textarea>
|
||||
</section>
|
||||
<div class="buttons">
|
||||
<input id="save-autoexec1" type="button" class="btn btn-success" value="Save" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="tab-gpio">
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="tab-system">
|
||||
<div id="recoverydiv">
|
||||
<h2>Check for firmware upgrade</h2>
|
||||
<h1>Check for firmware upgrade</h1>
|
||||
<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>
|
||||
<input type="button" id="fwcheck" class="btn btn-info" value="Update" />
|
||||
</div>
|
||||
<h2>Reboot to recovery system to perform firmware upgrade</h2>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Firmware version</th>
|
||||
<th scope="col">IDF version</th>
|
||||
<th scope="col">HW platform</th>
|
||||
<th scope="col">Branch</th>
|
||||
<th scope="col">Flash this FW</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="releaseTable">
|
||||
</tbody>
|
||||
</table>
|
||||
<h1>Reboot to recovery system to perform firmware upgrade</h1>
|
||||
<div class="buttons">
|
||||
<input type="button" id="recovery" value="Recovery" onclick='handleClick(this);' />
|
||||
<input type="button" id="recovery" class="btn btn-warning" value="Recovery" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="otadiv">
|
||||
<header><h1>Firmware upgrade</h1></header>
|
||||
<form name="multipart" action="otaform" method="post" enctype="multipart/form-data" onsubmit="do_upload(this); return false;">
|
||||
<progress id="progr" value="0" max="100" >Upload Progress</progress>
|
||||
<input type="file" name="ota" id="ota" size="20" accept=".bin" onchange="file_change();">
|
||||
<span id="file_info"></span>
|
||||
<input type="submit" id="update" disabled="" value="Upload">
|
||||
</form>
|
||||
<h2>Reboot system with new firmware</h2>
|
||||
<h1>Reboot system with new firmware</h1>
|
||||
<div class="buttons">
|
||||
<input type="button" id="reboot" value="Reboot" onclick='handleClick(this);' />
|
||||
<input type="button" id="reboot" class="btn btn-warning" value="Reboot" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user