add more owner functionality

This commit is contained in:
Lisa Passing 2015-04-20 15:37:34 +02:00
parent b735f08153
commit 6dc3dd357e
7 changed files with 52 additions and 8 deletions

View File

@ -0,0 +1,22 @@
`import Ember from 'ember'`
`import Ajax from 'travis/utils/ajax'`
Controller = Ember.Controller.extend
isLoading: false
githubProfile: (->
"https://github.com/#{@get('model.login')}"
).property()
avatarURL: (->
if @get('model.avatar_url')
"#{@get('model.avatar_url')}?s=128"
else
'https://secure.gravatar.com/avatar/?d=mm&s=128'
).property()
owner: (->
@get('model')
).property('model')
`export default Controller`

View File

@ -71,7 +71,7 @@ Router.map ->
@resource 'account', path: '/:login'
@route 'info', path: '/info'
@route 'ownerpage', path: 'ownerpage'
@resource 'owner', path: 'owner/:owner'
@route 'error404', path: '/*path'

20
app/routes/owner.coffee Normal file
View File

@ -0,0 +1,20 @@
`import Ember from 'ember'`
`import TravisRoute from 'travis/routes/basic'`
`import Ajax from 'travis/utils/ajax'`
Route = TravisRoute.extend
needsAuth: true
# controllerName: 'owner'
model: (params) ->
owner = {}
$.get("https://api-staging.travis-ci.org/v3/owner/#{params.owner}").then( (data) ->
console.log('******************')
owner = data
console.log(owner)
owner
)
`export default Route`

View File

@ -1,5 +1,5 @@
<div class="sync-button">
{{#if user.isSyncing }}
{{#if owner.is_syncing }}
<p>
<button class="button" disabled="disabled">
<span class="sync-spinner"><i></i><i></i><i></i></span>Syncing
@ -10,6 +10,6 @@
<button {{action sync}} class="button">
<span class="icon icon-sync"></span>Sync account</button>
</p>
<p class="sync-last">last synced {{format-time user.syncedAt}}</p>
<p class="sync-last">last synced {{format-time owner.synced_at}}</p>
{{/if}}
</div>

View File

@ -4,12 +4,14 @@
<section class="columns small-10 medium-5 large-4">
<div class="media">
<div class="media-elem">
<img src="//placehold.it/120x120" alt="">
<img {{bind-attr src="avatarURL"}} alt="">
</div>
<div class="media-body">
<h1 class="owner-title">Travis CI GmbH</h1>
<p class="owner-handle"><a href="//gtihub" title=""><span class="icon icon--github-circle"></span> travis-pro</a></p>
{{ownerpage-sync-button}}
<h1 class="owner-title">{{owner.name}}</h1>
{{!-- TODO: only sync btn if user part of org --}}
<p class="owner-handle"><a {{bind-attr href="githubProfile"}} title=""><span class="icon icon--github-circle"></span> {{owner.login}}</a></p>
{{owner-sync-button owner=owner}}
</div>
</div>
</section>

View File

@ -2,6 +2,6 @@
View = Ember.View.extend
layoutName: 'layouts/profile'
classNames: ['ownerpage']
classNames: ['owner']
`export default View`