Merge branch 'build-auto-refresh' into 'master'

Fixed issue with build auto-refresh not working

## What does this MR do?

Due to the `.json` at the end of the build URL fetch, the page wont correctly auto-reload the build log. This fixes that.

See merge request !5110
This commit is contained in:
Jacob Schatz 2016-07-06 21:04:27 +00:00
commit c66a7b0e94
2 changed files with 5 additions and 5 deletions

View file

@ -2,7 +2,7 @@ class @CiBuild
@interval: null
@state: null
constructor: (@build_url, @build_status, @state) ->
constructor: (@page_url, @build_url, @build_status, @state) ->
clearInterval(CiBuild.interval)
# Init breakpoint checker
@ -41,7 +41,7 @@ class @CiBuild
# Only valid for runnig build when output changes during time
#
CiBuild.interval = setInterval =>
if window.location.href.split("#").first() is @build_url
if window.location.href.split("#").first() is @page_url
@getBuildTrace()
, 4000
@ -57,7 +57,7 @@ class @CiBuild
getBuildTrace: ->
$.ajax
url: "#{@build_url}/trace.json?state=#{encodeURIComponent(@state)}"
url: "#{@page_url}/trace.json?state=#{encodeURIComponent(@state)}"
dataType: "json"
success: (log) =>
if log.state
@ -70,7 +70,7 @@ class @CiBuild
$('.js-build-output').html log.html
@checkAutoscroll()
else if log.status isnt @build_status
Turbolinks.visit @build_url
Turbolinks.visit @page_url
checkAutoscroll: ->
$("html,body").scrollTop $("#build-trace").height() if "enabled" is $("#autoscroll-button").data("state")

View file

@ -67,4 +67,4 @@
= render "sidebar"
:javascript
new CiBuild("#{namespace_project_build_url(@project.namespace, @project, @build, :json)}", "#{@build.status}", "#{trace_with_state[:state]}")
new CiBuild("#{namespace_project_build_url(@project.namespace, @project, @build)}", "#{namespace_project_build_url(@project.namespace, @project, @build, :json)}", "#{@build.status}", "#{trace_with_state[:state]}")