From 3271f1608e851dedec0e53090af8ebd81c02b6b1 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Wed, 07 Apr 2021 17:11:37 +0000
Subject: [PATCH] Kataloge verwalten repariert

---
 src/de/uhilger/mediaz/Server.java |    1 +
 www/ui/js/app.js                  |   32 +++++++++++++++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/de/uhilger/mediaz/Server.java b/src/de/uhilger/mediaz/Server.java
index af203fb..68a0ce4 100644
--- a/src/de/uhilger/mediaz/Server.java
+++ b/src/de/uhilger/mediaz/Server.java
@@ -132,6 +132,7 @@
         Ablageort ort = (Ablageort) e; 
           Ablageort ablageort = (Ablageort) e;
           logger.fine(ctx + ablageort.getUrl());
+          logger.fine(ablageort.getOrt());
           server.createContext(ctx + ablageort.getUrl(), 
                   new ListFileHandler(new File(ablageort.getOrt()).getAbsolutePath()));
       }
diff --git a/www/ui/js/app.js b/www/ui/js/app.js
index 12a6b1e..fe6d88c 100644
--- a/www/ui/js/app.js
+++ b/www/ui/js/app.js
@@ -74,15 +74,32 @@
       });
     } else {
       // Pfad listen
-      self.http_get('..' + self.ortPfad + '/' + self.mediaPfad + '/', function(responseText) {
+      console.log("vorher ortPfad: " + self.ortPfad);
+      console.log("vorher mediaPfad: " + self.mediaPfad);
+      //self.http_get('..' + self.ortPfad + '/' + self.mediaPfad + '/', function(responseText) {
+      var url = '..' + self.ortPfad + self.mediaPfad;
+      if(!url.endsWith('/')) {
+        url = url + '/';
+      }
+      console.log("url: " + url);      
+      self.http_get(url, 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;
+          console.log("mediaPfad bei Anzeige: " + self.mediaPfad);
           self.addEvtListener('.entity-eintrag', 'click', function (event) {
             var t = event.target;
-            //console.log(t.textContent);
+            var tx = t.textContent;
+            console.log("tx: " + tx);
+            console.log("mediaPfad nach Auswahl: " + self.mediaPfad);
             if(t.classList.contains("entity-typ-folder")) {
-              self.mediaPfad = self.mediaPfad + '/' + t.textContent;
+              if(self.mediaPfad.endsWith('/')) {
+                self.mediaPfad = self.mediaPfad + tx;                
+              } else {
+                self.mediaPfad = self.mediaPfad + '/' + tx;
+              }
+              //self.mediaPfad = self.mediaPfad + t.textContent;
+              console.log("mediaPfad neu: " + self.mediaPfad);
               self.media_liste();
             } else {
               console.log("Media-Inhalt auswaehlen oder abspielen");
@@ -95,8 +112,13 @@
               self.ortPfad = '/';              
             } else {
               var pos = self.mediaPfad.lastIndexOf('/');
-              var parent = self.mediaPfad.substring(0, pos);
-              //console.log("Parent: " + parent);
+              var parent;
+              if(pos > 1) {
+                parent = self.mediaPfad.substring(0, pos);
+              } else {
+                parent = '/';
+              }
+              console.log("Parent: " + parent);
               self.mediaPfad = parent;
             }
             self.media_liste();

--
Gitblit v1.9.3