Persoenliche Mediazentrale
ulrich
2021-04-10 a1b6691e14dc551ec6ff9007f5d4f8f5f8a90b43
www/ui/js/app.js
@@ -41,6 +41,7 @@
  // darunter der Inhalt des aktuellen Pfades
  this.media_liste = function() {
    self.reset_top_buttons();
    document.querySelector('.bereich-name').textContent = 'Medien-Inhalte';
    if(self.ortPfad === '/') {
      // Kataloge listen
      self.http_get('../api/store/Ablageort/liste/', function (responseText) {
@@ -106,7 +107,7 @@
  };
  
  this.ablageort_liste = function() {
    self.entitaet_liste('../api/store/Ablageort/liste/',
    self.entitaet_liste('Ablageort','../api/store/Ablageort/liste/',
      "data/tpl/ablageort_liste.tpl", '../api/store/Ablageort/', 
      "self.ablageort_form", function(responseText) {
        var ablageort = JSON.parse(responseText);
@@ -115,7 +116,7 @@
  };
  this.prefs_liste = function() {
    self.entitaet_liste('../api/store/Einstellung/liste/',
    self.entitaet_liste('Einstellungen','../api/store/Einstellung/liste/',
      "data/tpl/einstellung_liste.tpl", '../api/store/Einstellung/', 
      "self.prefs_form", function(responseText) {
        var einstellung = JSON.parse(responseText);
@@ -124,7 +125,7 @@
  };
  this.abspieler_liste = function() {
    self.entitaet_liste('../api/store/Abspieler/liste/',
    self.entitaet_liste('Abspieler','../api/store/Abspieler/liste/',
      "data/tpl/abspieler_liste.tpl", '../api/store/Abspieler/', 
      "self.abspieler_form", function(responseText) {
        var abspieler = JSON.parse(responseText);
@@ -133,7 +134,7 @@
  };
  
  this.abspielliste_liste = function() {
    self.entitaet_liste('../api/store/Abspielliste/liste/',
    self.entitaet_liste('Abspielliste','../api/store/Abspielliste/liste/',
      "data/tpl/abspielliste_liste.tpl", '../api/store/Abspielliste/', 
      "self.abspielliste_form", function(responseText) {
        var abspielliste = JSON.parse(responseText);
@@ -144,7 +145,7 @@
  /* -------------------- Entitaets-Formulare ------------------ */  
  
  this.abspielliste_form = function(al) {
    self.entitaet_form(al, al.name,
    self.entitaet_form('Abspielliste', al, al.name,
      "data/tpl/form_abspielliste.tpl", '../api/store/Abspielliste/',
      '#abspielliste-name', function() { 
          self.abspielliste_auswahl_fuellen();
@@ -153,7 +154,7 @@
  };
  
  this.abspieler_form = function(pl) {
    self.entitaet_form(pl, pl.key,
    self.entitaet_form('Abspieler', pl, pl.key,
      "data/tpl/form_abspieler.tpl", '../api/store/Abspieler/',
      '#abspieler-name', function() { 
          self.abspieler_auswahl_fuellen();
@@ -162,7 +163,7 @@
  };
  this.prefs_form = function(k) {
    self.entitaet_form(k, k.key,
    self.entitaet_form('Einstellungen', k, k.key,
      "data/tpl/form_einstellung.tpl", '../api/store/Einstellung/',
      '#einstellung-key', function() { 
          self.prefs_liste();
@@ -178,7 +179,7 @@
   * @returns {undefined} kein Rueckgabewert
   */
  this.ablageort_form = function(ort) {
    self.entitaet_form(ort, ort.name,
    self.entitaet_form('Ablageort', ort, ort.name,
      "data/tpl/form_ablageort.tpl", '../api/store/Ablageort/',
      '#ablageort-name', function() { 
        self.ablageort_liste();
@@ -227,9 +228,34 @@
    }
    var plname = document.querySelector('#playlist').value;
    self.http_put('../api/alist/' + plname, JSON.stringify(titel), function(responseText) {
      self.meldung_mit_timeout(responseText, 1500);
      //self.meldung_mit_timeout(responseText, 1500);
    });
  };  
  this.removeSelectedTitel = function() {
    var elem = document.querySelector(".selected");
    var parentElem = elem.parentNode;
    //console.log("elem: " + elem.nodeName + ", parent: " + parentElem.nodeName + ", len: " + parentElem.childNodes.length);
    var liElems = parentElem.getElementsByTagName(elem.nodeName); // nur die LI Elemente
    //console.log("liElems.anz: " + liElems.length);
    var gefunden = false;
    for(var i = 0; i < liElems.length && !gefunden; i++) {
      //console.log(liElems.item(i).textContent);
      if(liElems.item(i).classList.contains("selected")) {
        gefunden = true;
        var index = i;
        //console.log(elem.textContent + ' hat Index ' + i);
      }
    }
    // /mz/api/alist/[pl-name]/[nr]
    var plname = document.querySelector('#playlist').value;
    self.http_delete('../api/alist/' + plname + '/' + index,'', function(responseText) {
      // DELETE   http://localhost:9090/mz/api/alist/liste1/0
      //self.meldung_mit_timeout(responseText, 1500);
      self.titel_liste();
    });
  };
  
  /* Unterer Einblendbereich */
  
@@ -242,6 +268,7 @@
      self.abspielliste_auswahl_fuellen();
      self.addEvtListener('#dazu-btn', 'click', self.addSelectedTitel);
      self.addEvtListener('#play-btn', 'click', self.play);
      self.addEvtListener('#weg-btn', 'click', self.removeSelectedTitel);
      self.media_liste();
    });
  };
@@ -250,6 +277,7 @@
  
  this.titel_liste = function() {
    self.reset_top_buttons();
    document.querySelector('.bereich-name').textContent = 'Abspielliste';
    var plname = document.querySelector('#playlist').value;
    self.http_get('../api/alist/' + plname, function (responseText) {
      self.vorlage_laden_und_fuellen("data/tpl/titel_liste.tpl", JSON.parse(responseText), function (html) {
@@ -289,8 +317,9 @@
   *     self.ablageort_form(ablageort);
   *   });
   */
  this.entitaet_liste = function(listUrl, tpl, storeUrl, formFunc, cb) {
  this.entitaet_liste = function(bname, listUrl, tpl, storeUrl, formFunc, cb) {
    self.reset_top_buttons();
    document.querySelector('.bereich-name').textContent = bname;
    self.http_get(listUrl, function (responseText) {
      self.vorlage_laden_und_fuellen(tpl, JSON.parse(responseText), function (html) {
        document.querySelector(".zentraler-inhalt").innerHTML = html;
@@ -325,7 +354,8 @@
   *     });
   */
  this.entitaet_form = function(dat, key, tpl, url, selector, cb) {
  this.entitaet_form = function(bname, dat, key, tpl, url, selector, cb) {
    document.querySelector('.bereich-name').textContent = bname;
    self.vorlage_laden_und_fuellen(tpl, dat, function (html) {
      document.querySelector(".zentraler-inhalt").innerHTML = html;
      const form = document.querySelector('form');      
@@ -418,7 +448,7 @@
  };
  
  this.http_delete = function (u, data, cb) {
    console.log("delete " + u);
    // console.log("delete " + u);
    self.http_call('DELETE', u, data, cb);
  };