Display running repos info on landing page
This commit is contained in:
parent
cf1e77c5e5
commit
5e21afd1f4
5
app/controllers/home.coffee
Normal file
5
app/controllers/home.coffee
Normal file
|
@ -0,0 +1,5 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
Controller = Ember.Controller.extend()
|
||||
|
||||
`export default Controller`
|
7
app/helpers/landing-page-last-build-time.coffee
Normal file
7
app/helpers/landing-page-last-build-time.coffee
Normal file
|
@ -0,0 +1,7 @@
|
|||
`import { timeAgoInWords, safe } from 'travis/utils/helpers'`
|
||||
`import Ember from "ember"`
|
||||
|
||||
helper = Ember.Handlebars.makeBoundHelper (value, options) ->
|
||||
safe timeAgoInWords(value) || 'currently running'
|
||||
|
||||
`export default helper`
|
30
app/routes/home.coffee
Normal file
30
app/routes/home.coffee
Normal file
|
@ -0,0 +1,30 @@
|
|||
`import BasicRoute from 'travis/routes/basic'`
|
||||
`import config from 'travis/config/environment'`
|
||||
`import Repo from 'travis/models/repo'`
|
||||
`import limit from 'travis/utils/computed-limit'`
|
||||
|
||||
Route = BasicRoute.extend
|
||||
activate: ->
|
||||
if !config.pro && @pusher
|
||||
@pusher.subscribeAll(['common'])
|
||||
|
||||
@_super.apply(this, arguments)
|
||||
@store.set('isLandingPageOpened', true)
|
||||
|
||||
deactivate: ->
|
||||
@_super.apply(this, arguments)
|
||||
@store.set('isLandingPageOpened', false)
|
||||
|
||||
setupController: (controller, model) ->
|
||||
repos = Ember.ArrayProxy.extend(
|
||||
isLoadedBinding: 'repos.isLoaded'
|
||||
repos: Repo.withLastBuild(@store)
|
||||
sorted: Ember.computed.sort('repos', 'sortedReposKeys')
|
||||
content: limit('sorted', 'limit')
|
||||
sortedReposKeys: ['sortOrder:asc']
|
||||
limit: 3
|
||||
).create()
|
||||
|
||||
controller.set('repos', repos)
|
||||
|
||||
`export default Route`
|
|
@ -5,8 +5,19 @@ Store = DS.Store.extend
|
|||
defaultAdapter: 'application'
|
||||
adapter: 'application'
|
||||
|
||||
receivePusherEvent: (event, data) ->
|
||||
[name, type] = event.split(':')
|
||||
init: ->
|
||||
@_super.apply(this, arguments)
|
||||
|
||||
# we will let one start event every 5 seconds to populate some repos for
|
||||
# landing page
|
||||
setInterval =>
|
||||
@set('allowMoreLandingPageRepos', true)
|
||||
, 5000
|
||||
|
||||
canHandleEvent: (event, data) ->
|
||||
if @get('isLandingPageOpened') && @get('allowMoreLandingPageRepos') && event == 'build:started'
|
||||
@set('allowMoreLandingPageRepos', false)
|
||||
return true
|
||||
|
||||
auth = @container.lookup('auth:main')
|
||||
if !@get('isRecentTabOpen') && event != 'job:log' && auth.get('signedIn') &&
|
||||
|
@ -24,6 +35,11 @@ Store = DS.Store.extend
|
|||
|
||||
return if !@hasRecordForId('repo', id) && !permissions.contains(id)
|
||||
|
||||
receivePusherEvent: (event, data) ->
|
||||
[name, type] = event.split(':')
|
||||
|
||||
return unless @canHandleEvent(event, data)
|
||||
|
||||
if name == 'job' && data.job?.commit
|
||||
@pushPayload(commits: [data.job.commit])
|
||||
|
||||
|
|
|
@ -62,9 +62,16 @@
|
|||
<p>Here are just a few projects<br>currently running on Travis CI</p>
|
||||
</div>
|
||||
<div class="medium-6 columns">
|
||||
<img src="../images/landing-page/temp-repo-green.svg">
|
||||
<img src="../images/landing-page/temp-repo-red.svg">
|
||||
<img src="../images/landing-page/temp-repo-yellow.svg">
|
||||
<ul class="repos">
|
||||
{{#each repo in repos}}
|
||||
<li {{bind-attr class=":repo repo.lastBuildState"}}>
|
||||
{{repo.owner}}<br/>
|
||||
{{repo.name}}<br/>
|
||||
#{{repo.lastBuildNumber}}<br/>
|
||||
{{landing-page-last-build-time repo.lastBuildFinishedAt}}<br/>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user