Remove greenhouse 2 and garden
This commit is contained in:
parent
a5b5637cfe
commit
055f632c96
@ -1,116 +0,0 @@
|
|||||||
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();
|
|
@ -1,116 +0,0 @@
|
|||||||
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();
|
|
@ -1,77 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Garten</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="/static/css/style.css" rel="stylesheet">
|
|
||||||
<script src="/static/scripts/garden.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1>Garten</h1>
|
|
||||||
<table class="center">
|
|
||||||
<tr>
|
|
||||||
<td class="left">Bewässerung</td>
|
|
||||||
<td class="input">
|
|
||||||
<input id="water_switch" type="submit" value="" onclick="on_switch_water()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="left">Zeigesteuerte Bewässerung </td>
|
|
||||||
<td class="input">
|
|
||||||
<input id="auto_switch" type="submit" value="einschalten" onclick="on_switch_auto_state()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div id="water_times" style="visibility:hidden;">
|
|
||||||
<table class="center">
|
|
||||||
<tr>
|
|
||||||
<td>Vormittag</td>
|
|
||||||
<td>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Einschaltzeit</td>
|
|
||||||
<td class="input">
|
|
||||||
<input type="text" id="water_on_one" style="width: 70px;" onchange="on_change_config()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Ausschaltzeit</td>
|
|
||||||
<td class="input">
|
|
||||||
<input type="text" id="water_off_one" style="width: 70px;" onchange="on_change_config()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Nachmittag</td>
|
|
||||||
<td>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Einschaltzeit</td>
|
|
||||||
<td class="input">
|
|
||||||
<input type="text" id="water_on_two" style="width: 70px;" onchange="on_change_config()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Ausschaltzeit</td>
|
|
||||||
<td class="input">
|
|
||||||
<input type="text" id="water_off_two" style="width: 70px;" onchange="on_change_config()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
<footer>
|
|
||||||
<nav>
|
|
||||||
<a href="/">Home</a> | 
|
|
||||||
<a href="/greenhouse_1" class="center">Gewächshaus 1</a> | 
|
|
||||||
<a href="/greenhouse_2" class="center">Gewächshaus 2</a> | 
|
|
||||||
<a href="/garden" class="center">Gemüsegarten</a>
|
|
||||||
</nav>
|
|
||||||
</footer>
|
|
||||||
</html>
|
|
@ -1,77 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Gewächshaus 2</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="/static/css/style.css" rel="stylesheet">
|
|
||||||
<script src="/static/scripts/greenhouse_2.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1>Gewächshaus 2</h1>
|
|
||||||
<table class="center">
|
|
||||||
<tr>
|
|
||||||
<td class="left">Bewässerung</td>
|
|
||||||
<td class="input">
|
|
||||||
<input id="water_switch" type="submit" value="" onclick="on_switch_water()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="left">Zeigesteuerte Bewässerung </td>
|
|
||||||
<td class="input">
|
|
||||||
<input id="auto_switch" type="submit" value="einschalten" onclick="on_switch_auto_state()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div id="water_times" style="visibility:hidden;">
|
|
||||||
<table class="center">
|
|
||||||
<tr>
|
|
||||||
<td>Vormittag</td>
|
|
||||||
<td>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Einschaltzeit</td>
|
|
||||||
<td class="input">
|
|
||||||
<input type="text" id="water_on_one" style="width: 70px;" onchange="on_change_config()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Ausschaltzeit</td>
|
|
||||||
<td class="input">
|
|
||||||
<input type="text" id="water_off_one" style="width: 70px;" onchange="on_change_config()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Nachmittag</td>
|
|
||||||
<td>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Einschaltzeit</td>
|
|
||||||
<td class="input">
|
|
||||||
<input type="text" id="water_on_two" style="width: 70px;" onchange="on_change_config()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Ausschaltzeit</td>
|
|
||||||
<td class="input">
|
|
||||||
<input type="text" id="water_off_two" style="width: 70px;" onchange="on_change_config()"></input>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
<footer>
|
|
||||||
<nav>
|
|
||||||
<a href="/">Home</a> | 
|
|
||||||
<a href="/greenhouse_1" class="center">Gewächshaus 1</a> | 
|
|
||||||
<a href="/greenhouse_2" class="center">Gewächshaus 2</a> | 
|
|
||||||
<a href="/garden" class="center">Gemüsegarten</a>
|
|
||||||
</nav>
|
|
||||||
</footer>
|
|
||||||
</html>
|
|
@ -1,26 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Garten</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link href="/static/css/style.css" rel="stylesheet">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1>Garten</h1>
|
|
||||||
<div class="center">
|
|
||||||
<a href="/greenhouse_1">Gewächshaus 1</a><br>
|
|
||||||
<a href="/greenhouse_2">Gewächshaus 2</a><br>
|
|
||||||
<a href="/garden">Gemüsegarten</a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<footer>
|
|
||||||
<nav>
|
|
||||||
<a href="/">Home</a> | 
|
|
||||||
<a href="/greenhouse_1" class="center">Gewächshaus 1</a> | 
|
|
||||||
<a href="/greenhouse_2" class="center">Gewächshaus 2</a> | 
|
|
||||||
<a href="/garden" class="center">Gemüsegarten</a>
|
|
||||||
</nav>
|
|
||||||
</footer>
|
|
||||||
</html>
|
|
@ -1,10 +1,10 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Garden UI service
|
Description=Greenhouse UI service
|
||||||
After=multi-user.target gardencontrol.service
|
After=multi-user.target gardencontrol.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=idle
|
Type=idle
|
||||||
ExecStart=gunicorn --bind 0.0.0.0:80 gardenui:app
|
ExecStart=gunicorn --bind 0.0.0.0:80 greenhouseui:app
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
@ -1,4 +1,4 @@
|
|||||||
|
"""Flask application for greenhouse"""
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import xmlrpc.client
|
import xmlrpc.client
|
||||||
@ -10,10 +10,12 @@ from flask import request
|
|||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
|
|
||||||
LOG_LEVEL = logging.INFO
|
LOG_LEVEL = logging.INFO
|
||||||
LOG_FILE = "/var/log/sauna.log"
|
LOG_FILE = "/var/log/greenhouseui.log"
|
||||||
LOG_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
LOG_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
||||||
|
|
||||||
URL = 'http://{}:{}'.format('localhost', 64001)
|
HOST = "localhost"
|
||||||
|
PORT = 64001
|
||||||
|
URL = f"http://{HOST}:{PORT}"
|
||||||
|
|
||||||
# logging.basicConfig(format=LOG_FORMAT, level=LOG_LEVEL, filename=LOG_FILE)
|
# logging.basicConfig(format=LOG_FORMAT, level=LOG_LEVEL, filename=LOG_FILE)
|
||||||
logging.basicConfig(format=LOG_FORMAT, level=LOG_LEVEL)
|
logging.basicConfig(format=LOG_FORMAT, level=LOG_LEVEL)
|
||||||
@ -22,24 +24,14 @@ log = logging.getLogger()
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/', methods=['GET'])
|
||||||
def index():
|
def index():
|
||||||
|
"""Handle GET to index.html"""
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
@app.route('/garden')
|
|
||||||
def garden():
|
|
||||||
return render_template('garden.html')
|
|
||||||
|
|
||||||
@app.route('/greenhouse_1')
|
|
||||||
def greenhouse_1():
|
|
||||||
return render_template('greenhouse_1.html')
|
|
||||||
|
|
||||||
@app.route('/greenhouse_2')
|
|
||||||
def greenhouse_2():
|
|
||||||
return render_template('greenhouse_2.html')
|
|
||||||
|
|
||||||
@app.route('/sample/<idx>', methods=['GET'])
|
@app.route('/sample/<idx>', methods=['GET'])
|
||||||
def get_sample(idx='0'):
|
def get_sample(idx='0'):
|
||||||
|
"""Handle GET to /sample/<idx>"""
|
||||||
idx = int(idx)
|
idx = int(idx)
|
||||||
res = {}
|
res = {}
|
||||||
client = xmlrpc.client.ServerProxy(URL)
|
client = xmlrpc.client.ServerProxy(URL)
|
||||||
@ -65,6 +57,7 @@ def get_sample(idx='0'):
|
|||||||
|
|
||||||
@app.route('/config/<idx>', methods=['GET'])
|
@app.route('/config/<idx>', methods=['GET'])
|
||||||
def get_config(idx='0'):
|
def get_config(idx='0'):
|
||||||
|
"""Hadnle GET to config/<idx>"""
|
||||||
idx = int(idx)
|
idx = int(idx)
|
||||||
res = {}
|
res = {}
|
||||||
client = xmlrpc.client.ServerProxy(URL)
|
client = xmlrpc.client.ServerProxy(URL)
|
||||||
@ -88,6 +81,7 @@ def get_config(idx='0'):
|
|||||||
|
|
||||||
@app.route('/sample', methods=['PATCH'])
|
@app.route('/sample', methods=['PATCH'])
|
||||||
def patch_sample():
|
def patch_sample():
|
||||||
|
"""Handle PATCH to /sample"""
|
||||||
client = xmlrpc.client.ServerProxy(URL)
|
client = xmlrpc.client.ServerProxy(URL)
|
||||||
record = json.loads(request.data)
|
record = json.loads(request.data)
|
||||||
if 'id' in record and record['id'] == '1':
|
if 'id' in record and record['id'] == '1':
|
||||||
@ -106,6 +100,7 @@ def patch_sample():
|
|||||||
|
|
||||||
@app.route('/config', methods=['PATCH'])
|
@app.route('/config', methods=['PATCH'])
|
||||||
def patch_config():
|
def patch_config():
|
||||||
|
"""Handle PATCH to /config"""
|
||||||
client = xmlrpc.client.ServerProxy(URL)
|
client = xmlrpc.client.ServerProxy(URL)
|
||||||
record = json.loads(request.data)
|
record = json.loads(request.data)
|
||||||
if 'water' in record:
|
if 'water' in record:
|
||||||
@ -153,7 +148,6 @@ def patch_config():
|
|||||||
water['times'] = client.get_water_times(int(record['water']['id']))
|
water['times'] = client.get_water_times(int(record['water']['id']))
|
||||||
res['water'] = water
|
res['water'] = water
|
||||||
|
|
||||||
|
|
||||||
return make_response(jsonify(res), 200)
|
return make_response(jsonify(res), 200)
|
||||||
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Gewächshaus 1</title>
|
<title>Gewächshaus</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link href="/static/css/style.css" rel="stylesheet">
|
<link href="/static/css/style.css" rel="stylesheet">
|
||||||
<script src="/static/scripts/greenhouse_1.js"></script>
|
<script src="/static/scripts/greenhouse.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Gewächshaus 1</h1>
|
<h1>Gewächshaus</h1>
|
||||||
<hr>
|
<hr>
|
||||||
<table class="center">
|
<table class="center">
|
||||||
<tr>
|
<tr>
|
||||||
@ -112,12 +112,4 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<footer>
|
|
||||||
<nav>
|
|
||||||
<a href="/">Home</a> | 
|
|
||||||
<a href="/greenhouse_1" class="center">Gewächshaus 1</a> | 
|
|
||||||
<a href="/greenhouse_2" class="center">Gewächshaus 2</a> | 
|
|
||||||
<a href="/garden" class="center">Gemüsegarten</a>
|
|
||||||
</nav>
|
|
||||||
</footer>
|
|
||||||
</html>
|
</html>
|
19
setup.py
19
setup.py
@ -1,35 +1,36 @@
|
|||||||
|
"""Installer"""
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from setuptools.command.install import install
|
from setuptools.command.install import install
|
||||||
|
|
||||||
NAME = 'Gardenui'
|
NAME = 'Greenhouseui'
|
||||||
VERSION = '1'
|
VERSION = '1'
|
||||||
AUTHOR = 'Thomas Klaehn'
|
AUTHOR = 'Thomas Klaehn'
|
||||||
EMAIL = 'tkl@blackfinn.de'
|
EMAIL = 'tkl@blackfinn.de'
|
||||||
PACKAGES = ['gardenui']
|
PACKAGES = ['greenhouseui']
|
||||||
REQUIRES = ['Flask', 'gunicorn']
|
REQUIRES = ['Flask', 'gunicorn']
|
||||||
PACKAGE_DATA = {'gardenui': ['templates/*', 'static/css/*', 'static/scripts/*']}
|
PACKAGE_DATA = {'greenhouseui': ['templates/*', 'static/css/*', 'static/scripts/*']}
|
||||||
|
|
||||||
SERVICEDIR = "/lib/systemd/system"
|
SERVICEDIR = "/lib/systemd/system"
|
||||||
DAEMON_START_SCRIPT = os.path.join(SERVICEDIR, 'gardenui.service')
|
DAEMON_START_SCRIPT = os.path.join(SERVICEDIR, 'greenhouseui.service')
|
||||||
|
|
||||||
LOGFILE = "/var/log/gardenui.log"
|
LOGFILE = "/var/log/greenhouseui.log"
|
||||||
|
|
||||||
class Install(install):
|
class Install(install):
|
||||||
|
"""Installer"""
|
||||||
def run(self):
|
def run(self):
|
||||||
install.run(self)
|
install.run(self)
|
||||||
os.makedirs(SERVICEDIR, exist_ok=True)
|
os.makedirs(SERVICEDIR, exist_ok=True)
|
||||||
shutil.copyfile('gardenui.service', os.path.join(SERVICEDIR, DAEMON_START_SCRIPT))
|
shutil.copyfile('greenhouseui.service', os.path.join(SERVICEDIR, DAEMON_START_SCRIPT))
|
||||||
os.chmod(DAEMON_START_SCRIPT, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
|
os.chmod(DAEMON_START_SCRIPT, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
open(LOGFILE, 'r')
|
open(LOGFILE, 'r', encoding="UTF-8")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
os.makedirs(os.path.dirname(LOGFILE), exist_ok=True)
|
os.makedirs(os.path.dirname(LOGFILE), exist_ok=True)
|
||||||
open(LOGFILE, 'x')
|
open(LOGFILE, 'x', encoding="UTF-8")
|
||||||
os.chmod(LOGFILE, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP |
|
os.chmod(LOGFILE, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP |
|
||||||
stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)
|
stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user