From a2378dda4a23a7bb7eec9764c7a3b5bbbc1dd72f Mon Sep 17 00:00:00 2001 From: ulrich Date: Wed, 21 Apr 2021 12:49:08 +0000 Subject: [PATCH] Kleine Anpassungen an Bedienelementen --- www/ui/js/app.js | 52 +++++++++++++++++++++++++++++----------------------- 1 files changed, 29 insertions(+), 23 deletions(-) diff --git a/www/ui/js/app.js b/www/ui/js/app.js index 033dac4..b2162e7 100644 --- a/www/ui/js/app.js +++ b/www/ui/js/app.js @@ -156,30 +156,36 @@ } }; + this.ein_aus_btn = function() { + self.addEvtListener('#ein-aus-btn', 'click', function (event) { + var geraetName = event.target.attributes.gname.nodeValue; + var nameElem = event.target.parentNode.querySelector('.schalt-geraet-name'); + if(nameElem.classList.contains('schalt-geraet-true')) { + // ausschalten + self.http_get('../api/gstrg/geraet/' + geraetName + "/aus", function(responseText) { + // console.log(responseText); + self.geraet_schalt_liste(); + }); + } else { + // einschalten + self.http_get('../api/gstrg/geraet/' + geraetName + "/ein", function(responseText) { + // console.log(responseText); + self.geraet_schalt_liste(); + }); + } + }); + }; + this.geraet_schalt_liste = function() { + /*self.entitaet_liste('Geräte schalten','../api/store/Geraet/listealles/', + "data/tpl/geraet_schalt_liste.txt", '../api/store/Geraet/', + "self.form_geraet_status", function(responseText) {*/ self.entitaet_liste('Geräte schalten','../api/store/Geraet/listealles/', "data/tpl/geraet_schalt_liste.txt", '../api/store/Geraet/', - "self.form_geraet_status", function(responseText) { - var geraet = JSON.parse(responseText); - self.geraet_status_form(geraet); - }, function() { - self.addEvtListener('#ein-btn', 'click', function (event) { - var geraetName = event.target.attributes.gname.nodeValue; - //var geraetName = document.querySelector('.schalt-geraet-name').textContent; - self.http_get('../api/gstrg/geraet/' + geraetName + "/ein", function(responseText) { - // console.log(responseText); - self.geraet_schalt_liste(); - }); - }); - self.addEvtListener('#aus-btn', 'click', function (event) { - var geraetName = event.target.attributes.gname.nodeValue; - //var geraetName = document.querySelector('.schalt-geraet-name').textContent; - self.http_get('../api/gstrg/geraet/' + geraetName + "/aus", function(responseText) { - // console.log(responseText); - self.geraet_schalt_liste(); - }); - }); - }); + "", function(responseText) { + //var geraet = JSON.parse(responseText); + //self.geraet_status_form(geraet); + }, self.ein_aus_btn); }; this.geraet_liste = function() { @@ -365,7 +371,7 @@ self.addEvtListener('#media-btn', 'click', self.media_liste); self.addEvtListener('#plst-btn', 'click', self.titel_liste); - self.addEvtListener('#live-btn', 'click', self.livestream_liste); + self.addEvtListener('#live-btn', 'click', self.livestream_selection); self.addEvtListener('#switch-btn', 'click', self.geraet_schalt_liste); self.media_liste(); @@ -516,7 +522,7 @@ * var ablageort = JSON.parse(responseText); * self.ablageort_form(ablageort); * }); - */ + */ this.entitaet_liste = function(bname, listUrl, tpl, storeUrl, formFunc, cb, customListCode) { self.reset_top_buttons(); document.querySelector('.bereich-name').textContent = bname; -- Gitblit v1.9.3