Compare commits

...

2 Commits

Author SHA1 Message Date
schrom01 ca294dd17a implemented autorefresh 2022-08-27 00:29:46 +02:00
schrom01 b1c371d9b3 implemented autorefresh 2022-08-27 00:29:22 +02:00
13 changed files with 459 additions and 291 deletions

View File

@ -1,7 +1,9 @@
{% include "header.html" %}
<!DOCTYPE html>
<html lang="de">
<head>
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/dashboard.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/scrollingTable.css') }}">
<title>{{ translater.getTranslation("Irrigation") }}{{ translater.getTranslation("system") }}</title>
@ -24,26 +26,8 @@
</style>
<script>
function refreshZone(zone) {
executeAction('get_dashboard_zone_html', zone, '0', 'zone_'+ zone);
}
function refreshPipeline() {
executeAction('get_dashboard_pipeline_html', '0', '0', 'pipeline');
}
function refreshContent() {
refreshPipeline();
{% for zone in zoneManager.zones %}
refreshZone({{zone.number}});
{% endfor %}
}
</script>
</head>
<body>
{% include "header.html" %}
<main>
@ -51,17 +35,31 @@
<h2>{{ translater.getTranslation("Dashboard") }}</h2>
<h3>{{ translater.getTranslation("planed irrigationjobs") }}</h3>
<p>
<button onclick="refreshPipeline()">
refresh
</button>
</p>
<div id="pipeline">
{% include "dashboard/pipeline.html" %}
<div id="pipeline" class="scrollingtable">
<div>
<div>
<table>
<caption>{{ translater.getTranslation("planed irrigationjobs") }}</caption>
<thead>
<tr>
<th><div label="Nr."></div></th>
<th><div label="{{ translater.getTranslation("Zone") }}"></div></th>
<th><div label="{{ translater.getTranslation("planed duration") }}"></div></th>
<th><div label="{{ translater.getTranslation("delete") }}"></div></th>
<th class="scrollbarhead"></th> <!--ALWAYS ADD THIS EXTRA CELL AT END OF HEADER ROW-->
</tr>
</thead>
<tbody id="jobListBody">
{% include "dashboard/pipeline.html" %}
</tbody>
</table>
</div>
Text unter Table
</div>
</div>
<h3>{{ translater.getTranslation("irrigation zones") }}</h3>
<div id="zones">
{% for zone in zoneManager.zones %}
@ -80,3 +78,42 @@
</body>
</html>
<script>
function refreshZone(zone_json) {
const zone = JSON.parse(zone_json);
document.getElementById("name_zone_" + zone.number).innerHTML = zone.name;
document.getElementById("inner_icon_state_zone_" + zone.number).className = 'inner_icon ' + (zone.state ? 'dot_green' : 'dot_red');
document.getElementById("state_text_zone_" + zone.number).innerHTML = zone.state_text;
document.getElementById("end_time_row_zone_" + zone.number).style.display = ((zone.setState == 1 || zone.setState == 2) ? 'table-row' : 'none');
document.getElementById("end_time_zone_" + zone.number).innerHTML = zone.endTimeSetState;
document.getElementById("planed_duration_row_zone_" + zone.number).style.display = ((zone.planedDuration > 0) ? 'table-row' : 'none');
document.getElementById("planed_duration_zone" + zone.number).innerHTML = zone.planedDuration/60;
document.getElementById("inner_icon_mode_zone_" + zone.number).innerHTML = zone.autoMode ? 'A' : 'M';
document.getElementById("slider_state_zone_" + zone.number).checked = zone.autoMode ? true : false;
document.getElementById("mode_text_zone_" + zone.number).innerHTML = zone.operationMode_text;
document.getElementById("inner_icon_humidity_zone_" + zone.number).className = 'inner_icon ' + ((zone.actualHumidity >= zone.desiredHumidity) ? 'dot_green' : 'dot_red');
document.getElementById("acutal_humidity_zone_" + zone.number).innerHTML = zone.actualHumidity;
document.getElementById("desired_humidity_zone_" + zone.number).innerHTML = zone.desiredHumidity;
}
function buttonDeleteJobById(jobId) {
deleteJobById('delete_job_by_id',jobId);
var jobToDelete = document.getElementById("job_" + jobId);
document.getElementById("jobListBody").removeChild(jobToDelete);
}
function refreshPipeline(pipeline_html) {
document.getElementById("jobListBody").innerHTML = pipeline_html;
}
function refreshContent() {
executeAction('get_dashboard_pipeline_html', '0', '0', refreshPipeline);
{% for zone in zoneManager.zones %}
executeAction('get_zone_info', {{ zone.number }}, '0', refreshZone);
{% endfor %}
}
refreshContent();
</script>
{% include "footer.html" %}

View File

@ -0,0 +1,7 @@
<tr id="job_{{ job.id }}">
<!-- <td>{{ job.id }}</td> -->
<td>{{ job.zone.number|string}}</td>
<td>{{job.zone.name }}</td>
<td>{{ ((job.duration/60)|int)|string + " " + translater.getTranslation("minutes")}}</td>
<td><button onclick="buttonDeleteJobById('{{ job.id }}')">{{ translater.getTranslation("delete") }}</button></td>
</tr>

View File

@ -1,21 +1,9 @@
<table>
<thead>
<tr>
<td>ID</td>
<td>{{ translater.getTranslation("Zone") }}</td>
<td>{{ translater.getTranslation("planed duration") }}</td>
</tr>
</thead>
{% for job in zoneManager.pipeLine %}
{% include "dashboard/irrigationJob.html" %}
{% endfor %}
<tbody>
{% for job in zoneManager.pipeLine %}
<tr>
<td>{{ job.id }}</td>
<td>{{ job.zone.number|string + ": " + job.zone.name }}</td>
<td>{{ ((job.duration/60)|int)|string + " " + translater.getTranslation("minutes")}}</td>
<td><button onclick="deleteJobById('delete_job_by_id','{{ job.id }}', {{ job.zone.number }})">{{ translater.getTranslation("delete") }}</button></td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@ -1,92 +1,79 @@
<a href="/zones/{{ zone.number}}">
<h4>{{ zone.name }}</h3>
</a>
<table>
<tbody>
<tr>
<td class="icon">
<span class="outer_dot">
<span class="inner_icon {{ 'dot_green' if zone.state else 'dot_red' }}"></span>
</span>
</td>
<td class="property">{{ translater.getTranslation("state") }}:</td>
<td class="value" id="state_text_zone_{{ zone.number }}">
{{ translater.getTranslation("switched on") if zone.state else translater.getTranslation("switched off") }}
</td>
<td>
<select id="duration_zone_{{ zone.number }}">
{% for option in zoneManager.systemSettings.webDurationOptions %}
<option value="{{ option }}">{{ option }} {{ translater.getTranslation("minutes") }}</option>
{% endfor %}
</select>
<button onclick="switchZoneStateByValueID({{'"switch_zone_off"' if zone.state else '"switch_zone_on"'}},'{{ zone.number }}', 'duration_zone_{{ zone.number }}', 60)">{{ translater.getTranslation("turn off") if zone.state else translater.getTranslation("turn on") }}</button>
</td>
<td>
<button onclick="refreshZone({{ zone.number }})">
refresh
</button>
</td>
</tr>
{% if (zone.setState == 1 or zone.setState == 2) %}
<a href="/zones/{{ zone.number}}">
<h4 id="name_zone_{{ zone.number }}">{{ zone.name }}</h3>
</a>
<table>
<tbody>
<tr>
<td></td>
<td></td>
<td>
{{translater.getTranslation("until") + zone.endTimeSetState|string}}
<td class="icon">
<span class="outer_dot">
<span id="inner_icon_state_zone_{{ zone.number }}"></span>
</span>
</td>
<td class="property">{{ translater.getTranslation("state") }}:</td>
<td class="value" id="state_text_zone_{{ zone.number }}"></td>
<td>
<button onclick="switchZoneState({{'"switch_zone_off"' if zone.state else '"switch_zone_on"'}},'{{ zone.number }}', -1)">{{ translater.getTranslation("cancel") }}</button>
<select id="duration_zone_{{ zone.number }}">
{% for option in zoneManager.systemSettings.webDurationOptions %}
<option value="{{ option }}">{{ option }} {{ translater.getTranslation("minutes") }}</option>
{% endfor %}
</select>
<button onclick="switchZoneStateByValueID('switch_zone_on','{{ zone.number }}', 'duration_zone_{{ zone.number }}', 60)">{{ translater.getTranslation("turn on") }}</button>
<button onclick="switchZoneStateByValueID('switch_zone_off','{{ zone.number }}', 'duration_zone_{{ zone.number }}', 60)">{{ translater.getTranslation("turn off") }}</button>
</td>
</tr>
{% endif %}
{% if zone.planedDuration > 0 %}
<tr>
<tr id="end_time_row_zone_{{ zone.number }}">
<td></td>
<td></td>
<td>
{{translater.getTranslation("irragation is planed for") + " " + ((zone.planedDuration/60)|int)|string + " " + translater.getTranslation("minutes") + "." }}
{{translater.getTranslation("until") }} <p id="end_time_zone_{{ zone.number }}" class="end_time_value"></p>
</td>
<td>
<button onclick="switchZoneState('switch_zone_off','{{ zone.number }}', -1)">{{ translater.getTranslation("cancel") }}</button>
</td>
</tr>
<tr id="planed_duration_row_zone_{{ zone.number }}">
<td></td>
<td></td>
<td>
{{translater.getTranslation("irragation is planed for") }} <p id="planed_duration_zone{{ zone.number }}" class="planed_duration_value"></p> {{ translater.getTranslation("minutes") + "." }}
</td>
<td>
<button onclick="deleteJobsForZone('delete_jobs_for_zone','{{ zone.number }}')">{{ translater.getTranslation("delete") }}</button>
</td>
</tr>
{% endif %}
<tr>
<td class="icon">
<span class="outer_dot">
<p class="inner_icon">{{'A' if zone.autoMode else 'M'}}</p>
</span>
</td>
<td>
<label class="toggle">
<input type="checkbox" {{ "checked" if zone.autoMode }} onchange="switchZoneMode(this.checked, {{ zone.number }})">
<span class="slider"></span>
<span class="labels" data-on="A" data-off="M"></span>
</label>
</td>
<td class="property">{{ translater.getTranslation("operating mode") }}:</td>
<td class="value">{{translater.getTranslation("automatic mode") if zone.autoMode else translater.getTranslation("manual mode")}}</td>
<td>
<button onclick="executeAction('switch_zone_mode','{{ zone.number }}', '{{ 'manual' if zone.autoMode else 'automatic' }}')">{{translater.getTranslation("switch to manual mode") if zone.autoMode else translater.getTranslation("switch to automatic mode")}}</button>
</td>
</tr>
<tr>
<td class="icon">
<span class="outer_dot">
<span class="inner_icon {{ 'dot_green' if(zone.actualHumidity >= zone.desiredHumidity) else 'dot_red' }}"></span>
</span>
</td>
<td class="property">{{ translater.getTranslation("actual humidity") }}:</td>
<td class="value">{{ zone.actualHumidity}}</td>
</tr>
<tr>
<td class="icon">
<tr>
<td class="icon">
<span class="outer_dot">
<p id="inner_icon_mode_zone_{{ zone.number }}" class="inner_icon"></p>
</span>
</td>
<td>
<label class="toggle">
<input type="checkbox" id="slider_state_zone_{{ zone.number }}" onchange="switchZoneMode(this.checked, {{ zone.number }})">
<span class="slider"></span>
<span class="labels" data-on="A" data-off="M"></span>
</label>
</td>
<td class="property">{{ translater.getTranslation("operating mode") }}:</td>
<td id="mode_text_zone_{{ zone.number }}" class="value"></td>
</tr>
<tr>
<td class="icon">
<span class="outer_dot">
<span id="inner_icon_humidity_zone_{{ zone.number }}"></span>
</span>
</td>
<td class="property">{{ translater.getTranslation("actual humidity") }}:</td>
<td id="acutal_humidity_zone_{{ zone.number }}" class="value"></td>
</tr>
<tr>
<td class="icon">
</td>
<td class="property">{{ translater.getTranslation("desired humidity") }}:</td>
<td class="value">{{ zone.desiredHumidity }}</td>
</tr>
</tbody>
</table>
<p class="zone_number">{{ zone.number }}</p>
</td>
<td class="property">{{ translater.getTranslation("desired humidity") }}:</td>
<td id="desired_humidity_zone_{{ zone.number }}" class="value"></td>
</tr>
</tbody>
</table>
<p class="zone_number">{{ zone.number }}</p>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
</head>
<body>
</body>
</html>
<script>
setInterval(refreshContent, {{ (zoneManager.systemSettings.cronJobFrequency + 5) * 1000 }})
</script>

View File

@ -1,94 +1,91 @@
<!DOCTYPE html>
<html lang="de">
<head>
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/header.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/main.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/switch.css') }}">
<meta charset="UTF-8">
<!-- <meta http-equiv="refresh" content="5" > -->
<script>
<head>
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/header.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/main.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/switch.css') }}">
<meta charset="UTF-8">
<script>
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
function executeAction(command, index, value, elementId) {
var url = '{{url_for("executeAction")}}';
var messageString = 'no';
var varString = 'command=' + command + '&index=' + index + '&value=' + value;
send_web_request(url, messageString, varString, elementId);
}
function executeActionByValueID(command, index, valueID, valueFactor){
var value = document.getElementById(valueID).value * valueFactor;
executeAction(command, index, value);
}
function executeAction(command, index, value, handleResponse) {
var url = '{{url_for("executeAction")}}';
var messageString = 'no';
var varString = 'command=' + command + '&index=' + index + '&value=' + value;
send_web_request(url, messageString, varString, handleResponse);
}
function executeActionByValueID(command, index, valueID, valueFactor){
var value = document.getElementById(valueID).value * valueFactor;
executeAction(command, index, value);
}
function switchZoneMode(autoMode, zone) {
executeAction('switch_zone_mode' ,zone, (autoMode ? 'automatic' : 'manual'));
sleep(1000).then(() => {
refreshZone(zone);
refreshPipeline();
});
function switchZoneMode(autoMode, zone) {
executeAction('switch_zone_mode' ,zone, (autoMode ? 'automatic' : 'manual'));
sleep(1000).then(() => {
refreshContent();
});
}
function switchZoneState(command, zone, value) {
executeAction(command, zone, value);
sleep(1000).then(() => {
refreshZone(zone);
refreshPipeline();
});
}
function switchZoneStateByValueID(command, zone, valueID, valueFactor) {
executeActionByValueID(command, zone, valueID, valueFactor);
sleep(1000).then(() => {
refreshZone(zone);
refreshPipeline();
});
}
function deleteJobsForZone(command, zone) {
executeAction(command, zone);
sleep(1000).then(() => {
refreshZone(zone);
refreshPipeline();
});
}
function deleteJobById(command, jobId, zone) {
executeAction(command, jobId);
sleep(1000).then(() => {
refreshZone(zone);
refreshPipeline();
});
}
}
function switchZoneState(command, zone, value) {
executeAction(command, zone, value);
sleep(1000).then(() => {
refreshContent();
});
}
function switchZoneStateByValueID(command, zone, valueID, valueFactor) {
executeActionByValueID(command, zone, valueID, valueFactor);
sleep(1000).then(() => {
refreshContent();
});
}
function deleteJobsForZone(command, zone) {
executeAction(command, zone);
sleep(1000).then(() => {
refreshContent();
});
}
function deleteJobById(command, jobId) {
executeAction(command, jobId);
sleep(1000).then(() => {
refreshContent();
});
}
setInterval(refreshContent, {{ (zoneManager.systemSettings.cronJobFrequency + 1) * 1000 }})
</script>
</head>
<body>
<header>
<nav>
<ul>
{% for item in nav.top %}
<li {{ 'class=active' if item.is_active else '' }}>
<a href="{{ item.url }}">
{{ item.label }}
</a>
</li>
{% endfor %}
</ul>
</nav>
</script>
<a class="heading" href="{{ url_for('startPage')}}">
<img src="{{ url_for('static', filename='img/header/wassertropfen.png') }}" alt="" class="title-img">
</head>
<body>
<header>
<nav>
<ul>
{% for item in nav.top %}
<li {{ 'class=active' if item.is_active else '' }}>
<a href="{{ item.url }}">
{{ item.label }}
</a>
</li>
{% endfor %}
</ul>
</nav>
<h1>{{ translater.getTranslation("Irrigation") }}-<br>{{ translater.getTranslation("system") }}</h1>
</a>
<a class="heading" href="{{ url_for('startPage')}}">
<img src="{{ url_for('static', filename='img/header/wassertropfen.png') }}" alt="" class="title-img">
<img src="{{ url_for('static', filename='img/header/blumenbeet.jpg') }}" alt="" class="header-img">
<h1>{{ translater.getTranslation("Irrigation") }}-<br>{{ translater.getTranslation("system") }}</h1>
</a>
</header>
<script src="{{ url_for('static', filename='js/action.js') }}"></script>
<script src="{{ url_for('static', filename='js/webhook.js') }}"></script>
</body>
<img src="{{ url_for('static', filename='img/header/blumenbeet.jpg') }}" alt="" class="header-img">
</header>
<script src="{{ url_for('static', filename='js/action.js') }}"></script>
<script src="{{ url_for('static', filename='js/webhook.js') }}"></script>
</body>
</html>

View File

@ -50,59 +50,73 @@ class Webserver:
value = int(value_str)
except:
pass
match command:
case "switch_zone_on":
if (index and value):
self.zoneManager.switchZoneIndexState(zoneIndex=index, state=True, duration=value)
sucess = True
elif(index):
self.zoneManager.switchZoneIndexState(zoneIndex=index, state=True, duration=self.zoneManager.systemSettings.defaultManualIrrigationDuration)
sucess = True
case "switch_zone_off":
if (index and value):
self.zoneManager.switchZoneIndexState(zoneIndex=index, state=False, duration=value, instant=True)
sucess = True
elif(index):
self.zoneManager.switchZoneIndexState(zoneIndex=index, state=False, duration=self.zoneManager.systemSettings.defaultManualOffDuration, instant=True)
sucess = True
case "switch_zone_mode":
if (index and value_str):
zone = self.zoneManager.getZone(index)
match value_str:
case "automatic":
zone.switchMode(autoMode=True)
sucess = True
case "manual":
zone.switchMode(autoMode=False)
sucess = True
case "set_desired_humidity":
if (index and value):
zone = self.zoneManager.getZone(index)
zone.desiredHumidity = value
sucess = True
case "delete_jobs_for_zone":
if (index):
zone = self.zoneManager.getZone(index)
self.zoneManager.deleteIrrigationJobsForZone(zone)
case "delete_job_by_id":
if (index):
self.zoneManager.deleteIrrigationJobByID(index)
case "get_dashboard_zone_html":
if (index):
zone = self.zoneManager.getZone(index)
return render_template('dashboard/zone.html', translater=self.translater, zoneManager=self.zoneManager, zone=zone)
case "get_dashboard_pipeline_html":
return render_template("dashboard/pipeline.html", translater=self.translater, zoneManager=self.zoneManager)
case "get_zone_list":
return self.zoneManager.zonesToJSON()
case "get_zone_info":
if (index):
zone = self.zoneManager.getZone(index)
return zone.toJSON()
case "get_pipeline":
return self.zoneManager.pipelineToJSON()
return self.zoneManager.zonesToJSON()
#return render_template('action.html', translater=self.translater, zones=self.zoneManager.zones, sucess=sucess)
elif(request.method == 'GET'):
try:
command = request.args['command']
except:
pass
try:
index_str = request.args['index']
index = int(index_str)
except:
pass
try:
value_str = request.args['value']
value = int(value_str)
except:
pass
match command:
case "switch_zone_on":
if (index and value):
self.zoneManager.switchZoneIndexState(zoneIndex=index, state=True, duration=value)
sucess = True
elif(index):
self.zoneManager.switchZoneIndexState(zoneIndex=index, state=True, duration=self.zoneManager.systemSettings.defaultManualIrrigationDuration)
sucess = True
case "switch_zone_off":
if (index and value):
self.zoneManager.switchZoneIndexState(zoneIndex=index, state=False, duration=value, instant=True)
sucess = True
elif(index):
self.zoneManager.switchZoneIndexState(zoneIndex=index, state=False, duration=self.zoneManager.systemSettings.defaultManualOffDuration, instant=True)
sucess = True
case "switch_zone_mode":
if (index and value_str):
zone = self.zoneManager.getZone(index)
match value_str:
case "automatic":
zone.switchMode(autoMode=True)
sucess = True
case "manual":
zone.switchMode(autoMode=False)
sucess = True
case "set_desired_humidity":
if (index and value):
zone = self.zoneManager.getZone(index)
zone.desiredHumidity = value
sucess = True
case "delete_jobs_for_zone":
if (index):
zone = self.zoneManager.getZone(index)
self.zoneManager.deleteIrrigationJobsForZone(zone)
case "delete_job_by_id":
if (index):
self.zoneManager.deleteIrrigationJobByID(index)
case "get_dashboard_zone_html":
if (index):
zone = self.zoneManager.getZone(index)
return render_template('dashboard/zone.html', translater=self.translater, zoneManager=self.zoneManager, zone=zone)
case "get_dashboard_pipeline_html":
return render_template("dashboard/pipeline.html", translater=self.translater, zoneManager=self.zoneManager)
case "get_zone_list":
return self.zoneManager.zonesToJSON(self.translater)
case "get_zone_info":
if (index):
zone = self.zoneManager.getZone(index)
return zone.toJSON(self.translater)
case "get_pipeline":
return self.zoneManager.pipelineToJSON(self.translater)
return render_template('action.html', translater=self.translater, zones=self.zoneManager.zones, sucess=sucess)
@app.route('/dashboard')
@ -113,16 +127,16 @@ class Webserver:
@app.route('/zones/<zoneNumber>')
def showZones(zoneNumber=False):
if (zoneNumber):
return render_template('zones/zone.html', translater=self.translater, zone=self.zoneManager.getZone(zoneNumber))
return render_template('zones/zone.html', translater=self.translater, zoneManager=self.zoneManager, zone=self.zoneManager.getZone(zoneNumber))
else:
return render_template('zones/zones.html', translater=self.translater, zones=self.zoneManager.zones)
return render_template('zones/zones.html', translater=self.translater, zoneManager=self.zoneManager)
@app.route('/times')
def showTimes():
return render_template('times.html', translater=self.translater)
return render_template('times.html', translater=self.translater, zoneManager=self.zoneManager)
@app.route('/system')
def showSystem():
return render_template('system.html', translater=self.translater)
return render_template('system.html', translater=self.translater, zoneManager=self.zoneManager)
app.run(debug=True, port=self.port)
app.run(debug=True, host="0.0.0.0", port=self.port)

View File

@ -1,3 +1,5 @@
#zones{
display: grid;
grid-template-columns: repeat(3, 1fr);
@ -57,6 +59,10 @@ td.value{
text-align: left;
position: relative;
}
p.end_time_value, p.planed_duration_value {
display: inline;
}

View File

@ -0,0 +1,118 @@
.scrollingtable {
box-sizing: border-box;
display: inline-block;
vertical-align: middle;
overflow: hidden;
width: auto; /*set table width here if using fixed value*/
/*min-width: 100%;*/ /*set table width here if using %*/
height: 300px; /*set table height here; can be fixed value or %*/
/*min-height: 104px;*/ /*if using % height, make this at least large enough to fit scrollbar arrows + captions + thead*/
font-family: Verdana, Tahoma, sans-serif;
font-size: 15px;
line-height: 20px;
padding-top: 20px; /*this determines top caption height*/
padding-bottom: 20px; /*this determines bottom caption height*/
text-align: left;
}
.scrollingtable * {box-sizing: border-box;}
.scrollingtable > div {
position: relative;
border-top: 1px solid black; /*top table border*/
height: 100%;
padding-top: 20px; /*this determines column header height*/
}
.scrollingtable > div:before {
top: 0;
background: cornflowerblue; /*column header background color*/
}
.scrollingtable > div:before,
.scrollingtable > div > div:after {
content: "";
position: absolute;
z-index: -1;
width: 100%;
height: 50%;
left: 0;
}
.scrollingtable > div > div {
/*min-height: 43px;*/ /*if using % height, make this at least large enough to fit scrollbar arrows*/
max-height: 100%;
overflow: scroll; /*set to auto if using fixed or % width; else scroll*/
overflow-x: hidden;
border: 1px solid black; /*border around table body*/
}
.scrollingtable > div > div:after {background: white;} /*match page background color*/
.scrollingtable > div > div > table {
width: 100%;
border-spacing: 0;
margin-top: -20px; /*inverse of column header height*/
/*margin-right: 17px;*/ /*uncomment if using % width*/
}
.scrollingtable > div > div > table > caption {
position: absolute;
top: -20px; /*inverse of caption height*/
margin-top: -1px; /*inverse of border-width*/
width: 100%;
font-weight: bold;
text-align: center;
}
.scrollingtable > div > div > table > * > tr > * {padding: 0;}
.scrollingtable > div > div > table > thead {
vertical-align: bottom;
white-space: nowrap;
text-align: center;
}
.scrollingtable > div > div > table > thead > tr > * > div {
display: inline-block;
padding: 0 6px 0 6px; /*header cell padding*/
}
.scrollingtable > div > div > table > thead > tr > :first-child:before {
content: "";
position: absolute;
top: 0;
left: 0;
height: 20px; /*match column header height*/
border-left: 1px solid black; /*leftmost header border*/
}
.scrollingtable > div > div > table > thead > tr > * > div[label]:before,
.scrollingtable > div > div > table > thead > tr > * > div > div:first-child,
.scrollingtable > div > div > table > thead > tr > * + :before {
position: absolute;
top: 0;
white-space: pre-wrap;
color: white; /*header row font color*/
}
.scrollingtable > div > div > table > thead > tr > * > div[label]:before,
.scrollingtable > div > div > table > thead > tr > * > div[label]:after {content: attr(label);}
.scrollingtable > div > div > table > thead > tr > * + :before {
content: "";
display: block;
min-height: 20px; /*match column header height*/
padding-top: 1px;
border-left: 1px solid black; /*borders between header cells*/
}
.scrollingtable .scrollbarhead {float: right;}
.scrollingtable .scrollbarhead:before {
position: absolute;
width: 100px;
top: -1px; /*inverse border-width*/
background: white; /*match page background color*/
}
.scrollingtable > div > div > table > tbody > tr:after {
content: "";
display: table-cell;
position: relative;
padding: 0;
border-top: 1px solid black;
top: -1px; /*inverse of border width*/
}
.scrollingtable > div > div > table > tbody {vertical-align: top;}
.scrollingtable > div > div > table > tbody > tr {background: white;}
.scrollingtable > div > div > table > tbody > tr > * {
border-bottom: 1px solid black;
padding: 0 6px 0 6px;
height: 20px; /*match column header height*/
}
.scrollingtable > div > div > table > tbody:last-of-type > tr:last-child > * {border-bottom: none;}
.scrollingtable > div > div > table > tbody > tr:nth-child(even) {background: gainsboro;} /*alternate row color*/
.scrollingtable > div > div > table > tbody > tr > * + * {border-left: 1px solid black;} /*borders between body cells*/

View File

@ -1,12 +1,4 @@
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
function send_web_request(url, messageString, varString, elementId) {
function send_web_request(url, messageString, varString, handleResponse) {
// Browserkompatibles Request-Objekt erzeugen:
r = null;
@ -40,17 +32,20 @@ function send_web_request(url, messageString, varString, elementId) {
{
// HTTP-POST
r.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(elementId).innerHTML = this.responseText;
}
};
r.open('POST', url, true);
r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
if(handleResponse != null) {
// HTTP-POST
r.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
handleResponse(this.responseText);
}
};
}
r.send(varString);

View File

@ -14,14 +14,16 @@ class Zone:
self.endTimeSetState = endTimeSetState
self.planedDuration = planedDuration
def toJSON(self):
def toJSON(self, translater):
return {
"number": self.number,
"name": self.name,
"actualHumidity": self.actualHumidity,
"desiredHumidity": self.desiredHumidity,
"autoMode": self.autoMode,
"operationMode_text": translater.getTranslation("automatic mode" if self.autoMode else "manual mode"),
"state": self.state,
"state_text": translater.getTranslation("switched on" if self.state else "switched off"),
"setState": self.setState,
"endTimeSetState" : self.endTimeSetState,
"planedDuration": self.planedDuration,

View File

@ -16,17 +16,17 @@ class ZoneManager:
self.pipeLine = []
self.piplineMutexLock = threading.Lock()
def zonesToJSON(self):
def zonesToJSON(self, translater):
zoneList = []
for zone in self.zones:
zoneList.append(zone.toJSON())
zoneList.append(zone.toJSON(translater))
return zoneList
def pipelineToJSON(self):
def pipelineToJSON(self, translater):
jobList = []
with self.piplineMutexLock:
for irrigationJob in self.pipeLine:
jobList.append(irrigationJob.toJSON())
jobList.append(irrigationJob.toJSON(translater))
return jobList
@ -67,7 +67,9 @@ class ZoneManager:
return False
def switchZoneState(self, zone, state, duration, instant=False):
if(instant or self.systemSettings.multiZoneIrrigation or state==False ): #or (not self.isAnyZoneBusy())
if(not duration > 0):
zone.switchState(state=False, duration=0, instant=True)
elif(instant or self.systemSettings.multiZoneIrrigation or state==False ): #or (not self.isAnyZoneBusy())
zone.switchState(state=state, duration=duration, instant=True)
else:
self.addIrrigationJob(IrrigationJob(id=self.random.randint(a=100000000, b=999999999), zone=zone, duration=duration))
@ -115,10 +117,10 @@ class IrrigationJob:
self.duration = duration
self.zone.switchState(state=True, duration=duration, instant=False)
def toJSON(self):
def toJSON(self, translater):
return {
"id": self.id,
"zone": self.zone.toJSON(),
"zone": self.zone.toJSON(translater),
"duration": self.duration,
}

View File

@ -6,7 +6,7 @@ from ZoneManager import ZoneManager
from SystemSettings import SystemSettings
from FileIO import FileIO
systemSettings = SystemSettings(cronJobFrequency=2, dataDir="/Data", multiZoneIrrigation=False, defaultAutoIrrigationDuration=10, defaultManualIrrigationDuration=10, defaultManualOffDuration=10, webDurationOptions=[1, 5, 10, 15, 20, 25, 30, 45, 60])
systemSettings = SystemSettings(cronJobFrequency=0.5, dataDir="/Data", multiZoneIrrigation=False, defaultAutoIrrigationDuration=10, defaultManualIrrigationDuration=10, defaultManualOffDuration=10, webDurationOptions=[1, 5, 10, 15, 20, 25, 30, 45, 60])
fileIO = FileIO(systemSettings)
zoneManager = ZoneManager(systemSettings=systemSettings, fileIO=fileIO)
webserver = Webserver(zoneManager=zoneManager, port=80)