Autorefresh of Dashboard #3

Merged
Roman_Schenk merged 6 commits from Webserver_Layout into master 2022-08-27 00:31:54 +02:00
3 changed files with 94 additions and 0 deletions
Showing only changes of commit 442a7a8b11 - Show all commits

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="de">
<head>
<title>{{ translater.getTranslation("Irrigation") }}{{ translater.getTranslation("system") }}</title>
</head>
<body>
{% include "header.html" %}
<main>
<h2>Action</h2>
<div>
<p>
Sucess: {{ sucess }}
</p>
</div>
</main>
</body>
</html>

View File

@ -89,6 +89,10 @@ class Webserver:
self.zoneManager.deleteIrrigationJobByID(index) self.zoneManager.deleteIrrigationJobByID(index)
case "get_zone_list": case "get_zone_list":
return self.zoneManager.zonesToJSON() return self.zoneManager.zonesToJSON()
case "get_zone_info":
if (index):
zone = self.zoneManager.getZone(index)
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 render_template('action.html', translater=self.translater, zones=self.zoneManager.zones, sucess=sucess)

View File

@ -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.");
}
}