mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2026-01-04 15:48:53 +03:00
Improve file server (#1785)
* . * . * . * . * . * . * . Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
@@ -1,18 +1,43 @@
|
||||
<html>
|
||||
<head>
|
||||
<link href="firework.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="jquery-3.6.0.min.js"></script>
|
||||
<script type="text/javascript" src="firework.js"></script>
|
||||
<link href="/fileserver/html/firework.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="/fileserver/html/jquery-3.6.0.min.js"></script>
|
||||
<script type="text/javascript" src="/fileserver/html/firework.js"></script>
|
||||
<style>
|
||||
#files_table {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#files_table td, #files_table th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#files_table tr:nth-child(even){
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
#files_table tr:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
#files_table th {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
text-align: left;
|
||||
background-color: #0011ff;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
</body>
|
||||
<table class="fixed" border="0" style="font-family: arial">
|
||||
<col width="300px" /><col width="200px" />
|
||||
<table class="fixed" border="0" width=100% style="font-family: arial">
|
||||
<tr><td>
|
||||
<h2>ESP32 File Server</h2>
|
||||
</td><td>
|
||||
<button id="dirup" type="button" onclick="dirup()">Directory up</button>
|
||||
<h2>Content on SD-Card</h2>
|
||||
</td>
|
||||
<td>
|
||||
<td rowspan="2" width="500px">
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>
|
||||
@@ -35,6 +60,11 @@
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span id="currentpath"></span> <button id="dirup" type="button" onclick="dirup()" disabled>🠑 Directory up</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript" src="/fileserver/html/common.js">
|
||||
@@ -59,6 +89,7 @@ function dirup() {
|
||||
found = zw;
|
||||
}
|
||||
var res = str.substring(0, found+1);
|
||||
|
||||
window.location.href = res;
|
||||
}
|
||||
|
||||
@@ -111,6 +142,31 @@ function upload() {
|
||||
xhttp.send(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkAtRootLevel(res) {
|
||||
if (getPath() == "/fileserver/") { // Already at root level
|
||||
document.getElementById("dirup").disabled = true;
|
||||
console.log("Already on sd-card root level!");
|
||||
return true;
|
||||
}
|
||||
|
||||
document.getElementById("dirup").disabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getPath() {
|
||||
return window.location.pathname.replace(/\/+$/, '') + "/"
|
||||
}
|
||||
|
||||
checkAtRootLevel();
|
||||
|
||||
console.log("Current path: " + getPath().replace("/fileserver", ""));
|
||||
document.getElementById("currentpath").innerHTML = "Current path: <b>" + getPath().replace("/fileserver", "") + "</b>";
|
||||
|
||||
document.cookie = "page=" + getPath() + "; path=/";
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
@@ -18,7 +18,7 @@
|
||||
<script>
|
||||
async function loadPage(page) {
|
||||
console.log("loadPage(" + page + ")");
|
||||
document.cookie = "page="+page;
|
||||
document.cookie = "page="+page + "; path=/";
|
||||
document.getElementById('maincontent').src = page;
|
||||
|
||||
[].forEach.call(document.querySelectorAll('.submenu'), function (el) {
|
||||
@@ -108,7 +108,7 @@
|
||||
LoadWebUiVersion();
|
||||
|
||||
if (getCookie("page") == "" || getCookie("page") == "reboot_page.html") {
|
||||
document.cookie = "page=overview.html";
|
||||
document.cookie = "page=overview.html" + "; path=/";
|
||||
}
|
||||
console.log("Loading page: " + getCookie("page"));
|
||||
document.getElementById('maincontent').src = getCookie("page");
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
Then pick the <i><span style="font-family:monospace">AI-on-the-edge-device__update__*.zip</span></i> file!</p>
|
||||
<p>Alternatively you can use a file in the following format:</p>
|
||||
<ul>
|
||||
<li><span style="font-family:monospace">AI-on-the-edge-device__update__*.zip</span></li>
|
||||
<li><span style="font-family:monospace">AI-on-the-edge-device__firmware__*.bin</span></li>
|
||||
<li><span style="font-family:monospace">*.zip</span></li>
|
||||
<li><span style="font-family:monospace">*.bin</span></li>
|
||||
<li><span style="font-family:monospace">*.tfl/tflite</span></li>
|
||||
</ul>
|
||||
<p>Make sure the file extention is lower case.</p>
|
||||
@@ -183,7 +183,7 @@
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
document.cookie = "page=overview.html"; // Make sure after the reboot we go to the overview page
|
||||
document.cookie = "page=overview.html" + "; path=/"; // Make sure after the reboot we go to the overview page
|
||||
|
||||
if (xhttp.responseText.startsWith("reboot")) { // Reboot required
|
||||
console.log("Upload completed, the device will now restart and install the update!");
|
||||
|
||||
@@ -59,7 +59,7 @@ if (!file.name.includes("remote-setup")){
|
||||
document.getElementById("status").innerText = "Status: Update completed!";
|
||||
document.getElementById("doUpdate").disabled = true;
|
||||
document.getElementById("newfile").disabled = false;
|
||||
document.cookie = "page=overview.html"; // Make sure after the reboot we go to the overview page
|
||||
document.cookie = "page=overview.html" + "; path=/"; // Make sure after the reboot we go to the overview page
|
||||
|
||||
if (xhttp.responseText.startsWith("reboot"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user