diff --git a/src/js/client.js b/src/js/client.js index 84f4b731c..375af9025 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -2815,6 +2815,17 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }); }; + Client.prototype.filesCopy = function (id, type, path, newPath, callback) { + var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; + + put('/api/v1/' + objpath + '/files/' + path, { action: 'copy', newFilePath: newPath }, {}, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + + callback(null, data); + }); + }; + Client.prototype.filesCreateDirectory = function (id, type, path, callback) { var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id; diff --git a/src/js/filemanager.js b/src/js/filemanager.js index a943f9352..9ef6b8930 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -377,7 +377,22 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl $scope.refresh(); }); } else { + // TODO collect files recoursively if we have folders + // copy files + async.eachLimit($scope.clipboard, 5, function (entry, callback) { + var newFilePath = sanitize($scope.cwd + '/' + ((destinationEntry && destinationEntry.isDirectory) ? destinationEntry.fileName : '') + '/' + entry.fileName); + + // TODO this will NOT overwrite files in destination! + Client.filesCopy($scope.id, $scope.type, entry.fullFilePath, newFilePath, callback); + }, function (error) { + if (error) return Client.error(error); + + // clear clipboard + $scope.clipboard = []; + + $scope.refresh(); + }); } };