mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-13 15:06:53 +03:00
Update WebUI
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
<html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xml:lang="en">
|
||||
<head>
|
||||
<link href="/firework.css?v=$COMMIT_HASH" rel="stylesheet">
|
||||
<script type="text/javascript" src="/jquery-3.6.0.min.js?v=$COMMIT_HASH"></script>
|
||||
<script type="text/javascript" src="/firework.js?v=$COMMIT_HASH"></script>
|
||||
<style>
|
||||
h1 {font-size: 2em;}
|
||||
h2 {font-size: 1.5em; margin-block-start: 0.0em; margin-block-end: 0.2em;}
|
||||
h3 {font-size: 1.2em;}
|
||||
p {font-size: 1em;}
|
||||
|
||||
#files_table {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
border-collapse: collapse;
|
||||
@@ -27,147 +33,172 @@
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
text-align: left;
|
||||
background-color: #0011ff;
|
||||
color: white;
|
||||
background-color:lightgrey;
|
||||
color: black;
|
||||
}
|
||||
|
||||
input[type=file] {
|
||||
padding: 5px 0px;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
padding: 5px 10px;
|
||||
display: inline-block;
|
||||
border: 1px solid #ccc;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.button {
|
||||
padding: 4px 10px;
|
||||
width: 100px;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
</body>
|
||||
<table class="fixed" border="0" width=100% style="font-family: arial">
|
||||
<tr><td>
|
||||
<h2>Content on SD-Card</h2>
|
||||
</td>
|
||||
<td rowspan="2" width="500px">
|
||||
<table border="0">
|
||||
|
||||
</body>
|
||||
<table class="fixed" border="0" width=100% style="font-family: arial">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="newfile">Upload a file</label>
|
||||
<td style="vertical-align: top;width: 300px;">
|
||||
<h2>Fileserver</h2>
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<input id="newfile" type="file" onchange="setpath()" style="width:100%;">
|
||||
<td rowspan="2">
|
||||
<table border="0" style="width:100%">
|
||||
<tr>
|
||||
<td style="width:80px">
|
||||
<label for="newfile">Source</label>
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<input id="newfile" type="file" onchange="setpath()" style="width:100%;">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<label for="filepath">Destination</label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="filepath" type="text" style="width:94%;">
|
||||
</td>
|
||||
<td>
|
||||
<button id="upload" type="button" class="button" onclick="upload()">Upload</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="filepath">Set path on server</label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="filepath" type="text" style="width:100%;">
|
||||
</td>
|
||||
<td>
|
||||
<button id="upload" type="button" onclick="upload()">Upload</button>
|
||||
<td colspan="2">
|
||||
<button style="font-size:16px; padding: 5px 10px" id="dirup" type="button" onclick="dirup()" disabled>🡹 Directory up</button>
|
||||
<span style="padding-left:15px" id="currentpath"></span>
|
||||
</td>
|
||||
</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="/common.js?v=$COMMIT_HASH">
|
||||
</script>
|
||||
<script language="JavaScript">
|
||||
function setpath() {
|
||||
var fileserverpraefix = "/fileserver";
|
||||
var anz_zeichen_fileserver = fileserverpraefix.length;
|
||||
var default_path = window.location.pathname.substring(anz_zeichen_fileserver) + document.getElementById("newfile").files[0].name;
|
||||
document.getElementById("filepath").value = default_path;
|
||||
}
|
||||
<script type="text/javascript" src="/common.js?v=$COMMIT_HASH">
|
||||
</script>
|
||||
<script language="JavaScript">
|
||||
function setpath() {
|
||||
var fileserverpraefix = "/fileserver";
|
||||
var anz_zeichen_fileserver = fileserverpraefix.length;
|
||||
var default_path = window.location.pathname.substring(anz_zeichen_fileserver) + document.getElementById("newfile").files[0].name;
|
||||
document.getElementById("filepath").value = default_path;
|
||||
}
|
||||
|
||||
function dirup() {
|
||||
var str = window.location.href;
|
||||
str = str.substring(0, str.length-1);
|
||||
var zw = str.indexOf("/");
|
||||
var found = zw;
|
||||
while (zw >= 0)
|
||||
{
|
||||
zw = str.indexOf("/", found+1);
|
||||
if (zw >= 0)
|
||||
found = zw;
|
||||
}
|
||||
var res = str.substring(0, found+1);
|
||||
|
||||
window.location.href = res;
|
||||
}
|
||||
|
||||
|
||||
function upload() {
|
||||
var filePath = document.getElementById("filepath").value;
|
||||
var upload_path = "/upload/" + filePath;
|
||||
var fileInput = document.getElementById("newfile").files;
|
||||
|
||||
/* Max size of an individual file. Make sure this
|
||||
* value is same as that set in file_server.c */
|
||||
var MAX_FILE_SIZE = 8000*1024;
|
||||
var MAX_FILE_SIZE_STR = "8000KB";
|
||||
|
||||
if (fileInput.length == 0) {
|
||||
firework.launch('No file selected!', 'danger', 30000);
|
||||
} else if (filePath.length == 0) {
|
||||
firework.launch('File path on server is not set!', 'danger', 30000);
|
||||
} else if (filePath.length > 100) {
|
||||
firework.launch('Filename is to long! Max 100 characters.', 'danger', 30000);
|
||||
} else if (filePath.indexOf(' ') >= 0) {
|
||||
firework.launch('File path on server cannot have spaces!', 'danger', 30000);
|
||||
} else if (filePath[filePath.length-1] == '/') {
|
||||
firework.launch('File name not specified after path!', 'danger', 30000);
|
||||
} else if (fileInput[0].size > MAX_FILE_SIZE) {
|
||||
firework.launch("File size must be less than " + MAX_FILE_SIZE_STR + "!", 'danger', 30000);
|
||||
} else {
|
||||
document.getElementById("newfile").disabled = true;
|
||||
document.getElementById("filepath").disabled = true;
|
||||
document.getElementById("upload").disabled = true;
|
||||
|
||||
var file = fileInput[0];
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
document.open();
|
||||
document.write(xhttp.responseText);
|
||||
document.close();
|
||||
} else if (xhttp.status == 0) {
|
||||
firework.launch('Server closed the connection abruptly!', 'danger', 30000);
|
||||
UpdatePage(false);
|
||||
} else {
|
||||
firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000);
|
||||
UpdatePage(false);
|
||||
}
|
||||
function dirup() {
|
||||
var str = window.location.href;
|
||||
str = str.substring(0, str.length-1);
|
||||
var zw = str.indexOf("/");
|
||||
var found = zw;
|
||||
while (zw >= 0)
|
||||
{
|
||||
zw = str.indexOf("/", found+1);
|
||||
if (zw >= 0)
|
||||
found = zw;
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", upload_path, true);
|
||||
xhttp.send(file);
|
||||
}
|
||||
}
|
||||
var res = str.substring(0, found+1);
|
||||
|
||||
window.location.href = res;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
function upload() {
|
||||
var filePath = document.getElementById("filepath").value;
|
||||
var upload_path = "/upload/" + filePath;
|
||||
var fileInput = document.getElementById("newfile").files;
|
||||
|
||||
document.getElementById("dirup").disabled = false;
|
||||
return false;
|
||||
}
|
||||
/* Max size of an individual file. Make sure this
|
||||
* value is same as that set in file_server.c */
|
||||
var MAX_FILE_SIZE = 8000*1024;
|
||||
var MAX_FILE_SIZE_STR = "8000KB";
|
||||
|
||||
if (fileInput.length == 0) {
|
||||
firework.launch('No file selected!', 'danger', 30000);
|
||||
} else if (filePath.length == 0) {
|
||||
firework.launch('File path on server is not set!', 'danger', 30000);
|
||||
} else if (filePath.length > 100) {
|
||||
firework.launch('Filename is to long! Max 100 characters.', 'danger', 30000);
|
||||
} else if (filePath.indexOf(' ') >= 0) {
|
||||
firework.launch('File path on server cannot have spaces!', 'danger', 30000);
|
||||
} else if (filePath[filePath.length-1] == '/') {
|
||||
firework.launch('File name not specified after path!', 'danger', 30000);
|
||||
} else if (fileInput[0].size > MAX_FILE_SIZE) {
|
||||
firework.launch("File size must be less than " + MAX_FILE_SIZE_STR + "!", 'danger', 30000);
|
||||
} else {
|
||||
document.getElementById("newfile").disabled = true;
|
||||
document.getElementById("filepath").disabled = true;
|
||||
document.getElementById("upload").disabled = true;
|
||||
|
||||
var file = fileInput[0];
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (xhttp.readyState == 4) {
|
||||
if (xhttp.status == 200) {
|
||||
document.open();
|
||||
document.write(xhttp.responseText);
|
||||
document.close();
|
||||
firework.launch('File upload completed', 'success', 5000);
|
||||
} else if (xhttp.status == 0) {
|
||||
firework.launch('Server closed the connection abruptly!', 'danger', 30000);
|
||||
UpdatePage(false);
|
||||
} else {
|
||||
firework.launch('An error occured: ' + xhttp.responseText, 'danger', 30000);
|
||||
UpdatePage(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", upload_path, true);
|
||||
xhttp.send(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getPath() {
|
||||
return window.location.pathname.replace(/\/+$/, '') + "/"
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
checkAtRootLevel();
|
||||
document.getElementById("dirup").disabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log("Current path: " + getPath().replace("/fileserver", ""));
|
||||
document.getElementById("currentpath").innerHTML = "Current path: <b>" + getPath().replace("/fileserver", "") + "</b>";
|
||||
|
||||
document.cookie = "page=" + getPath() + "; path=/";
|
||||
function getPath() {
|
||||
return window.location.pathname.replace(/\/+$/, '') + "/"
|
||||
}
|
||||
|
||||
</script>
|
||||
checkAtRootLevel();
|
||||
|
||||
</body>
|
||||
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>
|
||||
</html>
|
||||
Reference in New Issue
Block a user