summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ci/build.coffee
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-08-25 18:42:46 -0700
committerDouwe Maan <douwe@gitlab.com>2015-08-25 18:42:46 -0700
commit046b28312704f3131e72dcd2dbdacc5264d4aa62 (patch)
treea8c2b14a6e1db3b662fee2c79af70d9fcb643c2e /app/assets/javascripts/ci/build.coffee
parente449426a4e7d15cdd582d4f136add52cbfb5e04e (diff)
downloadgitlab-ce-046b28312704f3131e72dcd2dbdacc5264d4aa62.tar.gz
Groundwork for merging CI into CE
Diffstat (limited to 'app/assets/javascripts/ci/build.coffee')
-rw-r--r--app/assets/javascripts/ci/build.coffee41
1 files changed, 41 insertions, 0 deletions
diff --git a/app/assets/javascripts/ci/build.coffee b/app/assets/javascripts/ci/build.coffee
new file mode 100644
index 00000000000..be4a3aa757a
--- /dev/null
+++ b/app/assets/javascripts/ci/build.coffee
@@ -0,0 +1,41 @@
+class CiBuild
+ @interval: null
+
+ constructor: (build_url, build_status) ->
+ clearInterval(CiBuild.interval)
+
+ if build_status == "running" || build_status == "pending"
+ #
+ # Bind autoscroll button to follow build output
+ #
+ $("#autoscroll-button").bind "click", ->
+ state = $(this).data("state")
+ if "enabled" is state
+ $(this).data "state", "disabled"
+ $(this).text "enable autoscroll"
+ else
+ $(this).data "state", "enabled"
+ $(this).text "disable autoscroll"
+
+ #
+ # Check for new build output if user still watching build page
+ # Only valid for runnig build when output changes during time
+ #
+ CiBuild.interval = setInterval =>
+ if window.location.href is build_url
+ $.ajax
+ url: build_url
+ dataType: "json"
+ success: (build) =>
+ if build.status == "running"
+ $('#build-trace code').html build.trace_html
+ $('#build-trace code').append '<i class="fa-refresh fa-spin"/>'
+ @checkAutoscroll()
+ else
+ Turbolinks.visit build_url
+ , 4000
+
+ checkAutoscroll: ->
+ $("html,body").scrollTop $("#build-trace").height() if "enabled" is $("#autoscroll-button").data("state")
+
+@CiBuild = CiBuild