Move chown entries into main filemanager controller

This commit is contained in:
Johannes Zellner
2022-08-25 21:22:43 +02:00
parent 5413e52198
commit 6603087f72
4 changed files with 87 additions and 81 deletions
+2 -45
View File
@@ -12,6 +12,7 @@ angular.module('Application').component('filetree', {
onUploadFolder: '&',
onRenameEntry: '&',
onExtractEntry: '&',
onChownEntries: '&',
onDeleteEntries: '&'
},
templateUrl: 'components/filetree.html?<%= revision %>',
@@ -40,13 +41,6 @@ function FileTreeController($scope, $translate, $timeout, Client) {
// register so parent can call child
$scope.$parent.registerChild($scope);
$scope.owners = [
{ name: 'cloudron', value: 1000 },
{ name: 'www-data', value: 33 },
{ name: 'git', value: 1001 },
{ name: 'root', value: 0 }
];
function isArchive(f) {
return f.match(/\.tgz$/) ||
f.match(/\.tar$/) ||
@@ -582,43 +576,6 @@ function FileTreeController($scope, $translate, $timeout, Client) {
}
};
$scope.chownEntry = {
busy: false,
error: null,
newOwner: 0,
recursive: false,
showRecursiveOption: false,
show: function () {
$scope.chownEntry.error = null;
// set default uid from first file
$scope.chownEntry.newOwner = $scope.selected[0].uid;
$scope.chownEntry.busy = false;
// default for directories is recursive
$scope.chownEntry.recursive = !!$scope.selected.find(function (entry) { return entry.isDirectory; });
$scope.chownEntry.showRecursiveOption = !!$scope.chownEntry.recursive;
$('#chownEntryModal-' + $scope.$id).modal('show');
},
submit: function () {
$scope.chownEntry.busy = true;
async.eachLimit($scope.selected, 5, function (entry, callback) {
var filePath = sanitize($scope.cwd + '/' + entry.fileName);
Client.filesChown($scope.backendId, $scope.backendType, filePath, $scope.chownEntry.newOwner, $scope.chownEntry.recursive, callback);
}, function (error) {
$scope.chownEntry.busy = false;
if (error) return Client.error(error);
$scope.refresh();
$('#chownEntryModal-' + $scope.$id).modal('hide');
});
}
};
$scope.newFile = {
busy: false,
@@ -679,7 +636,7 @@ function FileTreeController($scope, $translate, $timeout, Client) {
click: function ($itemScope, $event, entry) { ctrl.onRenameEntry({ cwd: $scope.cwd, entry: entry }); }
}, {
text: tr['filemanager.list.menu.chown'],
click: function ($itemScope, $event, entry) { $scope.chownEntry.show(); }
click: function ($itemScope, $event, entry) { ctrl.onChownEntries({ cwd: $scope.cwd, entries: $scope.selected }); }
}, {
text: tr['filemanager.list.menu.extract'],
displayed: function ($itemScope, $event, entry) { return !entry.isDirectory && isArchive(entry.fileName); },