From b379f5d6fa95c9c938c38ce592739ea732847821 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Sun, 04 Apr 2021 18:08:17 +0000
Subject: [PATCH] Durchstich Neuer Ablageort
---
www/ui/js/app.js | 76 +++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 1 deletions(-)
diff --git a/www/ui/js/app.js b/www/ui/js/app.js
index 4eaffef..f7cd6be 100644
--- a/www/ui/js/app.js
+++ b/www/ui/js/app.js
@@ -1,10 +1,84 @@
-function AppVorlage() {
+function Ablageort(n, o, u) {
+ this.name = n;
+ this.ort = o;
+ this.url = u;
+}
+
+
+
+function Mediazentrale() {
var self = this;
var appMenu;
// var vorlagen;
var cache; // mustache templates
+
+ this.form_ablageort_neu = function() {
+ self.vorlage_laden_und_fuellen("data/tpl/form_ablageort.tpl", "", function(html) {
+ document.querySelector(".zentraler-inhalt").innerHTML = html;
+ self.addEvtListener('#ok-btn', 'click', function() {
+ // hier neuen Ablageort speichern
+ var a = new Ablageort(
+ document.querySelector('#ablageort-name').value,
+ document.querySelector('#ablageort-ort').value,
+ document.querySelector('#ablageort-url').value
+ );
+ // {"name":"Katalog","ort":"/home/ulrich/Videos","url":"/media/test"}
+ //var daten = self.serialisieren(a);
+ var daten = JSON.stringify(a);
+ self.http_post('../api/store/Ablageort', daten, function(){
+ // hier die Antwort verarbeiten
+ });
+ });
+ self.addEvtListener('#cancel-btn', 'click', function() {
+ // hier die Aktion abbrechen
+ });
+ });
+ };
+
+ this.addEvtListener = function(selector, eventName, func) {
+ var elems = document.querySelectorAll(selector);
+ var index;
+ for (index = 0; index < elems.length; index++) {
+ elems[index].addEventListener(eventName, func);
+ }
+ };
+
+ this.http_get = function(u, cb) {
+ self.http_call('GET', u, null, cb);
+ };
+
+ this.http_post = function(u, data, cb) {
+ self.http_call('POST', u, data, cb);
+ };
+
+ this.http_call = function (method, u, data, scallback) {
+ var xhr = new XMLHttpRequest();
+ var url = u;
+ xhr.onreadystatechange = function() {
+ if (this.readyState === 4 && this.status === 200) {
+ scallback(this.responseText);
+ }
+ };
+ xhr.open(method, url);
+ if(method === 'GET') {
+ xhr.send();
+ } else if(method === 'POST' || method === 'PUT') {
+ xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ xhr.send(data);
+ }
+ };
+
+ this.serialisieren = function(obj) {
+ return '{"' + obj.constructor.name + '":' + JSON.stringify(obj) + '}';
+ };
+
+
+
+
+ /* ab hier aus App-Vorlage */
+
this.init = function() {
//self.vorlagen = new Vorlagen();
self.cache = new Array();
--
Gitblit v1.9.3