diff --git a/src/filemanager.html b/src/filemanager.html
index dd123182e..6092adf90 100644
--- a/src/filemanager.html
+++ b/src/filemanager.html
@@ -126,6 +126,37 @@
+
+
@@ -204,7 +235,8 @@
{{ entry.size | prettyDiskSize }} |
{{ entry.uid | prettyOwner }} |
-
+
+
|
diff --git a/src/js/client.js b/src/js/client.js
index eee1d21f7..715d13aef 100644
--- a/src/js/client.js
+++ b/src/js/client.js
@@ -2425,6 +2425,15 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
+ Client.prototype.filesChown = function (appId, path, uid, recursive, callback) {
+ put('/api/v1/apps/' + appId + '/files/' + path, { uid: uid, recursive: recursive }, {}, function (error, data, status) {
+ if (error) return callback(error);
+ if (status !== 200) return callback(new ClientError(status, data));
+
+ callback(null, data);
+ });
+ };
+
Client.prototype.filesRename = function (appId, path, newPath, callback) {
put('/api/v1/apps/' + appId + '/files/' + path, { newFilePath: newPath }, {}, function (error, data, status) {
if (error) return callback(error);
diff --git a/src/js/filemanager.js b/src/js/filemanager.js
index a8f02382a..466c2d64f 100644
--- a/src/js/filemanager.js
+++ b/src/js/filemanager.js
@@ -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,