diff --git a/services/web/app/coffee/Features/LinkedFiles/LinkedFilesController.coffee b/services/web/app/coffee/Features/LinkedFiles/LinkedFilesController.coffee index bb5a93efb9..c9edeefe32 100644 --- a/services/web/app/coffee/Features/LinkedFiles/LinkedFilesController.coffee +++ b/services/web/app/coffee/Features/LinkedFiles/LinkedFilesController.coffee @@ -27,7 +27,7 @@ module.exports = LinkedFilesController = { if error? logger.error {err: error, project_id, name, linkedFileData, parent_folder_id, user_id}, 'error writing linked file to disk' return Agent.handleError(error, req, res, next) - EditorController.upsertFile project_id, parent_folder_id, name, fsPath, linkedFileData, "upload", user_id, (error) -> + EditorController.upsertFile project_id, parent_folder_id, name, fsPath, linkedFileData, "upload", user_id, (error, file) -> return next(error) if error? - res.send(204) # created + res.json(new_file_id: file._id) # created } diff --git a/services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee b/services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee index ebecf1132e..fc86208717 100644 --- a/services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee +++ b/services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee @@ -19,3 +19,17 @@ define [ , 0 , this ) + + openFileById: (id) -> + file = @ide.fileTreeManager.selectEntityById(id) + @$scope.ui.view = "file" + @$scope.openFile = null + @$scope.$apply() + window.setTimeout( + () => + @$scope.openFile = file + @$scope.$apply() + @$scope.$digest() + , 0 + , this + ) diff --git a/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee b/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee index c14e097842..cdc8cd5d2c 100644 --- a/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee +++ b/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee @@ -49,8 +49,15 @@ define [ $scope.refreshFile = (file) -> $scope.refreshing = true ide.fileTreeManager.refreshLinkedFile(file) - .then () -> - loadTextFileFilePreview() + .then (response) -> + { data } = response + new_file_id = data.new_file_id + $timeout( + () -> + ide.binaryFilesManager.openFileById(new_file_id) + , 1000 + ) + # loadTextFileFilePreview() .finally () -> $scope.refreshing = false diff --git a/services/web/public/coffee/ide/file-tree/FileTreeManager.coffee b/services/web/public/coffee/ide/file-tree/FileTreeManager.coffee index 8536db63c7..2cd6ea4031 100644 --- a/services/web/public/coffee/ide/file-tree/FileTreeManager.coffee +++ b/services/web/public/coffee/ide/file-tree/FileTreeManager.coffee @@ -112,6 +112,15 @@ define [ entity.selected = false entity.selected = true + selectEntityById: (entity_id) -> + @selected_entity_id = entity_id # For reselecting after a reconnect + selected_entity = null + @ide.fileTreeManager.forEachEntity (entity) -> + if entity.id == entity_id + selected_entity = entity + entity.selected = true + return selected_entity + toggleMultiSelectEntity: (entity) -> entity.multiSelected = !entity.multiSelected @$scope.multiSelectedCount = @multiSelectedCount()