Main view mostly works on new router
This commit is contained in:
parent
360b1d1a73
commit
f0e95ddd3f
|
@ -1,64 +1,4 @@
|
||||||
require 'auth'
|
|
||||||
require 'controllers'
|
|
||||||
require 'helpers'
|
|
||||||
require 'models'
|
|
||||||
require 'pusher'
|
|
||||||
require 'routes'
|
|
||||||
require 'slider'
|
|
||||||
require 'store'
|
|
||||||
require 'tailing'
|
|
||||||
require 'templates'
|
|
||||||
require 'views'
|
|
||||||
|
|
||||||
require 'config/locales'
|
|
||||||
require 'data/sponsors'
|
|
||||||
|
|
||||||
require 'travis/instrumentation'
|
|
||||||
# $.mockjaxSettings.log = false
|
# $.mockjaxSettings.log = false
|
||||||
# Ember.LOG_BINDINGS = true
|
# Ember.LOG_BINDINGS = true
|
||||||
# Ember.ENV.RAISE_ON_DEPRECATION = true
|
# Ember.ENV.RAISE_ON_DEPRECATION = true
|
||||||
# Pusher.log = -> console.log(arguments)
|
# Pusher.log = -> console.log(arguments)
|
||||||
|
|
||||||
Travis.reopen
|
|
||||||
App: Em.Application.extend
|
|
||||||
autoinit: false
|
|
||||||
currentUserBinding: 'auth.user'
|
|
||||||
authStateBinding: 'auth.state'
|
|
||||||
|
|
||||||
init: ->
|
|
||||||
@_super.apply this, arguments
|
|
||||||
|
|
||||||
@store = Travis.Store.create()
|
|
||||||
@store.loadMany(Travis.Sponsor, Travis.SPONSORS)
|
|
||||||
|
|
||||||
@slider = new Travis.Slider()
|
|
||||||
@pusher = new Travis.Pusher(Travis.config.pusher_key)
|
|
||||||
@tailing = new Travis.Tailing()
|
|
||||||
|
|
||||||
@set('auth', Travis.Auth.create(app: this, endpoint: Travis.config.api_endpoint))
|
|
||||||
|
|
||||||
storeAfterSignInPath: (path) ->
|
|
||||||
@get('auth').storeAfterSignInPath(path)
|
|
||||||
|
|
||||||
autoSignIn: (path) ->
|
|
||||||
@get('auth').autoSignIn()
|
|
||||||
|
|
||||||
signIn: ->
|
|
||||||
@get('auth').signIn()
|
|
||||||
|
|
||||||
signOut: ->
|
|
||||||
@get('auth').signOut()
|
|
||||||
@get('router').send('afterSignOut')
|
|
||||||
|
|
||||||
receive: ->
|
|
||||||
@store.receive.apply(@store, arguments)
|
|
||||||
|
|
||||||
toggleSidebar: ->
|
|
||||||
$('body').toggleClass('maximized')
|
|
||||||
# TODO gotta force redraws here :/
|
|
||||||
element = $('<span></span>')
|
|
||||||
$('#top .profile').append(element)
|
|
||||||
Em.run.later (-> element.remove()), 10
|
|
||||||
element = $('<span></span>')
|
|
||||||
$('#repo').append(element)
|
|
||||||
Em.run.later (-> element.remove()), 10
|
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
require 'helpers'
|
require 'helpers'
|
||||||
require 'travis/ticker'
|
require 'travis/ticker'
|
||||||
|
|
||||||
Travis.reopen
|
Travis.Controller = Em.Controller.extend()
|
||||||
Controller: Em.Controller.extend()
|
Travis.TopController = Em.Controller.extend
|
||||||
|
|
||||||
TopController: Em.Controller.extend
|
|
||||||
userBinding: 'Travis.app.currentUser'
|
userBinding: 'Travis.app.currentUser'
|
||||||
|
|
||||||
ApplicationController: Em.Controller.extend()
|
Travis.ApplicationController = Em.Controller.extend()
|
||||||
MainController: Em.Controller.extend()
|
Travis.MainController = Em.Controller.extend()
|
||||||
StatsLayoutController: Em.Controller.extend()
|
Travis.StatsLayoutController = Em.Controller.extend()
|
||||||
ProfileLayoutController: Em.Controller.extend()
|
Travis.ProfileLayoutController = Em.Controller.extend()
|
||||||
AuthLayoutController: Em.Controller.extend()
|
Travis.AuthLayoutController = Em.Controller.extend()
|
||||||
|
Travis.CurrentUserController = Em.ObjectController.extend()
|
||||||
|
|
||||||
require 'controllers/accounts'
|
require 'controllers/accounts'
|
||||||
|
require 'controllers/build'
|
||||||
require 'controllers/builds'
|
require 'controllers/builds'
|
||||||
require 'controllers/flash'
|
require 'controllers/flash'
|
||||||
require 'controllers/home'
|
require 'controllers/home'
|
||||||
|
|
11
assets/scripts/app/controllers/build.coffee
Normal file
11
assets/scripts/app/controllers/build.coffee
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Travis.BuildController = Ember.Controller.extend
|
||||||
|
needs: ['repo']
|
||||||
|
repoBinding: 'controllers.repo.repo'
|
||||||
|
buildBinding: 'controllers.repo.build'
|
||||||
|
commitBinding: 'build.commit'
|
||||||
|
|
||||||
|
currentItemBinding: 'build'
|
||||||
|
|
||||||
|
loading: (->
|
||||||
|
!@get('build.isLoaded')
|
||||||
|
).property('build.isLoaded')
|
|
@ -1,5 +1,8 @@
|
||||||
Travis.FlashController = Ember.ArrayController.extend
|
Travis.FlashController = Ember.ArrayController.extend
|
||||||
broadcastBinding: 'Travis.app.currentUser.broadcasts'
|
needs: ['currentUser']
|
||||||
|
currentUserBinding: 'controllers.currentUser'
|
||||||
|
|
||||||
|
broadcastBinding: 'currentUser.broadcasts'
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
@set('flashes', Ember.A())
|
@set('flashes', Ember.A())
|
||||||
|
@ -14,8 +17,8 @@ Travis.FlashController = Ember.ArrayController.extend
|
||||||
).property('broadcasts.isLoaded', 'broadcasts.length')
|
).property('broadcasts.isLoaded', 'broadcasts.length')
|
||||||
|
|
||||||
broadcasts: (->
|
broadcasts: (->
|
||||||
if Travis.app.get('currentUser') then Travis.Broadcast.find() else Ember.A()
|
if @get('currentUser') then Travis.Broadcast.find() else Ember.A()
|
||||||
).property('Travis.app.currentUser')
|
).property('currentUser')
|
||||||
|
|
||||||
loadFlashes: (msgs) ->
|
loadFlashes: (msgs) ->
|
||||||
for msg in msgs
|
for msg in msgs
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
Travis.RepoController = Travis.Controller.extend
|
Travis.RepoController = Travis.Controller.extend
|
||||||
bindings: []
|
bindings: []
|
||||||
|
needs: ['repos']
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
@_super.apply this, arguments
|
@_super.apply this, arguments
|
||||||
|
@ -33,7 +34,7 @@ Travis.RepoController = Travis.Controller.extend
|
||||||
this["view#{$.camelize(action)}"]()
|
this["view#{$.camelize(action)}"]()
|
||||||
|
|
||||||
viewIndex: ->
|
viewIndex: ->
|
||||||
@_bind('repo', 'controllers.reposController.firstObject')
|
@_bind('repo', 'controllers.repos.firstObject')
|
||||||
@_bind('build', 'repo.lastBuild')
|
@_bind('build', 'repo.lastBuild')
|
||||||
@connectTab('current')
|
@connectTab('current')
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ Travis.RepoController = Travis.Controller.extend
|
||||||
Travis["#{$.camelize(name)}View"]
|
Travis["#{$.camelize(name)}View"]
|
||||||
|
|
||||||
@set('tab', tab)
|
@set('tab', tab)
|
||||||
@connectOutlet(outletName: 'pane', controller: this, viewClass: viewClass)
|
#@connectOutlet(outletName: 'pane', controller: this, viewClass: viewClass)
|
||||||
|
|
||||||
_bind: (to, from) ->
|
_bind: (to, from) ->
|
||||||
@bindings.push Ember.oneWay(this, to, from)
|
@bindings.push Ember.oneWay(this, to, from)
|
||||||
|
@ -85,3 +86,7 @@ Travis.RepoController = Travis.Controller.extend
|
||||||
_unbind: ->
|
_unbind: ->
|
||||||
binding.disconnect(this) for binding in @bindings
|
binding.disconnect(this) for binding in @bindings
|
||||||
@bindings.clear()
|
@bindings.clear()
|
||||||
|
|
||||||
|
urlGithub: (->
|
||||||
|
Travis.Urls.githubRepo(@get('repo.slug'))
|
||||||
|
).property('repo.slug'),
|
||||||
|
|
|
@ -6,6 +6,7 @@ Travis.ReposController = Ember.ArrayController.extend
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
|
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
|
||||||
|
@_super.apply this, arguments
|
||||||
|
|
||||||
updateTimes: ->
|
updateTimes: ->
|
||||||
if content = @get('content')
|
if content = @get('content')
|
||||||
|
@ -27,7 +28,6 @@ Travis.ReposController = Ember.ArrayController.extend
|
||||||
)
|
)
|
||||||
limit: 30
|
limit: 30
|
||||||
@set('content', content)
|
@set('content', content)
|
||||||
# @set('content', Travis.Repo.find())
|
|
||||||
|
|
||||||
viewOwned: ->
|
viewOwned: ->
|
||||||
@set('content', Travis.Repo.accessibleBy(Travis.app.get('currentUser.login')))
|
@set('content', Travis.Repo.accessibleBy(Travis.app.get('currentUser.login')))
|
||||||
|
|
|
@ -17,6 +17,7 @@ require 'travis/model'
|
||||||
repo: DS.belongsTo('Travis.Repo', key: 'repository_id')
|
repo: DS.belongsTo('Travis.Repo', key: 'repository_id')
|
||||||
build: DS.belongsTo('Travis.Build', key: 'build_id')
|
build: DS.belongsTo('Travis.Build', key: 'build_id')
|
||||||
commit: DS.belongsTo('Travis.Commit', key: 'commit_id')
|
commit: DS.belongsTo('Travis.Commit', key: 'commit_id')
|
||||||
|
commits: DS.belongsTo('Travis.Commit', key: 'commit_id')
|
||||||
log: ( ->
|
log: ( ->
|
||||||
Travis.Artifact.create(job: this)
|
Travis.Artifact.create(job: this)
|
||||||
).property()
|
).property()
|
||||||
|
@ -76,11 +77,11 @@ require 'travis/model'
|
||||||
|
|
||||||
subscribe: ->
|
subscribe: ->
|
||||||
if id = @get('id')
|
if id = @get('id')
|
||||||
Travis.app.pusher.subscribe "job-#{id}"
|
Travis.pusher.subscribe "job-#{id}"
|
||||||
|
|
||||||
onStateChange: (->
|
onStateChange: (->
|
||||||
if @get('state') == 'finished' && Travis.app
|
if @get('state') == 'finished' && Travis.pusher
|
||||||
Travis.app.pusher.unsubscribe "job-#{@get('id')}"
|
Travis.pusher.unsubscribe "job-#{@get('id')}"
|
||||||
).observes('state')
|
).observes('state')
|
||||||
|
|
||||||
isAttributeLoaded: (key) ->
|
isAttributeLoaded: (key) ->
|
||||||
|
@ -98,16 +99,16 @@ require 'travis/model'
|
||||||
@Travis.Job.reopenClass
|
@Travis.Job.reopenClass
|
||||||
queued: (queue) ->
|
queued: (queue) ->
|
||||||
@find()
|
@find()
|
||||||
Travis.app.store.filter this, (job) ->
|
Travis.store.filter this, (job) ->
|
||||||
queued = ['created', 'queued'].indexOf(job.get('state')) != -1
|
queued = ['created', 'queued'].indexOf(job.get('state')) != -1
|
||||||
# TODO: why queue is sometimes just common instead of build.common?
|
# TODO: why queue is sometimes just common instead of build.common?
|
||||||
queued && (!queue || job.get('queue') == "builds.#{queue}" || job.get('queue') == queue)
|
queued && (!queue || job.get('queue') == "builds.#{queue}" || job.get('queue') == queue)
|
||||||
|
|
||||||
running: ->
|
running: ->
|
||||||
@find(state: 'started')
|
@find(state: 'started')
|
||||||
Travis.app.store.filter this, (job) ->
|
Travis.store.filter this, (job) ->
|
||||||
job.get('state') == 'started'
|
job.get('state') == 'started'
|
||||||
|
|
||||||
findMany: (ids) ->
|
findMany: (ids) ->
|
||||||
Travis.app.store.findMany this, ids
|
Travis.store.findMany this, ids
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ $.extend Travis.Pusher.prototype,
|
||||||
"#{Travis.Pusher.CHANNEL_PREFIX}#{channel}"
|
"#{Travis.Pusher.CHANNEL_PREFIX}#{channel}"
|
||||||
|
|
||||||
receive: (event, data) ->
|
receive: (event, data) ->
|
||||||
|
return
|
||||||
return if event.substr(0, 6) == 'pusher'
|
return if event.substr(0, 6) == 'pusher'
|
||||||
data = @normalize(event, data) if data.id
|
data = @normalize(event, data) if data.id
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
require 'travis/location'
|
#require 'travis/location'
|
||||||
|
#
|
||||||
Ember.Route.reopen
|
#Ember.Route.reopen
|
||||||
enter: (router) ->
|
# enter: (router) ->
|
||||||
@_super(router)
|
# @_super(router)
|
||||||
_gaq.push(['_trackPageview', @absoluteRoute(router)]) if @get('isLeafRoute') && _gaq?
|
# _gaq.push(['_trackPageview', @absoluteRoute(router)]) if @get('isLeafRoute') && _gaq?
|
||||||
|
#
|
||||||
defaultRoute = Ember.Route.extend
|
defaultRoute = Ember.Route.extend
|
||||||
route: '/'
|
route: '/'
|
||||||
index: 1000
|
index: 1000
|
||||||
|
@ -17,26 +17,26 @@ lineNumberRoute = Ember.Route.extend
|
||||||
|
|
||||||
dynamicSegmentPattern: "([0-9]+)"
|
dynamicSegmentPattern: "([0-9]+)"
|
||||||
|
|
||||||
Travis.Router = Ember.Router.extend
|
Travis.OldRouter = Ember.Object.extend
|
||||||
location: 'travis'
|
location: 'travis'
|
||||||
# enableLogging: true
|
# enableLogging: true
|
||||||
enableLogging: false
|
enableLogging: false
|
||||||
initialState: 'loading'
|
initialState: 'loading'
|
||||||
|
|
||||||
showRoot: Ember.Route.transitionTo('root.home.show')
|
# showRoot: Ember.Route.transitionTo('root.home.show')
|
||||||
showStats: Ember.Route.transitionTo('root.stats')
|
# showStats: Ember.Route.transitionTo('root.stats')
|
||||||
|
#
|
||||||
showRepo: Ember.Route.transitionTo('root.home.repo.show')
|
# showRepo: Ember.Route.transitionTo('root.home.repo.show')
|
||||||
showBuilds: Ember.Route.transitionTo('root.home.repo.builds.index')
|
# showBuilds: Ember.Route.transitionTo('root.home.repo.builds.index')
|
||||||
showBuild: Ember.Route.transitionTo('root.home.repo.builds.show')
|
# showBuild: Ember.Route.transitionTo('root.home.repo.builds.show')
|
||||||
showPullRequests: Ember.Route.transitionTo('root.home.repo.pullRequests')
|
# showPullRequests: Ember.Route.transitionTo('root.home.repo.pullRequests')
|
||||||
showBranches: Ember.Route.transitionTo('root.home.repo.branches')
|
# showBranches: Ember.Route.transitionTo('root.home.repo.branches')
|
||||||
showEvents: Ember.Route.transitionTo('root.home.repo.events')
|
# showEvents: Ember.Route.transitionTo('root.home.repo.events')
|
||||||
showJob: Ember.Route.transitionTo('root.home.repo.job')
|
# showJob: Ember.Route.transitionTo('root.home.repo.job')
|
||||||
|
#
|
||||||
showProfile: Ember.Route.transitionTo('root.profile')
|
# showProfile: Ember.Route.transitionTo('root.profile')
|
||||||
showAccount: Ember.Route.transitionTo('root.profile.account')
|
# showAccount: Ember.Route.transitionTo('root.profile.account')
|
||||||
showUserProfile: Ember.Route.transitionTo('root.profile.account.profile')
|
# showUserProfile: Ember.Route.transitionTo('root.profile.account.profile')
|
||||||
|
|
||||||
saveLineNumberHash: (path) ->
|
saveLineNumberHash: (path) ->
|
||||||
Ember.run.next this, ->
|
Ember.run.next this, ->
|
||||||
|
@ -372,3 +372,24 @@ Travis.Router = Ember.Router.extend
|
||||||
job.removeObserver('log.id', observer)
|
job.removeObserver('log.id', observer)
|
||||||
|
|
||||||
job.addObserver('log.id', observer)
|
job.addObserver('log.id', observer)
|
||||||
|
|
||||||
|
Ember.Router.reopen
|
||||||
|
location: Ember.HistoryLocation.create()
|
||||||
|
|
||||||
|
Travis.Router.map ->
|
||||||
|
|
||||||
|
Travis.IndexRoute = Ember.Route.extend
|
||||||
|
renderTemplate: ->
|
||||||
|
$('body').attr('id', 'home')
|
||||||
|
|
||||||
|
@render 'repos', outlet: 'left'
|
||||||
|
@render 'sidebar', outlet: 'right'
|
||||||
|
@render 'top', outlet: 'top'
|
||||||
|
@render 'flash', outlet: 'flash'
|
||||||
|
@render 'repo'
|
||||||
|
@render 'build', outlet: 'pane', into: 'repo'
|
||||||
|
|
||||||
|
setupController: (controller)->
|
||||||
|
@container.lookup('controller:repos').activate()
|
||||||
|
@container.lookup('view:application').connectLayout 'home'
|
||||||
|
@container.lookup('controller:repo').activate('index')
|
||||||
|
|
|
@ -5,7 +5,7 @@ DATA_PROXY =
|
||||||
@savedData[name]
|
@savedData[name]
|
||||||
|
|
||||||
Travis.Store = DS.Store.extend
|
Travis.Store = DS.Store.extend
|
||||||
revision: 4
|
revision: 11
|
||||||
adapter: Travis.RestAdapter.create()
|
adapter: Travis.RestAdapter.create()
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
|
@ -71,6 +71,7 @@ Travis.Store = DS.Store.extend
|
||||||
!!@typeMapFor(type).idToCid[id]
|
!!@typeMapFor(type).idToCid[id]
|
||||||
|
|
||||||
receive: (event, data) ->
|
receive: (event, data) ->
|
||||||
|
console.log event, data
|
||||||
[name, type] = event.split(':')
|
[name, type] = event.split(':')
|
||||||
|
|
||||||
mappings = @adapter.get('mappings')
|
mappings = @adapter.get('mappings')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'travis/ajax'
|
require 'travis/ajax'
|
||||||
require 'models'
|
require 'models'
|
||||||
|
|
||||||
@Travis.RestAdapter = DS.RESTAdapter.extend
|
Travis.RestAdapter = DS.RESTAdapter.extend
|
||||||
mappings:
|
mappings:
|
||||||
broadcasts: Travis.Broadcast
|
broadcasts: Travis.Broadcast
|
||||||
repositories: Travis.Repo
|
repositories: Travis.Repo
|
||||||
|
@ -38,3 +38,5 @@ require 'models'
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
@_super.apply this, arguments
|
@_super.apply this, arguments
|
||||||
|
|
||||||
|
Travis.RestAdapter.map 'Travis.Commit', {}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{{#with view}}
|
{{#if loading}}
|
||||||
{{#if loading}}
|
|
||||||
<span>Loading</span>
|
<span>Loading</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<dl id="summary">
|
<dl id="summary">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<dt>{{t builds.name}}</dt>
|
<dt>{{t builds.name}}</dt>
|
||||||
|
@ -51,5 +50,4 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
{{view Travis.LogView contextBinding="build.jobs.firstObject"}}
|
{{view Travis.LogView contextBinding="build.jobs.firstObject"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/with}}
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
{{view Travis.ReposListTabsView}}
|
{{view Travis.ReposListTabsView}}
|
||||||
|
|
||||||
<div class="tab">
|
<div class="tab">
|
||||||
{{#collection Travis.ReposListView contentBinding="controller"}}
|
{{#collection Travis.ReposListView contentBinding="this"}}
|
||||||
{{#with view.repo}}
|
{{#with view.repo}}
|
||||||
<div class="slug-and-status">
|
<div class="slug-and-status">
|
||||||
<span class="status"></span>
|
<span class="status"></span>
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
{{#if view.isEmpty}}
|
{{#if view.isEmpty}}
|
||||||
{{view Travis.ReposEmptyView}}
|
{{view Travis.ReposEmptyView}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if view.repo.isLoaded}}
|
{{#if repo.isLoaded}}
|
||||||
{{#with view.repo}}
|
{{#with repo}}
|
||||||
<h3>
|
<h3>
|
||||||
<a {{bindAttr href="view.urlGithub"}}>{{slug}}</a>
|
<a {{bindAttr href="urlGithub"}}>{{slug}}</a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<p class="description">{{description}}</p>
|
<p class="description">{{description}}</p>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@Travis.reopen
|
Travis.reopen
|
||||||
ApplicationView: Travis.View.extend
|
ApplicationView: Travis.View.extend
|
||||||
templateName: 'layouts/home'
|
templateName: 'layouts/home'
|
||||||
classNames: ['application']
|
classNames: ['application']
|
||||||
|
|
|
@ -53,15 +53,7 @@
|
||||||
elementId: 'build'
|
elementId: 'build'
|
||||||
classNameBindings: ['color', 'loading']
|
classNameBindings: ['color', 'loading']
|
||||||
|
|
||||||
repoBinding: 'controller.repo'
|
loadingBinding: 'controller.loading'
|
||||||
buildBinding: 'controller.build'
|
|
||||||
commitBinding: 'build.commit'
|
|
||||||
|
|
||||||
currentItemBinding: 'build'
|
|
||||||
|
|
||||||
loading: (->
|
|
||||||
!@get('build.isLoaded')
|
|
||||||
).property('build.isLoaded')
|
|
||||||
|
|
||||||
color: (->
|
color: (->
|
||||||
Travis.Helpers.colorForState(@get('build.state'))
|
Travis.Helpers.colorForState(@get('build.state'))
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
ReposListTabsView: Travis.View.extend
|
ReposListTabsView: Travis.View.extend
|
||||||
templateName: 'repos/list/tabs'
|
templateName: 'repos/list/tabs'
|
||||||
tabBinding: 'controller.tab'
|
tabBinding: 'controller.tab'
|
||||||
|
needs: ['currentUser']
|
||||||
|
currentUserBinding: 'controllers.currentUser'
|
||||||
|
|
||||||
activate: (event) ->
|
activate: (event) ->
|
||||||
@get('controller').activate(event.target.name)
|
@get('controller').activate(event.target.name)
|
||||||
|
@ -33,9 +35,9 @@
|
||||||
classOwned: (->
|
classOwned: (->
|
||||||
classes = []
|
classes = []
|
||||||
classes.push('active') if @get('tab') == 'owned'
|
classes.push('active') if @get('tab') == 'owned'
|
||||||
classes.push('display-inline') if Travis.app.get('currentUser')
|
classes.push('display-inline') if @get('currentUser')
|
||||||
classes.join(' ')
|
classes.join(' ')
|
||||||
).property('tab', 'Travis.app.currentUser')
|
).property('tab', 'currentUser')
|
||||||
|
|
||||||
classSearch: (->
|
classSearch: (->
|
||||||
'active' if @get('tab') == 'search'
|
'active' if @get('tab') == 'search'
|
||||||
|
|
|
@ -2,21 +2,15 @@
|
||||||
RepoView: Travis.View.extend
|
RepoView: Travis.View.extend
|
||||||
templateName: 'repos/show'
|
templateName: 'repos/show'
|
||||||
|
|
||||||
reposBinding: 'controller.repos'
|
classNameBindings: ['loading:isLoaded']
|
||||||
repoBinding: 'controller.repo'
|
|
||||||
|
|
||||||
class: (->
|
isLoadedBinding: 'controller.repo.isLoaded'
|
||||||
'loading' unless @get('repo.isLoaded')
|
reposBinding: 'controllers.repos'
|
||||||
).property('repo.isLoaded')
|
|
||||||
|
|
||||||
isEmpty: (->
|
isEmpty: (->
|
||||||
@get('repos.isLoaded') && @get('repos.length') == 0
|
@get('repos.isLoaded') && @get('repos.length') == 0
|
||||||
).property('repos.isLoaded', 'repos.length')
|
).property('repos.isLoaded', 'repos.length')
|
||||||
|
|
||||||
urlGithub: (->
|
|
||||||
Travis.Urls.githubRepo(@get('repo.slug'))
|
|
||||||
).property('repo.slug'),
|
|
||||||
|
|
||||||
RepoShowStatsView: Travis.View.extend
|
RepoShowStatsView: Travis.View.extend
|
||||||
templateName: 'repos/show/stats'
|
templateName: 'repos/show/stats'
|
||||||
repoBinding: 'parentView.repo'
|
repoBinding: 'parentView.repo'
|
||||||
|
@ -208,6 +202,6 @@
|
||||||
).property('tab')
|
).property('tab')
|
||||||
|
|
||||||
hasPermission: (->
|
hasPermission: (->
|
||||||
if permissions = Travis.app.get('currentUser.permissions')
|
if permissions = Travis.get('currentUser.permissions')
|
||||||
permissions.contains @get('repo.id')
|
permissions.contains @get('repo.id')
|
||||||
).property('Travis.app.currentUser.permissions.length', 'repo.id')
|
).property('Travis.currentUser.permissions.length', 'repo.id')
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
|
|
||||||
didInsertElement: ->
|
didInsertElement: ->
|
||||||
controller = @get 'controller'
|
controller = @get 'controller'
|
||||||
unless controller.get('content')
|
# TODO: move this stuff to controller
|
||||||
Travis.app.get('router.sidebarController').tickables.push(controller)
|
#unless controller.get('content')
|
||||||
controller.set 'content', Travis.Sponsor.decks()
|
#Travis.app.get('router.sidebarController').tickables.push(controller)
|
||||||
|
#controller.set 'content', Travis.Sponsor.decks()
|
||||||
@_super.apply this, arguments
|
@_super.apply this, arguments
|
||||||
|
|
||||||
LinksView: Em.View.extend
|
LinksView: Em.View.extend
|
||||||
|
@ -21,9 +22,9 @@
|
||||||
|
|
||||||
didInsertElement: ->
|
didInsertElement: ->
|
||||||
controller = @get 'controller'
|
controller = @get 'controller'
|
||||||
unless controller.get('content')
|
#unless controller.get('content')
|
||||||
controller.set 'content', Travis.Sponsor.links()
|
# controller.set 'content', Travis.Sponsor.links()
|
||||||
Travis.app.get('router.sidebarController').tickables.push(controller)
|
# Travis.app.get('router.sidebarController').tickables.push(controller)
|
||||||
@_super.apply this, arguments
|
@_super.apply this, arguments
|
||||||
|
|
||||||
WorkersView: Em.View.extend
|
WorkersView: Em.View.extend
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
classProfile: (->
|
classProfile: (->
|
||||||
classes = ['profile menu']
|
classes = ['profile menu']
|
||||||
classes.push('active') if @get('tab') == 'profile'
|
classes.push('active') if @get('tab') == 'profile'
|
||||||
classes.push(Travis.app.get('authState'))
|
classes.push(Travis.get('authState'))
|
||||||
classes.join(' ')
|
classes.join(' ')
|
||||||
).property('tab', 'Travis.app.authState')
|
).property('tab', 'Travis.authState')
|
||||||
|
|
||||||
showProfile: ->
|
showProfile: ->
|
||||||
$('#top .profile ul').show()
|
$('#top .profile ul').show()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
jQuery.support.cors = true
|
jQuery.support.cors = true
|
||||||
|
|
||||||
@Travis.ajax = Em.Object.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'
|
||||||
|
|
|
@ -54,7 +54,7 @@ Travis.LimitedArray = Em.ArrayProxy.extend
|
||||||
if addedCount
|
if addedCount
|
||||||
if index < limit
|
if index < limit
|
||||||
addedObjects = array.slice(index, index + addedCount)
|
addedObjects = array.slice(index, index + addedCount)
|
||||||
@replaceContent(index, 0, addedObjects)
|
@get('arrangedContent').replace(index, 0, addedObjects)
|
||||||
|
|
||||||
@balanceArray()
|
@balanceArray()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
@Travis.Model = DS.Model.extend
|
@Travis.Model = DS.Model.extend
|
||||||
primaryKey: 'id'
|
|
||||||
id: DS.attr('number')
|
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
@loadedAttributes = []
|
@loadedAttributes = []
|
||||||
@_super.apply this, arguments
|
@_super.apply this, arguments
|
||||||
|
@ -58,15 +55,15 @@
|
||||||
@Travis.Model.reopenClass
|
@Travis.Model.reopenClass
|
||||||
find: ->
|
find: ->
|
||||||
if arguments.length == 0
|
if arguments.length == 0
|
||||||
Travis.app.store.findAll(this)
|
Travis.store.findAll(this)
|
||||||
else
|
else
|
||||||
@_super.apply(this, arguments)
|
@_super.apply(this, arguments)
|
||||||
|
|
||||||
filter: (callback) ->
|
filter: (callback) ->
|
||||||
Travis.app.store.filter(this, callback)
|
Travis.store.filter(this, callback)
|
||||||
|
|
||||||
load: (attrs) ->
|
load: (attrs) ->
|
||||||
Travis.app.store.load(this, attrs)
|
Travis.store.load(this, attrs)
|
||||||
|
|
||||||
select: (id) ->
|
select: (id) ->
|
||||||
@find().forEach (record) ->
|
@find().forEach (record) ->
|
||||||
|
@ -86,7 +83,7 @@
|
||||||
name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1)
|
name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1)
|
||||||
|
|
||||||
pluralName: ->
|
pluralName: ->
|
||||||
Travis.app.store.adapter.pluralize(@singularName())
|
Travis.store.adapter.pluralize(@singularName())
|
||||||
|
|
||||||
isAttribute: (name) ->
|
isAttribute: (name) ->
|
||||||
Ember.get(this, 'attributes').has(name) ||
|
Ember.get(this, 'attributes').has(name) ||
|
||||||
|
|
|
@ -1,18 +1,6 @@
|
||||||
require 'ext/jquery'
|
require 'ext/jquery'
|
||||||
require 'ext/ember/namespace'
|
require 'ext/ember/namespace'
|
||||||
|
|
||||||
if window.history.state == undefined
|
|
||||||
window.history.state = {}
|
|
||||||
oldPushState = window.history.pushState
|
|
||||||
window.history.pushState = (state, title, href) ->
|
|
||||||
window.history.state = state
|
|
||||||
oldPushState.apply this, arguments
|
|
||||||
|
|
||||||
oldReplaceState = window.history.replaceState
|
|
||||||
window.history.replaceState = (state, title, href) ->
|
|
||||||
window.history.state = state
|
|
||||||
oldReplaceState.apply this, arguments
|
|
||||||
|
|
||||||
# TODO: how can I put it in Travis namespace and use immediately?
|
# TODO: how can I put it in Travis namespace and use immediately?
|
||||||
Storage = Em.Object.extend
|
Storage = Em.Object.extend
|
||||||
init: ->
|
init: ->
|
||||||
|
@ -28,8 +16,62 @@ Storage = Em.Object.extend
|
||||||
clear: ->
|
clear: ->
|
||||||
@set('storage', {})
|
@set('storage', {})
|
||||||
|
|
||||||
|
window.Travis = Em.Application.create Ember.Evented,
|
||||||
|
autoinit: false
|
||||||
|
currentUserBinding: 'auth.user'
|
||||||
|
authStateBinding: 'auth.state'
|
||||||
|
|
||||||
@Travis = Em.Namespace.create Ember.Evented,
|
setup: ->
|
||||||
|
@store = Travis.Store.create(
|
||||||
|
adapter: Travis.RestAdapter.create(serializer: DS.RESTSerializer)
|
||||||
|
)
|
||||||
|
#@store.loadMany(Travis.Sponsor, Travis.SPONSORS)
|
||||||
|
|
||||||
|
@slider = new Travis.Slider()
|
||||||
|
@pusher = new Travis.Pusher(Travis.config.pusher_key)
|
||||||
|
@tailing = new Travis.Tailing()
|
||||||
|
|
||||||
|
@set('auth', Travis.Auth.create(app: this, endpoint: Travis.config.api_endpoint))
|
||||||
|
|
||||||
|
storeAfterSignInPath: (path) ->
|
||||||
|
@get('auth').storeAfterSignInPath(path)
|
||||||
|
|
||||||
|
autoSignIn: (path) ->
|
||||||
|
@get('auth').autoSignIn()
|
||||||
|
|
||||||
|
signIn: ->
|
||||||
|
@get('auth').signIn()
|
||||||
|
|
||||||
|
signOut: ->
|
||||||
|
@get('auth').signOut()
|
||||||
|
@get('router').send('afterSignOut')
|
||||||
|
|
||||||
|
receive: ->
|
||||||
|
@store.receive.apply(@store, arguments)
|
||||||
|
|
||||||
|
toggleSidebar: ->
|
||||||
|
$('body').toggleClass('maximized')
|
||||||
|
# TODO gotta force redraws here :/
|
||||||
|
element = $('<span></span>')
|
||||||
|
$('#top .profile').append(element)
|
||||||
|
Em.run.later (-> element.remove()), 10
|
||||||
|
element = $('<span></span>')
|
||||||
|
$('#repo').append(element)
|
||||||
|
Em.run.later (-> element.remove()), 10
|
||||||
|
|
||||||
|
setLocale: (locale) ->
|
||||||
|
return unless locale
|
||||||
|
I18n.locale = locale
|
||||||
|
Travis.set('locale', locale)
|
||||||
|
|
||||||
|
defaultLocale: 'en'
|
||||||
|
|
||||||
|
ready: ->
|
||||||
|
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
|
||||||
|
I18n.fallbacks = true
|
||||||
|
@setLocale 'locale', @get('defaultLocale')
|
||||||
|
|
||||||
|
$.extend Travis,
|
||||||
config:
|
config:
|
||||||
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
|
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
|
||||||
pusher_key: $('meta[name="travis.pusher_key"]').attr('value')
|
pusher_key: $('meta[name="travis.pusher_key"]').attr('value')
|
||||||
|
@ -37,21 +79,6 @@ Storage = Em.Object.extend
|
||||||
|
|
||||||
CONFIG_KEYS: ['rvm', 'gemfile', 'env', 'jdk', 'otp_release', 'php', 'node_js', 'perl', 'python', 'scala', 'compiler']
|
CONFIG_KEYS: ['rvm', 'gemfile', 'env', 'jdk', 'otp_release', 'php', 'node_js', 'perl', 'python', 'scala', 'compiler']
|
||||||
|
|
||||||
ROUTES:
|
|
||||||
'profile/:login/me': ['profile', 'user']
|
|
||||||
'profile/:login': ['profile', 'hooks']
|
|
||||||
'profile': ['profile', 'hooks']
|
|
||||||
'stats': ['stats', 'show']
|
|
||||||
':owner/:name/jobs/:id/:line': ['home', 'job']
|
|
||||||
':owner/:name/jobs/:id': ['home', 'job']
|
|
||||||
':owner/:name/builds/:id': ['home', 'build']
|
|
||||||
':owner/:name/builds': ['home', 'builds']
|
|
||||||
':owner/:name/pull_requests': ['home', 'pullRequests']
|
|
||||||
':owner/:name/branches': ['home', 'branches']
|
|
||||||
':owner/:name': ['home', 'current']
|
|
||||||
'': ['home', 'index']
|
|
||||||
'#': ['home', 'index']
|
|
||||||
|
|
||||||
QUEUES: [
|
QUEUES: [
|
||||||
{ name: 'common', display: 'Common' }
|
{ name: 'common', display: 'Common' }
|
||||||
{ name: 'linux', display: 'Linux' }
|
{ name: 'linux', display: 'Linux' }
|
||||||
|
@ -60,11 +87,6 @@ Storage = Em.Object.extend
|
||||||
|
|
||||||
INTERVALS: { sponsors: -1, times: -1, updateTimes: 1000 }
|
INTERVALS: { sponsors: -1, times: -1, updateTimes: 1000 }
|
||||||
|
|
||||||
setLocale: (locale) ->
|
|
||||||
return unless locale
|
|
||||||
I18n.locale = locale
|
|
||||||
Travis.set('locale', locale)
|
|
||||||
|
|
||||||
storage: (->
|
storage: (->
|
||||||
storage = null
|
storage = null
|
||||||
try
|
try
|
||||||
|
@ -74,7 +96,7 @@ Storage = Em.Object.extend
|
||||||
|
|
||||||
storage
|
storage
|
||||||
)()
|
)()
|
||||||
default_locale: 'en'
|
|
||||||
sessionStorage: (->
|
sessionStorage: (->
|
||||||
storage = null
|
storage = null
|
||||||
try
|
try
|
||||||
|
@ -88,26 +110,25 @@ Storage = Em.Object.extend
|
||||||
storage
|
storage
|
||||||
)()
|
)()
|
||||||
|
|
||||||
run: (attrs) ->
|
|
||||||
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
|
|
||||||
|
|
||||||
I18n.fallbacks = true
|
|
||||||
Travis.setLocale 'locale', @default_locale
|
|
||||||
|
|
||||||
Ember.run.next this, ->
|
|
||||||
app = Travis.App.create(attrs || {})
|
|
||||||
# TODO: router expects the classes for controllers on main namespace, so
|
|
||||||
# if we want to keep app at Travis.app, we need to copy that, it would
|
|
||||||
# be ideal to send a patch to ember and get rid of this
|
|
||||||
$.each Travis, (key, value) ->
|
|
||||||
app[key] = value if value && value.isClass && key != 'constructor'
|
|
||||||
|
|
||||||
@app = app
|
|
||||||
@store = app.store
|
|
||||||
$ => app.initialize()
|
|
||||||
|
|
||||||
setupGoogleAnalytics() if Travis.config.ga_code
|
setupGoogleAnalytics() if Travis.config.ga_code
|
||||||
|
|
||||||
require 'ext/i18n'
|
require 'ext/i18n'
|
||||||
require 'travis/ajax'
|
require 'travis/ajax'
|
||||||
require 'app'
|
require 'auth'
|
||||||
|
require 'controllers'
|
||||||
|
require 'helpers'
|
||||||
|
require 'models'
|
||||||
|
require 'pusher'
|
||||||
|
require 'routes'
|
||||||
|
require 'slider'
|
||||||
|
require 'store'
|
||||||
|
require 'tailing'
|
||||||
|
require 'templates'
|
||||||
|
require 'views'
|
||||||
|
|
||||||
|
require 'config/locales'
|
||||||
|
require 'data/sponsors'
|
||||||
|
|
||||||
|
require 'travis/instrumentation'
|
||||||
|
|
||||||
|
Travis.setup()
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
<script src="/scripts/app.js"></script>
|
<script src="/scripts/app.js"></script>
|
||||||
<script>
|
<script>
|
||||||
minispade.require('travis')
|
minispade.require('travis')
|
||||||
Travis.run()
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body id="home"></body>
|
<body id="home"></body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user