play with config page

This commit is contained in:
Empire 2023-12-19 10:45:56 +01:00
parent 303bdd131f
commit 066b3ec24f
2 changed files with 65 additions and 9 deletions

View File

@ -1,15 +1,72 @@
<html> <html>
<meta> <meta>
<script src="ota.js"></script> <script src="ota.js"></script>
</meta> <script src="jsoneditor.js"></script>
<body> </meta>
<h2>firmeware OTA v3</h2>
<form id="upload_form" method="post"> <body>
<h2>firmeware OTA v3</h2>
<form id="upload_form" method="post">
<input type="file" name="file1" id="file1" onchange="uploadFile()"><br> <input type="file" name="file1" id="file1" onchange="uploadFile()"><br>
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress> <progress id="progressBar" value="0" max="100" style="width:300px;"></progress>
<h3 id="status"></h3> <h3 id="status"></h3>
<h3 id="answer"></h3> <h3 id="answer"></h3>
<p id="loaded_n_total"></p> <p id="loaded_n_total"></p>
</form> </form>
</body>
<h2>config</h2>
<div id="editor_holder" data-theme="html" class="je-ready">
</div>
<button id="submit">Submit (console.log)</button>
<script>
// Initialize the editor with a JSON schema
var editor = new JSONEditor(document.getElementById('editor_holder'),{
schema: {
type: "object",
title: "Car",
properties: {
make: {
type: "string",
enum: [
"Toyota",
"BMW",
"Honda",
"Ford",
"Chevy",
"VW"
]
},
model: {
type: "string"
},
year: {
type: "integer",
enum: [
1995,1996,1997,1998,1999,
2000,2001,2002,2003,2004,
2005,2006,2007,2008,2009,
2010,2011,2012,2013,2014
],
default: 2008
},
safety: {
type: "integer",
format: "rating",
maximum: "5",
exclusiveMaximum: false,
readonly: false
}
}
}
});
// Hook up the submit button to log to the console
document.getElementById('submit').addEventListener('click',function() {
// Get the value from the editor
console.log(editor.getValue());
});
</script>
</body>
</html> </html>

View File

@ -30,7 +30,6 @@ pub fn httpd(initial_config:bool) -> EspHttpServer<'static> {
response.write(include_bytes!("ota.js"))?; response.write(include_bytes!("ota.js"))?;
return Ok(()) return Ok(())
}).unwrap(); }).unwrap();
server server
.fn_handler("/ota", Method::Post, |mut request| { .fn_handler("/ota", Method::Post, |mut request| {
let ota = OtaUpdate::begin(); let ota = OtaUpdate::begin();