download log files using buildPdfDownloadUrl

This commit is contained in:
Henry Oswald
2018-08-16 14:25:08 +01:00
parent 5ed95694da
commit c33192b852
@@ -224,6 +224,12 @@ define [
_csrf: window.csrfToken _csrf: window.csrfToken
}, {params: params} }, {params: params}
buildPdfDownloadUrl = (pdfDownloadDomain, path)->
if pdfDownloadDomain?
return "#{pdfDownloadDomain}#{path}"
else
return path
parseCompileResponse = (response) -> parseCompileResponse = (response) ->
# keep last url # keep last url
@@ -244,11 +250,7 @@ define [
$scope.pdf.compileInProgress = false $scope.pdf.compileInProgress = false
$scope.pdf.autoCompileDisabled = false $scope.pdf.autoCompileDisabled = false
buildPdfDownloadUrl = (path)->
if pdfDownloadDomain?
return "#{pdfDownloadDomain}#{path}"
else
return path
# make a cache to look up files by name # make a cache to look up files by name
fileByPath = {} fileByPath = {}
if response?.outputFiles? if response?.outputFiles?
@@ -267,24 +269,24 @@ define [
if response.status == "timedout" if response.status == "timedout"
$scope.pdf.view = 'errors' $scope.pdf.view = 'errors'
$scope.pdf.timedout = true $scope.pdf.timedout = true
fetchLogs(fileByPath) fetchLogs(fileByPath, {pdfDownloadDomain:pdfDownloadDomain})
else if response.status == "terminated" else if response.status == "terminated"
$scope.pdf.view = 'errors' $scope.pdf.view = 'errors'
$scope.pdf.compileTerminated = true $scope.pdf.compileTerminated = true
fetchLogs(fileByPath) fetchLogs(fileByPath, {pdfDownloadDomain:pdfDownloadDomain})
else if response.status in ["validation-fail", "validation-pass"] else if response.status in ["validation-fail", "validation-pass"]
$scope.pdf.view = 'pdf' $scope.pdf.view = 'pdf'
$scope.pdf.url = buildPdfDownloadUrl last_pdf_url $scope.pdf.url = buildPdfDownloadUrl pdfDownloadDomain, last_pdf_url
$scope.shouldShowLogs = true $scope.shouldShowLogs = true
$scope.pdf.failedCheck = true if response.status is "validation-fail" $scope.pdf.failedCheck = true if response.status is "validation-fail"
event_tracking.sendMB "syntax-check-#{response.status}" event_tracking.sendMB "syntax-check-#{response.status}"
fetchLogs(fileByPath, { validation: true }) fetchLogs(fileByPath, { validation: true, pdfDownloadDomain:pdfDownloadDomain})
else if response.status == "exited" else if response.status == "exited"
$scope.pdf.view = 'pdf' $scope.pdf.view = 'pdf'
$scope.pdf.compileExited = true $scope.pdf.compileExited = true
$scope.pdf.url = buildPdfDownloadUrl last_pdf_url $scope.pdf.url = buildPdfDownloadUrl pdfDownloadDomain, last_pdf_url
$scope.shouldShowLogs = true $scope.shouldShowLogs = true
fetchLogs(fileByPath) fetchLogs(fileByPath, {pdfDownloadDomain:pdfDownloadDomain})
else if response.status == "autocompile-backoff" else if response.status == "autocompile-backoff"
if $scope.pdf.isAutoCompileOnLoad # initial autocompile if $scope.pdf.isAutoCompileOnLoad # initial autocompile
$scope.pdf.view = 'uncompiled' $scope.pdf.view = 'uncompiled'
@@ -300,7 +302,7 @@ define [
$scope.pdf.view = 'errors' $scope.pdf.view = 'errors'
$scope.pdf.failure = true $scope.pdf.failure = true
$scope.shouldShowLogs = true $scope.shouldShowLogs = true
fetchLogs(fileByPath) fetchLogs(fileByPath, {pdfDownloadDomain:pdfDownloadDomain})
else if response.status == 'clsi-maintenance' else if response.status == 'clsi-maintenance'
$scope.pdf.view = 'errors' $scope.pdf.view = 'errors'
$scope.pdf.clsiMaintenance = true $scope.pdf.clsiMaintenance = true
@@ -320,12 +322,12 @@ define [
# define the base url. if the pdf file has a build number, pass it to the clsi in the url # define the base url. if the pdf file has a build number, pass it to the clsi in the url
if fileByPath['output.pdf']?.url? if fileByPath['output.pdf']?.url?
$scope.pdf.url = buildPdfDownloadUrl fileByPath['output.pdf'].url $scope.pdf.url = buildPdfDownloadUrl pdfDownloadDomain, fileByPath['output.pdf'].url
else if fileByPath['output.pdf']?.build? else if fileByPath['output.pdf']?.build?
build = fileByPath['output.pdf'].build build = fileByPath['output.pdf'].build
$scope.pdf.url = buildPdfDownloadUrl "/project/#{$scope.project_id}/build/#{build}/output/output.pdf" $scope.pdf.url = buildPdfDownloadUrl pdfDownloadDomain, "/project/#{$scope.project_id}/build/#{build}/output/output.pdf"
else else
$scope.pdf.url = buildPdfDownloadUrl "/project/#{$scope.project_id}/output/output.pdf" $scope.pdf.url = buildPdfDownloadUrl pdfDownloadDomain, "/project/#{$scope.project_id}/output/output.pdf"
# check if we need to bust cache (build id is unique so don't need it in that case) # check if we need to bust cache (build id is unique so don't need it in that case)
if not fileByPath['output.pdf']?.build? if not fileByPath['output.pdf']?.build?
qs.cache_bust = "#{Date.now()}" qs.cache_bust = "#{Date.now()}"
@@ -335,7 +337,7 @@ define [
qs.popupDownload = true qs.popupDownload = true
$scope.pdf.downloadUrl = "/project/#{$scope.project_id}/output/output.pdf" + createQueryString(qs) $scope.pdf.downloadUrl = "/project/#{$scope.project_id}/output/output.pdf" + createQueryString(qs)
fetchLogs(fileByPath) fetchLogs(fileByPath, {pdfDownloadDomain:pdfDownloadDomain})
IGNORE_FILES = ["output.fls", "output.fdb_latexmk"] IGNORE_FILES = ["output.fls", "output.fdb_latexmk"]
$scope.pdf.outputFiles = [] $scope.pdf.outputFiles = []
@@ -376,11 +378,11 @@ define [
compileGroup:ide.compileGroup compileGroup:ide.compileGroup
clsiserverid:ide.clsiServerId clsiserverid:ide.clsiServerId
if file?.url? # FIXME clean this up when we have file.urls out consistently if file?.url? # FIXME clean this up when we have file.urls out consistently
opts.url = file.url opts.url = buildPdfDownloadUrl options.pdfDownloadDomain, file.url
else if file?.build? else if file?.build?
opts.url = "/project/#{$scope.project_id}/build/#{file.build}/output/#{name}" opts.url = buildPdfDownloadUrl options.pdfDownloadDomain, "/project/#{$scope.project_id}/build/#{file.build}/output/#{name}"
else else
opts.url = "/project/#{$scope.project_id}/output/#{name}" opts.url = buildPdfDownloadUrl options.pdfDownloadDomain, "/project/#{$scope.project_id}/output/#{name}"
# check if we need to bust cache (build id is unique so don't need it in that case) # check if we need to bust cache (build id is unique so don't need it in that case)
if not file?.build? if not file?.build?
opts.params.cache_bust = "#{Date.now()}" opts.params.cache_bust = "#{Date.now()}"