diff --git a/Webserver/Templates/dashboard.html b/Webserver/Templates/dashboard.html deleted file mode 100644 index 502b46c..0000000 --- a/Webserver/Templates/dashboard.html +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - {{ translater.getTranslation("Irrigation") }}{{ translater.getTranslation("system") }} - - - - - - {% include "header.html" %} - - -
- -

{{ translater.getTranslation("Dashboard") }}

- - -

{{ translater.getTranslation("planed irrigationjobs") }}

-
- - - - - - - - - - - - {% for job in zoneManager.pipeLine %} - - - - - - - {% endfor %} - -
ID{{ translater.getTranslation("Zone") }}{{ translater.getTranslation("planed duration") }}
{{ job.id }}{{ job.zone.number|string + ": " + job.zone.name }}{{ ((job.duration/60)|int)|string + " " + translater.getTranslation("minutes")}}
-
- - -

{{ translater.getTranslation("irrigation zones") }}

-
- {% for zone in zoneManager.zones %} -
- -

{{ zone.name }}

-
- - - - - - - - - - {% if (zone.setState == 1 or zone.setState == 2) %} - - - - - - - {% endif %} - {% if zone.planedDuration > 0 %} - - - - - - - {% endif %} - - - - - - - - - - - - - - - - - -
- - - - {{ translater.getTranslation("state") }}: - {{ translater.getTranslation("switched on") if zone.state else translater.getTranslation("switched off") }} - - - -
- {{translater.getTranslation("until") + zone.endTimeSetState|string}} - - -
- {{translater.getTranslation("irragation is planed for") + " " + ((zone.planedDuration/60)|int)|string + " " + translater.getTranslation("minutes") + "." }} - - -
- - {{ translater.getTranslation("operating mode") }}:{{translater.getTranslation("automatic mode") if zone.autoMode else translater.getTranslation("manual mode")}} - -
- - - - {{ translater.getTranslation("actual humidity") }}:{{ zone.actualHumidity}}
- - {{ translater.getTranslation("desired humidity") }}:{{ zone.desiredHumidity }}
-

{{ zone.number }}

-
- - {% endfor %} - - - -
- -
-



- - - \ No newline at end of file diff --git a/Webserver/Templates/header.html b/Webserver/Templates/header.html index e275f31..9751ae0 100644 --- a/Webserver/Templates/header.html +++ b/Webserver/Templates/header.html @@ -5,11 +5,16 @@ - + diff --git a/Webserver/__init__.py b/Webserver/__init__.py index e126274..92e15c9 100644 --- a/Webserver/__init__.py +++ b/Webserver/__init__.py @@ -87,6 +87,10 @@ class Webserver: 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_zone_list": return self.zoneManager.zonesToJSON() case "get_zone_info": @@ -95,12 +99,13 @@ class Webserver: return zone.toJSON() case "get_pipeline": 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') 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/') diff --git a/Webserver/static/js/action.js b/Webserver/static/js/action.js index e6d8b62..5ce0379 100644 --- a/Webserver/static/js/action.js +++ b/Webserver/static/js/action.js @@ -5,4 +5,4 @@ function executeActionByValueID(command, index, valueID, valueFactor){ } function switchZoneMode(autoMode, zone) { executeAction('switch_zone_mode' ,zone, (autoMode ? 'automatic' : 'manual')) -} \ No newline at end of file +} diff --git a/Webserver/static/js/webhook.js b/Webserver/static/js/webhook.js index 11b5f58..eebdd88 100644 --- a/Webserver/static/js/webhook.js +++ b/Webserver/static/js/webhook.js @@ -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: r = null; @@ -41,14 +41,22 @@ function send_web_request($url, $messagestring, $varstring) { // 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.send($varstring); - if($messagestring != 'no') + r.send(varString); + + + if(messageString != 'no') { - alert($messagestring); + alert(messageString); } sleep(500).then(() => {