ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/html/ota.html

210 lines
5.6 KiB
HTML
Raw Normal View History

2024-01-01 09:38:14 +00:00
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<form method="POST" action="#" enctype="multipart/form-data" id="upload_form">
<h1>ESPMega PRO</h1>
<h3>Device Information</h3>
<p style="text-align: left">
Hostname
2024-05-18 09:17:12 +00:00
<span style="float: right" id="hostname">Loading ...</span>
2024-01-01 09:38:14 +00:00
</p>
<p style="text-align: left">
IP Address
2024-05-18 09:17:12 +00:00
<span style="float: right" id="ip_address">Loading ...</span>
2024-01-01 09:38:14 +00:00
</p>
<p style="text-align: left">
MAC Address
2024-05-18 09:17:12 +00:00
<span style="float: right" id="mac_address">Loading ...</span>
2024-01-01 09:38:14 +00:00
</p>
<p style="text-align: left">
2024-05-18 09:17:12 +00:00
Model
<span style="float: right" id="model">Loading ...</span>
</p>
<p style="text-align: left">
FW Version
<span style="float: right" id="fw_version">Loading ...</span>
</p>
<p style="text-align: left">
SDK Version
<span style="float: right" id="sdk_version">Loading ...</span>
</p>
<p style="text-align: left">
IDF Version
<span style="float: right" id="idf_version">Loading ...</span>
2024-01-01 09:38:14 +00:00
</p>
<p style="text-align: left">
API Server
2024-05-18 09:17:12 +00:00
<span style="float: right" id="api_server">Loading ...</span>
2024-01-01 09:38:14 +00:00
</p>
<p style="text-align: left">
API Endpoint
2024-05-18 09:17:12 +00:00
<span style="float: right" id="api_endpoint">Loading ...</span>
2024-01-01 09:38:14 +00:00
</p>
<p style="text-align: left">
Centrally Managed
2024-05-18 09:17:12 +00:00
<span style="float: right" id="centrally_managed">Loading ...</span>
2024-01-01 09:38:14 +00:00
</p>
<button type="button" class="conf" onclick="window.location.href='config'">Settings</button><br /><br />
<hr>
<h3>Upload Software Package</h3>
2024-01-15 08:19:49 +00:00
<input type="file" name="update" id="file" onchange="sub(this)" style="display: none" accept=".bin" />
2024-01-01 09:38:14 +00:00
<label id="file-input" for="file">Choose file...</label>
<input type="submit" class="btn" value="Program" /><br /><br />
<div id="prg"></div>
<br />
<div id="prgbar">
<div id="bar"></div>
</div>
<br />
2024-02-08 11:36:57 +00:00
<hr>
<h3>Device Control</h3>
<input type="button" class="btn" value="Reboot" onclick="window.location.href='/reboot'" />
2024-01-01 09:38:14 +00:00
<b>SIWAT SYSTEM 2023</b>
</form>
<script>
2024-05-18 20:03:22 +00:00
window.onload =function () {
2024-05-18 09:17:12 +00:00
fetch("/get_device_info")
.then(response => response.json())
.then(data => {
console.log(data);
document.getElementById("hostname").innerHTML = data.hostname;
document.getElementById("ip_address").innerHTML = data.ip_address;
document.getElementById("mac_address").innerHTML = data.mac_address;
document.getElementById("model").innerHTML = data.model;
2024-05-18 20:03:22 +00:00
document.getElementById("software_version").innerHTML = data.fw_version;
2024-05-18 09:17:12 +00:00
document.getElementById("sdk_version").innerHTML = data.sdk_version;
document.getElementById("idf_version").innerHTML = data.idf_version;
2024-05-18 09:24:01 +00:00
document.getElementById("api_server").innerHTML = data.api_server + ":" + data.api_port;
2024-05-18 09:17:12 +00:00
document.getElementById("api_endpoint").innerHTML = data.api_endpoint;
document.getElementById("centrally_managed").innerHTML = data.centrally_managed;
}).catch(error => {
console.error(error);
});
2024-05-18 20:03:22 +00:00
};
2024-01-01 09:38:14 +00:00
function sub(obj) {
var fileName = obj.value.split("\\");
document.getElementById("file-input").innerHTML =
" " + fileName[fileName.length - 1];
}
$("form").submit(function (e) {
e.preventDefault();
var form = $("#upload_form")[0];
var data = new FormData(form);
$.ajax({
2024-01-01 15:13:54 +00:00
url: "/ota_update",
2024-01-01 09:38:14 +00:00
type: "POST",
data: data,
contentType: false,
processData: false,
xhr: function () {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener(
"progress",
function (evt) {
if (evt.lengthComputable) {
var per = evt.loaded / evt.total;
if (Math.round(per * 100) < 100) {
$("#prg").html("Updating . . . (" + Math.round(per * 100) + "%)");
}
else {
$("#prg").html("Update Completed, Rebooting . . .");
}
$("#bar").css("width", Math.round(per * 100) + "%");
}
},
false
);
return xhr;
},
success: function (d, s) {
console.log("success!");
},
error: function (a, b, c) { },
});
});
</script>
<style>
hr {
display: block;
color: #aaaaaa;
background-color: #aaaaaa;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 0px;
height: 3px;
}
#file-input,
input {
width: 100%;
height: 44px;
border-radius: 4px;
margin: 10px auto;
font-size: 15px;
}
input {
background: #f1f1f1;
border: 0;
padding: 0 15px;
}
body {
background-image: url("https://fs.siwatsystem.com/arona_bg.png");
background-size: cover;
font-family: sans-serif;
font-size: 14px;
color: #777;
}
#file-input {
background-color: #CCCCCC;
color: #5E5E5E;
padding: 0;
border: 1px solid #ddd;
line-height: 44px;
text-align: center;
display: block;
cursor: pointer;
}
#bar,
#prgbar {
background-color: #D9D9D9;
border-radius: 10px;
}
#bar {
background-color: #29CD1F;
width: 0%;
height: 10px;
}
form {
background: rgba(255, 255, 255, 0.95);
max-width: 258px;
margin: 75px auto;
padding: 30px;
border-radius: 15px;
text-align: center;
}
.btn {
background: #CA3D3D;
color: #fff;
cursor: pointer;
}
.conf {
background: #417df3;
color: #fff;
cursor: pointer;
width: 100%;
height: 44px;
border-radius: 4px;
margin: 10px auto;
font-size: 15px;
border: 0;
}
</style>