Add new file creation action and collapse new and upload actions
This commit is contained in:
@@ -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);
|
||||
|
||||
+35
-1
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user