Add extract context menu item
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user