Explorar el Código

Fixed visual bug

Manuel Gall hace 11 meses
padre
commit
fad8398980
Se han modificado 4 ficheros con 32 adiciones y 3 borrados
  1. 21 1
      server/ustore.rb
  2. 1 0
      ui/css/ustore.css
  3. 5 0
      ui/index.html
  4. 5 2
      ui/js/ustore.js

+ 21 - 1
server/ustore.rb

@@ -65,6 +65,16 @@ end
 
 class GetImages < Riddl::Implementation
   def response
+    selectElements = @p[0];
+    
+    if(selectElements.nil? || selectElements == "")
+      selectElements = 100;
+    else
+      selectElements = @p[0].value.to_i;
+    end
+    
+    pp selectElements
+  
     Dir.chdir( __dir__  + '/../storage')
     i = 1
     while i < @r.length do
@@ -74,12 +84,22 @@ class GetImages < Riddl::Implementation
     
     ret = [];
     ret2 = [];
-    Dir.glob('*').select{ |e| 
+    i = 0
+    
+    #Sort for Date (newest first)
+    files_sorted_by_time = Dir['*'].sort_by{ |f| File.mtime(f) }.reverse
+
+    
+    files_sorted_by_time.select{ |e|
+      if(i > selectElements)
+        break
+      end
       if  File.symlink?(e)
         ret2.append(e)
       elsif( File.file?(e))
         ret.append(e)
       end
+      i = i +1
     }
     ret = ret.sort_by{|x| x.downcase}
     ret2 = ret2.sort_by{|x| x.downcase}

+ 1 - 0
ui/css/ustore.css

@@ -17,6 +17,7 @@
   float: left;
   text-align: center;
   width: 8em;
+  height: 8em;
 }
 
 .FolderImage{

+ 5 - 0
ui/index.html

@@ -148,6 +148,11 @@
             <a class="showremoveitems" href="javascript:removeSelectedItems();">[Remove Selected Items]</a>
             <a class="showremoveitems" href="javascript:selectAll();">[Select All]</a>
             <a class="showremoveitems" href="javascript:unselectAll();">[Close Selection]</a>
+            <br>
+            <a class="showhowmany" href="javascript:showitems(100);">Show 100</a>
+            <a class="showhowmany" href="javascript:showitems(500);"> 500</a>
+            <a class="showhowmany" href="javascript:showitems(1000);"> 1000</a>
+            <a class="showhowmany" href="javascript:showitems(10000);"> 10000</a>
           </div>
           
           <template id="DataItem">

+ 5 - 2
ui/js/ustore.js

@@ -17,6 +17,9 @@ $(document).on('change', '#selectfolders', function(e) {
   listFolders(this.options[e.target.selectedIndex].text);
 });
 
+function showitems(anzahl){
+  listData($( "#selectfolders option:selected" ).text(), anzahl);
+}
 
 function listFolders(folder = ""){
   $('#Folders').text("");
@@ -105,7 +108,7 @@ function deleteFolder(datalink) {
 }
 
 
-function listData(folder = ""){
+function listData(folder = "", anzahl = 100){
   $('#Data').text("");
   const imageext = ["png", "jpg", "svg", "JPG", "PNG", "SVG"]
   const movieext = ["mp4"]
@@ -113,7 +116,7 @@ function listData(folder = ""){
   
   $.ajax({
 	  type: "GET",
-	  url: "../server/images/" + folder,
+	  url: "../server/images/" + folder + "?anzahl=" + anzahl,
 	  dataType: "json",
 	  success: function(data) {
       $.each( data, function( key, value ) {