Add file browser button to volume listing
This commit is contained in:
@@ -2603,22 +2603,24 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
|
||||
// FileManager API
|
||||
// mode can be 'download', 'open', 'link' or 'data'
|
||||
Client.prototype.filesGet = function (appId, path, mode, callback) {
|
||||
Client.prototype.filesGet = function (id, type, path, mode, callback) {
|
||||
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
|
||||
|
||||
if (mode === 'download') {
|
||||
window.open(client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path + '?download=true&access_token=' + token);
|
||||
window.open(client.apiOrigin + '/api/v1/' + objpath + '/files/' + path + '?download=true&access_token=' + token);
|
||||
callback(null);
|
||||
} else if (mode === 'open') {
|
||||
window.open(client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path + '?download=false&access_token=' + token);
|
||||
window.open(client.apiOrigin + '/api/v1/' + objpath + '/files/' + path + '?download=false&access_token=' + token);
|
||||
callback(null);
|
||||
} else if (mode === 'link') {
|
||||
callback(null, client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path + '?download=false&access_token=' + token);
|
||||
callback(null, client.apiOrigin + '/api/v1/' + objpath + '/files/' + path + '?download=false&access_token=' + token);
|
||||
} else {
|
||||
function responseHandler(data, headers, status) {
|
||||
if (headers()['content-type'] && headers()['content-type'].indexOf('application/json') !== -1) return JSON.parse(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
get('/api/v1/apps/' + appId + '/files/' + path, { transformResponse: responseHandler }, function (error, data, status) {
|
||||
get('/api/v1/' + objpath + '/files/' + path, { transformResponse: responseHandler }, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
@@ -2627,8 +2629,10 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype.filesRemove = function (appId, path, callback) {
|
||||
del('/api/v1/apps/' + appId + '/files/' + path, null, function (error, data, status) {
|
||||
Client.prototype.filesRemove = function (id, type, path, callback) {
|
||||
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
|
||||
|
||||
del('/api/v1/' + objpath + '/files/' + path, null, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
@@ -2636,8 +2640,10 @@ 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) {
|
||||
Client.prototype.filesExtract = function (id, type, path, callback) {
|
||||
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
|
||||
|
||||
put('/api/v1/' + objpath + '/files/' + path, { action: 'extract' }, {}, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
@@ -2645,8 +2651,10 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.filesChown = function (appId, path, uid, recursive, callback) {
|
||||
put('/api/v1/apps/' + appId + '/files/' + path, { action: 'chown', uid: uid, recursive: recursive }, {}, function (error, data, status) {
|
||||
Client.prototype.filesChown = function (id, type, path, uid, recursive, callback) {
|
||||
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
|
||||
|
||||
put('/api/v1/' + objpath + '/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));
|
||||
|
||||
@@ -2654,8 +2662,10 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.filesRename = function (appId, path, newPath, callback) {
|
||||
put('/api/v1/apps/' + appId + '/files/' + path, { action: 'rename', newFilePath: newPath }, {}, function (error, data, status) {
|
||||
Client.prototype.filesRename = function (id, type, path, newPath, callback) {
|
||||
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
|
||||
|
||||
put('/api/v1/' + objpath + '/files/' + path, { action: 'rename', newFilePath: newPath }, {}, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
@@ -2663,8 +2673,10 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.filesCreateDirectory = function (appId, path, callback) {
|
||||
post('/api/v1/apps/' + appId + '/files/' + path, { directory: path }, {}, function (error, data, status) {
|
||||
Client.prototype.filesCreateDirectory = function (id, type, path, callback) {
|
||||
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
|
||||
|
||||
post('/api/v1/' + objpath + '/files/' + path, { directory: path }, {}, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
@@ -2672,8 +2684,10 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.filesCreateFile = function (appId, path, callback) {
|
||||
post('/api/v1/apps/' + appId + '/files/' + path, {}, {}, function (error, data, status) {
|
||||
Client.prototype.filesCreateFile = function (id, type, path, callback) {
|
||||
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
|
||||
|
||||
post('/api/v1/' + objpath + '/files/' + path, {}, {}, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
@@ -2681,7 +2695,9 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.filesUpload = function (appId, path, file, overwrite, progressHandler, callback) {
|
||||
Client.prototype.filesUpload = function (id, type, path, file, overwrite, progressHandler, callback) {
|
||||
var objpath = (type === 'app' ? 'apps/' : 'volumes/') + id;
|
||||
|
||||
var fd = new FormData();
|
||||
fd.append('file', file);
|
||||
|
||||
@@ -2695,7 +2711,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
}
|
||||
|
||||
$http({
|
||||
url: client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path,
|
||||
url: client.apiOrigin + '/api/v1/' + objpath + '/files/' + path,
|
||||
method: 'POST',
|
||||
data: fd,
|
||||
transformRequest: angular.identity,
|
||||
|
||||
Reference in New Issue
Block a user