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
|
||||
# Ember.LOG_BINDINGS = true
|
||||
# Ember.ENV.RAISE_ON_DEPRECATION = true
|
||||
# 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 'travis/ticker'
|
||||
|
||||
Travis.reopen
|
||||
Controller: Em.Controller.extend()
|
||||
|
||||
TopController: Em.Controller.extend
|
||||
Travis.Controller = Em.Controller.extend()
|
||||
Travis.TopController = Em.Controller.extend
|
||||
userBinding: 'Travis.app.currentUser'
|
||||
|
||||
ApplicationController: Em.Controller.extend()
|
||||
MainController: Em.Controller.extend()
|
||||
StatsLayoutController: Em.Controller.extend()
|
||||
ProfileLayoutController: Em.Controller.extend()
|
||||
AuthLayoutController: Em.Controller.extend()
|
||||
Travis.ApplicationController = Em.Controller.extend()
|
||||
Travis.MainController = Em.Controller.extend()
|
||||
Travis.StatsLayoutController = Em.Controller.extend()
|
||||
Travis.ProfileLayoutController = Em.Controller.extend()
|
||||
Travis.AuthLayoutController = Em.Controller.extend()
|
||||
Travis.CurrentUserController = Em.ObjectController.extend()
|
||||
|
||||
require 'controllers/accounts'
|
||||
require 'controllers/build'
|
||||
require 'controllers/builds'
|
||||
require 'controllers/flash'
|
||||
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
|
||||
broadcastBinding: 'Travis.app.currentUser.broadcasts'
|
||||
needs: ['currentUser']
|
||||
currentUserBinding: 'controllers.currentUser'
|
||||
|
||||
broadcastBinding: 'currentUser.broadcasts'
|
||||
|
||||
init: ->
|
||||
@set('flashes', Ember.A())
|
||||
|
@ -14,8 +17,8 @@ Travis.FlashController = Ember.ArrayController.extend
|
|||
).property('broadcasts.isLoaded', 'broadcasts.length')
|
||||
|
||||
broadcasts: (->
|
||||
if Travis.app.get('currentUser') then Travis.Broadcast.find() else Ember.A()
|
||||
).property('Travis.app.currentUser')
|
||||
if @get('currentUser') then Travis.Broadcast.find() else Ember.A()
|
||||
).property('currentUser')
|
||||
|
||||
loadFlashes: (msgs) ->
|
||||
for msg in msgs
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Travis.RepoController = Travis.Controller.extend
|
||||
bindings: []
|
||||
needs: ['repos']
|
||||
|
||||
init: ->
|
||||
@_super.apply this, arguments
|
||||
|
@ -33,7 +34,7 @@ Travis.RepoController = Travis.Controller.extend
|
|||
this["view#{$.camelize(action)}"]()
|
||||
|
||||
viewIndex: ->
|
||||
@_bind('repo', 'controllers.reposController.firstObject')
|
||||
@_bind('repo', 'controllers.repos.firstObject')
|
||||
@_bind('build', 'repo.lastBuild')
|
||||
@connectTab('current')
|
||||
|
||||
|
@ -77,7 +78,7 @@ Travis.RepoController = Travis.Controller.extend
|
|||
Travis["#{$.camelize(name)}View"]
|
||||
|
||||
@set('tab', tab)
|
||||
@connectOutlet(outletName: 'pane', controller: this, viewClass: viewClass)
|
||||
#@connectOutlet(outletName: 'pane', controller: this, viewClass: viewClass)
|
||||
|
||||
_bind: (to, from) ->
|
||||
@bindings.push Ember.oneWay(this, to, from)
|
||||
|
@ -85,3 +86,7 @@ Travis.RepoController = Travis.Controller.extend
|
|||
_unbind: ->
|
||||
binding.disconnect(this) for binding in @bindings
|
||||
@bindings.clear()
|
||||
|
||||
urlGithub: (->
|
||||
Travis.Urls.githubRepo(@get('repo.slug'))
|
||||
).property('repo.slug'),
|
||||
|
|
|
@ -6,6 +6,7 @@ Travis.ReposController = Ember.ArrayController.extend
|
|||
|
||||
init: ->
|
||||
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
|
||||
@_super.apply this, arguments
|
||||
|
||||
updateTimes: ->
|
||||
if content = @get('content')
|
||||
|
@ -27,7 +28,6 @@ Travis.ReposController = Ember.ArrayController.extend
|
|||
)
|
||||
limit: 30
|
||||
@set('content', content)
|
||||
# @set('content', Travis.Repo.find())
|
||||
|
||||
viewOwned: ->
|
||||
@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')
|
||||
build: DS.belongsTo('Travis.Build', key: 'build_id')
|
||||
commit: DS.belongsTo('Travis.Commit', key: 'commit_id')
|
||||
commits: DS.belongsTo('Travis.Commit', key: 'commit_id')
|
||||
log: ( ->
|
||||
Travis.Artifact.create(job: this)
|
||||
).property()
|
||||
|
@ -76,11 +77,11 @@ require 'travis/model'
|
|||
|
||||
subscribe: ->
|
||||
if id = @get('id')
|
||||
Travis.app.pusher.subscribe "job-#{id}"
|
||||
Travis.pusher.subscribe "job-#{id}"
|
||||
|
||||
onStateChange: (->
|
||||
if @get('state') == 'finished' && Travis.app
|
||||
Travis.app.pusher.unsubscribe "job-#{@get('id')}"
|
||||
if @get('state') == 'finished' && Travis.pusher
|
||||
Travis.pusher.unsubscribe "job-#{@get('id')}"
|
||||
).observes('state')
|
||||
|
||||
isAttributeLoaded: (key) ->
|
||||
|
@ -98,16 +99,16 @@ require 'travis/model'
|
|||
@Travis.Job.reopenClass
|
||||
queued: (queue) ->
|
||||
@find()
|
||||
Travis.app.store.filter this, (job) ->
|
||||
Travis.store.filter this, (job) ->
|
||||
queued = ['created', 'queued'].indexOf(job.get('state')) != -1
|
||||
# TODO: why queue is sometimes just common instead of build.common?
|
||||
queued && (!queue || job.get('queue') == "builds.#{queue}" || job.get('queue') == queue)
|
||||
|
||||
running: ->
|
||||
@find(state: 'started')
|
||||
Travis.app.store.filter this, (job) ->
|
||||
Travis.store.filter this, (job) ->
|
||||
job.get('state') == 'started'
|
||||
|
||||
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}"
|
||||
|
||||
receive: (event, data) ->
|
||||
return
|
||||
return if event.substr(0, 6) == 'pusher'
|
||||
data = @normalize(event, data) if data.id
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'travis/location'
|
||||
|
||||
Ember.Route.reopen
|
||||
enter: (router) ->
|
||||
@_super(router)
|
||||
_gaq.push(['_trackPageview', @absoluteRoute(router)]) if @get('isLeafRoute') && _gaq?
|
||||
|
||||
#require 'travis/location'
|
||||
#
|
||||
#Ember.Route.reopen
|
||||
# enter: (router) ->
|
||||
# @_super(router)
|
||||
# _gaq.push(['_trackPageview', @absoluteRoute(router)]) if @get('isLeafRoute') && _gaq?
|
||||
#
|
||||
defaultRoute = Ember.Route.extend
|
||||
route: '/'
|
||||
index: 1000
|
||||
|
@ -17,26 +17,26 @@ lineNumberRoute = Ember.Route.extend
|
|||
|
||||
dynamicSegmentPattern: "([0-9]+)"
|
||||
|
||||
Travis.Router = Ember.Router.extend
|
||||
Travis.OldRouter = Ember.Object.extend
|
||||
location: 'travis'
|
||||
# enableLogging: true
|
||||
enableLogging: false
|
||||
initialState: 'loading'
|
||||
|
||||
showRoot: Ember.Route.transitionTo('root.home.show')
|
||||
showStats: Ember.Route.transitionTo('root.stats')
|
||||
|
||||
showRepo: Ember.Route.transitionTo('root.home.repo.show')
|
||||
showBuilds: Ember.Route.transitionTo('root.home.repo.builds.index')
|
||||
showBuild: Ember.Route.transitionTo('root.home.repo.builds.show')
|
||||
showPullRequests: Ember.Route.transitionTo('root.home.repo.pullRequests')
|
||||
showBranches: Ember.Route.transitionTo('root.home.repo.branches')
|
||||
showEvents: Ember.Route.transitionTo('root.home.repo.events')
|
||||
showJob: Ember.Route.transitionTo('root.home.repo.job')
|
||||
|
||||
showProfile: Ember.Route.transitionTo('root.profile')
|
||||
showAccount: Ember.Route.transitionTo('root.profile.account')
|
||||
showUserProfile: Ember.Route.transitionTo('root.profile.account.profile')
|
||||
# showRoot: Ember.Route.transitionTo('root.home.show')
|
||||
# showStats: Ember.Route.transitionTo('root.stats')
|
||||
#
|
||||
# showRepo: Ember.Route.transitionTo('root.home.repo.show')
|
||||
# showBuilds: Ember.Route.transitionTo('root.home.repo.builds.index')
|
||||
# showBuild: Ember.Route.transitionTo('root.home.repo.builds.show')
|
||||
# showPullRequests: Ember.Route.transitionTo('root.home.repo.pullRequests')
|
||||
# showBranches: Ember.Route.transitionTo('root.home.repo.branches')
|
||||
# showEvents: Ember.Route.transitionTo('root.home.repo.events')
|
||||
# showJob: Ember.Route.transitionTo('root.home.repo.job')
|
||||
#
|
||||
# showProfile: Ember.Route.transitionTo('root.profile')
|
||||
# showAccount: Ember.Route.transitionTo('root.profile.account')
|
||||
# showUserProfile: Ember.Route.transitionTo('root.profile.account.profile')
|
||||
|
||||
saveLineNumberHash: (path) ->
|
||||
Ember.run.next this, ->
|
||||
|
@ -372,3 +372,24 @@ Travis.Router = Ember.Router.extend
|
|||
job.removeObserver('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]
|
||||
|
||||
Travis.Store = DS.Store.extend
|
||||
revision: 4
|
||||
revision: 11
|
||||
adapter: Travis.RestAdapter.create()
|
||||
|
||||
init: ->
|
||||
|
@ -71,6 +71,7 @@ Travis.Store = DS.Store.extend
|
|||
!!@typeMapFor(type).idToCid[id]
|
||||
|
||||
receive: (event, data) ->
|
||||
console.log event, data
|
||||
[name, type] = event.split(':')
|
||||
|
||||
mappings = @adapter.get('mappings')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'travis/ajax'
|
||||
require 'models'
|
||||
|
||||
@Travis.RestAdapter = DS.RESTAdapter.extend
|
||||
Travis.RestAdapter = DS.RESTAdapter.extend
|
||||
mappings:
|
||||
broadcasts: Travis.Broadcast
|
||||
repositories: Travis.Repo
|
||||
|
@ -38,3 +38,5 @@ require 'models'
|
|||
return
|
||||
else
|
||||
@_super.apply this, arguments
|
||||
|
||||
Travis.RestAdapter.map 'Travis.Commit', {}
|
||||
|
|
|
@ -1,55 +1,53 @@
|
|||
{{#with view}}
|
||||
{{#if loading}}
|
||||
<span>Loading</span>
|
||||
{{#if loading}}
|
||||
<span>Loading</span>
|
||||
{{else}}
|
||||
<dl id="summary">
|
||||
<div class="left">
|
||||
<dt>{{t builds.name}}</dt>
|
||||
<dd class="number">
|
||||
<span class="status"></span>
|
||||
{{#with build}}
|
||||
<a {{action showBuild repo this href=true}}>{{number}}</a>
|
||||
{{/with}}
|
||||
</dd>
|
||||
<dt>{{t builds.state}}</dt>
|
||||
<dd class="state">{{capitalize build.state}}</dd>
|
||||
<dt class="finished_at_label">{{t builds.finished_at}}</dt>
|
||||
<dd class="finished_at timeago" {{bindAttr title="finishedAt"}}>{{formatTime build.finishedAt}}</dd>
|
||||
<dt>{{t builds.duration}}</dt>
|
||||
<dd class="duration" {{bindAttr title="startedAt"}}>{{formatDuration build.duration}}</dd>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<dt>{{t builds.commit}}</dt>
|
||||
<dd class="commit"><a href="{{unbound urlGithubCommit}}">{{formatCommit build.commit}}</a></dd>
|
||||
{{#if commit.compareUrl}}
|
||||
<dt>{{t builds.compare}}</dt>
|
||||
<dd class="compare"><a href="{{unbound commit.compareUrl}}">{{pathFrom build.commit.compareUrl}}</a></dd>
|
||||
{{/if}}
|
||||
{{#if commit.authorName}}
|
||||
<dt>{{t builds.author}}</dt>
|
||||
<dd class="author"><a href="{{unbound urlAuthor}}">{{build.commit.authorName}}</a></dd>
|
||||
{{/if}}
|
||||
{{#if commit.committerName}}
|
||||
<dt>{{t builds.committer}}</dt>
|
||||
<dd class="committer"><a href="{{unbound urlCommitter}}">{{build.commit.committerName}}</a></dd>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<dt>{{t builds.message}}</dt>
|
||||
<dd class="message">{{{formatMessage build.commit.message}}}</dd>
|
||||
|
||||
{{#unless isMatrix}}
|
||||
<dt>{{t builds.config}}</dt>
|
||||
<dd class="config">{{formatConfig build.config}}</dd>
|
||||
{{/unless}}
|
||||
</dl>
|
||||
|
||||
{{#if build.isMatrix}}
|
||||
{{view Travis.JobsView jobsBinding="build.requiredJobs" required="true"}}
|
||||
{{view Travis.JobsView jobsBinding="build.allowedFailureJobs"}}
|
||||
{{else}}
|
||||
<dl id="summary">
|
||||
<div class="left">
|
||||
<dt>{{t builds.name}}</dt>
|
||||
<dd class="number">
|
||||
<span class="status"></span>
|
||||
{{#with build}}
|
||||
<a {{action showBuild repo this href=true}}>{{number}}</a>
|
||||
{{/with}}
|
||||
</dd>
|
||||
<dt>{{t builds.state}}</dt>
|
||||
<dd class="state">{{capitalize build.state}}</dd>
|
||||
<dt class="finished_at_label">{{t builds.finished_at}}</dt>
|
||||
<dd class="finished_at timeago" {{bindAttr title="finishedAt"}}>{{formatTime build.finishedAt}}</dd>
|
||||
<dt>{{t builds.duration}}</dt>
|
||||
<dd class="duration" {{bindAttr title="startedAt"}}>{{formatDuration build.duration}}</dd>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<dt>{{t builds.commit}}</dt>
|
||||
<dd class="commit"><a href="{{unbound urlGithubCommit}}">{{formatCommit build.commit}}</a></dd>
|
||||
{{#if commit.compareUrl}}
|
||||
<dt>{{t builds.compare}}</dt>
|
||||
<dd class="compare"><a href="{{unbound commit.compareUrl}}">{{pathFrom build.commit.compareUrl}}</a></dd>
|
||||
{{/if}}
|
||||
{{#if commit.authorName}}
|
||||
<dt>{{t builds.author}}</dt>
|
||||
<dd class="author"><a href="{{unbound urlAuthor}}">{{build.commit.authorName}}</a></dd>
|
||||
{{/if}}
|
||||
{{#if commit.committerName}}
|
||||
<dt>{{t builds.committer}}</dt>
|
||||
<dd class="committer"><a href="{{unbound urlCommitter}}">{{build.commit.committerName}}</a></dd>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<dt>{{t builds.message}}</dt>
|
||||
<dd class="message">{{{formatMessage build.commit.message}}}</dd>
|
||||
|
||||
{{#unless isMatrix}}
|
||||
<dt>{{t builds.config}}</dt>
|
||||
<dd class="config">{{formatConfig build.config}}</dd>
|
||||
{{/unless}}
|
||||
</dl>
|
||||
|
||||
{{#if build.isMatrix}}
|
||||
{{view Travis.JobsView jobsBinding="build.requiredJobs" required="true"}}
|
||||
{{view Travis.JobsView jobsBinding="build.allowedFailureJobs"}}
|
||||
{{else}}
|
||||
{{view Travis.LogView contextBinding="build.jobs.firstObject"}}
|
||||
{{/if}}
|
||||
{{view Travis.LogView contextBinding="build.jobs.firstObject"}}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{{view Travis.ReposListTabsView}}
|
||||
|
||||
<div class="tab">
|
||||
{{#collection Travis.ReposListView contentBinding="controller"}}
|
||||
{{#collection Travis.ReposListView contentBinding="this"}}
|
||||
{{#with view.repo}}
|
||||
<div class="slug-and-status">
|
||||
<span class="status"></span>
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
{{#if view.isEmpty}}
|
||||
{{view Travis.ReposEmptyView}}
|
||||
{{else}}
|
||||
{{#if view.repo.isLoaded}}
|
||||
{{#with view.repo}}
|
||||
{{#if repo.isLoaded}}
|
||||
{{#with repo}}
|
||||
<h3>
|
||||
<a {{bindAttr href="view.urlGithub"}}>{{slug}}</a>
|
||||
<a {{bindAttr href="urlGithub"}}>{{slug}}</a>
|
||||
</h3>
|
||||
|
||||
<p class="description">{{description}}</p>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@Travis.reopen
|
||||
Travis.reopen
|
||||
ApplicationView: Travis.View.extend
|
||||
templateName: 'layouts/home'
|
||||
classNames: ['application']
|
||||
|
|
|
@ -53,15 +53,7 @@
|
|||
elementId: 'build'
|
||||
classNameBindings: ['color', 'loading']
|
||||
|
||||
repoBinding: 'controller.repo'
|
||||
buildBinding: 'controller.build'
|
||||
commitBinding: 'build.commit'
|
||||
|
||||
currentItemBinding: 'build'
|
||||
|
||||
loading: (->
|
||||
!@get('build.isLoaded')
|
||||
).property('build.isLoaded')
|
||||
loadingBinding: 'controller.loading'
|
||||
|
||||
color: (->
|
||||
Travis.Helpers.colorForState(@get('build.state'))
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
ReposListTabsView: Travis.View.extend
|
||||
templateName: 'repos/list/tabs'
|
||||
tabBinding: 'controller.tab'
|
||||
needs: ['currentUser']
|
||||
currentUserBinding: 'controllers.currentUser'
|
||||
|
||||
activate: (event) ->
|
||||
@get('controller').activate(event.target.name)
|
||||
|
@ -33,9 +35,9 @@
|
|||
classOwned: (->
|
||||
classes = []
|
||||
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(' ')
|
||||
).property('tab', 'Travis.app.currentUser')
|
||||
).property('tab', 'currentUser')
|
||||
|
||||
classSearch: (->
|
||||
'active' if @get('tab') == 'search'
|
||||
|
|
|
@ -2,21 +2,15 @@
|
|||
RepoView: Travis.View.extend
|
||||
templateName: 'repos/show'
|
||||
|
||||
reposBinding: 'controller.repos'
|
||||
repoBinding: 'controller.repo'
|
||||
classNameBindings: ['loading:isLoaded']
|
||||
|
||||
class: (->
|
||||
'loading' unless @get('repo.isLoaded')
|
||||
).property('repo.isLoaded')
|
||||
isLoadedBinding: 'controller.repo.isLoaded'
|
||||
reposBinding: 'controllers.repos'
|
||||
|
||||
isEmpty: (->
|
||||
@get('repos.isLoaded') && @get('repos.length') == 0
|
||||
).property('repos.isLoaded', 'repos.length')
|
||||
|
||||
urlGithub: (->
|
||||
Travis.Urls.githubRepo(@get('repo.slug'))
|
||||
).property('repo.slug'),
|
||||
|
||||
RepoShowStatsView: Travis.View.extend
|
||||
templateName: 'repos/show/stats'
|
||||
repoBinding: 'parentView.repo'
|
||||
|
@ -208,6 +202,6 @@
|
|||
).property('tab')
|
||||
|
||||
hasPermission: (->
|
||||
if permissions = Travis.app.get('currentUser.permissions')
|
||||
if permissions = Travis.get('currentUser.permissions')
|
||||
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: ->
|
||||
controller = @get 'controller'
|
||||
unless controller.get('content')
|
||||
Travis.app.get('router.sidebarController').tickables.push(controller)
|
||||
controller.set 'content', Travis.Sponsor.decks()
|
||||
# TODO: move this stuff to controller
|
||||
#unless controller.get('content')
|
||||
#Travis.app.get('router.sidebarController').tickables.push(controller)
|
||||
#controller.set 'content', Travis.Sponsor.decks()
|
||||
@_super.apply this, arguments
|
||||
|
||||
LinksView: Em.View.extend
|
||||
|
@ -21,9 +22,9 @@
|
|||
|
||||
didInsertElement: ->
|
||||
controller = @get 'controller'
|
||||
unless controller.get('content')
|
||||
controller.set 'content', Travis.Sponsor.links()
|
||||
Travis.app.get('router.sidebarController').tickables.push(controller)
|
||||
#unless controller.get('content')
|
||||
# controller.set 'content', Travis.Sponsor.links()
|
||||
# Travis.app.get('router.sidebarController').tickables.push(controller)
|
||||
@_super.apply this, arguments
|
||||
|
||||
WorkersView: Em.View.extend
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
classProfile: (->
|
||||
classes = ['profile menu']
|
||||
classes.push('active') if @get('tab') == 'profile'
|
||||
classes.push(Travis.app.get('authState'))
|
||||
classes.push(Travis.get('authState'))
|
||||
classes.join(' ')
|
||||
).property('tab', 'Travis.app.authState')
|
||||
).property('tab', 'Travis.authState')
|
||||
|
||||
showProfile: ->
|
||||
$('#top .profile ul').show()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
jQuery.support.cors = true
|
||||
|
||||
@Travis.ajax = Em.Object.create
|
||||
Travis.ajax = Em.Object.create
|
||||
DEFAULT_OPTIONS:
|
||||
accepts:
|
||||
json: 'application/vnd.travis-ci.2+json'
|
||||
|
|
|
@ -54,7 +54,7 @@ Travis.LimitedArray = Em.ArrayProxy.extend
|
|||
if addedCount
|
||||
if index < limit
|
||||
addedObjects = array.slice(index, index + addedCount)
|
||||
@replaceContent(index, 0, addedObjects)
|
||||
@get('arrangedContent').replace(index, 0, addedObjects)
|
||||
|
||||
@balanceArray()
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
@Travis.Model = DS.Model.extend
|
||||
primaryKey: 'id'
|
||||
id: DS.attr('number')
|
||||
|
||||
init: ->
|
||||
@loadedAttributes = []
|
||||
@_super.apply this, arguments
|
||||
|
@ -58,15 +55,15 @@
|
|||
@Travis.Model.reopenClass
|
||||
find: ->
|
||||
if arguments.length == 0
|
||||
Travis.app.store.findAll(this)
|
||||
Travis.store.findAll(this)
|
||||
else
|
||||
@_super.apply(this, arguments)
|
||||
|
||||
filter: (callback) ->
|
||||
Travis.app.store.filter(this, callback)
|
||||
Travis.store.filter(this, callback)
|
||||
|
||||
load: (attrs) ->
|
||||
Travis.app.store.load(this, attrs)
|
||||
Travis.store.load(this, attrs)
|
||||
|
||||
select: (id) ->
|
||||
@find().forEach (record) ->
|
||||
|
@ -86,7 +83,7 @@
|
|||
name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1)
|
||||
|
||||
pluralName: ->
|
||||
Travis.app.store.adapter.pluralize(@singularName())
|
||||
Travis.store.adapter.pluralize(@singularName())
|
||||
|
||||
isAttribute: (name) ->
|
||||
Ember.get(this, 'attributes').has(name) ||
|
||||
|
|
|
@ -1,18 +1,6 @@
|
|||
require 'ext/jquery'
|
||||
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?
|
||||
Storage = Em.Object.extend
|
||||
init: ->
|
||||
|
@ -28,8 +16,62 @@ Storage = Em.Object.extend
|
|||
clear: ->
|
||||
@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:
|
||||
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
|
||||
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']
|
||||
|
||||
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: [
|
||||
{ name: 'common', display: 'Common' }
|
||||
{ name: 'linux', display: 'Linux' }
|
||||
|
@ -60,11 +87,6 @@ Storage = Em.Object.extend
|
|||
|
||||
INTERVALS: { sponsors: -1, times: -1, updateTimes: 1000 }
|
||||
|
||||
setLocale: (locale) ->
|
||||
return unless locale
|
||||
I18n.locale = locale
|
||||
Travis.set('locale', locale)
|
||||
|
||||
storage: (->
|
||||
storage = null
|
||||
try
|
||||
|
@ -74,7 +96,7 @@ Storage = Em.Object.extend
|
|||
|
||||
storage
|
||||
)()
|
||||
default_locale: 'en'
|
||||
|
||||
sessionStorage: (->
|
||||
storage = null
|
||||
try
|
||||
|
@ -88,26 +110,25 @@ Storage = Em.Object.extend
|
|||
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
|
||||
|
||||
require 'ext/i18n'
|
||||
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>
|
||||
minispade.require('travis')
|
||||
Travis.run()
|
||||
</script>
|
||||
</head>
|
||||
<body id="home"></body>
|
||||
|
|
Loading…
Reference in New Issue
Block a user