moved Dashboard.html in speparate folder to refresh zones.
This commit is contained in:
parent
442a7a8b11
commit
1066adcc63
|
@ -1,161 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="de">
|
|
||||||
<head>
|
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/dashboard.css') }}">
|
|
||||||
|
|
||||||
<title>{{ translater.getTranslation("Irrigation") }}{{ translater.getTranslation("system") }}</title>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
@media screen and (min-width: 2051px){
|
|
||||||
#zones{
|
|
||||||
grid-template-rows: repeat( {{ (zoneManager.zones|length / 3) + 1 }} , minmax(150px, auto));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 2050px) and (min-width: 1351px){
|
|
||||||
#zones{
|
|
||||||
grid-template-rows: repeat( {{ (zoneManager.zones|length / 2) + 1 }} , minmax(150px, auto));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 1350px){
|
|
||||||
#zones{
|
|
||||||
grid-template-rows: repeat( {{ zoneManager.zones|length }} , minmax(150px, auto));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{% include "header.html" %}
|
|
||||||
|
|
||||||
|
|
||||||
<main>
|
|
||||||
|
|
||||||
<h2>{{ translater.getTranslation("Dashboard") }}</h2>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>{{ translater.getTranslation("planed irrigationjobs") }}</h3>
|
|
||||||
<div id="pipeline">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td>ID</td>
|
|
||||||
<td>{{ translater.getTranslation("Zone") }}</td>
|
|
||||||
<td>{{ translater.getTranslation("planed duration") }}</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<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="executeAction('delete_job_by_id','{{ job.id }}', 0)">{{ translater.getTranslation("delete") }}</button></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<h3>{{ translater.getTranslation("irrigation zones") }}</h3>
|
|
||||||
<div id="zones">
|
|
||||||
{% for zone in zoneManager.zones %}
|
|
||||||
<div id="zone_{{ zone.number }}" class="zone">
|
|
||||||
<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">
|
|
||||||
{{ 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="executeActionByValueID({{'"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>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
{% if (zone.setState == 1 or zone.setState == 2) %}
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td>
|
|
||||||
{{translater.getTranslation("until") + zone.endTimeSetState|string}}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<button onclick="executeAction({{'"switch_zone_off"' if zone.state else '"switch_zone_on"'}},'{{ zone.number }}', -1)">{{ translater.getTranslation("cancel") }}</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
{% if zone.planedDuration > 0 %}
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td>
|
|
||||||
{{translater.getTranslation("irragation is planed for") + " " + ((zone.planedDuration/60)|int)|string + " " + translater.getTranslation("minutes") + "." }}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<button onclick="executeAction('delete_jobs_for_zone','{{ zone.number }}', 0)">{{ translater.getTranslation("delete") }}</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
<tr>
|
|
||||||
<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="H"></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">
|
|
||||||
|
|
||||||
</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>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</main>
|
|
||||||
<p><br><br></p>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -5,11 +5,16 @@
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/main.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/main.css') }}">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/switch.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='Styles/switch.css') }}">
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="refresh" content="5" >
|
<!-- <meta http-equiv="refresh" content="5" > -->
|
||||||
<script>
|
<script>
|
||||||
function executeAction(command, index, value) {
|
|
||||||
send_web_request('{{url_for("executeAction")}}', 'no', 'command=' + command + '&index=' + index + '&value=' + value);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -87,6 +87,10 @@ class Webserver:
|
||||||
case "delete_job_by_id":
|
case "delete_job_by_id":
|
||||||
if (index):
|
if (index):
|
||||||
self.zoneManager.deleteIrrigationJobByID(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_zone_list":
|
case "get_zone_list":
|
||||||
return self.zoneManager.zonesToJSON()
|
return self.zoneManager.zonesToJSON()
|
||||||
case "get_zone_info":
|
case "get_zone_info":
|
||||||
|
@ -95,12 +99,13 @@ class Webserver:
|
||||||
return zone.toJSON()
|
return zone.toJSON()
|
||||||
case "get_pipeline":
|
case "get_pipeline":
|
||||||
return self.zoneManager.pipelineToJSON()
|
return self.zoneManager.pipelineToJSON()
|
||||||
return render_template('action.html', translater=self.translater, zones=self.zoneManager.zones, sucess=sucess)
|
return self.zoneManager.zonesToJSON()
|
||||||
|
#return render_template('action.html', translater=self.translater, zones=self.zoneManager.zones, sucess=sucess)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/dashboard')
|
@app.route('/dashboard')
|
||||||
def showDashboard():
|
def showDashboard():
|
||||||
return render_template('dashboard.html', translater=self.translater, zoneManager=self.zoneManager)
|
return render_template('dashboard/dashboard.html', translater=self.translater, zoneManager=self.zoneManager)
|
||||||
|
|
||||||
@app.route('/zones')
|
@app.route('/zones')
|
||||||
@app.route('/zones/<zoneNumber>')
|
@app.route('/zones/<zoneNumber>')
|
||||||
|
|
|
@ -5,4 +5,4 @@ function executeActionByValueID(command, index, valueID, valueFactor){
|
||||||
}
|
}
|
||||||
function switchZoneMode(autoMode, zone) {
|
function switchZoneMode(autoMode, zone) {
|
||||||
executeAction('switch_zone_mode' ,zone, (autoMode ? 'automatic' : 'manual'))
|
executeAction('switch_zone_mode' ,zone, (autoMode ? 'automatic' : 'manual'))
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ function sleep (time) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function send_web_request($url, $messagestring, $varstring) {
|
function send_web_request(url, messageString, varString, elementId) {
|
||||||
// Browserkompatibles Request-Objekt erzeugen:
|
// Browserkompatibles Request-Objekt erzeugen:
|
||||||
r = null;
|
r = null;
|
||||||
|
|
||||||
|
@ -41,14 +41,22 @@ function send_web_request($url, $messagestring, $varstring) {
|
||||||
|
|
||||||
|
|
||||||
// HTTP-POST
|
// HTTP-POST
|
||||||
r.open('POST', $url, true);
|
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');
|
r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
r.send($varstring);
|
r.send(varString);
|
||||||
if($messagestring != 'no')
|
|
||||||
|
|
||||||
|
if(messageString != 'no')
|
||||||
{
|
{
|
||||||
alert($messagestring);
|
alert(messageString);
|
||||||
}
|
}
|
||||||
sleep(500).then(() => {
|
sleep(500).then(() => {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue