diff --git a/src/js/client.js b/src/js/client.js index 649785281..feff14408 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -2585,8 +2585,17 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }); }; + Client.prototype.filesExtract = function (appId, path, callback) { + put('/api/v1/apps/' + appId + '/files/' + path, { action: 'extract' }, {}, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + + callback(null, data); + }); + }; + Client.prototype.filesChown = function (appId, path, uid, recursive, callback) { - put('/api/v1/apps/' + appId + '/files/' + path, { uid: uid, recursive: recursive }, {}, function (error, data, status) { + put('/api/v1/apps/' + appId + '/files/' + path, { action: 'chown', uid: uid, recursive: recursive }, {}, function (error, data, status) { if (error) return callback(error); if (status !== 200) return callback(new ClientError(status, data)); @@ -2595,7 +2604,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }; Client.prototype.filesRename = function (appId, path, newPath, callback) { - put('/api/v1/apps/' + appId + '/files/' + path, { newFilePath: newPath }, {}, function (error, data, status) { + put('/api/v1/apps/' + appId + '/files/' + path, { action: 'rename', newFilePath: newPath }, {}, function (error, data, status) { if (error) return callback(error); if (status !== 200) return callback(new ClientError(status, data)); diff --git a/src/js/filemanager.js b/src/js/filemanager.js index 7109b392f..a0255dfb9 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -82,8 +82,16 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio { name: 'root', value: 0 } ]; + function isArchive(f) { + return f.match(/\.tar\.gz$/) || f.match(/\.tgz$/) || f.match(/\.zip$/); + } + $scope.menuOptions = [ { + text: 'Extract Here', + enabled: function ($itemScope, $event, entry) { return !entry.isDirectory && isArchive(entry.fileName); }, + click: function ($itemScope, $event, entry) { extract(entry); } + }, { text: 'Download', enabled: function ($itemScope, $event, entry) { return !entry.isDirectory; }, click: function ($itemScope, $event, entry) { download(entry); } @@ -122,6 +130,16 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio return '/' + filePath; } + function extract(entry) { + var filePath = sanitize($scope.cwd + '/' + entry.fileName); + + if (entry.isDirectory) return; + + Client.filesExtract($scope.appId, filePath, function (error) { + if (error) return Client.error(error); + }); + } + function download(entry) { var filePath = sanitize($scope.cwd + '/' + entry.fileName);