Merge branch 'master' into clsi-dynamic-load

This commit is contained in:
Henry Oswald 2016-05-20 12:28:06 +01:00
commit 11724fce13
4 changed files with 28 additions and 14 deletions

View file

@ -28,7 +28,7 @@ div.binary-file.full-size(
div.scroll-container
p
| {{ bibtexPreview.data }}
p
p(ng-show="bibtexPreview.shouldShowDots")
| ...
p.no-preview(

View file

@ -9,4 +9,12 @@ define [
openFile: (file) ->
@$scope.ui.view = "file"
@$scope.openFile = file
@$scope.openFile = null
@$scope.$apply()
window.setTimeout(
() =>
@$scope.openFile = file
@$scope.$apply()
, 0
, this
)

View file

@ -7,20 +7,12 @@ define [
$scope.bibtexPreview =
loading: false
shouldShowDots: false
error: false
data: null
$scope.failedLoad = false
$rootScope.$on 'entity:selected', () ->
$scope.failedLoad = false
$scope.loadBibtexIfRequired()
$scope.loadBibtexIfRequired = () ->
if $scope.extension($scope.openFile) == 'bib'
$scope.bibtexPreview.data = null
$scope.loadBibtexFilePreview()
window.sl_binaryFilePreviewError = () =>
$scope.failedLoad = true
$scope.$apply()
@ -31,11 +23,15 @@ define [
$scope.loadBibtexFilePreview = () ->
url = "/project/#{project_id}/file/#{$scope.openFile.id}?range=0-#{TWO_MEGABYTES}"
$scope.bibtexPreview.loading = true
$scope.bibtexPreview.shouldShowDots = false
$scope.$apply()
$http.get(url)
.success (data) ->
$scope.bibtexPreview.loading = false
$scope.bibtexPreview.error = false
# show dots when payload is closs to cutoff
if data.length >= (TWO_MEGABYTES - 200)
$scope.bibtexPreview.shouldShowDots = true
try
# remove last partial line
data = data.replace(/\n.*$/, '')
@ -56,6 +52,11 @@ define [
table_wrap.style.height = desired_height + 'px'
table_wrap.style['max-height'] = desired_height + 'px'
$scope.loadBibtexIfRequired = () ->
if $scope.extension($scope.openFile) == 'bib'
$scope.bibtexPreview.data = null
$scope.loadBibtexFilePreview()
$scope.loadBibtexIfRequired()
]

View file

@ -78,12 +78,15 @@ define [
# prepare query string
qs = {}
# define the base url. if the pdf file has a build number, pass it to the clsi in the url
if fileByPath['output.pdf']?.build?
if fileByPath['output.pdf']?.url?
$scope.pdf.url = fileByPath['output.pdf'].url
else if fileByPath['output.pdf']?.build?
build = fileByPath['output.pdf'].build
$scope.pdf.url = "/project/#{$scope.project_id}/build/#{build}/output/output.pdf"
# no need to bust cache, build id is unique
else
$scope.pdf.url = "/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)
if not fileByPath['output.pdf']?.build?
qs.cache_bust = "#{Date.now()}"
# add a query string parameter for the compile group
if response.compileGroup?
@ -125,7 +128,9 @@ define [
params:
build:file.build
clsiserverid:ide.clsiServerId
if file?.build?
if file.url? # FIXME clean this up when we have file.urls out consistently
opts.url = file.url
else if file?.build?
opts.url = "/project/#{$scope.project_id}/build/#{file.build}/output/#{name}"
else
opts.url = "/project/#{$scope.project_id}/output/#{name}"