Skip to content

Commit

Permalink
Merge pull request #803 from HubSpot/fix_waiting_on_log
Browse files Browse the repository at this point in the history
Watch reset and check active tasks manually
  • Loading branch information
Tom Petr committed Dec 21, 2015
2 parents 4c8aa00 + 55c281b commit 5e9aab5
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions SingularityUI/app/views/AutoTailer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AUTO_TAIL_TIMEOUT = 5 * 60 * 1000
class AutoTailer extends Backbone.View

initialize: ({@requestId, @autoTailFilename, @autoTailTimestamp}) ->

@history = new RequestHistoricalTasks [], {@requestId}

@activeTasks = new RequestTasks [],
Expand All @@ -29,14 +29,14 @@ class AutoTailer extends Backbone.View


# Start polling for task changes, and check
# Task History changes in case we need
# to back out of the file redirect
# Task History changes in case we need
# to back out of the file redirect
startAutoTailPolling: ->
@showAutoTailWaitingDialog()
@stopAutoTailPolling()

@listenTo @history, 'reset', @handleHistoryReset
@listenToOnce @activeTasks, 'add', @handleActiveTasksAdd
@listenTo @activeTasks, 'reset', @handleActiveTasksAdd

@autoTailPollInterval = interval 2000, =>
if @autoTailTaskFiles
Expand All @@ -61,14 +61,18 @@ class AutoTailer extends Backbone.View
matchingTask = tasks.find (task) -> task.get('taskId').startedAt > timestamp
if matchingTask
$('.auto-tail-checklist').addClass 'waiting-for-file'
@stopListening @activeTasks, 'add'
@stopListening @activeTasks, 'reset'
@autoTailTaskFiles = new TaskFiles [], taskId: matchingTask.get('id')

handleActiveTasksAdd: (task) =>
$('.auto-tail-checklist').addClass 'waiting-for-file'
@autoTailTaskId = task.get('id')
@autoTailTaskFiles = new TaskFiles [], taskId: @autoTailTaskId
@listenTo @autoTailTaskFiles, 'add', @handleTaskFilesAdd
handleActiveTasksAdd: (tasks) =>
timestamp = @autoTailTimestamp
matchingTask = tasks.find (task) -> task.get('taskId').startedAt > timestamp
if matchingTask
$('.auto-tail-checklist').addClass 'waiting-for-file'
@autoTailTaskId = matchingTask.get('id')
@autoTailTaskFiles = new TaskFiles [], taskId: @autoTailTaskId
@stopListening @activeTasks, 'reset'
@listenTo @autoTailTaskFiles, 'add', @handleTaskFilesAdd

handleTaskFilesAdd: =>
if @autoTailTaskFiles.findWhere({name: @autoTailFilename})
Expand All @@ -92,7 +96,7 @@ class AutoTailer extends Backbone.View
showAutoTailWaitingDialog: ->
vex.dialog.alert
overlayClosesOnClick: false
message: autoTailWaitingTemplate
message: autoTailWaitingTemplate
autoTailFilename: @autoTailFilename
buttons: [
$.extend _.clone(vex.dialog.buttons.NO), text: 'Close'
Expand Down

0 comments on commit 5e9aab5

Please sign in to comment.