add emergency recovery/reboot button (no JS)

This commit is contained in:
Christian Herzog
2019-10-02 18:36:06 +02:00
parent a5bd1b584e
commit 1547f89a4b
3 changed files with 40 additions and 30 deletions

View File

@@ -528,8 +528,10 @@ function checkStatus(){
$('a[href^="#tab-audio"]').hide(); $('a[href^="#tab-audio"]').hide();
$('a[href^="#tab-gpio"]').hide(); $('a[href^="#tab-gpio"]').hide();
$('a[href^="#tab-nvs"]').show(); $('a[href^="#tab-nvs"]').show();
$( "footer.footer" ).removeClass('sl'); $("footer.footer").removeClass('sl');
$( "footer.footer" ).addClass('recovery'); $("footer.footer").addClass('recovery');
$("#boot-button").html('Reboot');
$("#boot-form").attr('action', '/reboot.json');
enableStatusTimer = true; enableStatusTimer = true;
} else { } else {
recovery = false; recovery = false;
@@ -537,8 +539,10 @@ function checkStatus(){
$('a[href^="#tab-audio"]').show(); $('a[href^="#tab-audio"]').show();
$('a[href^="#tab-gpio"]').show(); $('a[href^="#tab-gpio"]').show();
$('a[href^="#tab-nvs"]').hide(); $('a[href^="#tab-nvs"]').hide();
$( "footer.footer" ).removeClass('recovery'); $("footer.footer").removeClass('recovery');
$( "footer.footer" ).addClass('sl'); $("footer.footer").addClass('sl');
$("#boot-button").html('Recovery');
$("#boot-form").attr('action', '/recovery.json');
enableStatusTimer = false; enableStatusTimer = false;
} }
} }
@@ -567,7 +571,7 @@ function checkStatus(){
blockAjax = false; blockAjax = false;
}) })
.fail(function() { .fail(function() {
//don't do anything, the server might be down while esp32 recalibrates radio blockAjax = false;
}); });
} }
@@ -585,32 +589,28 @@ function getConfig() {
$("input#autoexec1").val(data["autoexec1"]); $("input#autoexec1").val(data["autoexec1"]);
} }
if (recovery) { $("tbody#nvsTable").append(
$("tbody#nvsTable").append( "<tr>"+
"<tr>"+ "<td>"+key+"</td>"+
"<td>"+key+"</td>"+ "<td class='value'>"+
"<td class='value'>"+ "<input type='text' class='form-control nvs' id='"+key+"'>"+
"<input type='text' class='form-control nvs' id='"+key+"'>"+ "</td>"+
"</td>"+ "</tr>"
"</tr>" );
); $("input#"+key).val(data[key]);
$("input#"+key).val(data[key]); console.log(key+": "+data[key]); //TODO
console.log("#"+key, data[key]);
}
} }
} }
if (recovery) { $("tbody#nvsTable").append(
$("tbody#nvsTable").append( "<tr>"+
"<tr>"+ "<td>"+
"<td>"+ "<input type='text' class='form-control' id='nvs-new-key' placeholder='new key'>"+
"<input type='text' class='form-control' id='nvs-new-key' placeholder='new key'>"+ "</td>"+
"</td>"+ "<td>"+
"<td>"+ "<input type='text' class='form-control' id='nvs-new-value' placeholder='new value'>"+
"<input type='text' class='form-control' id='nvs-new-value' placeholder='new value'>"+ "</td>"+
"</td>"+ "</tr>"
"</tr>" );
);
}
}) })
.fail(function() { .fail(function() {
console.log("failed to fetch config!"); console.log("failed to fetch config!");

View File

@@ -260,6 +260,11 @@
</div> </div>
<div class="tab-pane fade" id="tab-system"> <div class="tab-pane fade" id="tab-system">
<div id="boot-div">
<form id="boot-form" action="/recovery.json" method="post" target="dummyframe">
<button id="boot-button" type="submit" class="btn btn-primary">Recovery</button>
</form>
</div>
<h1>Check for firmware upgrade</h1> <h1>Check for firmware upgrade</h1>
<div class="buttons"> <div class="buttons">
<input type="button" id="fwcheck" class="btn btn-info" value="Check for updates" /> <input type="button" id="fwcheck" class="btn btn-info" value="Check for updates" />
@@ -294,7 +299,7 @@
<div class="tab-pane fade" id="tab-credits"> <div class="tab-pane fade" id="tab-credits">
<section> <section>
<p><strong>squeezelite-esp32</strong>, &copy; 2019, philippe44, sle118, daduke<br />Licender under ???</p> <p><strong>squeezelite-esp32</strong>, &copy; 2019, philippe44, sle118, daduke<br />Licensed under the GPL</p>
<p> <p>
This app would not be possible without the following libraries: This app would not be possible without the following libraries:
</p> </p>
@@ -309,5 +314,6 @@
</div> </div>
<footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer> <footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer>
<iframe width="0" height="0" border="0" name="dummyframe" id="dummyframe"></iframe>
</body> </body>
</html> </html>

View File

@@ -327,3 +327,7 @@ span#flash-status {
td.value { td.value {
width: 80%; width: 80%;
} }
#boot-div {
float: right;
}