Просмотр исходного кода

Added urls that can be placed within the dashboard

Manuel Gall лет назад: 3
Родитель
Сommit
c8f65fe530
4 измененных файлов с 3796 добавлено и 3 удалено
  1. 8 0
      dashboard
  2. 4 0
      dashboard.xml
  3. 3709 0
      defaultContent/js/Sortable.js
  4. 75 3
      defaultContent/js/ui.js

+ 8 - 0
dashboard

@@ -409,6 +409,13 @@ class DeleteNext < Riddl::Implementation
 end 
 end 
 
 
 
 
+class DeleteAll < Riddl::Implementation
+  def response
+  
+    File.unlink(File.join('data',@r.last,'data.db')) rescue nil
+    nil
+  end
+end 
 
 
 
 
 
 
@@ -490,6 +497,7 @@ server = Riddl::Server.new(File.join(__dir__,'/dashboard.xml'), :host => 'localh
       run Delete if delete 'deleteMsg'
       run Delete if delete 'deleteMsg'
       run DeleteID if delete 'deleteByID'
       run DeleteID if delete 'deleteByID'
       run DeletePK if delete 'deletePK'
       run DeletePK if delete 'deletePK'
+      run DeleteAll if delete 'deleteAll'
       run DeleteIDDirect if delete
       run DeleteIDDirect if delete
       
       
       
       

+ 4 - 0
dashboard.xml

@@ -48,6 +48,9 @@
       <parameter name="primarykey" type="string"/>
       <parameter name="primarykey" type="string"/>
     </optional>
     </optional>
   </message>  
   </message>  
+  <message name="deleteAll">
+    <parameter name="deleteAll" type="string"/>
+  </message>
   <message name="ui">
   <message name="ui">
     <parameter name="ui" mimetype="text/html"/>
     <parameter name="ui" mimetype="text/html"/>
   </message>
   </message>
@@ -111,6 +114,7 @@
       <delete in='deleteMsg' />
       <delete in='deleteMsg' />
       <delete in='deleteByID' />
       <delete in='deleteByID' />
       <delete in='deletePK' />
       <delete in='deletePK' />
+      <delete in='deleteAll' />
       <delete />
       <delete />
       
       
       <resource relative="\d+">
       <resource relative="\d+">

Разница между файлами не показана из-за своего большого размера
+ 3709 - 0
defaultContent/js/Sortable.js


+ 75 - 3
defaultContent/js/ui.js

@@ -5,19 +5,28 @@ function getAllData(){
   
   
 
 
 
 
+
   var url_string = window.location.href
   var url_string = window.location.href
   var url = new URL(url_string);
   var url = new URL(url_string);
   if(!url.searchParams.has("display")){
   if(!url.searchParams.has("display")){
-    var urlarray = ["aktivieren","aktivierenPrio","stornieren","moveTop","moveX","edit"]
+    var urlarray = ["aktivieren","aktivierenPrio","stornieren","moveTop","moveX","move","edit"]
   }else{
   }else{
 
 
     var urlparams = url.searchParams.get("display").replace("/","");
     var urlparams = url.searchParams.get("display").replace("/","");
     var urlarray = urlparams.split(",");
     var urlarray = urlparams.split(",");
   }
   }
+  
+  
+  if(url.searchParams.has("menu")){
+    console.log("MENU");
+    menuentries = url.searchParams.get("menu").split(",")
+    $( "#data" ).append("<a class='ontop'href='" + menuentries[1] + "' target='_blank'>" + menuentries[0] +"</a>" );
+  }
 
 
   $.ajax({
   $.ajax({
     type: "GET",
     type: "GET",
     url: 'data.db',
     url: 'data.db',
+    async: false,
     success: function(ret) {      
     success: function(ret) {      
       if(!$(ret.data).length == 0){
       if(!$(ret.data).length == 0){
         container = document.getElementById("data");
         container = document.getElementById("data");
@@ -38,7 +47,7 @@ function getAllData(){
           tablehead += "<th class='editable'>" + Object.keys(JSON.parse(ret.data[0].alldata))[i]
           tablehead += "<th class='editable'>" + Object.keys(JSON.parse(ret.data[0].alldata))[i]
           
           
           if(url.searchParams.has("showfilter")){
           if(url.searchParams.has("showfilter")){
-            tablehead +=  '<br><input type="text" id="searchtable' + ++joinkey +'" onkeyup="searchtable(' + joinkey + ')" placeholder="Search for ' + Object.keys(JSON.parse(ret.data[0].alldata))[i] + '">'
+            tablehead +=  '<br><input styl="width: 100%;" type="text" id="searchtable' + ++joinkey +'" onkeyup="searchtable(' + joinkey + ')" placeholder="Search for ' + Object.keys(JSON.parse(ret.data[0].alldata))[i] + '" name="' +Object.keys(JSON.parse(ret.data[0].alldata))[i] + '">'
           }
           }
          tablehead += '</th>'
          tablehead += '</th>'
         }
         }
@@ -78,7 +87,60 @@ function getAllData(){
     }
     }
     
     
   });
   });
+  
+  
+  if(url.searchParams.has("searchkey")){
+    var searchkey = url.searchParams.get("searchkey").replace("/","");
+    $('[name="' + searchkey +'"]').val(url.searchParams.get("searchterm").replace("/",""));
+    $('[name="' + searchkey +'"]').keyup();
+  }
+  
+  
+  if(url.searchParams.has("sendListBack")){
+    
+    
+    $('body').append('<a onclick="collectdata2sendBack()" href="#">Sende Liste</a>');
+
+    
+  }
+  
+  /*
+  new Sortable(document.getElementById('data'),{
+	  handle: '.handle',
+	  animation: 150
+  });
+  */
+  
+}
+
+function collectdata2sendBack(){
+  console.log("sending");
+  var sendback = [];
+  $('[name="pkvalues"]:visible').each(function(){
+    sendback.push($(this).html());
+  });
+  
+  sendDataElementBack(sendback)
+}
+
+//https://www.therogerlab.com/sandbox/pages/how-to-reorder-table-rows-in-javascript?s=0ea4985d74a189e8b7b547976e7192ae.4122809346f6a15e41c9a43f6fcb5fd5
+var row;
+
+function start(){  
+  row = event.target; 
 }
 }
+function dragover(){
+  var e = event;
+  e.preventDefault(); 
+    
+  let children= Array.from(e.target.parentNode.parentNode.children);
+  
+  if(children.indexOf(e.target.parentNode)>children.indexOf(row))
+    e.target.parentNode.after(row);
+  else
+    e.target.parentNode.before(row);
+}
+
 function searchtable(key) {
 function searchtable(key) {
   console.log("AAA");
   console.log("AAA");
   // Declare variables
   // Declare variables
@@ -204,6 +266,13 @@ function setSingleData(singleData, urlarray, i = -1, url = ""){
   $(entry).attr("class","tableentry");
   $(entry).attr("class","tableentry");
   
   
   
   
+  if(urlarray.includes("move")){
+    $(entry).attr("draggable","true");
+    $(entry).attr("ondragstart","start()");
+    $(entry).attr("ondragover","dragover()");
+  }
+  
+  
   
   
   
   
   if(url.searchParams.has("colorize")){
   if(url.searchParams.has("colorize")){
@@ -245,13 +314,16 @@ function setSingleData(singleData, urlarray, i = -1, url = ""){
   if(urlarray.includes("moveX")){
   if(urlarray.includes("moveX")){
     tableentry += "<td><a onclick='move(" + singleData.__orderID__ +",7)' href='#'>MovetoX</a></td>"
     tableentry += "<td><a onclick='move(" + singleData.__orderID__ +",7)' href='#'>MovetoX</a></td>"
   }
   }
+  if(urlarray.includes("move")){
+    tableentry += '<td class="handle"><a href="#">⇅</a></td>'
+  }
   if(urlarray.includes("edit")){
   if(urlarray.includes("edit")){
     tableentry += "<td class='edit'><a onclick='edit(" + singleData.__orderID__ +")' href='#'>Edit</a></td>"
     tableentry += "<td class='edit'><a onclick='edit(" + singleData.__orderID__ +")' href='#'>Edit</a></td>"
   }
   }
 
 
 
 
   if(singleData.hasOwnProperty('pkvalue')){
   if(singleData.hasOwnProperty('pkvalue')){
-    tableentry += "<td>" + singleData.pkvalue + "</td>";
+    tableentry += "<td name='pkvalues'>" + singleData.pkvalue + "</td>";
   }
   }
   tableentry += "<td class='editable'>" +  Object.values(JSON.parse(singleData.alldata)).join("</td><td class='editable'>")  + "</td>"
   tableentry += "<td class='editable'>" +  Object.values(JSON.parse(singleData.alldata)).join("</td><td class='editable'>")  + "</td>"
   $(entry).html(tableentry); 
   $(entry).html(tableentry);