flask_inference_api3 / settings.html
DmitrMakeev's picture
Update settings.html
68fb27d verified
raw
history blame
5.31 kB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>My static Space</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
-webkit-appearance: inner-spin-button;
opacity: 1;
}
input[type="number"] {
-moz-appearance: textfield;
}
</style>
</head>
<body>
<div class="container mt-3">
<div class="container text-center">
<h1>Настройки системы</h1>
</div>
<!-- Уровень - PH -->
<br>
<h4>Уровень pH</h4>
<p>EEPROM : <span id="pH_eep"></span></p>
<form>
<label for="pH_set">Новое : </label>
<input type="number" id="pH_set" value="5.6" min="1" max="14" step="0.01">
</form>
<button id="pH_set_but" type="button" class="btn btn-primary">Записать</button>
<!-- PH ON - sec -->
<br><br>
<h4>pH доз. ON sec.</h4>
<p>EEPROM : <span id="ph_on_eep"></span></p>
<form>
<label for="ph_on_set">Новое : </label>
<input type="number" id="ph_on_set" value="2.5" min="0.1" max="20" step="0.01">
</form>
<!-- Уровень - EC -->
<br><br>
<h4>Уровень EC</h4>
<p>EEPROM : <span id="ec_eep"></span></p>
<form>
<label for="ec_set">Новое : </label>
<input type="number" id="ec_set" value="0.85" min="0.1" max="4" step="0.01">
</form>
<button id="ec_set_but" type="button" class="btn btn-primary">Записать</button>
<!-- EC доз. A_ON sec. -->
<br>
<h4>EC доз. A_ON sec.</h4>
<p>EEPROM : <span id="ec_A_eep"></span></p>
<form>
<label for="ec_A_set">Новое : </label>
<input type="number" id="ec_A_set" value="1.5" min="0.1" max="20" step="0.01">
</form>
<br>
<h4>EC доз. B_ON sec.</h4>
<p>EEPROM : <span id="ec_B_eep"></span></p>
<form>
<label for="ec_B_set">Новое : </label>
<input type="number" id="ec_B_set" value="1.5" min="0.1" max="20" step="0.01">
</form>
<br>
<h4>EC доз. C_ON sec.</h4>
<p>EEPROM : <span id="ec_C_eep"></span></p>
<form>
<label for="ec_C_set">Новое : </label>
<input type="number" id="ec_C_set" value="1.5" min="0.1" max="20" step="0.01">
</form>
<br>
<h4>Свет ON </h4>
<p>EEPROM: <span id="l_ON_h_eep"></span> : <span id="l_ON_m_eep"></span></p>
<form>
<label for="l_ON_h_set">Новое h : </label>
<input type="number" id="l_ON_h_set" value="12" min="0" max="23" step="1">
</form>
<form>
<label for="l_ON_m_set">Новое m : </label>
<input type="number" id="l_ON_m_set" value="30" min="0" max="59" step="1">
</form>
<br>
<h4>Свет OFF </h4>
<p>EEPROM: <span id="l_OFF_h_eep"></span> : <span id="l_OFF_m_eep"></span></p>
<form>
<label for="l_OFF_h_set">Новое h : </label>
<input type="number" id="l_OFF_h_set" value="12" min="0" max="23" step="1">
</form>
<form>
<label for="l_OFF_m_set">Новое m : </label>
<input type="number" id="l_OFF_m_set" value="30" min="0" max="59" step="1">
</form>
<br>
<h4>Тем. воздуха</h4>
<p>EEPROM : <span id="t_Voz_eep"></span></p>
<form>
<label for="t_Voz_eep_set">Новое : </label>
<input type="number" id="t_Voz_eep_set" value="25" min="10" max="40" step="1">
</form>
</div>
<script>
function updateValues(data) {
document.getElementById("pH_eep").textContent = data.ph_eep;
document.getElementById("ph_on_eep").textContent = data.ph_on_eep;
document.getElementById("ec_eep").textContent = data.ec_eep;
document.getElementById("ec_A_eep").textContent = data.ec_A_eep;
document.getElementById("ec_B_eep").textContent = data.ec_B_eep;
document.getElementById("ec_C_eep").textContent = data.ec_C_eep;
document.getElementById("l_ON_h_eep").textContent = data.l_ON_h_eep;
document.getElementById("l_ON_m_eep").textContent = data.l_ON_m_eep;
document.getElementById("l_OFF_h_eep").textContent = data.l_OFF_h_eep;
document.getElementById("l_OFF_m_eep").textContent = data.l_OFF_m_eep;
document.getElementById("t_Voz_eep").textContent = data.t_Voz_eep;
}
function fetchValues() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "/settings_api", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
updateValues(response);
}
};
xhr.send();
}
fetchValues();
setInterval(fetchValues, 10000);
</script>
<script>
document.getElementById("pH_set_but").addEventListener("click", function() {
var pHValue = document.getElementById("pH_set").value;
var xhr = new XMLHttpRequest();
xhr.open("GET", "/pH_set?value=" + pHValue, true);
xhr.send();
});
</script>
<script>
document.getElementById("ed_set_but").addEventListener("click", function() {
var ecValue = document.getElementById("ec_set").value;
var xhr = new XMLHttpRequest();
xhr.open("GET", "/EC_set?value=" + ecValue, true);
xhr.send();
});
</script>
</body>
</html>