travis-web/app/routes/owner.coffee
2015-09-07 11:45:58 +02:00

35 lines
1015 B
CoffeeScript

`import Ember from 'ember'`
`import TravisRoute from 'travis/routes/basic'`
`import Ajax from 'travis/utils/ajax'`
`import config from 'travis/config/environment'`
Route = TravisRoute.extend
deactivate: ->
@controllerFor('loading').set('layoutName', null)
model: (params) ->
options = {}
if @get('auth.signedIn')
options.headers = { Authorization: "token #{@auth.token()}" }
$.ajax(config.apiEndpoint + "/v3/owner/#{params.owner}", options)
beforeModel: ->
@controllerFor('loading').set('layoutName', 'simple')
@_super.apply(this, arguments)
actions:
error: (error, transition, originRoute) ->
login = transition.params.owner.owner
message = if error.status == 404
"Couldn't find an owner with login \"#{login}\""
else
"There was an error while loading data, please try again."
@controllerFor('error').set('layoutName', 'simple')
@controllerFor('error').set('message', message)
return true
`export default Route`