diff --git a/Webserver/Templates/action.html b/Webserver/Templates/action.html new file mode 100644 index 0000000..2e5ea85 --- /dev/null +++ b/Webserver/Templates/action.html @@ -0,0 +1,23 @@ + + + + + {{ translater.getTranslation("Irrigation") }}{{ translater.getTranslation("system") }} + + + {% include "header.html" %} + +
+ +

Action

+ +
+

+ Sucess: {{ sucess }} +

+
+ +
+ + + \ No newline at end of file diff --git a/Webserver/__init__.py b/Webserver/__init__.py index 319b6a3..e126274 100644 --- a/Webserver/__init__.py +++ b/Webserver/__init__.py @@ -89,6 +89,10 @@ class Webserver: self.zoneManager.deleteIrrigationJobByID(index) 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 render_template('action.html', translater=self.translater, zones=self.zoneManager.zones, sucess=sucess) diff --git a/Webserver/static/js/webhook.js b/Webserver/static/js/webhook.js new file mode 100644 index 0000000..11b5f58 --- /dev/null +++ b/Webserver/static/js/webhook.js @@ -0,0 +1,67 @@ +function sleep (time) { + + return new Promise((resolve) => setTimeout(resolve, time)); + +} + + + +function send_web_request($url, $messagestring, $varstring) { + // Browserkompatibles Request-Objekt erzeugen: + r = null; + + if(window.XMLHttpRequest) + { + + r = new XMLHttpRequest(); + } + else if(window.ActiveXObject) + { + + try + { + r = new ActiveXObject('Msxml2.XMLHTTP'); + } + catch(e1) + { + try + { + r = new ActiveXObject('Microsoft.XMLHTTP'); + } + catch(e2) + { + alert("Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut."); + } + } + } + + // Wenn Request-Objekt vorhanden, dann Anfrage senden: + if(r != null) + { + + + // HTTP-POST + r.open('POST', $url, true); + + r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + + r.send($varstring); + if($messagestring != 'no') + { + alert($messagestring); + } + sleep(500).then(() => { + + //window.location.href = window.location.href; + //document.location.reload(); + + }); + + } + else + { + alert("Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut."); + } + + +} \ No newline at end of file