add org filter to dashboard, prepare sync button
This commit is contained in:
parent
35851ef34b
commit
faca83ba5f
10
app/components/orgs-filter.coffee
Normal file
10
app/components/orgs-filter.coffee
Normal file
|
@ -0,0 +1,10 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
Component = Ember.Component.extend
|
||||
|
||||
actions: {
|
||||
select: (org) ->
|
||||
@sendAction('action', org)
|
||||
}
|
||||
|
||||
`export default Component`
|
10
app/components/sync-button.coffee
Normal file
10
app/components/sync-button.coffee
Normal file
|
@ -0,0 +1,10 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
Component = Ember.Component.extend
|
||||
actions: {
|
||||
sync: ->
|
||||
console.log(@get('user'));
|
||||
}
|
||||
|
||||
|
||||
`export default Component`
|
|
@ -1,12 +1,19 @@
|
|||
`import Ember from 'ember'`
|
||||
`import config from 'travis/config/environment'`
|
||||
|
||||
Controller = Ember.Controller.extend
|
||||
#queryParams: ['filter']
|
||||
queryParams: ['org']
|
||||
filter: null
|
||||
org: null
|
||||
|
||||
filteredRepositories: (->
|
||||
filter = @get('filter')
|
||||
repos = @get('model')
|
||||
org = @get('org')
|
||||
|
||||
if org
|
||||
repos = repos.filter (item, index) ->
|
||||
item.get('owner.login') == org
|
||||
|
||||
if Ember.isBlank(filter)
|
||||
repos
|
||||
|
@ -14,16 +21,45 @@ Controller = Ember.Controller.extend
|
|||
repos.filter (item, index) ->
|
||||
item.slug.match(new RegExp(filter))
|
||||
|
||||
).property('filter', 'model')
|
||||
).property('filter', 'model', 'org')
|
||||
|
||||
updateFilter: () ->
|
||||
value = @get('_lastFilterValue')
|
||||
@transitionToRoute queryParams: { filter: value }
|
||||
@set('filter', value)
|
||||
|
||||
selectedOrg: (->
|
||||
@get('orgs').findBy('login', @get('org'))
|
||||
).property('org', 'orgs.[]')
|
||||
|
||||
orgs: (->
|
||||
orgs = Ember.ArrayProxy.create(
|
||||
content: []
|
||||
isLoading: true
|
||||
)
|
||||
|
||||
apiEndpoint = config.apiEndpoint
|
||||
$.ajax(apiEndpoint + '/v3/orgs', {
|
||||
headers: {
|
||||
Authorization: 'token ' + @auth.token()
|
||||
}
|
||||
}).then (response) ->
|
||||
array = response.organizations.map( (org) ->
|
||||
Ember.Object.create(org)
|
||||
)
|
||||
orgs.set('content', array)
|
||||
orgs.set('isLoading', false)
|
||||
|
||||
orgs
|
||||
).property()
|
||||
|
||||
actions:
|
||||
updateFilter: (value) ->
|
||||
@set('_lastFilterValue', value)
|
||||
Ember.run.throttle this, @updateFilter, [], 200, false
|
||||
|
||||
selectOrg: (org) ->
|
||||
login = if org then org.get('login') else null
|
||||
@set('org', login)
|
||||
|
||||
`export default Controller`
|
||||
|
|
28
app/templates/components/orgs-filter.hbs
Normal file
28
app/templates/components/orgs-filter.hbs
Normal file
|
@ -0,0 +1,28 @@
|
|||
<div class="filter filter--org">
|
||||
<div class="filter-current">
|
||||
{{#if orgs.isLoading}}
|
||||
<span class="loading"></span>
|
||||
{{else}}
|
||||
<a href="" title="">
|
||||
{{#if selected }}<img src="https://placehold.it/30x30" alt="">{{selected.name}} {{else}} All organizations {{/if}}
|
||||
</a><span class="icon-arrow-down"></span>
|
||||
{{/if}}
|
||||
</div>
|
||||
<ul class="filter-dropdown">
|
||||
{{#if selected }}
|
||||
<li><a href="#" title="" {{action 'select'}}>All organizations</a></li>
|
||||
{{/if}}
|
||||
{{#each org in orgs}}
|
||||
<li>
|
||||
<a href="#" title="" {{action 'select' org}}><img src="https://placehold.it/30x30" alt="">
|
||||
{{#if org.name }}
|
||||
{{org.name}}
|
||||
{{else}}
|
||||
{{org.login}}
|
||||
{{/if}}
|
||||
</a>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
2
app/templates/components/sync-button.hbs
Normal file
2
app/templates/components/sync-button.hbs
Normal file
|
@ -0,0 +1,2 @@
|
|||
<button {{action sync}}>HERE</button>
|
||||
{{user.syncedAt}}
|
|
@ -1,20 +1,13 @@
|
|||
<div id="filters" class="section section--white section--maxheight">
|
||||
<div class="row">
|
||||
<div class="filter filter--org">
|
||||
<div class="filter-current">
|
||||
<img src="https://placehold.it/30x30" alt="">something else</a><span class="icon-arrow-down"></span>
|
||||
</div>
|
||||
<ul class="filter-dropdown">
|
||||
<li><a href="#" title="">All organizations</a></li>
|
||||
<li class="is-selected"><a href="#" title=""><img src="https://placehold.it/30x30" alt="">something else</a></li>
|
||||
<li><a href="#" title=""><img src="https://placehold.it/30x30" alt="">something</a></li>
|
||||
<li><a href="#" title=""><img src="https://placehold.it/30x30" alt="">eurucamp</a></li>
|
||||
</ul>
|
||||
{{orgs-filter orgs=orgs selected=selectedOrg action="selectOrg"}}
|
||||
<div class="">
|
||||
{{sync-button user=auth.currentUser}}
|
||||
</div>
|
||||
<div class="search">
|
||||
{{!-- <div class="search">
|
||||
{{filter-input placeholder="Search all repositories" class="search-field"
|
||||
action="updateFilter" on="key-up"}}
|
||||
</div>
|
||||
</div> --}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
Location = Ember.HistoryLocation.extend
|
||||
getURL: ->
|
||||
location = @get('location')
|
||||
location.pathname + location.hash
|
||||
location.pathname + location.search + location.hash
|
||||
|
||||
`export default Location`
|
||||
|
|
Loading…
Reference in New Issue
Block a user