From ca9872be43938cf03f23ca9ac05a2acd69429cf3 Mon Sep 17 00:00:00 2001
From: ulrich <undisclosed@undiclosed>
Date: Tue, 06 Apr 2021 14:49:30 +0000
Subject: [PATCH] Katalog (in Arbeit)

---
 www/ui/js/app.js |   71 +++++++++++++++++++++++++++++++++--
 1 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/www/ui/js/app.js b/www/ui/js/app.js
index 691185d..b7b98a2 100644
--- a/www/ui/js/app.js
+++ b/www/ui/js/app.js
@@ -10,6 +10,59 @@
   var self = this;
   var appMenu;
   var cache; // mustache templates
+  var ortPfad;
+  var mediaPfad;
+  
+  // auf der obersten Ebene werden die Kataloge angezeigt,
+  // darunter der Inhalt des aktuellen Pfades
+  this.media_liste = function() {
+    if(self.ortPfad === '/') {
+      // Kataloge listen
+      self.http_get('../api/store/Ablageort/', function (responseText) {
+        self.vorlage_laden_und_fuellen("data/tpl/katalog_root_liste.tpl", JSON.parse(responseText), function (html) {
+          document.querySelector(".zentraler-inhalt").innerHTML = html;
+          self.addEvtListener('.entity-eintrag', 'click', function (event) {
+            var t = event.target;
+            self.http_get('../api/store/Ablageort/' + t.textContent, function(responseText) {
+              var ablageort = JSON.parse(responseText);
+              console.log(ablageort.url);
+              self.ortPfad = ablageort.url;
+              self.media_liste();
+            });
+          });
+        });
+      });
+    } else {
+      // Pfad listen
+      self.http_get('..' + self.ortPfad + '/' + self.mediaPfad + '/', function(responseText) {
+        //console.log(responseText);
+        self.vorlage_laden_und_fuellen("data/tpl/katalog_inhalt_liste.tpl", JSON.parse(responseText), function (html) {
+          document.querySelector(".zentraler-inhalt").innerHTML = html;
+          self.addEvtListener('.entity-eintrag', 'click', function (event) {
+            var t = event.target;
+            //console.log(t.textContent);
+            if(t.classList.contains("entity-typ-folder")) {
+              self.mediaPfad = self.mediaPfad + '/' + t.textContent;
+              self.media_liste();
+            } else {
+              console.log("Media-Inhalt auswaehlen oder abspielen");
+            }
+          });
+          self.addEvtListener('#zurueck-btn', 'click', function (event) {
+            if(self.mediaPfad === '/') {
+              self.ortPfad = '/';              
+            } else {
+              var pos = self.mediaPfad.lastIndexOf('/');
+              var parent = self.mediaPfad.substring(0, pos);
+              //console.log("Parent: " + parent);
+              self.mediaPfad = parent;
+            }
+            self.media_liste();
+          });        
+        });
+      });
+    }
+  };
 
   this.ablageort_liste = function() {
     self.http_get('../api/store/Ablageort/', function (responseText) {
@@ -18,10 +71,13 @@
         self.addEvtListener('.entity-eintrag', 'click', function (event) {
           var t = event.target;
           self.http_get('../api/store/Ablageort/' + t.textContent, function(responseText){
-            ablageort = JSON.parse(responseText);
+            var ablageort = JSON.parse(responseText);
             self.ablageort_form(ablageort);
           });
         });
+        self.addEvtListener('#neu-btn', 'click', function (event) {
+          eval("self.ablageort_form" + "(this)");
+        });        
       });
     });
   };
@@ -57,10 +113,12 @@
             // hier die Antwort verarbeiten
           });
         }
-        document.querySelector(".zentraler-inhalt").innerHTML = '';
+        //document.querySelector(".zentraler-inhalt").innerHTML = '';
+        self.ablageort_liste();
       });
       self.addEvtListener('#cancel-btn', 'click', function () {
-        document.querySelector(".zentraler-inhalt").innerHTML = '';
+        //document.querySelector(".zentraler-inhalt").innerHTML = '';
+        self.ablageort_liste();
       });
       self.addEvtListener('#loeschen-btn', 'click', function() {
         var aoname = document.querySelector('#ablageort-name').value;
@@ -71,7 +129,8 @@
             self.http_delete('../api/store/Ablageort/' + aoname, '', function (responseText) {
               // hier die Antwort verarbeiten
               self.dialog_schliessen();
-              document.querySelector(".zentraler-inhalt").innerHTML = '';
+              //document.querySelector(".zentraler-inhalt").innerHTML = '';
+              self.ablageort_liste();
             });
           });
         });
@@ -87,6 +146,8 @@
     }
   };
 
+  /* asynchroner HTTP Client */
+  
   this.http_get = function (u, cb) {
     self.http_call('GET', u, null, cb);
   };
@@ -125,6 +186,8 @@
 
   this.init = function () {
     //self.vorlagen = new Vorlagen();
+    self.mediaPfad = '/';
+    self.ortPfad = '/';
     self.cache = new Array();
     self.appMenu = new AppMenu();
     self.appMenu.init(

--
Gitblit v1.9.3