mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
51 lines
1.4 KiB
CoffeeScript
51 lines
1.4 KiB
CoffeeScript
define [
|
|
"base"
|
|
], (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", "$modal", ($http, $modal) ->
|
|
ide = {}
|
|
ide.$http = $http
|
|
|
|
@recentEvents = []
|
|
ide.pushEvent = (type, meta = {}) =>
|
|
@recentEvents.push type: type, meta: meta, date: new Date()
|
|
if @recentEvents.length > 40
|
|
@recentEvents.shift()
|
|
|
|
ide.reportError = (error, meta = {}) =>
|
|
meta.client_id = @socket?.socket?.sessionid
|
|
meta.transport = @socket?.socket?.transport?.name
|
|
meta.client_now = new Date()
|
|
meta.recent_events = @recentEvents
|
|
errorObj = {}
|
|
if typeof error == "object"
|
|
for key in Object.getOwnPropertyNames(error)
|
|
errorObj[key] = error[key]
|
|
else if typeof error == "string"
|
|
errorObj.message = error
|
|
$http.post "/error/client", {
|
|
error: errorObj
|
|
meta: meta
|
|
_csrf: window.csrfToken
|
|
}
|
|
|
|
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()
|
|
]
|