From 29be41b5182c30eaf79c53eb3e8fa052e62b594d Mon Sep 17 00:00:00 2001 From: ulrich Date: Tue, 20 Apr 2021 22:17:18 +0000 Subject: [PATCH] Anzeige des Schaltzustands von Geraeten --- src/de/uhilger/mediaz/api/StorageHandler.java | 5 ++++- www/ui/app.css | 38 +++++++++++++++++++++++++++++++++++++- www/ui/data/tpl/geraet_schalt_liste.txt | 10 +++++----- www/ui/js/app.js | 6 ++++-- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/de/uhilger/mediaz/api/StorageHandler.java b/src/de/uhilger/mediaz/api/StorageHandler.java index 5d8db1b..62dc218 100644 --- a/src/de/uhilger/mediaz/api/StorageHandler.java +++ b/src/de/uhilger/mediaz/api/StorageHandler.java @@ -140,7 +140,10 @@ newList.add(g); } } - list = newList; + //list = newList; + Gson gson = new Gson(); + Object o = gson.fromJson(bodyLesen(e), fs.typeFromName(type).getType()); + return gson.toJson(newList); } else { list = fs.list(type); } diff --git a/www/ui/app.css b/www/ui/app.css index b177dfa..1bd6fcc 100644 --- a/www/ui/app.css +++ b/www/ui/app.css @@ -174,7 +174,43 @@ } .schalt-geraet-name { - / * background-color: red; */ + /* background-color: red; */ +} + +.schalt-geraet-false { + color: red; +} + +.schalt-geraet-true { + color: green; + font-weight: bold; +} + +.schalt-btn { + display: inline-block; + height: 38px; + /* padding: 0 30px; */ + text-align: center; + font-size: 11px; + font-weight: 600; + line-height: 38px; + letter-spacing: .1rem; + text-transform: uppercase; + text-decoration: none; + white-space: nowrap; + /* background-color: transparent;*/ + border-radius: 4px; + border: 1px solid #bbb; + cursor: pointer; + box-sizing: border-box; +} + +.schalt-btn-ein { + color: green; +} + +.schalt-btn-aus { + color: red; } .entity-liste-kopf { diff --git a/www/ui/data/tpl/geraet_schalt_liste.txt b/www/ui/data/tpl/geraet_schalt_liste.txt index 928924a..41bcfcb 100644 --- a/www/ui/data/tpl/geraet_schalt_liste.txt +++ b/www/ui/data/tpl/geraet_schalt_liste.txt @@ -1,9 +1,9 @@ <div class='entity-formular'> - {{#ArrayList}} + {{#.}} <div class='geraet-schalt-eintrag'> - <button class="button schalt-btn" id="ein-btn" gname="{{.}}">Ein</button> - <button class="button schalt-btn" id="aus-btn" gname="{{.}}">Aus</button> - <div class='schalt-geraet-name entity-eintrag'>{{.}}</div> + <button class="schalt-btn schalt-btn-ein" id="ein-btn" gname="{{name}}">Ein</button> + <button class="schalt-btn schalt-btn-aus" id="aus-btn" gname="{{name}}">Aus</button> + <div class='schalt-geraet-name schalt-geraet-{{status}} entity-eintrag'>{{name}}</div> </div> - {{/ArrayList}} + {{/.}} </div> \ No newline at end of file diff --git a/www/ui/js/app.js b/www/ui/js/app.js index 98a5675..3825b66 100644 --- a/www/ui/js/app.js +++ b/www/ui/js/app.js @@ -166,14 +166,16 @@ 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); + // 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); + // console.log(responseText); + self.geraet_schalt_liste(); }); }); }); -- Gitblit v1.9.3