mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 21:25:21 +00:00
Use standard promises with the http service.
This commit is contained in:
parent
eab00c95df
commit
155f515a50
29 changed files with 106 additions and 105 deletions
|
@ -28,7 +28,7 @@ define [
|
|||
# authentication fails, we will handle it ourselves
|
||||
$http
|
||||
.post(element.attr('action'), formData, {disableAutoLoginRedirect: true})
|
||||
.success (data, status, headers, config) ->
|
||||
.then (data, status, headers, config) ->
|
||||
scope[attrs.name].inflight = false
|
||||
response.success = true
|
||||
response.error = false
|
||||
|
@ -51,7 +51,7 @@ define [
|
|||
else
|
||||
ga('send', 'event', formName, 'success')
|
||||
|
||||
.error (data, status, headers, config) ->
|
||||
.catch (data, status, headers, config) ->
|
||||
scope[attrs.name].inflight = false
|
||||
response.success = false
|
||||
response.error = true
|
||||
|
|
|
@ -34,7 +34,7 @@ define [
|
|||
$scope.bibtexPreview.shouldShowDots = false
|
||||
$scope.$apply()
|
||||
$http.get(url)
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
$scope.bibtexPreview.loading = false
|
||||
$scope.bibtexPreview.error = false
|
||||
# show dots when payload is closs to cutoff
|
||||
|
@ -46,7 +46,7 @@ define [
|
|||
finally
|
||||
$scope.bibtexPreview.data = data
|
||||
$timeout($scope.setHeight, 0)
|
||||
.error (err) ->
|
||||
.catch (err) ->
|
||||
$scope.bibtexPreview.error = true
|
||||
$scope.bibtexPreview.loading = false
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ define [
|
|||
chat.state.loading = true
|
||||
return $http
|
||||
.get(url)
|
||||
.success (messages = [])->
|
||||
.then (messages = [])->
|
||||
chat.state.loading = false
|
||||
if messages.length < MESSAGE_LIMIT
|
||||
chat.state.atEnd = true
|
||||
|
|
|
@ -23,9 +23,9 @@ define [
|
|||
$scope.state.inflight = true
|
||||
$scope.state.error = false
|
||||
cloneProject($scope.inputs.projectName)
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
window.location = "/project/#{data.project_id}"
|
||||
.error (body, statusCode) ->
|
||||
.catch (body, statusCode) ->
|
||||
$scope.state.inflight = false
|
||||
if statusCode == 400
|
||||
$scope.state.error = { message: body }
|
||||
|
|
|
@ -63,11 +63,11 @@ define [
|
|||
$scope.state.inflight = true
|
||||
ide.fileTreeManager
|
||||
.createDoc(name, parent_folder)
|
||||
.error (e)->
|
||||
$scope.error = e
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
$modalInstance.close()
|
||||
.catch (e)->
|
||||
$scope.error = e
|
||||
|
||||
$scope.cancel = () ->
|
||||
$modalInstance.dismiss('cancel')
|
||||
|
@ -95,12 +95,12 @@ define [
|
|||
$scope.state.inflight = true
|
||||
ide.fileTreeManager
|
||||
.createFolder(name, parent_folder)
|
||||
.error (e)->
|
||||
$scope.error = e
|
||||
$scope.state.inflight = false
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
$modalInstance.close()
|
||||
.catch (e)->
|
||||
$scope.error = e
|
||||
$scope.state.inflight = false
|
||||
|
||||
$scope.cancel = () ->
|
||||
$modalInstance.dismiss('cancel')
|
||||
|
|
|
@ -73,7 +73,7 @@ define [
|
|||
@$scope.history.loading = true
|
||||
@ide.$http
|
||||
.get(url)
|
||||
.success (data) =>
|
||||
.then (data) =>
|
||||
@_loadUpdates(data.updates)
|
||||
@$scope.history.nextBeforeTimestamp = data.nextBeforeTimestamp
|
||||
if !data.nextBeforeTimestamp?
|
||||
|
@ -109,12 +109,12 @@ define [
|
|||
|
||||
@ide.$http
|
||||
.get(url)
|
||||
.success (data) =>
|
||||
.then (data) =>
|
||||
diff.loading = false
|
||||
{text, highlights} = @_parseDiff(data)
|
||||
diff.text = text
|
||||
diff.highlights = highlights
|
||||
.error () ->
|
||||
.catch () ->
|
||||
diff.loading = false
|
||||
diff.error = true
|
||||
else
|
||||
|
|
|
@ -9,7 +9,7 @@ define [
|
|||
.restoreDeletedDoc(
|
||||
$scope.history.diff.doc
|
||||
)
|
||||
.success (response) ->
|
||||
.then (response) ->
|
||||
$scope.history.diff.restoredDocNewId = response.doc_id
|
||||
$scope.history.diff.restoreInProgress = false
|
||||
$scope.history.diff.restoreDeletedSuccess = true
|
||||
|
@ -37,7 +37,7 @@ define [
|
|||
$scope.state.inflight = true
|
||||
ide.historyManager
|
||||
.restoreDiff(diff)
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
$modalInstance.close()
|
||||
ide.editorManager.openDoc(diff.doc)
|
||||
|
|
|
@ -28,7 +28,7 @@ define [
|
|||
labels.loadProjectLabelsFromServer = () ->
|
||||
$http
|
||||
.get("/project/#{window.project_id}/labels")
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
if data.projectLabels
|
||||
for docId, docLabels of data.projectLabels
|
||||
state.documents[docId] = docLabels
|
||||
|
@ -39,6 +39,6 @@ define [
|
|||
"/project/#{window.project_id}/doc/#{docId}/labels",
|
||||
{_csrf: window.csrfToken}
|
||||
)
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
|
||||
return labels
|
||||
|
|
|
@ -385,11 +385,11 @@ define [
|
|||
options.rootDocOverride_id = getRootDocOverride_id()
|
||||
|
||||
sendCompileRequest(options)
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
$scope.pdf.view = "pdf"
|
||||
$scope.pdf.compiling = false
|
||||
parseCompileResponse(data)
|
||||
.error (err, status) ->
|
||||
.catch (err, status) ->
|
||||
if status == 429
|
||||
$scope.pdf.rateLimited = true
|
||||
$scope.pdf.compiling = false
|
||||
|
@ -514,9 +514,9 @@ define [
|
|||
clsiserverid:ide.clsiServerId
|
||||
}
|
||||
})
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
deferred.resolve(data.pdf or [])
|
||||
.error (error) ->
|
||||
.catch (error) ->
|
||||
deferred.reject(error)
|
||||
|
||||
return deferred.promise
|
||||
|
@ -559,12 +559,12 @@ define [
|
|||
clsiserverid:ide.clsiServerId
|
||||
}
|
||||
})
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
if data.code? and data.code.length > 0
|
||||
doc = ide.fileTreeManager.findEntityByPath(data.code[0].file)
|
||||
return if !doc?
|
||||
deferred.resolve({doc: doc, line: data.code[0].line})
|
||||
.error (error) ->
|
||||
.catch (error) ->
|
||||
deferred.reject(error)
|
||||
|
||||
return deferred.promise
|
||||
|
|
|
@ -188,7 +188,7 @@ define [
|
|||
|
||||
refreshRanges = () ->
|
||||
$http.get "/project/#{$scope.project_id}/ranges"
|
||||
.success (docs) ->
|
||||
.then (docs) ->
|
||||
for doc in docs
|
||||
if !$scope.reviewPanel.overview.docsCollapsedState[doc.id]?
|
||||
$scope.reviewPanel.overview.docsCollapsedState[doc.id] = false
|
||||
|
@ -438,7 +438,7 @@ define [
|
|||
thread.submitting = true
|
||||
$scope.$broadcast "comment:add", thread_id, offset, length
|
||||
$http.post("/project/#{$scope.project_id}/thread/#{thread_id}/messages", {content, _csrf: window.csrfToken})
|
||||
.error (error) ->
|
||||
.catch (error) ->
|
||||
ide.showGenericMessageModal("Error submitting comment", "Sorry, there was a problem submitting your comment")
|
||||
$scope.$broadcast "editor:clearSelection"
|
||||
$timeout () ->
|
||||
|
@ -458,7 +458,7 @@ define [
|
|||
thread_id = entry.thread_id
|
||||
content = entry.replyContent
|
||||
$http.post("/project/#{$scope.project_id}/thread/#{thread_id}/messages", {content, _csrf: window.csrfToken})
|
||||
.error (error) ->
|
||||
.catch (error) ->
|
||||
ide.showGenericMessageModal("Error submitting comment", "Sorry, there was a problem submitting your comment")
|
||||
|
||||
trackingMetadata =
|
||||
|
@ -598,7 +598,7 @@ define [
|
|||
_refreshingRangeUsers = true
|
||||
|
||||
$http.get "/project/#{$scope.project_id}/changes/users"
|
||||
.success (users) ->
|
||||
.then (users) ->
|
||||
_refreshingRangeUsers = false
|
||||
$scope.users = {}
|
||||
# Always include ourself, since if we submit an op, we might need to display info
|
||||
|
@ -608,7 +608,7 @@ define [
|
|||
for user in users
|
||||
if user.id?
|
||||
$scope.users[user.id] = formatUser(user)
|
||||
.error () ->
|
||||
.catch () ->
|
||||
_refreshingRangeUsers = false
|
||||
|
||||
_threadsLoaded = false
|
||||
|
@ -619,7 +619,7 @@ define [
|
|||
_threadsLoaded = true
|
||||
$scope.reviewPanel.loadingThreads = true
|
||||
$http.get "/project/#{$scope.project_id}/threads"
|
||||
.success (threads) ->
|
||||
.then (threads) ->
|
||||
$scope.reviewPanel.loadingThreads = false
|
||||
for thread_id, _ of $scope.reviewPanel.resolvedThreadIds
|
||||
delete $scope.reviewPanel.resolvedThreadIds[thread_id]
|
||||
|
|
|
@ -24,7 +24,7 @@ define [
|
|||
oldName = $scope.project.name
|
||||
$scope.project.name = newName
|
||||
settings.saveProjectSettings({name: $scope.project.name})
|
||||
.error (response, statusCode) ->
|
||||
.catch (response, statusCode) ->
|
||||
$scope.project.name = oldName
|
||||
if statusCode == 400
|
||||
ide.showGenericMessageModal("Error renaming project", response)
|
||||
|
|
|
@ -15,16 +15,16 @@ define [
|
|||
ide.socket.on 'project:membership:changed', (data) =>
|
||||
if data.members
|
||||
projectMembers.getMembers()
|
||||
.success (responseData) =>
|
||||
.then (responseData) =>
|
||||
if responseData.members
|
||||
$scope.project.members = responseData.members
|
||||
.error (responseDate) =>
|
||||
.catch (responseDate) =>
|
||||
console.error "Error fetching members for project"
|
||||
if data.invites
|
||||
projectInvites.getInvites()
|
||||
.success (responseData) =>
|
||||
.then (responseData) =>
|
||||
if responseData.invites
|
||||
$scope.project.invites = responseData.invites
|
||||
.error (responseDate) =>
|
||||
.catch (responseDate) =>
|
||||
console.error "Error fetching invites for project"
|
||||
]
|
||||
|
|
|
@ -34,7 +34,7 @@ define [
|
|||
$scope.autocompleteContacts = []
|
||||
do loadAutocompleteUsers = () ->
|
||||
$http.get "/user/contacts"
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
$scope.autocompleteContacts = data.contacts or []
|
||||
for contact in $scope.autocompleteContacts
|
||||
if contact.type == "user"
|
||||
|
@ -102,7 +102,7 @@ define [
|
|||
request = projectInvites.sendInvite(email, $scope.inputs.privileges)
|
||||
|
||||
request
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
if data.error
|
||||
$scope.state.error = true
|
||||
$scope.state.errorReason = "#{data.error}"
|
||||
|
@ -125,7 +125,7 @@ define [
|
|||
# with new collaborator information.
|
||||
addNextMember()
|
||||
, 0
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = true
|
||||
$scope.state.errorReason = null
|
||||
|
@ -137,12 +137,12 @@ define [
|
|||
$scope.state.inflight = true
|
||||
projectMembers
|
||||
.removeMember(member)
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
index = $scope.project.members.indexOf(member)
|
||||
return if index == -1
|
||||
$scope.project.members.splice(index, 1)
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = "Sorry, something went wrong :("
|
||||
|
||||
|
@ -151,12 +151,12 @@ define [
|
|||
$scope.state.inflight = true
|
||||
projectInvites
|
||||
.revokeInvite(invite._id)
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
index = $scope.project.invites.indexOf(invite)
|
||||
return if index == -1
|
||||
$scope.project.invites.splice(index, 1)
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = "Sorry, something went wrong :("
|
||||
|
||||
|
@ -165,10 +165,10 @@ define [
|
|||
$scope.state.inflight = true
|
||||
projectInvites
|
||||
.resendInvite(invite._id)
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
event.target.blur()
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = "Sorry, something went wrong resending the invite :("
|
||||
event.target.blur()
|
||||
|
|
|
@ -11,10 +11,10 @@ define [
|
|||
params:
|
||||
clsiserverid:ide.clsiServerId
|
||||
$http opts
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
$scope.status.loading = false
|
||||
$scope.data = data.texcount
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.status.error = true
|
||||
|
||||
$scope.cancel = () ->
|
||||
|
|
|
@ -12,10 +12,10 @@ define [
|
|||
headers:
|
||||
"X-CSRF-Token": window.csrfToken
|
||||
})
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.unsubscribing = false
|
||||
$scope.subscribed = false
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.unsubscribing = true
|
||||
|
||||
$scope.deleteAccount = () ->
|
||||
|
@ -59,7 +59,7 @@ define [
|
|||
password: $scope.state.password
|
||||
disableAutoLoginRedirect: true # we want to handle errors ourselves
|
||||
})
|
||||
.success () ->
|
||||
.then () ->
|
||||
$modalInstance.close()
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = false
|
||||
|
@ -69,7 +69,7 @@ define [
|
|||
window.location = "/login"
|
||||
, 1000
|
||||
)
|
||||
.error (data, status) ->
|
||||
.catch (data, status) ->
|
||||
$scope.state.inflight = false
|
||||
if status == 403
|
||||
$scope.state.invalidCredentials = true
|
||||
|
|
|
@ -8,7 +8,7 @@ define [
|
|||
newItems: 0
|
||||
|
||||
refreshAnnouncements = ->
|
||||
$http.get("/announcements").success (announcements) ->
|
||||
$http.get("/announcements").then (announcements) ->
|
||||
$scope.announcements = announcements
|
||||
$scope.ui.newItems = _.filter(announcements, (announcement) -> !announcement.read).length
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ define [
|
|||
|
||||
|
||||
$http.post(MESSAGES_URL, body)
|
||||
.success ->
|
||||
.then ->
|
||||
$scope.upgradeComplete = true
|
||||
.error ->
|
||||
.catch ->
|
||||
console.log "something went wrong changing plan"
|
|
@ -11,10 +11,10 @@ define [
|
|||
$scope.clearSessions = () ->
|
||||
console.log ">> clearing all sessions"
|
||||
$http({method: 'POST', url: "/user/sessions/clear", headers: {'X-CSRF-Token': window.csrfToken}})
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.otherSessions = []
|
||||
$scope.state.error = false
|
||||
$scope.state.success = true
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.state.error = true
|
||||
]
|
||||
|
|
|
@ -26,7 +26,7 @@ define [
|
|||
email: email,
|
||||
_csrf: window.csrfToken
|
||||
})
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
$scope.users.push data.user if data.user?
|
||||
$scope.inputs.emails = ""
|
||||
|
||||
|
@ -43,7 +43,7 @@ define [
|
|||
headers:
|
||||
"X-Csrf-Token": window.csrfToken
|
||||
})
|
||||
.success () ->
|
||||
.then () ->
|
||||
index = $scope.users.indexOf(user)
|
||||
return if index == -1
|
||||
$scope.users.splice(index, 1)
|
||||
|
|
|
@ -162,10 +162,10 @@ define [
|
|||
|
||||
|
||||
$http.post("/user/subscription/create", postData)
|
||||
.success (data, status, headers)->
|
||||
.then (data, status, headers)->
|
||||
event_tracking.sendMB "subscription-submission-success"
|
||||
window.location.href = "/user/subscription/thank-you"
|
||||
.error (data, status, headers)->
|
||||
.catch (data, status, headers)->
|
||||
$scope.processing = false
|
||||
$scope.genericError = "Something went wrong processing the request"
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ define [
|
|||
$scope.state.error = false
|
||||
$scope
|
||||
.renameProject(project, $scope.inputs.projectName)
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = false
|
||||
$modalInstance.close()
|
||||
.error (body, statusCode) ->
|
||||
.catch (body, statusCode) ->
|
||||
$scope.state.inflight = false
|
||||
if statusCode == 400
|
||||
$scope.state.error = { message: body }
|
||||
|
@ -49,11 +49,11 @@ define [
|
|||
$scope.state.inflight = true
|
||||
$scope
|
||||
.cloneProject(project, $scope.inputs.projectName)
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = false
|
||||
$modalInstance.close()
|
||||
.error (body, statusCode) ->
|
||||
.catch (body, statusCode) ->
|
||||
$scope.state.inflight = false
|
||||
if statusCode == 400
|
||||
$scope.state.error = { message: body }
|
||||
|
@ -80,11 +80,11 @@ define [
|
|||
$scope.state.error = false
|
||||
$scope
|
||||
.createProject($scope.inputs.projectName, template)
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = false
|
||||
$modalInstance.close(data.project_id)
|
||||
.error (body, statusCode) ->
|
||||
.catch (body, statusCode) ->
|
||||
$scope.state.inflight = false
|
||||
if statusCode == 400
|
||||
$scope.state.error = { message: body }
|
||||
|
|
|
@ -13,7 +13,7 @@ define [
|
|||
headers:
|
||||
"X-Csrf-Token": window.csrfToken
|
||||
})
|
||||
.success (data) ->
|
||||
.then (data) ->
|
||||
notification.hide = true
|
||||
|
||||
App.controller "ProjectInviteNotificationController", ($scope, $http) ->
|
||||
|
@ -30,9 +30,9 @@ define [
|
|||
"X-Csrf-Token": window.csrfToken
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
})
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.notification.inflight = false
|
||||
$scope.notification.accepted = true
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.notification.inflight = false
|
||||
$scope.notification.error = true
|
|
@ -262,7 +262,7 @@ define [
|
|||
projectName: name
|
||||
template: template
|
||||
})
|
||||
.success((data, status, headers, config) ->
|
||||
.then((data, status, headers, config) ->
|
||||
$scope.projects.push {
|
||||
name: name
|
||||
_id: data.project_id
|
||||
|
@ -291,7 +291,7 @@ define [
|
|||
newProjectName: newName,
|
||||
_csrf: window.csrfToken
|
||||
}
|
||||
.success () ->
|
||||
.then () ->
|
||||
project.name = newName
|
||||
|
||||
$scope.openRenameProjectModal = () ->
|
||||
|
@ -313,7 +313,7 @@ define [
|
|||
_csrf: window.csrfToken
|
||||
projectName: cloneName
|
||||
})
|
||||
.success((data, status, headers, config) ->
|
||||
.then((data, status, headers, config) ->
|
||||
$scope.projects.push {
|
||||
name: cloneName
|
||||
id: data.project_id
|
||||
|
|
|
@ -94,10 +94,10 @@ define [
|
|||
_csrf: window.csrfToken,
|
||||
name: name
|
||||
}
|
||||
.success (data, status, headers, config) ->
|
||||
.then (data, status, headers, config) ->
|
||||
$scope.state.inflight = false
|
||||
$modalInstance.close(data)
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = true
|
||||
|
||||
|
@ -126,10 +126,10 @@ define [
|
|||
_csrf: window.csrfToken,
|
||||
name: name
|
||||
}
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
$modalInstance.close(name)
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = true
|
||||
|
||||
|
@ -151,10 +151,10 @@ define [
|
|||
headers:
|
||||
"X-CSRF-Token": window.csrfToken
|
||||
})
|
||||
.success () ->
|
||||
.then () ->
|
||||
$scope.state.inflight = false
|
||||
$modalInstance.close()
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.state.inflight = false
|
||||
$scope.state.error = true
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ define [
|
|||
email: email,
|
||||
_csrf: window.csrfToken
|
||||
})
|
||||
.success (user) ->
|
||||
.then (user) ->
|
||||
$scope.users.push user
|
||||
$scope.inputs.emails = ""
|
||||
.error () ->
|
||||
.catch () ->
|
||||
$scope.error = true
|
|
@ -68,9 +68,9 @@ define [
|
|||
$scope.inflight = true
|
||||
|
||||
$http.post("#{SUBSCRIPTION_URL}?origin=confirmChangePlan", body)
|
||||
.success ->
|
||||
.then ->
|
||||
location.reload()
|
||||
.error ->
|
||||
.catch ->
|
||||
console.log "something went wrong changing plan"
|
||||
|
||||
$scope.cancel = () ->
|
||||
|
@ -83,9 +83,9 @@ define [
|
|||
url: "/subscription/group/user",
|
||||
method: "DELETE",
|
||||
params: {admin_user_id: $scope.admin_id, _csrf: window.csrfToken}
|
||||
}).success ->
|
||||
}).then ->
|
||||
location.reload()
|
||||
.error ->
|
||||
.catch ->
|
||||
console.log "something went wrong changing plan"
|
||||
|
||||
$scope.cancel = () ->
|
||||
|
@ -141,9 +141,9 @@ define [
|
|||
_csrf : window.csrfToken
|
||||
$scope.inflight = true
|
||||
$http.post("#{SUBSCRIPTION_URL}?origin=downgradeToStudent", body)
|
||||
.success ->
|
||||
.then ->
|
||||
location.reload()
|
||||
.error ->
|
||||
.catch ->
|
||||
console.log "something went wrong changing plan"
|
||||
|
||||
$scope.cancelSubscription = ->
|
||||
|
@ -152,9 +152,9 @@ define [
|
|||
|
||||
$scope.inflight = true
|
||||
$http.post("/user/subscription/cancel", body)
|
||||
.success ->
|
||||
.then ->
|
||||
location.reload()
|
||||
.error ->
|
||||
.catch ->
|
||||
console.log "something went wrong changing plan"
|
||||
|
||||
|
||||
|
@ -176,7 +176,7 @@ define [
|
|||
_csrf : window.csrfToken
|
||||
$scope.inflight = true
|
||||
$http.put("/user/subscription/extend", body)
|
||||
.success ->
|
||||
.then ->
|
||||
location.reload()
|
||||
.error ->
|
||||
.catch ->
|
||||
console.log "something went wrong changing plan"
|
||||
|
|
|
@ -16,19 +16,19 @@ define [
|
|||
$scope.cancelSubscription = ->
|
||||
$scope.inflight = true
|
||||
request = $http.post "/user/subscription/cancel", {_csrf:window.csrfToken}
|
||||
request.success (data, status)->
|
||||
request.then (data, status)->
|
||||
$scope.inflight = false
|
||||
$scope.view = "groupSubscriptionInvite"
|
||||
request.error (data, status)->
|
||||
request.catch (data, status)->
|
||||
console.log "the request failed"
|
||||
|
||||
$scope.joinGroup = ->
|
||||
$scope.view = "requestSent"
|
||||
$scope.inflight = true
|
||||
request = $http.post "/user/subscription/#{group_subscription_id}/group/begin-join", {_csrf:window.csrfToken}
|
||||
request.success (data, status)->
|
||||
request.then (data, status)->
|
||||
$scope.inflight = false
|
||||
if status != 200 # assume request worked
|
||||
$scope.requestSent = false
|
||||
request.error (data, status)->
|
||||
request.catch (data, status)->
|
||||
console.log "the request failed"
|
|
@ -7,7 +7,7 @@ define [
|
|||
|
||||
App.controller "UserProfileController", ($scope, $modal, $http)->
|
||||
$scope.institutions = []
|
||||
$http.get("/user/personal_info").success (data)->
|
||||
$http.get("/user/personal_info").then (data)->
|
||||
$scope.userInfoForm =
|
||||
first_name: data.first_name || ""
|
||||
last_name: data.last_name || ""
|
||||
|
@ -43,8 +43,8 @@ define [
|
|||
|
||||
sendUpdate = ->
|
||||
request = $http.post "/user/settings", $scope.userInfoForm
|
||||
request.success (data, status)->
|
||||
request.error (data, status)->
|
||||
request.then (data, status)->
|
||||
request.catch (data, status)->
|
||||
console.log "the request failed"
|
||||
|
||||
$scope.updateInstitutionsList = (inputVal)->
|
||||
|
|
|
@ -11,10 +11,10 @@ define [
|
|||
if doRequest?
|
||||
inflight = true
|
||||
doRequest()
|
||||
.success () ->
|
||||
.then () ->
|
||||
inflight = false
|
||||
processPendingRequests()
|
||||
.error () ->
|
||||
.catch () ->
|
||||
inflight = false
|
||||
processPendingRequests()
|
||||
|
||||
|
@ -26,20 +26,21 @@ define [
|
|||
errorCallbacks = []
|
||||
|
||||
# Adhere to the $http promise conventions
|
||||
promise.success = (callback) ->
|
||||
promise.then = (callback, errCallback) ->
|
||||
successCallbacks.push callback
|
||||
errorCallbacks.push errCallback if errCallback?
|
||||
return promise
|
||||
|
||||
promise.error = (callback) ->
|
||||
promise.catch = (callback) ->
|
||||
errorCallbacks.push callback
|
||||
return promise
|
||||
|
||||
doRequest = () ->
|
||||
$http(args...)
|
||||
.success (args...) ->
|
||||
.then (args...) ->
|
||||
for cb in successCallbacks
|
||||
cb(args...)
|
||||
.error (args...) ->
|
||||
.catch (args...) ->
|
||||
for cb in errorCallbacks
|
||||
cb(args...)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue