Initial commit
This commit is contained in:
73
gardenui/static/css/style.css
Normal file
73
gardenui/static/css/style.css
Normal file
@@ -0,0 +1,73 @@
|
||||
html, body {
|
||||
font-size: 22px !important;
|
||||
font-family: arial, verdana, helvetica, sans-serif;
|
||||
color: #b6b6b6;
|
||||
background: #282929;
|
||||
}
|
||||
|
||||
h1, h2, h3 {text-align: center;}
|
||||
p {text-align: center;}
|
||||
div {text-align: center;}
|
||||
|
||||
.center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
input {
|
||||
border: 1px #999999 solid;
|
||||
background-color: #f6f6f6;
|
||||
padding: 2px 4px 2px 4px;
|
||||
margin: 0 0 0.5rem 0;
|
||||
font-size: 1.0rem;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
input[type="submit" i] {
|
||||
color: #b6b6b6;
|
||||
background-color: #282929;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-color: #b6b6b6;
|
||||
border-width: 3px;
|
||||
border-radius: 18px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.table_left {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
footer {
|
||||
position: fixed;
|
||||
/* left: 50%; */
|
||||
bottom: 20px;
|
||||
/* transform: translate(-50%, -50%); */
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
a {
|
||||
outline: none;
|
||||
color: #b6b6b6;
|
||||
text-decoration-line: none;
|
||||
}
|
||||
|
||||
select {
|
||||
color: #b6b6b6;
|
||||
background-color: #282929;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border-color: #b6b6b6;
|
||||
border-width: 3px;
|
||||
border-radius: 16px;
|
||||
font-size: 20px;
|
||||
}
|
116
gardenui/static/scripts/garden.js
Normal file
116
gardenui/static/scripts/garden.js
Normal file
@@ -0,0 +1,116 @@
|
||||
var on_switch_water = function() {
|
||||
var state = true;
|
||||
if(document.getElementById("water_switch").value == "ausschalten") {
|
||||
state = false;
|
||||
}
|
||||
var json_str = JSON.stringify({"id": "3", "waterstate": state});
|
||||
patch_sample(json_str);
|
||||
}
|
||||
|
||||
var on_switch_auto_state = function() {
|
||||
var state = true;
|
||||
if(document.getElementById("auto_switch").value == "ausschalten") {
|
||||
state = false;
|
||||
}
|
||||
var json_str = JSON.stringify({"water": {"id": "3", "autostate": state}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var on_change_config = function() {
|
||||
var on_time_one = document.getElementById("water_on_one").value;
|
||||
var off_time_one = document.getElementById("water_off_one").value;
|
||||
var on_time_two = document.getElementById("water_on_two").value;
|
||||
var off_time_two = document.getElementById("water_off_two").value;
|
||||
var json_str = JSON.stringify({"water": {"id": "3", "times": [{"on_time": on_time_one, "off_time": off_time_one}, {"on_time": on_time_two, "off_time": off_time_two}]}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var http_patch_config = new XMLHttpRequest();
|
||||
http_patch_config.onreadystatechange = function () {
|
||||
if (http_patch_config.readyState === 4) {
|
||||
var status = http_patch_config.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_config(http_patch_config.responseText);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
var patch_config = function(config) {
|
||||
http_patch_config.abort();
|
||||
http_patch_config.open("PATCH", "/config");
|
||||
http_patch_config.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
http_patch_config.send(config);
|
||||
}
|
||||
|
||||
var patch_http = new XMLHttpRequest();
|
||||
var patch_sample = function(sample) {
|
||||
patch_http.abort();
|
||||
patch_http.open("PATCH", "/sample");
|
||||
patch_http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
patch_http.send(sample);
|
||||
}
|
||||
|
||||
var parse_config = function (event) {
|
||||
var config = JSON.parse(event)
|
||||
var output = "einschalten"
|
||||
var visibility = 'hidden'
|
||||
if(config.water && config.water.id == '3') {
|
||||
if(config.water.autostate) {
|
||||
output = "ausschalten"
|
||||
visibility = "visible"
|
||||
document.getElementById("water_on_one").value = config.water.times[0].on_time;
|
||||
document.getElementById("water_off_one").value = config.water.times[0].off_time;
|
||||
document.getElementById("water_on_two").value = config.water.times[1].on_time;
|
||||
document.getElementById("water_off_two").value = config.water.times[1].off_time;
|
||||
}
|
||||
document.getElementById("auto_switch").value = output;
|
||||
document.getElementById("water_times").style.visibility = visibility
|
||||
}
|
||||
}
|
||||
|
||||
var parse_sample = function (event) {
|
||||
var sample = JSON.parse(event)
|
||||
if(sample.water && sample.water.id == '3') {
|
||||
var switch_caption = "einschalten";
|
||||
if(sample.water.state) {
|
||||
switch_caption = "ausschalten";
|
||||
}
|
||||
document.getElementById("water_switch").value = switch_caption;
|
||||
}
|
||||
}
|
||||
|
||||
var http = new XMLHttpRequest();
|
||||
http.onreadystatechange = function () {
|
||||
if (http.readyState === 4) {
|
||||
var status = http.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_sample(http.responseText);
|
||||
setTimeout(function () {
|
||||
http.open("GET", 'sample/3');
|
||||
http.send();
|
||||
}, 500);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
http.open("GET", "sample/3");
|
||||
http.send();
|
||||
|
||||
var http_get_config = new XMLHttpRequest();
|
||||
http_get_config.onreadystatechange = function () {
|
||||
if (http_get_config.readyState === 4) {
|
||||
var status = http_get_config.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_config(http_get_config.responseText);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
http_get_config.open("GET", "config/3");
|
||||
http_get_config.send();
|
176
gardenui/static/scripts/greenhouse_1.js
Normal file
176
gardenui/static/scripts/greenhouse_1.js
Normal file
@@ -0,0 +1,176 @@
|
||||
var on_switch_heat = function() {
|
||||
var state = true;
|
||||
if(document.getElementById("heat_switch").value == "ausschalten") {
|
||||
state = false;
|
||||
}
|
||||
var json_str = JSON.stringify({"id": "1", "heatstate": state});
|
||||
patch_sample(json_str);
|
||||
}
|
||||
|
||||
var on_switch_heat_autostate = function() {
|
||||
var state = true;
|
||||
if(document.getElementById("heat_auto_switch").value == "ausschalten") {
|
||||
state = false;
|
||||
}
|
||||
var json_str = JSON.stringify({"heat": {"id": "1", "autostate": state}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var on_increase_on_temperature = function() {
|
||||
var json_str = JSON.stringify({"heat": {"id": "1", "increase_on_temperature": true}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var on_increase_off_temperature = function() {
|
||||
var json_str = JSON.stringify({"heat": {"id": "1", "increase_off_temperature": true}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var on_decrease_on_temperature = function() {
|
||||
var json_str = JSON.stringify({"heat": {"id": "1", "decrease_on_temperature": true}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var on_decrease_off_temperature = function() {
|
||||
var json_str = JSON.stringify({"heat": {"id": "1", "decrease_off_temperature": true}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var on_switch_water = function() {
|
||||
var state = true;
|
||||
if(document.getElementById("water_switch").value == "ausschalten") {
|
||||
state = false;
|
||||
}
|
||||
var json_str = JSON.stringify({"id": "1", "waterstate": state});
|
||||
patch_sample(json_str);
|
||||
}
|
||||
|
||||
var on_switch_water_auto_state = function() {
|
||||
var state = true;
|
||||
if(document.getElementById("water_auto_switch").value == "ausschalten") {
|
||||
state = false;
|
||||
}
|
||||
var json_str = JSON.stringify({"water": {"id": "1", "autostate": state}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var on_change_config = function() {
|
||||
var on_time_one = document.getElementById("water_on_one").value;
|
||||
var off_time_one = document.getElementById("water_off_one").value;
|
||||
var on_time_two = document.getElementById("water_on_two").value;
|
||||
var off_time_two = document.getElementById("water_off_two").value;
|
||||
var json_str = JSON.stringify({"water": {"id": "1", "times": [{"on_time": on_time_one, "off_time": off_time_one}, {"on_time": on_time_two, "off_time": off_time_two}]}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var http_patch_config = new XMLHttpRequest();
|
||||
http_patch_config.onreadystatechange = function () {
|
||||
if (http_patch_config.readyState === 4) {
|
||||
var status = http_patch_config.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_config(http_patch_config.responseText);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
var patch_config = function(config) {
|
||||
http_patch_config.abort();
|
||||
http_patch_config.open("PATCH", "/config");
|
||||
http_patch_config.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
http_patch_config.send(config);
|
||||
}
|
||||
|
||||
var patch_http = new XMLHttpRequest();
|
||||
var patch_sample = function(sample) {
|
||||
patch_http.abort();
|
||||
patch_http.open("PATCH", "/sample");
|
||||
patch_http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
patch_http.send(sample);
|
||||
}
|
||||
|
||||
var parse_config = function (event) {
|
||||
var config = JSON.parse(event)
|
||||
var output = "einschalten"
|
||||
var visibility = 'hidden'
|
||||
if(config.heat && config.heat.id == '1') {
|
||||
if(config.heat.autostate) {
|
||||
output = "ausschalten"
|
||||
visibility = "visible"
|
||||
document.getElementById("on_temperature").innerHTML = config.heat.on_temperature;
|
||||
document.getElementById("off_temperature").innerHTML = config.heat.off_temperature;
|
||||
}
|
||||
document.getElementById("heat_auto_switch").value = output;
|
||||
document.getElementById("config_temperatures").style.visibility = visibility
|
||||
}
|
||||
output = "einschalten"
|
||||
visibility = 'hidden'
|
||||
if(config.water && config.water.id == '1') {
|
||||
if(config.water.autostate) {
|
||||
output = "ausschalten"
|
||||
visibility = "visible"
|
||||
document.getElementById("water_on_one").value = config.water.times[0].on_time;
|
||||
document.getElementById("water_off_one").value = config.water.times[0].off_time;
|
||||
document.getElementById("water_on_two").value = config.water.times[1].on_time;
|
||||
document.getElementById("water_off_two").value = config.water.times[1].off_time;
|
||||
}
|
||||
document.getElementById("water_auto_switch").value = output;
|
||||
document.getElementById("water_times").style.visibility = visibility
|
||||
}
|
||||
}
|
||||
|
||||
var parse_sample = function (event) {
|
||||
var sample = JSON.parse(event)
|
||||
if(sample.heat && sample.heat.id == '1') {
|
||||
var switch_caption = "einschalten";
|
||||
if(sample.heat.state) {
|
||||
switch_caption = "ausschalten";
|
||||
}
|
||||
document.getElementById("heat_switch").value = switch_caption;
|
||||
}
|
||||
if(sample.temperature && sample.temperature.id == '1') {
|
||||
document.getElementById("temperature_value").innerHTML = sample.temperature.value;
|
||||
}
|
||||
if(sample.water && sample.water.id == '1') {
|
||||
var switch_caption = "einschalten";
|
||||
if(sample.water.state) {
|
||||
switch_caption = "ausschalten";
|
||||
}
|
||||
document.getElementById("water_switch").value = switch_caption;
|
||||
}
|
||||
}
|
||||
|
||||
var http = new XMLHttpRequest();
|
||||
http.onreadystatechange = function () {
|
||||
if (http.readyState === 4) {
|
||||
var status = http.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_sample(http.responseText);
|
||||
setTimeout(function () {
|
||||
http.open("GET", 'sample/1');
|
||||
http.send();
|
||||
}, 500);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
http.open("GET", "sample/1");
|
||||
http.send();
|
||||
|
||||
var http_get_config = new XMLHttpRequest();
|
||||
http_get_config.onreadystatechange = function () {
|
||||
if (http_get_config.readyState === 4) {
|
||||
var status = http_get_config.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_config(http_get_config.responseText);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
http_get_config.open("GET", "config/1");
|
||||
http_get_config.send();
|
116
gardenui/static/scripts/greenhouse_2.js
Normal file
116
gardenui/static/scripts/greenhouse_2.js
Normal file
@@ -0,0 +1,116 @@
|
||||
var on_switch_water = function() {
|
||||
var state = true;
|
||||
if(document.getElementById("water_switch").value == "ausschalten") {
|
||||
state = false;
|
||||
}
|
||||
var json_str = JSON.stringify({"id": "2", "waterstate": state});
|
||||
patch_sample(json_str);
|
||||
}
|
||||
|
||||
var on_switch_auto_state = function() {
|
||||
var state = true;
|
||||
if(document.getElementById("auto_switch").value == "ausschalten") {
|
||||
state = false;
|
||||
}
|
||||
var json_str = JSON.stringify({"water": {"id": "2", "autostate": state}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var on_change_config = function() {
|
||||
var on_time_one = document.getElementById("water_on_one").value;
|
||||
var off_time_one = document.getElementById("water_off_one").value;
|
||||
var on_time_two = document.getElementById("water_on_two").value;
|
||||
var off_time_two = document.getElementById("water_off_two").value;
|
||||
var json_str = JSON.stringify({"water": {"id": "2", "times": [{"on_time": on_time_one, "off_time": off_time_one}, {"on_time": on_time_two, "off_time": off_time_two}]}});
|
||||
patch_config(json_str);
|
||||
}
|
||||
|
||||
var http_patch_config = new XMLHttpRequest();
|
||||
http_patch_config.onreadystatechange = function () {
|
||||
if (http_patch_config.readyState === 4) {
|
||||
var status = http_patch_config.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_config(http_patch_config.responseText);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
var patch_config = function(config) {
|
||||
http_patch_config.abort();
|
||||
http_patch_config.open("PATCH", "/config");
|
||||
http_patch_config.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
http_patch_config.send(config);
|
||||
}
|
||||
|
||||
var patch_http = new XMLHttpRequest();
|
||||
var patch_sample = function(sample) {
|
||||
patch_http.abort();
|
||||
patch_http.open("PATCH", "/sample");
|
||||
patch_http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
patch_http.send(sample);
|
||||
}
|
||||
|
||||
var parse_config = function (event) {
|
||||
var config = JSON.parse(event)
|
||||
var output = "einschalten"
|
||||
var visibility = 'hidden'
|
||||
if(config.water && config.water.id == '2') {
|
||||
if(config.water.autostate) {
|
||||
output = "ausschalten"
|
||||
visibility = "visible"
|
||||
document.getElementById("water_on_one").value = config.water.times[0].on_time;
|
||||
document.getElementById("water_off_one").value = config.water.times[0].off_time;
|
||||
document.getElementById("water_on_two").value = config.water.times[1].on_time;
|
||||
document.getElementById("water_off_two").value = config.water.times[1].off_time;
|
||||
}
|
||||
document.getElementById("auto_switch").value = output;
|
||||
document.getElementById("water_times").style.visibility = visibility
|
||||
}
|
||||
}
|
||||
|
||||
var parse_sample = function (event) {
|
||||
var sample = JSON.parse(event)
|
||||
if(sample.water && sample.water.id == '2') {
|
||||
var switch_caption = "einschalten";
|
||||
if(sample.water.state) {
|
||||
switch_caption = "ausschalten";
|
||||
}
|
||||
document.getElementById("water_switch").value = switch_caption;
|
||||
}
|
||||
}
|
||||
|
||||
var http = new XMLHttpRequest();
|
||||
http.onreadystatechange = function () {
|
||||
if (http.readyState === 4) {
|
||||
var status = http.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_sample(http.responseText);
|
||||
setTimeout(function () {
|
||||
http.open("GET", 'sample/2');
|
||||
http.send();
|
||||
}, 500);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
http.open("GET", "sample/2");
|
||||
http.send();
|
||||
|
||||
var http_get_config = new XMLHttpRequest();
|
||||
http_get_config.onreadystatechange = function () {
|
||||
if (http_get_config.readyState === 4) {
|
||||
var status = http_get_config.status;
|
||||
if (status === 0 || (status >= 200 && status < 400)) {
|
||||
// The request has been completed successfully
|
||||
parse_config(http_get_config.responseText);
|
||||
}
|
||||
} else {
|
||||
// request error
|
||||
}
|
||||
}
|
||||
http_get_config.open("GET", "config/2");
|
||||
http_get_config.send();
|
Reference in New Issue
Block a user