Handle out of sync errors with a pop-up

This commit is contained in:
James Allen 2014-07-02 17:04:29 +01:00
parent e870d7190b
commit b61da1a9f0
3 changed files with 37 additions and 17 deletions

View file

@ -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')

View file

@ -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()

View file

@ -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()
]