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,7 +1,9 @@
<html>
<meta>
<script src="ota.js"></script>
<script src="jsoneditor.js"></script>
</meta>
<body>
<h2>firmeware OTA v3</h2>
<form id="upload_form" method="post">
@ -11,5 +13,60 @@
<h3 id="answer"></h3>
<p id="loaded_n_total"></p>
</form>
<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>

View File

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