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

View File

@ -23,6 +23,24 @@ Log.Scroll.prototype = $.extend new Log.Listener,
$('#main').scrollTop(0) $('#main').scrollTop(0)
$('html, body').scrollTop(element.offset()?.top - (window.innerHeight / 3)) # weird, html works in chrome, body in firefox $('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 View = BasicView.extend
templateName: 'jobs/pre' templateName: 'jobs/pre'
currentUserBinding: 'controller.auth.currentUser' currentUserBinding: 'controller.auth.currentUser'
@ -66,7 +84,10 @@ View = BasicView.extend
console.log 'log view: create engine' if Log.DEBUG console.log 'log view: create engine' if Log.DEBUG
@scroll = new Log.Scroll beforeScroll: => @scroll = new Log.Scroll beforeScroll: =>
@unfoldHighlight() @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')) @logFolder = new LogFolder(@$().find('#log'))
@lineSelector = new LinesSelector(@$().find('#log'), @scroll, @logFolder) @lineSelector = new LinesSelector(@$().find('#log'), @scroll, @logFolder)
@observeParts() @observeParts()
@ -85,13 +106,8 @@ View = BasicView.extend
console.log 'log view: parts did change' if Log.DEBUG console.log 'log view: parts did change' if Log.DEBUG
for part, i in parts.slice(start, start + added) for part, i in parts.slice(start, start + added)
# console.log "limit in log view: #{@get('limited')}" # console.log "limit in log view: #{@get('limited')}"
break if @get('limited') break if @engine?.limit?.limited
@engine.set(part.number, part.content) @engine.set(part.number, part.content)
@propertyDidChange('limited')
limited: (->
@engine?.limit?.limited
).property()
plainTextLogUrl: (-> plainTextLogUrl: (->
if id = @get('log.job.id') if id = @get('log.job.id')