Ver código fonte

New functions e.g. sorting, add, highlight

Manuel Gall 2 anos atrás
pai
commit
86e7c99cbe
6 arquivos alterados com 3813 adições e 18 exclusões
  1. 69 9
      dashboard
  2. 6 1
      dashboard.xml
  3. 2 0
      defaultContent/index.html
  4. 6 3
      defaultContent/js/ui.js
  5. 21 5
      template/index.html
  6. 3709 0
      template/js/Sortable.js

+ 69 - 9
dashboard

@@ -145,7 +145,10 @@ class AddEntry < Riddl::Implementation
     
     
     
-    @a[0].send(JSON.dump(hash))
+    @a[0].send("reset")
+ 
+ 
+ 
     nil
     
   end
@@ -201,11 +204,61 @@ class Put < Riddl::Implementation
   
   def response  
     hash = Put::putentry(@r, @p, @h)
-    @a[0].send(JSON.dump(hash))
+  
+
+    @a[0].send("reset")
+ 
     nil
   end
 end
 
+class PostHtmlVals < Riddl::Implementation
+  def response
+    
+    Dir.mkdir(File.join('data',@r[-2])) rescue nil
+    Dir.mkdir(File.join('data',@r[-2], "js")) rescue nil
+    Dir.mkdir(File.join('data',@r[-2], "visus")) rescue nil
+    
+    
+    #prevent overriding ui and index in case user changed something there
+    if !File.file?(File.join('data',@r[-2],'js/ui.js'))
+      File.write(File.join('data',@r[-2],'js/ui.js'),File.open("defaultContent/js/ui.js").read)
+    end
+    
+    if !File.file?(File.join('data',@r[-2],'index.html'))
+      file = File.open("defaultContent/index.html").read
+      newfile = file.gsub("!replaceThisString!", @r[-2])
+
+      File.write(File.join('data',@r[-2],'index.html'), newfile)
+    end
+    
+    #prevent overriding visualization
+    if !File.file?(File.join('data',@r[-2],'visus.html'))
+      File.write(File.join('data',@r[-2],'visus.html'),File.open("defaultContent/visus.html").read)
+    end
+    
+    
+    file = JSON['{}']
+
+    
+    @p.each_with_index  do |child, idx|
+      file[child.name] = child.value
+    end
+    
+    
+    fname = File.join('data',@r[-2],'data.db')
+    db = SQLite3::Database.open fname
+      
+    db.execute "CREATE TABLE IF NOT EXISTS Entries(__orderID__ INTEGER PRIMARY KEY AUTOINCREMENT, alldata TEXT, cpeeInstance INTEGER)"
+    db.execute("INSERT OR REPLACE INTO Entries (alldata, cpeeInstance) VALUES (?,?)", JSON[file], "none")
+    
+    
+    @a[0].send("reset")
+    Riddl::Parameter::Complex.new('ui','text/html',  '<html><head><meta http-equiv="refresh" content="0; url =' +@h["REFERER"]+'"/></head>')
+  end
+end
+
+
 
 class PutPrio < Riddl::Implementation
   def response
@@ -360,6 +413,8 @@ class Delete < Riddl::Implementation
     db = SQLite3::Database.open fname
     alldata = @p[0].value.read
     db.execute("DELETE FROM Entries WHERE alldata = '" + alldata + "'")
+    @a[0].send("reset")   
+   
     nil
   end
 end
@@ -374,6 +429,7 @@ class DeleteID < Riddl::Implementation
   end
   def response
     DeleteID::remove(@r.last, @p[0].value.read)
+    @a[0].send("reset")
     nil
   end
 end
@@ -381,6 +437,7 @@ end
 class DeleteIDDirect < Riddl::Implementation
   def response
     DeleteID::remove(@r.last, @p[0].value)
+    @a[0].send("reset")
     nil
   end
 end
@@ -393,7 +450,7 @@ class DeletePK < Riddl::Implementation
     db = SQLite3::Database.open fname
     pkvalue = @p[0].value
     db.execute("DELETE FROM Entries WHERE pkvalue = '" + pkvalue + "'")
-    
+    @a[0].send("reset")   
     nil
   end
 end
@@ -536,11 +593,11 @@ server = Riddl::Server.new(File.join(__dir__,'/dashboard.xml'), :host => 'localh
       run Update if put 'update'
       run Storesortedtable, opts[:signals][idx] if put 'storesortedtable'
       run AddEntry, opts[:signals][idx] if post 'directADD'
-      run Delete if delete 'deleteMsg'
-      run DeleteID if delete 'deleteByID'
-      run DeletePK if delete 'deletePK'
-      run DeleteAll if delete 'deleteAll'
-      run DeleteIDDirect if delete
+      run Delete, opts[:signals][idx] if delete 'deleteMsg'
+      run DeleteID, opts[:signals][idx] if delete 'deleteByID'
+      run DeletePK, opts[:signals][idx] if delete 'deletePK'
+      run DeleteAll, opts[:signals][idx] if delete 'deleteAll'
+      run DeleteIDDirect, opts[:signals][idx] if delete
       
       
       on resource '\d+' do
@@ -556,6 +613,9 @@ server = Riddl::Server.new(File.join(__dir__,'/dashboard.xml'), :host => 'localh
         run GetAllData if get
       end
       
+      on resource 'htmlform' do
+        run PostHtmlVals, opts[:signals][idx] if post
+      end
       
       on resource 'search' do
         on resource 'PK' do
@@ -576,4 +636,4 @@ server = Riddl::Server.new(File.join(__dir__,'/dashboard.xml'), :host => 'localh
       
     end
   end
-end.loop!
+end.loop!

+ 6 - 1
dashboard.xml

@@ -100,7 +100,6 @@
   </message>
   
   
-  
   <resource>
     <get out="ui"/>
     <resource relative='getconfigs'>
@@ -132,6 +131,12 @@
         <get out="json"/>
       </resource>
       
+      
+      <resource relative='htmlform'>
+        <post out="ui"/>
+      </resource>
+      
+      
       <resource relative='search'>
         <resource relative='PK'>
           <resource relative=".*">

+ 2 - 0
defaultContent/index.html

@@ -35,6 +35,8 @@
     <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
     <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
     <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
+    <script type="text/javascript" src="/js_libs/jquery-ui.js"></script>
+    <script type="text/javascript" src="/js_libs/loadingoverlay.js"></script>
 
     <!-- custom stuff, play arround  -->
     <script type="text/javascript" src="../data/dashboardAnstehende/js/ui.js"></script>

+ 6 - 3
defaultContent/js/ui.js

@@ -30,11 +30,14 @@ function getAllData(){
         urlarray.forEach(function(element) { tablehead += "<th></th>" });
         
         
+        var joinkey = urlarray.length;
         if(ret.data[0].hasOwnProperty('pkvalue')){
           tablehead += "<th class='primarykey'>Primary Key</th>";
         }
+        else{
+          --joinkey
+        }
         
-        var joinkey = urlarray.length;
         
         for (var i = 0; i < Object.keys(JSON.parse(ret.data[0].alldata)).length; i++) {
           tablehead += "<th class='editable'>" + Object.keys(JSON.parse(ret.data[0].alldata))[i]
@@ -631,11 +634,11 @@ function init() {
     console.log("Got SSE");
     if (e.data == 'new') {
       reason = '';
-      showDocument();
+      getAllData();
     }
     if (e.data == 'reset') {
       reason = '';
-      showDocument();
+      getAllData();
     }
     else{
       if(e.data == "update"){

+ 21 - 5
template/index.html

@@ -53,8 +53,15 @@
         
      <h1>Configurations</h1>
      
+     <h2>Button Filtering</h2>
+        &display=[aktivieren,aktivierenPrio,stornieren,moveTop,moveX,move,move2,edit]<br><br>
+        
+        
+     <h2>"Menu"</h2>
+        ?menu=Buttonname,link/<br>
+        adds a button on the top left linking to "link" with label "Buttonname"<br><br>
      
-     <h2>Coloring entries</h1>
+     <h2>Coloring entries</h2>
         ?colorize=Yourcolumnname<br>
         &colorizestart=beginningtext of entrie that should be colorized<br>
         &colorizecol=3465a4 color without #<br><br>
@@ -62,16 +69,25 @@
         second color<br>
         ?colorize2=Yourcolumnname<br>
         &colorize2start=beginningtext of entrie that should be colorized<br>
-        &colorize2col=3465a4 color without #<br>
+        &colorize2col=3465a4 color without #<br><br>
+    
+    <h2>Allow entry filtering</h2>
+        ?showfilter=true/<br><br>
+    
+    
+    <h2>Move group</h2>
+    group1column=Wa%20Nr.<br>
     
+    group2column1=Wa%20Nr.&group2column2=Pos/#<br>
+    you can move multiple elements by grouping them based on their columns value e.g. WA Nr. all entries with same WaNR will be grouped <b>on buttonclick</b> on the move handle.
     
     
-    <h1>Search</h1>
-      e.g. https://centurio.evva.com/dashboard/LinieNfcId/search/PK/5
+    <h2>Search</h2>
+      e.g. https://centurio.evva.com/dashboard/LinieNfcId/search/PK/5<br><br>
       
       
       
-    <h1>Todo</h1>
+    <h2>Todo</h2>
     List all configs<br>
       Select config<br>
         Show visualizations<br>

Diferenças do arquivo suprimidas por serem muito extensas
+ 3709 - 0
template/js/Sortable.js