From be897ab076511adad66f8990400de94af5c554a4 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Sat, 27 Aug 2022 00:43:15 +0200 Subject: [PATCH] refactoring file structure --- Webserver/Templates/dashboard/dashboard.html | 47 +++---------- Webserver/Templates/footer.html | 2 +- Webserver/Templates/header.html | 73 +++++--------------- Webserver/static/js/action.js | 31 +++++++++ 4 files changed, 60 insertions(+), 93 deletions(-) diff --git a/Webserver/Templates/dashboard/dashboard.html b/Webserver/Templates/dashboard/dashboard.html index 8047d81..6f3cfbc 100644 --- a/Webserver/Templates/dashboard/dashboard.html +++ b/Webserver/Templates/dashboard/dashboard.html @@ -26,6 +26,16 @@ + + + @@ -78,42 +88,5 @@ - {% include "footer.html" %} \ No newline at end of file diff --git a/Webserver/Templates/footer.html b/Webserver/Templates/footer.html index 149a04d..11ba61e 100644 --- a/Webserver/Templates/footer.html +++ b/Webserver/Templates/footer.html @@ -10,6 +10,6 @@ \ No newline at end of file diff --git a/Webserver/Templates/header.html b/Webserver/Templates/header.html index 5af1b2b..20ded42 100644 --- a/Webserver/Templates/header.html +++ b/Webserver/Templates/header.html @@ -5,60 +5,25 @@ - + + + function executeAction(command, index, value, handleResponse) { + var url = '{{url_for("executeAction")}}'; + var messageString = 'no'; + var varString = 'command=' + command + '&index=' + index + '&value=' + value; + send_web_request(url, messageString, varString, handleResponse); + } + function executeActionByValueID(command, index, valueID, valueFactor){ + var value = document.getElementById(valueID).value * valueFactor; + executeAction(command, index, value); + } + + @@ -84,8 +49,6 @@ - - diff --git a/Webserver/static/js/action.js b/Webserver/static/js/action.js index 8b13789..cea92f2 100644 --- a/Webserver/static/js/action.js +++ b/Webserver/static/js/action.js @@ -1 +1,32 @@ +function switchZoneMode(autoMode, zone) { + executeAction('switch_zone_mode' ,zone, (autoMode ? 'automatic' : 'manual')); + sleep(1000).then(() => { + refreshContent(); + }); + +} +function switchZoneState(command, zone, value) { + executeAction(command, zone, value); + sleep(1000).then(() => { + refreshContent(); + }); +} +function switchZoneStateByValueID(command, zone, valueID, valueFactor) { + executeActionByValueID(command, zone, valueID, valueFactor); + sleep(1000).then(() => { + refreshContent(); + }); +} +function deleteJobsForZone(command, zone) { + executeAction(command, zone); + sleep(1000).then(() => { + refreshContent(); + }); +} +function deleteJobById(command, jobId) { + executeAction(command, jobId); + sleep(1000).then(() => { + refreshContent(); + }); +} \ No newline at end of file