From b61da1a9f087fcf8c8ce5ddc98d049ef4d688db9 Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 2 Jul 2014 17:04:29 +0100 Subject: [PATCH] Handle out of sync errors with a pop-up --- services/web/app/views/project/editor.jade | 11 +++++++++ .../app/ide/editor/EditorManager.coffee | 24 +++++++------------ .../public/coffee/app/ide/services/ide.coffee | 19 ++++++++++++++- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/services/web/app/views/project/editor.jade b/services/web/app/views/project/editor.jade index 9242a2b9b3..63fc12d3df 100644 --- a/services/web/app/views/project/editor.jade +++ b/services/web/app/views/project/editor.jade @@ -61,6 +61,17 @@ block content .ui-layout-east include ./editor/chat + script(type="text/ng-template", id="genericMessageModalTemplate") + .modal-header + button.close( + type="button" + data-dismiss="modal" + ng-click="done()" + ) × + h3 {{ title }} + .modal-body {{ message }} + .modal-footer + button.btn.btn-info(ng-click="done()") OK script(src='/socket.io/socket.io.js') diff --git a/services/web/public/coffee/app/ide/editor/EditorManager.coffee b/services/web/public/coffee/app/ide/editor/EditorManager.coffee index 93b72212bf..2906ca4f98 100644 --- a/services/web/public/coffee/app/ide/editor/EditorManager.coffee +++ b/services/web/public/coffee/app/ide/editor/EditorManager.coffee @@ -77,25 +77,17 @@ define [ _bindToDocumentEvents: (doc, sharejs_doc) -> sharejs_doc.on "error", (error) => - console.error "DOC ERROR", error @openDoc(doc, forceReopen: true) - - #TODO!!! - # Modal.createModal - # title: "Out of sync" - # message: "Sorry, this file has gone out of sync and we need to do a full refresh. Please let us know if this happens frequently." - # buttons:[ - # text: "Ok" - # ] + @ide.showGenericMessageModal( + "Out of sync" + "Sorry, this file has gone out of sync and we need to do a full refresh. Please let us know if this happens frequently." + ) sharejs_doc.on "externalUpdate", () => - #TODO!!! - # Modal.createModal - # title: "Document Updated Externally" - # message: "This document was just updated externally. Any recent changes you have made may have been overwritten. To see previous versions please look in the history." - # buttons:[ - # text: "Ok" - # ] + @ide.showGenericMessageModal( + "Document Updated Externally" + "This document was just updated externally. Any recent changes you have made may have been overwritten. To see previous versions please look in the history." + ) _unbindFromDocumentEvents: (document) -> document.off() diff --git a/services/web/public/coffee/app/ide/services/ide.coffee b/services/web/public/coffee/app/ide/services/ide.coffee index 6240dce580..a0d724dbfd 100644 --- a/services/web/public/coffee/app/ide/services/ide.coffee +++ b/services/web/public/coffee/app/ide/services/ide.coffee @@ -3,7 +3,7 @@ define [ ], (App) -> # We create and provide this as service so that we can access the global ide # from within other parts of the angular app. - App.factory "ide", ["$http", ($http) -> + App.factory "ide", ["$http", "$modal", ($http, $modal) -> ide = {} ide.$http = $http @@ -16,5 +16,22 @@ define [ ide.showGenericServerErrorMessage = () -> console.error "GENERIC SERVER ERROR MESSAGE STUB" + ide.showGenericMessageModal = (title, message) -> + $modal.open { + templateUrl: "genericMessageModalTemplate" + controller: "GenericMessageModalController" + resolve: + title: -> title + message: -> message + } + return ide ] + + App.controller "GenericMessageModalController", ["$scope", "$modalInstance", "title", "message", ($scope, $modalInstance, title, message) -> + $scope.title = title + $scope.message = message + + $scope.done = () -> + $modalInstance.close() + ]