Add filemanager chown dialog

This commit is contained in:
Johannes Zellner
2020-07-13 18:30:29 +02:00
parent fd3034bacc
commit b690c9bc95
3 changed files with 87 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ var app = angular.module('Application', ['angular-md5', 'ui-notification', 'ngDr
angular.module('Application').filter('prettyOwner', function () {
return function (uid) {
if (uid === 0) return 'root';
if (uid === 33) return 'cloudron';
if (uid === 33) return 'www-data';
if (uid === 1000) return 'cloudron';
if (uid === 1001) return 'git';
@@ -62,6 +62,13 @@ app.controller('FileManagerController', ['$scope', 'Client', function ($scope, C
$scope.app = null;
$scope.entries = [];
$scope.owners = [
{ name: 'cloudron', value: 1000 },
{ name: 'www-data', value: 33 },
{ name: 'git', value: 1001 },
{ name: 'root', value: 0 }
];
function sanitize(filePath) {
filePath = filePath.split('/').filter(function (a) { return !!a; }).reduce(function (a, v) {
if (v === '.'); // do nothing
@@ -337,6 +344,43 @@ app.controller('FileManagerController', ['$scope', 'Client', function ($scope, C
}
};
$scope.chownEntry = {
busy: false,
error: null,
entry: null,
newOwner: 0,
recursive: false,
show: function (entry) {
$scope.chownEntry.error = null;
$scope.chownEntry.entry = entry;
$scope.chownEntry.newOwner = entry.uid;
$scope.chownEntry.busy = false;
// default for directories is recursive
$scope.chownEntry.recursive = entry.isDirectory;
$('#chownEntryModal').modal('show');
},
submit: function () {
$scope.chownEntry.busy = true;
var filePath = sanitize($scope.cwd + '/' + $scope.chownEntry.entry.fileName);
Client.filesChown($scope.appId, filePath, $scope.chownEntry.newOwner, $scope.chownEntry.recursive, function (error, result) {
$scope.chownEntry.busy = false;
if (error) return Client.error(error);
console.log('chown', result);
$scope.refresh();
$('#chownEntryModal').modal('hide');
});
}
};
$scope.entryRemove = {
busy: false,
error: null,