Fix displaying a message for a limited log

This commit is contained in:
Piotr Sarnacki 2015-07-14 11:04:53 +02:00
parent 636f7cd987
commit a38309ff05
2 changed files with 29 additions and 14 deletions

View File

@ -44,13 +44,12 @@
{{#if view.showToTop}}
<a href='#' class="to-top" {{action "toTop" target=view}}>Top</a>
{{/if}}
{{#if view.limited}}
<p class="warning">
This log is too long to be displayed. Please reduce the verbosity of your
build or download the <a {{bind-attr href="view.plainTextLogUrl"}}>raw log</a>.
</p>
{{/if}}
</div>
</div>
{{#if view.limited}}
<p class="warning">
This log is too long to be displayed. Please reduce the verbosity of your
build or download the <a {{bind-attr href="view.plainTextLogUrl"}}>raw log</a>.
</p>
{{/if}}
</section>

View File

@ -23,6 +23,24 @@ Log.Scroll.prototype = $.extend new Log.Listener,
$('#main').scrollTop(0)
$('html, body').scrollTop(element.offset()?.top - (window.innerHeight / 3)) # weird, html works in chrome, body in firefox
Log.Limit = (max_lines, limitedLogCallback) ->
@max_lines = max_lines || 1000
@limitedLogCallback = limitedLogCallback || (->)
this
Log.Limit.prototype = Log.extend new Log.Listener,
count: 0,
insert: (log, node, pos) ->
if node.type == 'paragraph' && !node.hidden
@count += 1
if @limited
@limitedLogCallback()
return @count
Object.defineProperty Log.Limit.prototype, 'limited',
get: ->
@count >= @max_lines
View = BasicView.extend
templateName: 'jobs/pre'
currentUserBinding: 'controller.auth.currentUser'
@ -66,7 +84,10 @@ View = BasicView.extend
console.log 'log view: create engine' if Log.DEBUG
@scroll = new Log.Scroll beforeScroll: =>
@unfoldHighlight()
@engine = Log.create(limit: Log.LIMIT, listeners: [@scroll])
@limit = new Log.Limit Log.LIMIT, =>
@set('limited', true)
@engine = Log.create(listeners: [@scroll, @limit])
@engine.limit = @limit
@logFolder = new LogFolder(@$().find('#log'))
@lineSelector = new LinesSelector(@$().find('#log'), @scroll, @logFolder)
@observeParts()
@ -85,13 +106,8 @@ View = BasicView.extend
console.log 'log view: parts did change' if Log.DEBUG
for part, i in parts.slice(start, start + added)
# console.log "limit in log view: #{@get('limited')}"
break if @get('limited')
break if @engine?.limit?.limited
@engine.set(part.number, part.content)
@propertyDidChange('limited')
limited: (->
@engine?.limit?.limited
).property()
plainTextLogUrl: (->
if id = @get('log.job.id')