Use V3 API for dashboard

This commit is contained in:
Piotr Sarnacki 2015-01-27 16:42:42 +01:00
parent 93bb5f68e7
commit 84dbdffc7a
3 changed files with 22 additions and 15 deletions

View File

@ -5,6 +5,9 @@ window.Auth = Ember.Object.extend
init: ->
window.addEventListener('message', (e) => @receiveMessage(e))
token: ->
Travis.sessionStorage.getItem('travis.token')
endpoint: (->
@container.lookup('application:main').config.api_endpoint
).property(),

View File

@ -7,15 +7,15 @@ Route = TravisRoute.extend
filter: { replace: true }
model: ->
apiEndpoint = @get('config').api_endpoint
login = @controllerFor('currentUser').get('login')
$.ajax(apiEndpoint + '/repos?member='+ login, {
beforeSend: (xhr) ->
xhr.setRequestHeader('accept', 'application/json; version=2')
$.ajax(apiEndpoint + '/v3/repos', {
headers: {
Authorization: 'token ' + @auth.token()
}
}).then (response) ->
response.repos.map (elem) ->
[owner, name] = elem.slug.split('/')
elem.owner = owner
elem.name = name
Ember.Object.create(elem)
response.repositories.filter( (repo) ->
repo.active
).sortBy('last_build.finished_at').map( (repo) ->
Ember.Object.create(repo)
)
Travis.DashboardRepositoriesRoute = Route

View File

@ -38,15 +38,19 @@
<div class="row">
{{#each repo in filteredRepositories}}
<div class="large-4 medium-6 columns">
<div {{bind-attr class=":tile repo.last_build_state"}}>
<div {{bind-attr class=":tile repo.last_build.state"}}>
<div class="build-bar">
</div>
<div class="build-information">
<p class="org">{{repo.owner}}</p>
<p class="repo">{{#link-to "repo" repo.owner repo.name }}{{repo.name}}{{/link-to}}</p>
<div class="duration">{{formatDuration repo.last_build_duration}}</div>
<div class="finished">{{formatTime repo.last_build_finished_at}}</div>
<p class="build-status">{{#link-to "build" repo.owner repo.name repo.last_build_id}}#{{repo.last_build_number}} {{repo.last_build_state}}{{/link-to}}</p>
<p class="org">{{repo.owner.login}}</p>
<p class="repo">{{#link-to "repo" repo.owner.login repo.name}}{{repo.name}}{{/link-to}}</p>
<div class="duration">{{formatDuration repo.last_build.duration}}</div>
<div class="finished">{{formatTime repo.last_build.finished_at}}</div>
<p class="build-status">
{{#link-to "build" repo.owner.login repo.name repo.last_build.id}}
#{{repo.last_build.number}} {{repo.last_build.state}}
{{/link-to}}
</p>
</div>
<div class="star-feature">
</div>