From d5a9e4781c0a31a7678063109769ecd4bdea93c7 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Sat, 27 Aug 2022 19:08:50 +0200 Subject: [PATCH] Fixed Bug #2 --- Webserver/Templates/dashboard/dashboard.html | 2 +- Webserver/Translater.py | 1 + Webserver/__init__.py | 4 ++++ Webserver/static/js/dashboard.js | 14 +++++++++----- Zone.py | 14 +++++++++++--- ZoneManager.py | 4 ++++ 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Webserver/Templates/dashboard/dashboard.html b/Webserver/Templates/dashboard/dashboard.html index 6f3cfbc..23ccd54 100644 --- a/Webserver/Templates/dashboard/dashboard.html +++ b/Webserver/Templates/dashboard/dashboard.html @@ -64,7 +64,7 @@ - Text unter Table + diff --git a/Webserver/Translater.py b/Webserver/Translater.py index 90212af..770a264 100644 --- a/Webserver/Translater.py +++ b/Webserver/Translater.py @@ -32,6 +32,7 @@ class Translater: "planed duration": "geplante Dauer", "cancel": "abbrechen", "delete": "löschen", + "delete all jobs" : "alle Aufträge löschen", } diff --git a/Webserver/__init__.py b/Webserver/__init__.py index fe397f0..b278b5a 100644 --- a/Webserver/__init__.py +++ b/Webserver/__init__.py @@ -108,8 +108,12 @@ class Webserver: self.zoneManager.deleteIrrigationJobsForZone(zone) return "True" case "delete_job_by_id": + if(index_str == "all"): + self.zoneManager.clearIrrigationJobs() + return "True" if (index): self.zoneManager.deleteIrrigationJobByID(index) + return "True" case "get_dashboard_zone_html": if (index): zone = self.zoneManager.getZone(index) diff --git a/Webserver/static/js/dashboard.js b/Webserver/static/js/dashboard.js index 5e79593..b62e95f 100644 --- a/Webserver/static/js/dashboard.js +++ b/Webserver/static/js/dashboard.js @@ -15,13 +15,17 @@ function refreshZone(zone_json) { 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 buttonDeleteJobById(jobId) { + deleteJobById('delete_job_by_id',jobId); + if(jobId == "all") { + document.getElementById("jobListBody").innerHTML = ""; + } else { + var jobToDelete = document.getElementById("job_" + jobId); + document.getElementById("jobListBody").removeChild(jobToDelete); + } +} \ No newline at end of file diff --git a/Zone.py b/Zone.py index 5694dd8..17eaa1d 100644 --- a/Zone.py +++ b/Zone.py @@ -45,7 +45,10 @@ class Zone: self.zoneManager.switchZoneState(zone=self, state=True, duration=self.zoneManager.systemSettings.defaultAutoIrrigationDuration, instant=False) case 1: if(self.timeOver()): - self.setState = 0 + if (self.planedDuration > 0): + self.setState = 3 + else: + self.setState = 0 self.refreshStateAutomode() else: self.state = False @@ -70,7 +73,10 @@ class Zone: self.setState = 3 case 1: if(self.timeOver()): - self.setState = 0 + if (self.planedDuration > 0): + self.setState = 3 + else: + self.setState = 0 self.state = False case 2: if (self.timeOver()): @@ -105,7 +111,9 @@ class Zone: self.setState = 2 self.endTimeSetState = time.time() + duration else: - if(state): + if(self.setState == 1): + pass + elif(state): self.setState = 3 self.refreshState() diff --git a/ZoneManager.py b/ZoneManager.py index 181bc91..165c79c 100644 --- a/ZoneManager.py +++ b/ZoneManager.py @@ -60,6 +60,10 @@ class ZoneManager: else: i = i + 1 + def clearIrrigationJobs(self): + with self.piplineMutexLock: + self.pipeLine = [] + def isAnyZoneBusy(self): for zone in self.zones: if(zone.state):