Move chown entries into main filemanager controller
This commit is contained in:
@@ -57,37 +57,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal chown entry -->
|
||||
<div class="modal fade" id="{{ 'chownEntryModal-' + $id }}" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<!-- TODO remove fileName later once all translations have been updated -->
|
||||
<h4 class="modal-title">{{ 'filemanager.chownDialog.title' | tr:{ fileName: selected[0].fileName } }}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form role="form" name="chownEntryForm" ng-submit="chownEntry.submit()" autocomplete="off">
|
||||
<div class="form-group" ng-class="{ 'has-error': (chownEntryForm.newOwner.$dirty && chownEntry.error) }">
|
||||
<label class="control-label">{{ 'filemanager.chownDialog.newOwner' | tr }}</label>
|
||||
<div class="control-label" for="inputNewOwner" ng-show="chownEntry.error">{{ chownEntry.error }}</div>
|
||||
<select class="form-control" id="inputNewOwner" name="newOwner" ng-model="chownEntry.newOwner" ng-options="a.value as a.name for a in owners" ng-disabled="chownEntry.busy"></select>
|
||||
</div>
|
||||
<div class="form-group" ng-show="chownEntry.showRecursiveOption">
|
||||
<input type="checkbox" id="inputNewOwnerRecursive" ng-model="chownEntry.recursive">
|
||||
<label class="control-label" for="inputNewOwnerRecursive">{{ 'filemanager.chownDialog.recursiveCheckbox' | tr }}</label>
|
||||
</div>
|
||||
<input class="ng-hide" type="submit" ng-disabled="chownEntryForm.$invalid || chownEntry.busy"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'main.dialog.close' | tr }}</button>
|
||||
<button type="button" class="btn btn-primary" ng-click="chownEntry.submit()" ng-hide="chownEntry.error" ng-disabled="chownEntry.busy"><i class="fa fa-circle-notch fa-spin" ng-show="chownEntry.busy"></i> {{ 'filemanager.chownDialog.change' | tr }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- main content -->
|
||||
|
||||
<div class="toolbar">
|
||||
|
||||
@@ -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); },
|
||||
|
||||
Reference in New Issue
Block a user