Remove old filemanager assets

This commit is contained in:
Johannes Zellner
2023-07-18 18:55:44 +02:00
parent 978faa1f68
commit dd750d5d68
11 changed files with 3 additions and 3360 deletions

View File

@@ -3464,156 +3464,6 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
// FileManager API
// mode can be 'download', 'open', 'link' or 'data'
function getObjpath(id, type) {
if (type === 'mail') return 'mailserver';
if (type === 'app') return 'apps/' + id;
if (type === 'volume') return 'volumes/' + id;
}
Client.prototype.filesGetLink = function (id, type, path) {
var objpath = getObjpath(id, type);
return client.apiOrigin + '/api/v1/' + objpath + '/files/' + path + '?download=false&access_token=' + token;
};
Client.prototype.filesGet = function (id, type, path, mode, callback) {
var objpath = getObjpath(id, type);
if (mode === 'download') {
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/' + objpath + '/files/' + path + '?download=false&access_token=' + token);
callback(null);
} 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/' + objpath + '/files/' + path, { transformResponse: responseHandler }, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data);
});
}
};
Client.prototype.filesRemove = function (id, type, path, callback) {
var objpath = getObjpath(id, type);
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));
callback(null, data);
});
};
Client.prototype.filesExtract = function (id, type, path, callback) {
var objpath = getObjpath(id, type);
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));
callback(null, data);
});
};
Client.prototype.filesChown = function (id, type, path, uid, recursive, callback) {
var objpath = getObjpath(id, type);
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));
callback(null, data);
});
};
Client.prototype.filesRename = function (id, type, path, newPath, callback) {
var objpath = getObjpath(id, type);
put('/api/v1/' + objpath + '/files/' + path, { action: 'rename', newFilePath: decodeURIComponent(newPath) }, {}, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data);
});
};
Client.prototype.filesCopy = function (id, type, path, newPath, callback) {
var that = this;
var objpath = getObjpath(id, type);
put('/api/v1/' + objpath + '/files/' + path, { action: 'copy', newFilePath: decodeURIComponent(newPath) }, {}, function (error, data, status) {
if (error && error.statusCode === 409) return that.filesCopy(id, type, path, newPath + '-copy', callback);
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 = getObjpath(id, type);
post('/api/v1/' + objpath + '/files/' + path, { directory: decodeURIComponent(path) }, {}, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data);
});
};
Client.prototype.filesCreateFile = function (id, type, path, callback) {
var objpath = getObjpath(id, type);
post('/api/v1/' + objpath + '/files/' + path, {}, {}, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data);
});
};
Client.prototype.filesUpload = function (id, type, path, file, overwrite, progressHandler, callback) {
var objpath = getObjpath(id, type);
var fd = new FormData();
fd.append('file', file);
if (overwrite) fd.append('overwrite', 'true');
function done(error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data);
}
$http({
url: client.apiOrigin + '/api/v1/' + objpath + '/files/' + path,
method: 'POST',
data: fd,
transformRequest: angular.identity,
headers: {
'Content-Type': undefined,
Authorization: 'Bearer ' + token
},
uploadEventHandlers: {
progress: function (e) {
progressHandler(e.loaded);
}
}
}).success(defaultSuccessHandler(done)).error(defaultErrorHandler(done));
};
// ----------------------------------------------
// Eventlog helpers
// ----------------------------------------------