Check web UI version and show alert on mismatch with Firmware version (#1329)

* SHhw Web UI version and compare it with the firmware. If it does not match, show a warning in the log

* compare version on Web UI loading and show alert on mismatch

* restructured info page
This commit is contained in:
CaCO3
2022-11-14 19:58:22 +01:00
committed by GitHub
parent 395b9a4c5b
commit 39960b15ed
4 changed files with 135 additions and 86 deletions

View File

@@ -31,26 +31,72 @@ function LoadHostname() {
}
function LoadVersion() {
var fwVersion = "";
var webUiVersion = "";
function LoadFwVersion() {
_basepath = getbasepath();
var xhttp = new XMLHttpRequest();
xhttp.addEventListener('load', function(event) {
if (xhttp.status >= 200 && xhttp.status < 300) {
version = xhttp.responseText;
document.getElementById("Version").innerHTML = version;
fwVersion = xhttp.responseText;
document.getElementById("Version").innerHTML = fwVersion;
console.log(fwVersion);
compareVersions();
}
else {
console.warn(request.statusText, request.responseText);
console.warn(request.statusText, request.responseText);
fwVersion = "NaN";
}
});
try {
url = _basepath + '/version?type=GitBaseBranch';
xhttp.open("GET", url, true);
xhttp.send();
url = _basepath + '/version?type=GitBaseBranch';
xhttp.open("GET", url, true);
xhttp.send();
}
catch (error) {
fwVersion = "NaN";
}
}
function LoadWebUiVersion() {
_basepath = getbasepath();
var xhttp = new XMLHttpRequest();
xhttp.addEventListener('load', function(event) {
if (xhttp.status >= 200 && xhttp.status < 300) {
webUiVersion = xhttp.responseText;
console.log("Web UI Version: " + webUiVersion);
compareVersions();
}
else {
console.warn(request.statusText, request.responseText);
webUiVersion = "NaN";
}
});
try {
url = _basepath + '/version?type=HTMLVersion';
xhttp.open("GET", url, true);
xhttp.send();
}
catch (error) {
webUiVersion = "NaN";
}
}
function compareVersions() {
if (fwVersion == "" || webUiVersion == "") {
return;
}
arr = fwVersion.split(" ");
fWGitHash = arr[arr.length - 1].substring(0, 7);
if (fWGitHash != webUiVersion) {
alert("The Version of the Web Interface does not match the Firmware Version!");
}
catch (error)
{}
}

View File

@@ -83,7 +83,8 @@
<script type="text/javascript">
LoadHostname();
LoadVersion();
LoadFwVersion();
LoadWebUiVersion();
</script>
</div>

View File

@@ -37,13 +37,10 @@ div {
</div>
</td>
</tr>
</table>
</table>
<table style="font-family: arial">
<h3>Host Info</h3>
<table style="font-family: arial">
<tr>
<td>
@@ -77,8 +74,64 @@ div {
</tr>
</table>
<h3>Version Info</h3>
<table style="font-family: arial">
<tr>
<td>
Git-Branch:
</td>
<td>
<div id="gitbranch">
<object data="/version?type=GitBranch"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Tag:
</td>
<td>
<div>
<object data="/version?type=GitTag"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Revision:
</td>
<td>
<div>
<object data="/version?type=GitRevision"></object>
</div>
</td>
</tr>
<tr>
<td>
Build Time:
</td>
<td>
<div>
<object data="/version?type=BuildTime"></object>
</div>
</td>
</tr>
<tr>
<td>
HTML Version:
</td>
<td>
<div>
<object data="/version?type=HTMLVersion"></object>
</div>
</td>
</tr>
</table>
<h3>SD Card Info</h3>
<table style="font-family: arial">
<tr>
@@ -153,67 +206,6 @@ div {
</tr>
</table>
<table style="font-family: arial">
<h3>Version Info</h3>
<table style="font-family: arial">
<tr>
<td>
Git-Branch:
</td>
<td>
<div id="gitbranch">
<object data="/version?type=GitBranch"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Tag:
</td>
<td>
<div>
<object data="/version?type=GitTag"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Revision:
</td>
<td>
<div>
<object data="/version?type=GitRevision"></object>
</div>
</td>
</tr>
<tr>
<td>
Build Time:
</td>
<td>
<div>
<object data="/version?type=BuildTime"></object>
</div>
</td>
</tr>
<tr>
<td>
HTML Version:
</td>
<td>
<div>
<object data="/version?type=HTMLVersion"></object>
</div>
</td>
</tr>
</table>
<h3>Copyright</h3>
Copyright &copy; 2020 - 2022 by <a href="https://github.com/jomjol/AI-on-the-edge-device" target=_blank>Jomjol</a> and others.