diff --git a/src/components/filetree.html b/src/components/filetree.html index c5f3946c1..e08254a38 100644 --- a/src/components/filetree.html +++ b/src/components/filetree.html @@ -57,37 +57,6 @@ - - - -
diff --git a/src/components/filetree.js b/src/components/filetree.js index 8751fa334..69a6d1283 100644 --- a/src/components/filetree.js +++ b/src/components/filetree.js @@ -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); }, diff --git a/src/filemanager.html b/src/filemanager.html index 995ad0280..81f0f6e5f 100644 --- a/src/filemanager.html +++ b/src/filemanager.html @@ -81,8 +81,7 @@ + + + diff --git a/src/js/filemanager.js b/src/js/filemanager.js index f3ecc481f..3ebc1794a 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -79,11 +79,19 @@ var VIEW = { RIGHT: 'right' }; +var OWNERS = [ + { name: 'cloudron', value: 1000 }, + { name: 'www-data', value: 33 }, + { name: 'git', value: 1001 }, + { name: 'root', value: 0 } +]; + app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Client', function ($scope, $translate, $timeout, Client) { var search = decodeURIComponent(window.location.search).slice(1).split('&').map(function (item) { return item.split('='); }).reduce(function (o, k) { o[k[0]] = k[1]; return o; }, {}); // expose enums $scope.VIEW = VIEW; + $scope.OWNERS = OWNERS; $scope.initialized = false; $scope.status = null; @@ -290,6 +298,49 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl }; + // chown entries + + $scope.chownEntries = { + busy: false, + error: null, + entries: [], + newOwner: 0, + recursive: false, + showRecursiveOption: false, + + show: function (cwd, entries) { + $scope.chownEntries.error = null; + $scope.chownEntries.cwd = cwd; + $scope.chownEntries.entries = entries; + // set default uid from first file + $scope.chownEntries.newOwner = entries[0].uid; + $scope.chownEntries.busy = false; + + // default for directories is recursive + $scope.chownEntries.recursive = !!entries.find(function (entry) { return entry.isDirectory; }); + $scope.chownEntries.showRecursiveOption = false; + + $('#chownEntriesModal').modal('show'); + }, + + submit: function () { + $scope.chownEntries.busy = true; + + async.eachLimit($scope.chownEntries.entries, 5, function (entry, callback) { + var filePath = sanitize($scope.chownEntries.cwd + '/' + entry.fileName); + + Client.filesChown($scope.backendId, $scope.backendType, filePath, $scope.chownEntries.newOwner, $scope.chownEntries.recursive, callback); + }, function (error) { + $scope.chownEntries.busy = false; + if (error) return Client.error(error); + + $scope.refresh(); + + $('#chownEntriesModal').modal('hide'); + }); + } + }; + // extract archives $scope.extractStatus = {