diff --git a/src/filemanager.html b/src/filemanager.html
index 48ac9be36..5c049ebc4 100644
--- a/src/filemanager.html
+++ b/src/filemanager.html
@@ -118,6 +118,32 @@
+
+
@@ -268,10 +294,21 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/src/js/client.js b/src/js/client.js
index feff14408..e5a18d88f 100644
--- a/src/js/client.js
+++ b/src/js/client.js
@@ -2621,6 +2621,15 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
});
};
+ Client.prototype.filesCreateFile = function (appId, path, callback) {
+ post('/api/v1/apps/' + appId + '/files/' + path, {}, {}, function (error, data, status) {
+ if (error) return callback(error);
+ if (status !== 200) return callback(new ClientError(status, data));
+
+ callback(null, data);
+ });
+ };
+
Client.prototype.filesUpload = function (appId, path, file, progressHandler, callback) {
var fd = new FormData();
fd.append('file', file);
diff --git a/src/js/filemanager.js b/src/js/filemanager.js
index f507129ba..26415f7c9 100644
--- a/src/js/filemanager.js
+++ b/src/js/filemanager.js
@@ -437,6 +437,40 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
}
};
+ $scope.newFile = {
+ busy: false,
+ error: null,
+ name: '',
+
+ show: function () {
+ $scope.newFile.error = null;
+ $scope.newFile.name = '';
+ $scope.newFile.busy = false;
+
+ $scope.newFileForm.$setUntouched();
+ $scope.newFileForm.$setPristine();
+
+ $('#newFileModal').modal('show');
+ },
+
+ submit: function () {
+ $scope.newFile.busy = true;
+ $scope.newFile.error = null;
+
+ var filePath = sanitize($scope.cwd + '/' + $scope.newFile.name);
+
+ Client.filesUpload($scope.appId, filePath, new File([], $scope.newFile.name), function () {}, function (error) {
+ $scope.newFile.busy = false;
+ if (error && error.statusCode === 409) return $scope.newFile.error = 'Already exists';
+ if (error) return Client.error(error);
+
+ $scope.refresh();
+
+ $('#newFileModal').modal('hide');
+ });
+ }
+ };
+
$scope.renameEntry = {
busy: false,
error: null,
@@ -681,7 +715,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
});
// setup all the dialog focus handling
- ['newDirectoryModal', 'renameEntryModal'].forEach(function (id) {
+ ['newFileModal', 'newDirectoryModal', 'renameEntryModal'].forEach(function (id) {
$('#' + id).on('shown.bs.modal', function () {
$(this).find('[autofocus]:first').focus();
});