init
This commit is contained in:
35
static/config.html
Normal file
35
static/config.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>P80 printer webpage configuration</title>
|
||||
<script src="static/config.js"></script>
|
||||
</head>
|
||||
|
||||
<body onload="render_config();">
|
||||
<div class="navbar">
|
||||
<ul>
|
||||
<a href="/">Print</a>
|
||||
<a href="/config">Configuration</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="container" display="block">
|
||||
<form>
|
||||
<label for="address">Address:</label><br>
|
||||
<input type="text" id="address" name="address" title="Printer network address (ip/hostname)"
|
||||
maxlength="30"><br>
|
||||
|
||||
<label for="port">Port:</label><br>
|
||||
<input type="text" id="port" name="port" pattern="\d{1,5}" title="Port number (9100 by default)"><br>
|
||||
|
||||
<label for="profile">Profile:</label><br>
|
||||
<input type="text" id="profile" name="profile" title="Printer profile, fixed value for now" readonly><br>
|
||||
</form>
|
||||
<button type="submit" onclick="send_config()">Update config</button>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
36
static/config.js
Normal file
36
static/config.js
Normal file
@@ -0,0 +1,36 @@
|
||||
async function get_config() {
|
||||
response = await fetch("/config", {method: "GET", headers: {"Accept": "application/json"}})
|
||||
if (! response.ok){
|
||||
throw Error("config data request error: " + await response.text())
|
||||
}
|
||||
return response.json()
|
||||
}
|
||||
|
||||
async function render_config(){
|
||||
params = await get_config()
|
||||
for (par of Object.keys(params)) {
|
||||
if (params.par == null) {
|
||||
params.par = ""
|
||||
}
|
||||
}
|
||||
const {address, port, profile} = params
|
||||
document.getElementById("address").value = address
|
||||
document.getElementById("port").value = port
|
||||
document.getElementById("profile").value = profile
|
||||
}
|
||||
|
||||
async function send_config() {
|
||||
address_value = document.getElementById("address").value
|
||||
port_value = document.getElementById("port").value
|
||||
if (port_value == ""){
|
||||
port_value = null
|
||||
}
|
||||
else{
|
||||
port_value = parseInt(port_value)
|
||||
}
|
||||
|
||||
|
||||
response = await fetch("/config", {method: "POST", headers: {"Accept": "application/json", "Content-Type": "application/json"},
|
||||
body: JSON.stringify({"address": address_value, "port": port_value, })})
|
||||
document.location.reload()
|
||||
}
|
||||
22
static/index.html
Normal file
22
static/index.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>P80 printer webpage</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="navbar">
|
||||
<ul>
|
||||
<a href="/">Print</a>
|
||||
<a href="/config">Configuration</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="container" display="block">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
0
static/index.js
Normal file
0
static/index.js
Normal file
0
static/style.css
Normal file
0
static/style.css
Normal file
Reference in New Issue
Block a user