Add file browser button to volume listing
This commit is contained in:
@@ -67,8 +67,9 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
$scope.client = Client;
|
||||
$scope.cwd = '';
|
||||
$scope.cwdParts = [];
|
||||
$scope.appId = search.appId;
|
||||
$scope.app = null;
|
||||
$scope.id = search.appId || search.volumeId;
|
||||
$scope.type = search.appId ? 'app' : 'volume';
|
||||
$scope.title = '';
|
||||
$scope.entries = [];
|
||||
$scope.dropToBody = false;
|
||||
$scope.sortAsc = true;
|
||||
@@ -157,7 +158,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
$scope.extractStatus.error = null;
|
||||
$scope.extractStatus.busy = true;
|
||||
|
||||
Client.filesExtract($scope.appId, filePath, function (error) {
|
||||
Client.filesExtract($scope.id, $scope.type, filePath, function (error) {
|
||||
$scope.extractStatus.busy = false;
|
||||
|
||||
if (error) {
|
||||
@@ -177,7 +178,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
|
||||
if (entry.isDirectory) return;
|
||||
|
||||
Client.filesGet($scope.appId, filePath, 'download', function (error) {
|
||||
Client.filesGet($scope.id, $scope.type, filePath, 'download', function (error) {
|
||||
if (error) return Client.error(error);
|
||||
});
|
||||
}
|
||||
@@ -259,7 +260,8 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
$scope.refresh = function () {
|
||||
$scope.busy = true;
|
||||
|
||||
Client.filesGet($scope.appId, $scope.cwd, 'data', function (error, result) {
|
||||
console.log('getting', $scope.id, $scope.type, $scope.cwd);
|
||||
Client.filesGet($scope.id, $scope.type, $scope.cwd, 'data', function (error, result) {
|
||||
$scope.busy = false;
|
||||
if (error) return Client.error(error);
|
||||
|
||||
@@ -299,11 +301,11 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
if (mimeGroup === 'video' || mimeGroup === 'image') {
|
||||
$scope.mediaViewer.show(entry);
|
||||
} else if (mimeType === 'application/pdf') {
|
||||
Client.filesGet($scope.appId, filePath, 'open', function (error) { if (error) return Client.error(error); });
|
||||
Client.filesGet($scope.id, $scope.type, filePath, 'open', function (error) { if (error) return Client.error(error); });
|
||||
} else if (mimeGroup === 'text' || mimeGroup === 'application') {
|
||||
$scope.textEditor.show(entry);
|
||||
} else {
|
||||
Client.filesGet($scope.appId, filePath, 'open', function (error) { if (error) return Client.error(error); });
|
||||
Client.filesGet($scope.id, $scope.type, filePath, 'open', function (error) { if (error) return Client.error(error); });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -368,7 +370,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
|
||||
$scope.uploadStatus.fileName = file.name;
|
||||
|
||||
Client.filesUpload($scope.appId, filePath, file, overwrite, function (loaded) {
|
||||
Client.filesUpload($scope.id, $scope.type, filePath, file, overwrite, function (loaded) {
|
||||
$scope.uploadStatus.percentDone = ($scope.uploadStatus.done+loaded) * 100 / $scope.uploadStatus.size;
|
||||
}, function (error) {
|
||||
if (error) return callback(error);
|
||||
@@ -439,7 +441,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
|
||||
var filePath = sanitize($scope.cwd + '/' + $scope.newDirectory.name);
|
||||
|
||||
Client.filesCreateDirectory($scope.appId, filePath, function (error) {
|
||||
Client.filesCreateDirectory($scope.id, $scope.type, filePath, function (error) {
|
||||
$scope.newDirectory.busy = false;
|
||||
if (error && error.statusCode === 409) return $scope.newDirectory.error = 'Already exists';
|
||||
if (error) return Client.error(error);
|
||||
@@ -473,7 +475,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
|
||||
var filePath = sanitize($scope.cwd + '/' + $scope.newFile.name);
|
||||
|
||||
Client.filesUpload($scope.appId, filePath, new File([], $scope.newFile.name), false, function () {}, function (error) {
|
||||
Client.filesUpload($scope.id, $scope.type, filePath, new File([], $scope.newFile.name), false, function () {}, function (error) {
|
||||
$scope.newFile.busy = false;
|
||||
if (error && error.statusCode === 409) return $scope.newFile.error = 'Already exists';
|
||||
if (error) return Client.error(error);
|
||||
@@ -506,7 +508,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
var oldFilePath = sanitize($scope.cwd + '/' + $scope.renameEntry.entry.fileName);
|
||||
var newFilePath = sanitize(($scope.renameEntry.newName[0] === '/' ? '' : ($scope.cwd + '/')) + $scope.renameEntry.newName);
|
||||
|
||||
Client.filesRename($scope.appId, oldFilePath, newFilePath, function (error) {
|
||||
Client.filesRename($scope.id, $scope.type, oldFilePath, newFilePath, function (error) {
|
||||
$scope.renameEntry.busy = false;
|
||||
if (error) return Client.error(error);
|
||||
|
||||
@@ -525,7 +527,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
show: function (entry) {
|
||||
var filePath = sanitize($scope.cwd + '/' + entry.fileName);
|
||||
|
||||
Client.filesGet($scope.appId, filePath, 'link', function (error, result) {
|
||||
Client.filesGet($scope.id, $scope.type, filePath, 'link', function (error, result) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
$scope.mediaViewer.entry = entry;
|
||||
@@ -557,7 +559,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
var filePath = sanitize($scope.cwd + '/' + entry.fileName);
|
||||
var language = getLanguage(entry.fileName);
|
||||
|
||||
Client.filesGet($scope.appId, filePath, 'data', function (error, result) {
|
||||
Client.filesGet($scope.id, $scope.type, filePath, 'data', function (error, result) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
if (!$scope.textEditor.editor) {
|
||||
@@ -583,7 +585,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
var filePath = sanitize($scope.cwd + '/' + $scope.textEditor.entry.fileName);
|
||||
var file = new File([newContent], 'file');
|
||||
|
||||
Client.filesUpload($scope.appId, filePath, file, true, function () {}, function (error) {
|
||||
Client.filesUpload($scope.id, $scope.type, filePath, file, true, function () {}, function (error) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
$timeout(function () {
|
||||
@@ -635,7 +637,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
|
||||
var filePath = sanitize($scope.cwd + '/' + $scope.chownEntry.entry.fileName);
|
||||
|
||||
Client.filesChown($scope.appId, filePath, $scope.chownEntry.newOwner, $scope.chownEntry.recursive, function (error) {
|
||||
Client.filesChown($scope.id, $scope.type, filePath, $scope.chownEntry.newOwner, $scope.chownEntry.recursive, function (error) {
|
||||
$scope.chownEntry.busy = false;
|
||||
if (error) return Client.error(error);
|
||||
|
||||
@@ -663,7 +665,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
|
||||
var filePath = sanitize($scope.cwd + '/' + $scope.entryRemove.entry.fileName);
|
||||
|
||||
Client.filesRemove($scope.appId, filePath, function (error) {
|
||||
Client.filesRemove($scope.id, $scope.type, filePath, function (error) {
|
||||
$scope.entryRemove.busy = false;
|
||||
if (error) return Client.error(error);
|
||||
|
||||
@@ -701,13 +703,15 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
|
||||
Client.refreshUserInfo(function (error) {
|
||||
if (error) return Client.initError(error, init);
|
||||
|
||||
Client.getApp($scope.appId, function (error, result) {
|
||||
var getter = $scope.type === 'app' ? Client.getApp.bind(Client, $scope.id) : Client.getVolume.bind(Client, $scope.id);
|
||||
|
||||
getter(function (error, result) {
|
||||
if (error) {
|
||||
$scope.initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.app = result;
|
||||
$scope.title = $scope.type === 'app' ? (result.label || result.fqdn) : result.name;
|
||||
|
||||
// now mark the Client to be ready
|
||||
Client.setReady();
|
||||
|
||||
Reference in New Issue
Block a user