From 9a6876d2379b3f7402495cb612591cd2a04eea22 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 20 May 2016 09:17:25 +0100 Subject: [PATCH 1/3] Toggle the dots at the end of bib preview, based on size of payload. --- services/web/app/views/project/editor/binary-file.jade | 2 +- .../ide/binary-files/controllers/BinaryFileController.coffee | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/project/editor/binary-file.jade b/services/web/app/views/project/editor/binary-file.jade index 4f451f0020..eaaa6e6c65 100644 --- a/services/web/app/views/project/editor/binary-file.jade +++ b/services/web/app/views/project/editor/binary-file.jade @@ -28,7 +28,7 @@ div.binary-file.full-size( div.scroll-container p | {{ bibtexPreview.data }} - p + p(ng-show="bibtexPreview.shouldShowDots") | ... p.no-preview( diff --git a/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee b/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee index 124393d037..ef1fb77389 100644 --- a/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee +++ b/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee @@ -7,6 +7,7 @@ define [ $scope.bibtexPreview = loading: false + shouldShowDots: false error: false data: null @@ -31,11 +32,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.*$/, '') From 939c7a8c720344b88af2332b04ca3f519e4f122a Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 20 May 2016 11:20:00 +0100 Subject: [PATCH 2/3] Force reload BinaryFile view when a new object is selected. --- .../ide/binary-files/BinaryFilesManager.coffee | 10 +++++++++- .../controllers/BinaryFileController.coffee | 14 +++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee b/services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee index 9b80c0e0dc..02283bc49e 100644 --- a/services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee +++ b/services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee @@ -9,4 +9,12 @@ define [ openFile: (file) -> @$scope.ui.view = "file" - @$scope.openFile = file \ No newline at end of file + @$scope.openFile = null + @$scope.$apply() + window.setTimeout( + () => + @$scope.openFile = file + @$scope.$apply() + , 0 + , this + ) diff --git a/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee b/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee index ef1fb77389..7dceeff965 100644 --- a/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee +++ b/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee @@ -13,15 +13,6 @@ define [ $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() @@ -61,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() ] From eaa41e43614bc59f26323db2c5eabf1928155b35 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 20 May 2016 10:09:42 +0100 Subject: [PATCH 3/3] support displaying output files using .url parameter from clsi --- .../coffee/ide/pdf/controllers/PdfController.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index 1b9407bc27..43725df381 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -76,12 +76,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? @@ -111,7 +114,9 @@ define [ fetchLogs = (logFile, blgFile) -> getFile = (name, file) -> - if file?.build? + if file.url? # FIXME clean this up when we have file.urls out consistently + url = file.url + else if file?.build? url = "/project/#{$scope.project_id}/build/#{file.build}/output/#{name}" else url = "/project/#{$scope.project_id}/output/#{name}"