diff --git a/src/filemanager.html b/src/filemanager.html index 32c51e56a..4a8cd795d 100644 --- a/src/filemanager.html +++ b/src/filemanager.html @@ -62,7 +62,7 @@ + + +

@@ -85,6 +112,7 @@
Path: {{ cwd }} +
diff --git a/src/js/client.js b/src/js/client.js index ebd27ccaa..acc175eaf 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -2403,6 +2403,41 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }); }; + 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); + if (status !== 200) return callback(new ClientError(status, data)); + + callback(null, data); + }); + }; + + Client.prototype.filesCreateDirectory = function (appId, path, callback) { + post('/api/v1/apps/' + appId + '/files/' + path, { directory: path }, {}, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + + callback(null, data); + }); + }; + + Client.prototype.filesUploadFile = function (appId, path, file, callback) { + var fd = new FormData(); + fd.append('file', file); + + var config = { + headers: { 'Content-Type': undefined }, + transformRequest: angular.identity + }; + + post('/api/v1/apps/' + appId + '/files/' + path, fd, config, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + + callback(null, data); + }); + }; + client = new Client(); return client; }]); diff --git a/src/js/filemanager.js b/src/js/filemanager.js index fdfb72f3c..2632f622a 100644 --- a/src/js/filemanager.js +++ b/src/js/filemanager.js @@ -82,6 +82,37 @@ app.controller('FileManagerController', ['$scope', 'Client', function ($scope, C $scope.refresh(); } + $scope.newDirectory = { + busy: false, + error: null, + name: '', + + show: function () { + $scope.newDirectory.error = null; + $scope.newDirectory.name = ''; + $scope.newDirectory.busy = false; + + $('#newDirectoryModal').modal('show'); + }, + + submit: function () { + $scope.newDirectory.busy = true; + + var filePath = sanitize($scope.cwd + '/' + $scope.newDirectory.name); + + Client.filesCreateDirectory($scope.appId, filePath, function (error, result) { + $scope.newDirectory.busy = false; + if (error) return Client.error(error); + + console.log('create direcotory', result); + + $scope.refresh(); + + $('#newDirectoryModal').modal('hide'); + }); + } + }; + $scope.entryRemove = { busy: false, error: null,