|
class Dashing.TFSBuildQueue extends Dashing.Widget |
|
|
|
ready: -> |
|
@addDivs() |
|
|
|
onData: (data) -> |
|
@addDivs() |
|
|
|
addDivs: -> |
|
builds = @get('queue') if @get('queue') |
|
@handleBgIcon(builds.length) if builds |
|
divPa = $(@node).find('.builds') |
|
divPa.find('.build').remove() |
|
divPa.find('.build-in-progress').remove() |
|
maxItems = 6 |
|
maxItems = $(@node).data('max-items-to-show') if $(@node).data('max-items-to-show') |
|
for i,build of builds |
|
divPa.append(@buildDiv(build)) if i < maxItems |
|
|
|
buildDiv: (build) -> |
|
return if !build |
|
clazz = 'build' |
|
clazz += '-in-progress' if build['BuildStatus'] == 'InProgress' |
|
text = '<div class="'+clazz+'">' |
|
text += '<div class="controller">'+build['BuildController'] if build['BuildController'] |
|
text += '<span class="agent">' +build['BuildAgent']+'</span>' if build['BuildAgent'] |
|
text += '</div>' if build['BuildController'] and !$(@node).data('one-row') |
|
text += '<div class="details">' if !$(@node).data('one-row') |
|
text += ' ' if $(@node).data('one-row') |
|
text += @buildDetails(build['Date'], build['ElapsedTime'], build['User'], build['Project'], build['BuildDefinition'], build['Priority'])+'</div>' |
|
text += '</div>' |
|
|
|
buildDetails: (date, duration, user, project, definition, priority) -> |
|
text = '' |
|
date = @formatDateTime(new Date(parseInt(date.substr(6)))) |
|
text = "<i class='icon-simple icon-flag'></i>"+date+(" ("+user+")" if user) if date |
|
text += "<br>" if $(@node).data('details-new-lines') |
|
text += "<i class='icon-simple"+("-left-padded" if !$(@node).data('details-new-lines'))+" icon-resize-horizontal'></i>"+duration.substring(0, duration.indexOf('.')) if duration |
|
text += "<br>" if $(@node).data('details-new-lines') |
|
text += "<span class='nowrap'><i class='icon-simple"+("-left-padded" if !$(@node).data('details-new-lines'))+" icon-info-sign'></i>" |
|
text += definition + ' ('+priority+')' if definition |
|
text += '</span>' |
|
text |
|
|
|
formatDateTime: (dateTime) -> |
|
format = $(@node).data('date-time-format') |
|
if format |
|
format.replace('%Y',dateTime.getFullYear()).replace('%m', @zeroLPad(dateTime.getMonth()+1)).replace('%d',@zeroLPad(dateTime.getDate())).replace('%H',@zeroLPad(dateTime.getHours())).replace('%M', @zeroLPad(dateTime.getMinutes())).replace('%S', @zeroLPad(dateTime.getSeconds())) |
|
else |
|
dateTime.toLocaleDateString()+" "+dateTime.toLocaleTimeString() |
|
|
|
|
|
zeroLPad: (i) -> |
|
if i < 10 then "0" + i else i |
|
|
|
|
|
handleBgIcon: (number) -> |
|
$(@node).find(".icon-background").remove() |
|
max = $(@node).data('safe-queue-length') |
|
max = 6 if !max |
|
text = '<span class="icon-background queue-length' |
|
text += ' red' if number > max |
|
text += '">' + number + '</span>' |
|
$(@node).prepend(text) |