Show only first 15 elements from each queue for now
With shitloads of jobs in queues app becomes unusable, this is a quick solution to make it better.
This commit is contained in:
parent
834e45ceb5
commit
afa1d07fbe
|
@ -18,6 +18,12 @@
|
||||||
{{t no_job}}
|
{{t no_job}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
{{#if queue.isMore}}
|
||||||
|
<a {{action loadMoreJobs this.queue target="view"}} class="show-more-jobs">
|
||||||
|
{{queue.leftLength}} more jobs - show more
|
||||||
|
</a>
|
||||||
|
{{/if}}
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -38,10 +38,14 @@
|
||||||
templateName: 'queues/list'
|
templateName: 'queues/list'
|
||||||
controller: Em.ArrayController.create()
|
controller: Em.ArrayController.create()
|
||||||
|
|
||||||
|
loadMoreJobs: (event) ->
|
||||||
|
queue = event.context
|
||||||
|
queue.incrementProperty('limit', 20)
|
||||||
|
|
||||||
didInsertElement: ->
|
didInsertElement: ->
|
||||||
queues = for queue in Travis.QUEUES
|
queues = for queue in Travis.QUEUES
|
||||||
Em.ArrayController.create
|
Travis.LimitedArray.create
|
||||||
content: Travis.Job.queued(queue.name)
|
content: Travis.Job.queued(queue.name), limit: 15
|
||||||
id: "queue_#{queue.name}"
|
id: "queue_#{queue.name}"
|
||||||
name: queue.display
|
name: queue.display
|
||||||
@set 'controller.content', queues
|
@set 'controller.content', queues
|
||||||
|
|
|
@ -8,17 +8,42 @@ Travis.LimitedArray = Em.ArrayProxy.extend
|
||||||
arrangedContent: (->
|
arrangedContent: (->
|
||||||
if content = @get('content')
|
if content = @get('content')
|
||||||
content.slice(0, @get('limit'))
|
content.slice(0, @get('limit'))
|
||||||
).property('content')
|
).property('content', 'limit')
|
||||||
|
|
||||||
|
totalLength: (->
|
||||||
|
@get('content.length')
|
||||||
|
).property('content.length')
|
||||||
|
|
||||||
|
leftLength: (->
|
||||||
|
totalLength = @get('totalLength')
|
||||||
|
limit = @get('limit')
|
||||||
|
if totalLength > limit
|
||||||
|
totalLength - limit
|
||||||
|
else
|
||||||
|
0
|
||||||
|
).property('totalLength', 'limit')
|
||||||
|
|
||||||
|
isMore: (->
|
||||||
|
@get('leftLength') > 0
|
||||||
|
).property('leftLength')
|
||||||
|
|
||||||
contentArrayDidChange: (array, index, removedCount, addedCount) ->
|
contentArrayDidChange: (array, index, removedCount, addedCount) ->
|
||||||
@_super.apply this, arguments
|
@_super.apply this, arguments
|
||||||
if addedCount > 0
|
|
||||||
addedObjects = array.slice(index, index + addedCount)
|
limit = @get 'limit'
|
||||||
arrangedContent = @get('arrangedContent')
|
arrangedContent = @get('arrangedContent')
|
||||||
|
length = arrangedContent.get 'length'
|
||||||
|
|
||||||
|
if addedCount > 0 && length < limit
|
||||||
|
addedObjects = array.slice(index, index + addedCount)
|
||||||
for object in addedObjects
|
for object in addedObjects
|
||||||
arrangedContent.unshiftObject(object)
|
arrangedContent.unshiftObject(object)
|
||||||
|
|
||||||
limit = @get 'limit'
|
if removedCount
|
||||||
length = arrangedContent.get 'length'
|
removedObjects = array.slice(index, index + removedCount);
|
||||||
|
arrangedContent.removeObjects(removedObjects)
|
||||||
|
|
||||||
if length > limit
|
if length > limit
|
||||||
arrangedContent.replace(limit, length - limit)
|
arrangedContent.replace(limit, length - limit)
|
||||||
|
else if length < limit
|
||||||
|
@set('arrangedContent', @get('content').slice(0, @get('limit')))
|
||||||
|
|
|
@ -37,3 +37,6 @@
|
||||||
&:hover
|
&:hover
|
||||||
background-color: $color-border-slider-hover
|
background-color: $color-border-slider-hover
|
||||||
|
|
||||||
|
#right .show-more-jobs
|
||||||
|
text-decoration: underline
|
||||||
|
cursor: pointer
|
||||||
|
|
Loading…
Reference in New Issue
Block a user