Add file removal functionality

This commit is contained in:
Johannes Zellner
2020-07-09 11:00:11 +02:00
parent 7c2ab4e5bd
commit c674d679bd
3 changed files with 70 additions and 10 deletions

View File

@@ -2394,6 +2394,15 @@ 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) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data);
});
};
client = new Client();
return client;
}]);

View File

@@ -1,6 +1,6 @@
'use strict';
/* global angular */
/* global angular, $ */
// create main application module
var app = angular.module('Application', ['angular-md5', 'ui-notification']);
@@ -55,20 +55,22 @@ app.controller('FileManagerController', ['$scope', 'Client', function ($scope, C
console.log('uploadFolder');
};
$scope.remove = function (entry) {
console.log('remove', entry);
};
$scope.open = function (entry) {
var filePath = sanitize($scope.cwd + '/' + entry.filePath);
if (entry.isDirectory) {
setDirectory($scope.cwd + '/' + entry.filePath);
setDirectory(filePath);
} else if (entry.isFile) {
console.log('open', entry)
Client.filesGet($scope.appId, filePath, function (error, result) {
if (error) return Client.error(error);
console.log('open', result);
});
} else {}
};
$scope.goDirectoryUp = function () {
setDirectory($scope.cwd + '/..')
setDirectory($scope.cwd + '/..');
};
function setDirectory(path) {
@@ -80,6 +82,36 @@ app.controller('FileManagerController', ['$scope', 'Client', function ($scope, C
$scope.refresh();
}
$scope.entryRemove = {
busy: false,
error: null,
entry: {},
show: function (entry) {
$scope.entryRemove.error = null;
$scope.entryRemove.entry = entry;
$('#entryRemoveModal').modal('show');
},
submit: function () {
$scope.entryRemove.busy = true;
var filePath = sanitize($scope.cwd + '/' + $scope.entryRemove.entry.filePath);
Client.filesRemove($scope.appId, filePath, function (error, result) {
$scope.entryRemove.busy = false;
if (error) return Client.error(error);
console.log('remove', result);
$scope.refresh();
$('#entryRemoveModal').modal('hide');
});
}
};
function init() {
Client.getStatus(function (error, status) {