refactor ajax, get rid of the module
This commit is contained in:
parent
521fc3112d
commit
6cbe6f140e
|
@ -43,7 +43,7 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-api.git
|
remote: git://github.com/travis-ci/travis-api.git
|
||||||
revision: fa4c5db39b94234e9a3a87da0b4ccca466e034e2
|
revision: 5d9c867142162b20d8471530f7447bd4af93c0e4
|
||||||
specs:
|
specs:
|
||||||
travis-api (0.0.1)
|
travis-api (0.0.1)
|
||||||
backports (~> 2.5)
|
backports (~> 2.5)
|
||||||
|
@ -61,7 +61,7 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-core.git
|
remote: git://github.com/travis-ci/travis-core.git
|
||||||
revision: 7c84635b5c180a716150c4300bff3ea8f381248c
|
revision: adaa3d48f48a2a002827a2f15078323e53be1d10
|
||||||
branch: sf-travis-api
|
branch: sf-travis-api
|
||||||
specs:
|
specs:
|
||||||
travis-core (0.0.1)
|
travis-core (0.0.1)
|
||||||
|
@ -159,7 +159,7 @@ GEM
|
||||||
activesupport
|
activesupport
|
||||||
faraday (0.8.4)
|
faraday (0.8.4)
|
||||||
multipart-post (~> 1.1)
|
multipart-post (~> 1.1)
|
||||||
foreman (0.60.0)
|
foreman (0.60.2)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
fssm (0.2.9)
|
fssm (0.2.9)
|
||||||
guard (1.4.0)
|
guard (1.4.0)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'travis/model'
|
require 'travis/model'
|
||||||
|
|
||||||
@Travis.Build = Travis.Model.extend Travis.DurationCalculations, Travis.Ajax,
|
@Travis.Build = Travis.Model.extend Travis.DurationCalculations,
|
||||||
eventType: DS.attr('string')
|
eventType: DS.attr('string')
|
||||||
repoId: DS.attr('number')
|
repoId: DS.attr('number')
|
||||||
commitId: DS.attr('number')
|
commitId: DS.attr('number')
|
||||||
|
@ -46,7 +46,7 @@ require 'travis/model'
|
||||||
).property('config')
|
).property('config')
|
||||||
|
|
||||||
requeue: (->
|
requeue: (->
|
||||||
@post '/requests', build_id: @get('id')
|
Travis.ajax.post '/requests', build_id: @get('id')
|
||||||
)
|
)
|
||||||
|
|
||||||
@Travis.Build.reopenClass
|
@Travis.Build.reopenClass
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'travis/ajax'
|
require 'travis/ajax'
|
||||||
require 'travis/model'
|
require 'travis/model'
|
||||||
|
|
||||||
@Travis.User = Travis.Model.extend Travis.Ajax,
|
@Travis.User = Travis.Model.extend
|
||||||
name: DS.attr('string')
|
name: DS.attr('string')
|
||||||
email: DS.attr('string')
|
email: DS.attr('string')
|
||||||
login: DS.attr('string')
|
login: DS.attr('string')
|
||||||
|
@ -27,7 +27,7 @@ require 'travis/model'
|
||||||
permissions: (->
|
permissions: (->
|
||||||
unless @permissions
|
unless @permissions
|
||||||
@permissions = Ember.ArrayProxy.create(content: [])
|
@permissions = Ember.ArrayProxy.create(content: [])
|
||||||
@ajax '/users/permissions', 'get', success: (data) => @permissions.set('content', data.permissions)
|
Travis.ajax.get('/users/permissions', (data) => @permissions.set('content', data.permissions))
|
||||||
@permissions
|
@permissions
|
||||||
).property()
|
).property()
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ require 'travis/model'
|
||||||
).property()
|
).property()
|
||||||
|
|
||||||
sync: ->
|
sync: ->
|
||||||
@post('/users/sync')
|
Travis.ajax.post('/users/sync')
|
||||||
@setWithSession('isSyncing', true)
|
@setWithSession('isSyncing', true)
|
||||||
@poll()
|
@poll()
|
||||||
|
|
||||||
poll: ->
|
poll: ->
|
||||||
@ajax '/users', 'get', success: (data) =>
|
Travis.ajax.get '/users', (data) =>
|
||||||
if data.user.is_syncing
|
if data.user.is_syncing
|
||||||
Ember.run.later(this, this.poll.bind(this), 3000)
|
Ember.run.later(this, this.poll.bind(this), 3000)
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'travis/ajax'
|
require 'travis/ajax'
|
||||||
require 'models'
|
require 'models'
|
||||||
|
|
||||||
@Travis.RestAdapter = DS.RESTAdapter.extend Travis.Ajax,
|
@Travis.RestAdapter = DS.RESTAdapter.extend
|
||||||
mappings:
|
mappings:
|
||||||
repositories: Travis.Repo
|
repositories: Travis.Repo
|
||||||
repository: Travis.Repo
|
repository: Travis.Repo
|
||||||
|
@ -28,3 +28,6 @@ require 'models'
|
||||||
job: 'jobs'
|
job: 'jobs'
|
||||||
worker: 'workers'
|
worker: 'workers'
|
||||||
profile: 'profile'
|
profile: 'profile'
|
||||||
|
|
||||||
|
ajax: ->
|
||||||
|
Travis.ajax.ajax.apply(this, arguments)
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
jQuery.support.cors = true
|
jQuery.support.cors = true
|
||||||
|
|
||||||
@Travis.Ajax = Ember.Mixin.create
|
@Travis.ajax = Em.Object.create
|
||||||
DEFAULT_OPTIONS:
|
DEFAULT_OPTIONS:
|
||||||
accepts:
|
accepts:
|
||||||
json: 'application/vnd.travis-ci.2+json'
|
json: 'application/vnd.travis-ci.2+json'
|
||||||
|
|
||||||
|
get: (url, callback) ->
|
||||||
|
@ajax(url, 'get', success: callback)
|
||||||
|
|
||||||
post: (url, data, callback) ->
|
post: (url, data, callback) ->
|
||||||
@ajax(url, 'post', data: data, success: callback)
|
@ajax(url, 'post', data: data, success: callback)
|
||||||
|
|
||||||
|
@ -25,9 +28,16 @@ jQuery.support.cors = true
|
||||||
if options.data && method != 'GET' && method != 'get'
|
if options.data && method != 'GET' && method != 'get'
|
||||||
options.data = JSON.stringify(options.data)
|
options.data = JSON.stringify(options.data)
|
||||||
|
|
||||||
$.ajax($.extend(options, @DEFAULT_OPTIONS))
|
if options.success
|
||||||
|
success = options.success
|
||||||
|
options.success = (data) =>
|
||||||
|
if Travis.app?.router && data.flash
|
||||||
|
console.log(data.flash)
|
||||||
|
Travis.app.router.flashController.pushObject(data.flash)
|
||||||
|
delete data.flash
|
||||||
|
success.call(this, data)
|
||||||
|
|
||||||
@Travis.ajax = Em.Object.create @Travis.Ajax,
|
options.error = (data) =>
|
||||||
get: (url, callback) ->
|
Travis.app.router.flashController.pushObject(data.flash) if data.flash
|
||||||
@ajax(url, 'get', success: callback)
|
|
||||||
|
|
||||||
|
$.ajax($.extend(options, Travis.ajax.DEFAULT_OPTIONS))
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
dd0dc238
|
f99eb613
|
Loading…
Reference in New Issue
Block a user