More ember-cli compat changes
This commit is contained in:
parent
8124bc3780
commit
47c87317d0
|
@ -1,4 +1,4 @@
|
||||||
Travis.ApplicationAdapter = DS.ActiveModelAdapter.extend
|
Adapter = DS.ActiveModelAdapter.extend
|
||||||
host: Travis.config.api_endpoint
|
host: Travis.config.api_endpoint
|
||||||
ajaxOptions: (url, type, options) ->
|
ajaxOptions: (url, type, options) ->
|
||||||
hash = @_super(url, type, options)
|
hash = @_super(url, type, options)
|
||||||
|
@ -11,3 +11,6 @@ Travis.ApplicationAdapter = DS.ActiveModelAdapter.extend
|
||||||
hash.headers['Authorization'] ||= "token #{token}"
|
hash.headers['Authorization'] ||= "token #{token}"
|
||||||
|
|
||||||
hash
|
hash
|
||||||
|
|
||||||
|
|
||||||
|
Travis.ApplicationAdapter = Adapter
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
get = Ember.get
|
ApplicationAdapter = Travis.ApplicationAdapter
|
||||||
|
|
||||||
Travis.EnvVarAdapter = Travis.ApplicationAdapter.extend
|
Adapter = ApplicationAdapter.extend
|
||||||
namespace: 'settings'
|
namespace: 'settings'
|
||||||
|
|
||||||
buildURL: (type, id, record) ->
|
buildURL: (type, id, record) ->
|
||||||
url = @_super.apply this, arguments
|
url = @_super.apply this, arguments
|
||||||
|
|
||||||
if record && (repoId = get(record, 'repo.id'))
|
if record && (repoId = Ember.get(record, 'repo.id'))
|
||||||
delimiter = if url.indexOf('?') != -1 then '&' else '?'
|
delimiter = if url.indexOf('?') != -1 then '&' else '?'
|
||||||
url = "#{url}#{delimiter}repository_id=#{repoId}"
|
url = "#{url}#{delimiter}repository_id=#{repoId}"
|
||||||
|
|
||||||
|
@ -21,3 +21,5 @@ Travis.EnvVarAdapter = Travis.ApplicationAdapter.extend
|
||||||
id = Ember.get(record, 'id');
|
id = Ember.get(record, 'id');
|
||||||
|
|
||||||
this.ajax(this.buildURL(type.typeKey, id, record), "PATCH", { data: data })
|
this.ajax(this.buildURL(type.typeKey, id, record), "PATCH", { data: data })
|
||||||
|
|
||||||
|
Travis.EnvVarAdapter = Adapter
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
get = Ember.get
|
get = Ember.get
|
||||||
|
|
||||||
Travis.SshKeyAdapter = Travis.ApplicationAdapter.extend
|
ApplicationAdapter = Travis.ApplicationAdapter
|
||||||
|
|
||||||
|
Adapter = ApplicationAdapter.extend
|
||||||
namespace: 'settings'
|
namespace: 'settings'
|
||||||
|
|
||||||
createRecord: (store, type, record) ->
|
createRecord: (store, type, record) ->
|
||||||
|
@ -9,3 +11,5 @@ Travis.SshKeyAdapter = Travis.ApplicationAdapter.extend
|
||||||
serializer.serializeIntoHash(data, type, record, { includeId: true });
|
serializer.serializeIntoHash(data, type, record, { includeId: true });
|
||||||
|
|
||||||
this.ajax(this.buildURL(type.typeKey, null, record), "POST", { data: data })
|
this.ajax(this.buildURL(type.typeKey, null, record), "POST", { data: data })
|
||||||
|
|
||||||
|
Travis.SshKeyAdapter = Adapter
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
window.Auth = Ember.Object.extend
|
Auth = Ember.Object.extend
|
||||||
state: "signed-out"
|
state: "signed-out"
|
||||||
receivingEnd: "#{location.protocol}//#{location.host}"
|
receivingEnd: "#{location.protocol}//#{location.host}"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ window.Auth = Ember.Object.extend
|
||||||
Travis.sessionStorage.getItem('travis.token')
|
Travis.sessionStorage.getItem('travis.token')
|
||||||
|
|
||||||
endpoint: (->
|
endpoint: (->
|
||||||
@container.lookup('application:main').config.api_endpoint
|
@config.api_endpoint
|
||||||
).property(),
|
).property(),
|
||||||
|
|
||||||
signOut: ->
|
signOut: ->
|
||||||
|
@ -141,15 +141,4 @@ window.Auth = Ember.Object.extend
|
||||||
"#{location.protocol}//www.gravatar.com/avatar/#{@get('currentUser.gravatarId')}?s=48&d=mm"
|
"#{location.protocol}//www.gravatar.com/avatar/#{@get('currentUser.gravatarId')}?s=48&d=mm"
|
||||||
).property('currentUser.gravatarId')
|
).property('currentUser.gravatarId')
|
||||||
|
|
||||||
Ember.onLoad 'Ember.Application', (Application) ->
|
window.Auth = Auth
|
||||||
Application.initializer
|
|
||||||
name: "auth",
|
|
||||||
|
|
||||||
initialize: (container, application) ->
|
|
||||||
application.register 'auth:main', Auth
|
|
||||||
|
|
||||||
application.inject('route', 'auth', 'auth:main')
|
|
||||||
application.inject('controller', 'auth', 'auth:main')
|
|
||||||
application.inject('application', 'auth', 'auth:main')
|
|
||||||
|
|
||||||
application.inject('auth', 'store', 'store:main')
|
|
||||||
|
|
17
assets/scripts/app/initializers/auth.coffee
Normal file
17
assets/scripts/app/initializers/auth.coffee
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
initialize = (container, app) ->
|
||||||
|
app.register 'auth:main', Auth
|
||||||
|
|
||||||
|
app.inject('route', 'auth', 'auth:main')
|
||||||
|
app.inject('controller', 'auth', 'auth:main')
|
||||||
|
app.inject('application', 'auth', 'auth:main')
|
||||||
|
|
||||||
|
Auth.store = container.lookup('store:main')
|
||||||
|
Auth.config = container.lookup('config:main')
|
||||||
|
|
||||||
|
|
||||||
|
AuthInitializer =
|
||||||
|
name: 'auth'
|
||||||
|
initialize: initialize
|
||||||
|
|
||||||
|
Ember.onLoad 'Ember.Application', (Application) ->
|
||||||
|
Application.initializer AuthInitializer
|
13
assets/scripts/app/initializers/config.coffee
Normal file
13
assets/scripts/app/initializers/config.coffee
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
initialize = (container, application) ->
|
||||||
|
application.register 'config:main', application.config, { instantiate: false }
|
||||||
|
|
||||||
|
application.inject('controller', 'config', 'config:main')
|
||||||
|
application.inject('route', 'config', 'config:main')
|
||||||
|
application.inject('auth', 'config', 'config:main')
|
||||||
|
|
||||||
|
ConfigInitializer =
|
||||||
|
name: 'pusher'
|
||||||
|
initialize: initialize
|
||||||
|
|
||||||
|
Ember.onLoad 'Ember.Application', (Application) ->
|
||||||
|
Application.initializer ConfigInitializer
|
18
assets/scripts/app/initializers/google-analytics.coffee
Normal file
18
assets/scripts/app/initializers/google-analytics.coffee
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
initialize = (container) ->
|
||||||
|
if Travis.config.ga_code
|
||||||
|
window._gaq = []
|
||||||
|
_gaq.push(['_setAccount', Travis.config.ga_code])
|
||||||
|
|
||||||
|
ga = document.createElement('script')
|
||||||
|
ga.type = 'text/javascript'
|
||||||
|
ga.async = true
|
||||||
|
ga.src = 'https://ssl.google-analytics.com/ga.js'
|
||||||
|
s = document.getElementsByTagName('script')[0]
|
||||||
|
s.parentNode.insertBefore(ga, s)
|
||||||
|
|
||||||
|
GAInitializer =
|
||||||
|
name: 'google-analytics'
|
||||||
|
initialize: initialize
|
||||||
|
|
||||||
|
Ember.onLoad 'Ember.Application', (Application) ->
|
||||||
|
Application.initializer GAInitializer
|
14
assets/scripts/app/initializers/pusher.coffee
Normal file
14
assets/scripts/app/initializers/pusher.coffee
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
initialize = (container, application) ->
|
||||||
|
application.register 'pusher:main', application.pusher, { instantiate: false }
|
||||||
|
|
||||||
|
application.inject('route', 'pusher', 'pusher:main')
|
||||||
|
|
||||||
|
application.pusher.store = container.lookup('store:main')
|
||||||
|
|
||||||
|
|
||||||
|
PusherInitializer =
|
||||||
|
name: 'pusher'
|
||||||
|
initialize: initialize
|
||||||
|
|
||||||
|
Ember.onLoad 'Ember.Application', (Application) ->
|
||||||
|
Application.initializer PusherInitializer
|
55
assets/scripts/app/initializers/storage.coffee
Normal file
55
assets/scripts/app/initializers/storage.coffee
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
Storage = Em.Object.extend
|
||||||
|
init: ->
|
||||||
|
@set('storage', {})
|
||||||
|
key: (key) ->
|
||||||
|
"__#{key.replace('.', '__')}"
|
||||||
|
getItem: (k) ->
|
||||||
|
return @get("storage.#{@key(k)}")
|
||||||
|
setItem: (k,v) ->
|
||||||
|
@set("storage.#{@key(k)}", v)
|
||||||
|
removeItem: (k) ->
|
||||||
|
@setItem(k, null)
|
||||||
|
clear: ->
|
||||||
|
@set('storage', {})
|
||||||
|
|
||||||
|
sessionStorage = (->
|
||||||
|
storage = null
|
||||||
|
try
|
||||||
|
# firefox will not throw error on access for sessionStorage var,
|
||||||
|
# you need to actually get something from session
|
||||||
|
sessionStorage.getItem('foo')
|
||||||
|
storage = sessionStorage
|
||||||
|
catch err
|
||||||
|
storage = Storage.create()
|
||||||
|
|
||||||
|
storage
|
||||||
|
)()
|
||||||
|
|
||||||
|
storage = (->
|
||||||
|
storage = null
|
||||||
|
try
|
||||||
|
storage = window.localStorage || throw('no storage')
|
||||||
|
catch err
|
||||||
|
storage = Storage.create()
|
||||||
|
|
||||||
|
storage
|
||||||
|
)()
|
||||||
|
|
||||||
|
initialize = (container, application) ->
|
||||||
|
application.register 'storage:main', storage, { instantiate: false }
|
||||||
|
application.register 'sessionStorage:main', sessionStorage, { instantiate: false }
|
||||||
|
|
||||||
|
application.inject('auth', 'storage', 'storage:main')
|
||||||
|
application.inject('auth', 'sessionStorage', 'sessionStorage:main')
|
||||||
|
|
||||||
|
# I still use Travis.storage in some places which are not that easy to
|
||||||
|
# refactor
|
||||||
|
application.storage = storage
|
||||||
|
application.sessionStorage = sessionStorage
|
||||||
|
|
||||||
|
StorageInitializer =
|
||||||
|
name: 'storage'
|
||||||
|
initialize: initialize
|
||||||
|
|
||||||
|
Ember.onLoad 'Ember.Application', (Application) ->
|
||||||
|
Application.initializer StorageInitializer
|
15
assets/scripts/app/initializers/stylesheets-manager.coffee
Normal file
15
assets/scripts/app/initializers/stylesheets-manager.coffee
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
stylesheetsManager = Ember.Object.create
|
||||||
|
enable: (id) ->
|
||||||
|
$("##{id}").removeAttr('disabled')
|
||||||
|
|
||||||
|
disable: (id) ->
|
||||||
|
$("##{id}").attr('disabled', 'disabled')
|
||||||
|
|
||||||
|
initialize = (container, application) ->
|
||||||
|
application.register 'stylesheetsManager:main', stylesheetsManager, { instantiate: false }
|
||||||
|
|
||||||
|
application.inject('route', 'stylesheetsManager', 'stylesheetsManager:main')
|
||||||
|
|
||||||
|
StylesheetsManagerInitializer =
|
||||||
|
name: 'inject-stylesheets-manager'
|
||||||
|
initialize: initialize
|
|
@ -8,6 +8,11 @@ Ember.Router.reopen
|
||||||
|
|
||||||
Travis.Router.reopen
|
Travis.Router.reopen
|
||||||
location: 'history'
|
location: 'history'
|
||||||
|
didTransition: ->
|
||||||
|
@_super.apply @, arguments
|
||||||
|
|
||||||
|
if Travis.config.ga_code
|
||||||
|
_gaq.push ['_trackPageview', location.pathname]
|
||||||
|
|
||||||
Travis.Router.map ->
|
Travis.Router.map ->
|
||||||
@resource 'dashboard', ->
|
@resource 'dashboard', ->
|
|
@ -1,2 +1,6 @@
|
||||||
Travis.AccountSerializer = Travis.ApplicationSerializer.extend
|
ApplicationSerializer = Travis.ApplicationSerializer
|
||||||
|
|
||||||
|
Serializer = ApplicationSerializer.extend
|
||||||
primaryKey: 'login'
|
primaryKey: 'login'
|
||||||
|
|
||||||
|
Travis.AccountSerializer = Serializer
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
Travis.ApplicationSerializer = DS.ActiveModelSerializer.extend
|
Serializer = DS.ActiveModelSerializer.extend
|
||||||
defaultSerializer: 'application'
|
defaultSerializer: 'application'
|
||||||
serializer: 'application'
|
serializer: 'application'
|
||||||
|
|
||||||
extractSingle: (store, primaryType, rawPayload, recordId) ->
|
Travis.ApplicationSerializer = Serializer
|
||||||
#newPayload = {}
|
|
||||||
|
|
||||||
#if payload.build
|
|
||||||
|
|
||||||
@_super.apply(this, arguments)
|
|
||||||
|
|
||||||
extractArray: (store, type, payload) ->
|
|
||||||
@_super.apply(this, arguments)
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
Travis.BuildSerializer = Travis.ApplicationSerializer.extend
|
ApplicationSerializer = Travis.ApplicationSerializer
|
||||||
|
|
||||||
|
Serializer = ApplicationSerializer.extend
|
||||||
attrs: {
|
attrs: {
|
||||||
repo: { key: 'repository_id' }
|
repo: { key: 'repository_id' }
|
||||||
_config: { key: 'config' }
|
_config: { key: 'config' }
|
||||||
|
@ -11,3 +13,5 @@ Travis.BuildSerializer = Travis.ApplicationSerializer.extend
|
||||||
rawPayload.commits = [commit]
|
rawPayload.commits = [commit]
|
||||||
|
|
||||||
@_super(store, primaryType, rawPayload, recordId)
|
@_super(store, primaryType, rawPayload, recordId)
|
||||||
|
|
||||||
|
Travis.BuildSerializer = Serializer
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
Travis.EnvVarSerializer = Travis.ApplicationSerializer.extend
|
ApplicationSerializer = Travis.ApplicationSerializer
|
||||||
|
|
||||||
|
Serializer = ApplicationSerializer.extend
|
||||||
attrs: {
|
attrs: {
|
||||||
repo: { key: 'repository_id' }
|
repo: { key: 'repository_id' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Travis.EnvVarSerializer = Serializer
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
Travis.JobSerializer = Travis.ApplicationSerializer.extend
|
ApplicationSerializer = Travis.ApplicationSerializer
|
||||||
|
|
||||||
|
Serializer = ApplicationSerializer.extend
|
||||||
attrs: {
|
attrs: {
|
||||||
repo: { key: 'repository_id' }
|
repo: { key: 'repository_id' }
|
||||||
_config: { key: 'config' }
|
_config: { key: 'config' }
|
||||||
|
@ -11,3 +13,5 @@ Travis.JobSerializer = Travis.ApplicationSerializer.extend
|
||||||
rawPayload.commits = [commit]
|
rawPayload.commits = [commit]
|
||||||
|
|
||||||
@_super(store, primaryType, rawPayload, recordId)
|
@_super(store, primaryType, rawPayload, recordId)
|
||||||
|
|
||||||
|
Travis.JobSerializer = Serializer
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
Travis.RepoSerializer = Travis.ApplicationSerializer.extend
|
ApplicationSerializer = Travis.ApplicationSerializer
|
||||||
|
|
||||||
|
Serializer = ApplicationSerializer.extend
|
||||||
attrs: {
|
attrs: {
|
||||||
_lastBuildDuration: { key: 'last_build_duration' }
|
_lastBuildDuration: { key: 'last_build_duration' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Travis.RepoSerializer = Serializer
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
Travis.RequestSerializer = Travis.ApplicationSerializer.extend
|
ApplicationSerializer = Travis.ApplicationSerializer
|
||||||
|
|
||||||
|
Serializer = ApplicationSerializer.extend
|
||||||
attrs: {
|
attrs: {
|
||||||
branchName: { key: 'branch' }
|
branchName: { key: 'branch' }
|
||||||
tagName: { key: 'tag' }
|
tagName: { key: 'tag' }
|
||||||
repo: { key: 'repository_id' }
|
repo: { key: 'repository_id' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Travis.RequestSerializer = Serializer
|
||||||
|
|
|
@ -6,20 +6,6 @@ require 'app'
|
||||||
window.ENV ||= {}
|
window.ENV ||= {}
|
||||||
window.ENV.RAISE_ON_DEPRECATION = true
|
window.ENV.RAISE_ON_DEPRECATION = true
|
||||||
|
|
||||||
Storage = Em.Object.extend
|
|
||||||
init: ->
|
|
||||||
@set('storage', {})
|
|
||||||
key: (key) ->
|
|
||||||
"__#{key.replace('.', '__')}"
|
|
||||||
getItem: (k) ->
|
|
||||||
return @get("storage.#{@key(k)}")
|
|
||||||
setItem: (k,v) ->
|
|
||||||
@set("storage.#{@key(k)}", v)
|
|
||||||
removeItem: (k) ->
|
|
||||||
@setItem(k, null)
|
|
||||||
clear: ->
|
|
||||||
@set('storage', {})
|
|
||||||
|
|
||||||
window.Travis = TravisApplication.create(
|
window.Travis = TravisApplication.create(
|
||||||
LOG_ACTIVE_GENERATION: true,
|
LOG_ACTIVE_GENERATION: true,
|
||||||
LOG_MODULE_RESOLVER: true,
|
LOG_MODULE_RESOLVER: true,
|
||||||
|
@ -103,101 +89,6 @@ $.extend Travis,
|
||||||
|
|
||||||
INTERVALS: { times: -1, updateTimes: 1000 }
|
INTERVALS: { times: -1, updateTimes: 1000 }
|
||||||
|
|
||||||
sessionStorage = (->
|
|
||||||
storage = null
|
|
||||||
try
|
|
||||||
# firefox will not throw error on access for sessionStorage var,
|
|
||||||
# you need to actually get something from session
|
|
||||||
sessionStorage.getItem('foo')
|
|
||||||
storage = sessionStorage
|
|
||||||
catch err
|
|
||||||
storage = Storage.create()
|
|
||||||
|
|
||||||
storage
|
|
||||||
)()
|
|
||||||
|
|
||||||
storage = (->
|
|
||||||
storage = null
|
|
||||||
try
|
|
||||||
storage = window.localStorage || throw('no storage')
|
|
||||||
catch err
|
|
||||||
storage = Storage.create()
|
|
||||||
|
|
||||||
storage
|
|
||||||
)()
|
|
||||||
|
|
||||||
Travis.initializer
|
|
||||||
name: 'storage'
|
|
||||||
|
|
||||||
initialize: (container, application) ->
|
|
||||||
application.register 'storage:main', storage, { instantiate: false }
|
|
||||||
application.register 'sessionStorage:main', sessionStorage, { instantiate: false }
|
|
||||||
|
|
||||||
application.inject('auth', 'storage', 'storage:main')
|
|
||||||
application.inject('auth', 'sessionStorage', 'sessionStorage:main')
|
|
||||||
|
|
||||||
# I still use Travis.storage in some places which are not that easy to
|
|
||||||
# refactor
|
|
||||||
application.storage = storage
|
|
||||||
application.sessionStorage = sessionStorage
|
|
||||||
|
|
||||||
Travis.initializer
|
|
||||||
name: 'googleAnalytics'
|
|
||||||
|
|
||||||
initialize: (container) ->
|
|
||||||
if Travis.config.ga_code
|
|
||||||
window._gaq = []
|
|
||||||
_gaq.push(['_setAccount', Travis.config.ga_code])
|
|
||||||
|
|
||||||
ga = document.createElement('script')
|
|
||||||
ga.type = 'text/javascript'
|
|
||||||
ga.async = true
|
|
||||||
ga.src = 'https://ssl.google-analytics.com/ga.js'
|
|
||||||
s = document.getElementsByTagName('script')[0]
|
|
||||||
s.parentNode.insertBefore(ga, s)
|
|
||||||
|
|
||||||
Travis.initializer
|
|
||||||
name: 'inject-config'
|
|
||||||
|
|
||||||
initialize: (container, application) ->
|
|
||||||
application.register 'config:main', Travis.config, { instantiate: false }
|
|
||||||
|
|
||||||
application.inject('controller', 'config', 'config:main')
|
|
||||||
application.inject('route', 'config', 'config:main')
|
|
||||||
application.inject('auth', 'config', 'config:main')
|
|
||||||
|
|
||||||
Travis.initializer
|
|
||||||
name: 'inject-pusher'
|
|
||||||
|
|
||||||
initialize: (container, application) ->
|
|
||||||
application.register 'pusher:main', Travis.pusher, { instantiate: false }
|
|
||||||
|
|
||||||
application.inject('route', 'pusher', 'pusher:main')
|
|
||||||
|
|
||||||
Travis.pusher.store = container.lookup('store:main')
|
|
||||||
|
|
||||||
stylesheetsManager = Ember.Object.create
|
|
||||||
enable: (id) ->
|
|
||||||
$("##{id}").removeAttr('disabled')
|
|
||||||
|
|
||||||
disable: (id) ->
|
|
||||||
$("##{id}").attr('disabled', 'disabled')
|
|
||||||
|
|
||||||
Travis.initializer
|
|
||||||
name: 'inject-stylesheets-manager'
|
|
||||||
|
|
||||||
initialize: (container, application) ->
|
|
||||||
application.register 'stylesheetsManager:main', stylesheetsManager, { instantiate: false }
|
|
||||||
|
|
||||||
application.inject('route', 'stylesheetsManager', 'stylesheetsManager:main')
|
|
||||||
|
|
||||||
Travis.Router.reopen
|
|
||||||
didTransition: ->
|
|
||||||
@_super.apply @, arguments
|
|
||||||
|
|
||||||
if Travis.config.ga_code
|
|
||||||
_gaq.push ['_trackPageview', location.pathname]
|
|
||||||
|
|
||||||
Ember.LinkView.reopen
|
Ember.LinkView.reopen
|
||||||
loadingClass: 'loading_link'
|
loadingClass: 'loading_link'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user