Просмотр исходного кода

Merge branch 'master' into clsi-dynamic-load

Henry Oswald 10 лет назад
Родитель
Сommit
11724fce13

+ 1 - 1
services/web/app/views/project/editor/binary-file.jade

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

+ 9 - 1
services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee

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

+ 10 - 9
services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee

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

+ 8 - 3
services/web/public/coffee/ide/pdf/controllers/PdfController.coffee

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