Browse Source

Merge branch 'master' of https://intra.acdp.at/gogs/po1son/Universal-storage

Juergen 'eTM' Mangler 2 years ago
parent
commit
f179ae7317
5 changed files with 63 additions and 9 deletions
  1. 17 7
      server/ustore.rb
  2. 2 0
      server/ustore.xml
  3. 12 1
      ui/css/ustore.css
  4. 4 1
      ui/index.html
  5. 28 0
      ui/js/ustore.js

+ 17 - 7
server/ustore.rb

@@ -120,20 +120,28 @@ end
 
 class CreateSymlink  < Riddl::Implementation
   def response
-      
     datalink = File.join(File.dirname(__dir__),'storage/', @r.drop(1).join("/"))
     datalink2 = datalink
-    
-    
+
     data = JSON.parse(@p[0].value.read)
     #replace last oldfilename with new one
     datalink2 = datalink.reverse.sub(data["oldfilename"].reverse, data["filename"].reverse).reverse
+
+    File.symlink(datalink, datalink2)
+  end
+end
+
+
+class RenameFile  < Riddl::Implementation
+  def response
+    datalink = File.join(File.dirname(__dir__),'storage/', @r.drop(1).join("/"))
+    datalink2 = datalink
     
+    data = JSON.parse(@p[0].value.read)
+    #replace last oldfilename with new one
+    datalink2 = datalink.reverse.sub(data["oldfilename"].reverse, data["newfilename"].reverse).reverse
     
-    #puts datalink
-    #puts datalink2
-    
-    File.symlink(datalink, datalink2)
+    File.rename(datalink, datalink2)
   end
 end
 
@@ -218,9 +226,11 @@ server = Riddl::Server.new(File.join(__dir__,'/ustore.xml'), :host => 'localhost
       run UploadData if post
       run DeleteData if delete
       run CreateSymlink if post 'list'
+      run RenameFile if put 'list'
       on resource '.*' do
         run UploadData if post
         run CreateSymlink if post 'list'
+        run RenameFile if put 'list'
         run DeleteData if delete
       end
     end

+ 2 - 0
server/ustore.xml

@@ -105,11 +105,13 @@
 			<post />
       <post in="imageUpload"/>
       <post in="list"/>
+      <put in="list"/>
       <delete/>
       <resource relative=".*">
         <post />
         <post in="imageUpload"/>
         <post in="list"/>
+        <put in="list"/>
         <delete/>
       </resource>
     </resource>

+ 12 - 1
ui/css/ustore.css

@@ -48,7 +48,7 @@
 
 #detailcolumn{
   position: relative;
-  min-height: 95%;
+  min-height: 90%;
 }
 
 #MenuBar .showremoveitemsNot{
@@ -76,6 +76,17 @@
   
 }
 
+.mouseOver{
+	color:var(--x-ui-light-text-color) !important;
+	text-decoration:none !important;
+  overflow: hidden;
+  display: block;
+}
+/*
+.mouseOver::after{
+	content:"🛈";
+}
+*/
 
 #content-wrap {
   min-height: 95%;

+ 4 - 1
ui/index.html

@@ -154,7 +154,9 @@
             <div class="DataItem">
               <div class="spanwrapping">
                 <input data-class='multiRemovelink' class="showremoveitems" type="checkbox">
-                <span data-class='name'></span>
+              <!--<span data-class='name' class="dataitemname"></span>-->
+                
+                <a data-class='name' class="mouseOver" href="#" title="Filename"></a>
               </div>
               <div data-class='image' class="DataImg">
               </div>
@@ -162,6 +164,7 @@
               <a data-class='delete' href="#" onclick="">[⨯]</a>
               <a data-class='getLink' href="#" onclick="">📎</a>
               <a data-class='createSymlink' href="#" onclick="">🔗</a>
+              <a data-class='rename' href="#" onclick="">R</a>
               <a data-class='eventTrigger' href='#'style="visibility: hidden;" onclick=''>↧</a>
             </div>
           </template>

+ 28 - 0
ui/js/ustore.js

@@ -128,6 +128,7 @@ function listData(folder = ""){
         
         var clone = document.importNode(document.querySelector('#DataItem').content,true);
         $('[data-class=name]',clone).text(value);
+        $('[data-class=name]',clone).attr('title', value);
         
         //Image
         if(imageext.includes(ext)){
@@ -147,9 +148,13 @@ function listData(folder = ""){
 		    $('[data-class=multiRemovelink]',clone).attr('name', fullfolder );
         
 		    $('[data-class=getLink]',clone).attr('href','javascript:copy2Clipboard("' + fullfolder + '");');
+        
+		    $('[data-class=rename]',clone).attr('href','javascript:rename("' + fullfolder + '", "' + value.slice(0, - (ext.length +1)) +'");');
+        
 		    $('[data-class=createSymlink]',clone).attr('href','javascript:createSymlink("' + fullfolder + '", "' + value.slice(0, - (ext.length +1)) +'");');
         
         
+        
         var queryString = window.location.search;
         var urlParams = new URLSearchParams(queryString);
         
@@ -306,6 +311,29 @@ function createSymlink(datalink, oldfilename) {
   }
   
   
+}
+
+function rename(datalink, oldfilename) {
+  var filename = prompt("Please enter new filename, without file extension.", oldfilename);
+  
+  if (filename != null && filename != "") {
+    var sendfilename = {"link": datalink, "oldfilename": oldfilename, "newfilename": filename}
+    $.ajax({
+      type: "PUT",
+      data: JSON.stringify(sendfilename),
+      headers: {"content-id": "list"},
+      contentType: "application/json",
+      url: "../server/data/" + datalink,
+      success: function(res) {
+          listFolders(datalink.substr(0, datalink.lastIndexOf("/")))
+      },
+      error: function (request, status, error) {
+        alert(request.responseText + status + error);
+      }
+    });
+  }
+  
+  
 }