Эх сурвалжийг харах

[File Browser] Providing buttom 'Copy Path' for easy copy of S3 URL path in File Browser

ayush.goyal 4 жил өмнө
parent
commit
d619411d7f

+ 1 - 1
apps/filebrowser/src/filebrowser/templates/listdir.mako

@@ -115,7 +115,7 @@ ${ fb_components.menubar() }
               % endif
               % endif
             </ul>
             </ul>
           </div>
           </div>
-
+          <button class="btn fileToolbarBtn" title="${_('Copy Path')}" data-bind="enable: selectedFiles().length == 1 && isCurrentDirSelected().length == 0, click: copyPath"><i class="fa fa-fw fa-files-o"></i> ${_('Copy Path')}</button>
           <button class="btn fileToolbarBtn" title="${_('Restore from trash')}" data-bind="visible: inRestorableTrash(), click: restoreTrashSelected, enable: selectedFiles().length > 0 && isCurrentDirSelected().length == 0"><i class="fa fa-cloud-upload"></i> ${_('Restore')}</button>
           <button class="btn fileToolbarBtn" title="${_('Restore from trash')}" data-bind="visible: inRestorableTrash(), click: restoreTrashSelected, enable: selectedFiles().length > 0 && isCurrentDirSelected().length == 0"><i class="fa fa-cloud-upload"></i> ${_('Restore')}</button>
           <!-- ko ifnot: inTrash -->
           <!-- ko ifnot: inTrash -->
           % if not is_trash_enabled:
           % if not is_trash_enabled:

+ 7 - 0
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1700,6 +1700,13 @@ else:
         deleteSelected();
         deleteSelected();
       };
       };
 
 
+      self.copyPath = function () {
+        const path = $('<input>').val(self.selectedFile().path).appendTo('body').select()
+        document.execCommand('copy');
+        path.remove();
+        $.jHueNotify.info('${_('Path copied successfully to the clipboard')}');
+      }
+
       self.trashSelected = function () {
       self.trashSelected = function () {
         self.skipTrash(false);
         self.skipTrash(false);
         deleteSelected();
         deleteSelected();