diff --git a/services/web/app/coffee/Features/Compile/ClsiManager.coffee b/services/web/app/coffee/Features/Compile/ClsiManager.coffee index 032d806665..0e910d8591 100755 --- a/services/web/app/coffee/Features/Compile/ClsiManager.coffee +++ b/services/web/app/coffee/Features/Compile/ClsiManager.coffee @@ -8,11 +8,11 @@ logger = require "logger-sharelatex" url = require("url") module.exports = ClsiManager = - sendRequest: (project_id, settingsOverride = {}, callback = (error, success) ->) -> - ClsiManager._buildRequest project_id, settingsOverride, (error, req) -> + sendRequest: (project_id, options = {}, callback = (error, success) ->) -> + ClsiManager._buildRequest project_id, options, (error, req) -> return callback(error) if error? logger.log project_id: project_id, "sending compile to CLSI" - ClsiManager._postToClsi project_id, req, settingsOverride.compiler, (error, response) -> + ClsiManager._postToClsi project_id, req, options.compileGroup, (error, response) -> return callback(error) if error? logger.log project_id: project_id, response: response, "received compile response from CLSI" callback( @@ -21,19 +21,18 @@ module.exports = ClsiManager = ClsiManager._parseOutputFiles(project_id, response?.compile?.outputFiles) ) - getLogLines: (project_id, callback = (error, lines) ->) -> - request "#{Settings.apis.clsi.url}/project/#{project_id}/output/output.log", (error, response, body) -> - return callback(error) if error? - callback null, body?.split("\n") or [] + deleteAuxFiles: (project_id, options, callback = (error) ->) -> + compilerUrl = @_getCompilerUrl(options?.compileGroup) + request.del "#{compilerUrl}/project/#{project_id}", callback - deleteAuxFiles: (project_id, callback = (error) ->) -> - request.del "#{Settings.apis.clsi.url}/project/#{project_id}", callback - - _postToClsi: (project_id, req, compiler, callback = (error, response) ->) -> - if compiler == "priority" - compilerUrl = Settings.apis.clsi_priority.url + _getCompilerUrl: (compileGroup) -> + if compileGroup == "priority" + return Settings.apis.clsi_priority.url else - compilerUrl = Settings.apis.clsi.url + return Settings.apis.clsi.url + + _postToClsi: (project_id, req, compileGroup, callback = (error, response) ->) -> + compilerUrl = @_getCompilerUrl(compileGroup) request.post { url: "#{compilerUrl}/project/#{project_id}/compile" json: req diff --git a/services/web/app/coffee/Features/Compile/CompileController.coffee b/services/web/app/coffee/Features/Compile/CompileController.coffee index 64aaf43e95..663210b092 100755 --- a/services/web/app/coffee/Features/Compile/CompileController.coffee +++ b/services/web/app/coffee/Features/Compile/CompileController.coffee @@ -48,7 +48,7 @@ module.exports = CompileController = deleteAuxFiles: (req, res, next) -> project_id = req.params.Project_id - ClsiManager.deleteAuxFiles project_id, (error) -> + CompileManager.deleteAuxFiles project_id, (error) -> return next(error) if error? res.send(200) diff --git a/services/web/app/coffee/Features/Compile/CompileManager.coffee b/services/web/app/coffee/Features/Compile/CompileManager.coffee index 1835fa0c0c..d35322077b 100755 --- a/services/web/app/coffee/Features/Compile/CompileManager.coffee +++ b/services/web/app/coffee/Features/Compile/CompileManager.coffee @@ -40,6 +40,11 @@ module.exports = CompileManager = return callback(error) if error? logger.log files: outputFiles, "output files" callback(null, status, outputFiles, output) + + deleteAuxFiles: (project_id, callback = (error) ->) -> + CompileManager.getProjectCompileLimits project_id, (error, limits) -> + return callback(error) if error? + ClsiManager.deleteAuxFiles project_id, limits, callback getProjectCompileLimits: (project_id, callback = (error, limits) ->) -> Project.findById project_id, {owner_ref: 1}, (error, project) -> @@ -51,12 +56,6 @@ module.exports = CompileManager = compileGroup: owner.features?.compileGroup || Settings.defaultFeatures.compileGroup } - getLogLines: (project_id, callback)-> - Metrics.inc "editor.raw-logs" - ClsiManager.getLogLines project_id, (error, logLines)-> - return callback(error) if error? - callback null, logLines - COMPILE_DELAY: 1 # seconds _checkIfRecentlyCompiled: (project_id, user_id, callback = (error, recentlyCompiled) ->) -> key = "compile:#{project_id}:#{user_id}" diff --git a/services/web/app/views/project/editor/editor.jade b/services/web/app/views/project/editor/editor.jade index 775f8aa246..180c72e0b6 100644 --- a/services/web/app/views/project/editor/editor.jade +++ b/services/web/app/views/project/editor/editor.jade @@ -49,7 +49,7 @@ div.full-size( i.fa.fa-long-arrow-right br a.btn.btn-default.btn-xs( - tooltip-html-unsafe="#{translate('go_to_code_location_in_pdf')}" + tooltip-html-unsafe="#{translate('go_to_pdf_location_in_code')}" tooltip-placement="right" tooltip-append-to-body="true" ng-click="syncToCode()" diff --git a/services/web/app/views/project/editor/left-menu.jade b/services/web/app/views/project/editor/left-menu.jade index 7505f6a2b8..a68dbd586c 100644 --- a/services/web/app/views/project/editor/left-menu.jade +++ b/services/web/app/views/project/editor/left-menu.jade @@ -46,7 +46,7 @@ aside#left-menu.full-size( i.fa.fa-external-link.fa-fw |    #{translate("publish_as_template")} - div(ng-show="permissions.admin") + div(ng-show="!anonymous") h4() #{translate("sync")} span(ng-controller="DropboxController") ul.list-unstyled.nav() diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index 3ab4687e8a..ee898dd8f7 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -25,6 +25,7 @@ define [ $scope.pdf.timedout = false $scope.pdf.failure = false $scope.pdf.uncompiled = false + $scope.pdf.projectTooLarge = false $scope.pdf.url = null if response.status == "timedout" diff --git a/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee b/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee index aff181a5ee..431aabec97 100644 --- a/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee +++ b/services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee @@ -41,7 +41,7 @@ describe "ClsiManager", -> type: "log" }] }) - @ClsiManager.sendRequest @project_id, {compiler:"standard"}, @callback + @ClsiManager.sendRequest @project_id, {compileGroup:"standard"}, @callback it "should build the request", -> @ClsiManager._buildRequest @@ -77,15 +77,27 @@ describe "ClsiManager", -> describe "deleteAuxFiles", -> beforeEach -> @request.del = sinon.stub().callsArg(1) - @ClsiManager.deleteAuxFiles @project_id, @callback + + describe "with the standard compileGroup", -> + beforeEach -> + @ClsiManager.deleteAuxFiles @project_id, {compileGroup: "standard"}, @callback - it "should call the delete method in the CLSI", -> - @request.del - .calledWith("#{@settings.apis.clsi.url}/project/#{@project_id}") - .should.equal true + it "should call the delete method in the standard CLSI", -> + @request.del + .calledWith("#{@settings.apis.clsi.url}/project/#{@project_id}") + .should.equal true - it "should call the callback", -> - @callback.called.should.equal true + it "should call the callback", -> + @callback.called.should.equal true + + describe "with the priority compileGroup", -> + beforeEach -> + @ClsiManager.deleteAuxFiles @project_id, {compileGroup: "priority"}, @callback + + it "should call the delete method in the CLSI", -> + @request.del + .calledWith("#{@settings.apis.clsi_priority.url}/project/#{@project_id}") + .should.equal true describe "_buildRequest", -> beforeEach -> diff --git a/services/web/test/UnitTests/coffee/Compile/CompileControllerTests.coffee b/services/web/test/UnitTests/coffee/Compile/CompileControllerTests.coffee index 4c40e9d483..b3c004fdfe 100644 --- a/services/web/test/UnitTests/coffee/Compile/CompileControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Compile/CompileControllerTests.coffee @@ -196,14 +196,14 @@ describe "CompileController", -> describe "deleteAuxFiles", -> beforeEach -> - @ClsiManager.deleteAuxFiles = sinon.stub().callsArg(1) + @CompileManager.deleteAuxFiles = sinon.stub().callsArg(1) @req.params = Project_id: @project_id @res.send = sinon.stub() @CompileController.deleteAuxFiles @req, @res, @next it "should proxy to the CLSI", -> - @ClsiManager.deleteAuxFiles + @CompileManager.deleteAuxFiles .calledWith(@project_id) .should.equal true diff --git a/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee b/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee index 7e183e8050..fbcf6787cf 100644 --- a/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee +++ b/services/web/test/UnitTests/coffee/Compile/CompileManagerTests.coffee @@ -134,26 +134,25 @@ describe "CompileManager", -> compileGroup: @group }) .should.equal true - - describe "getLogLines", -> + + describe "deleteAuxFiles", -> beforeEach -> - @ClsiManager.getLogLines = sinon.stub().callsArgWith(1, null, @lines = ["log", "lines"]) - @CompileManager.getLogLines @project_id, @callback - - it "should call the new api", -> - @ClsiManager.getLogLines + @CompileManager.getProjectCompileLimits = sinon.stub().callsArgWith 1, null, @limits = { compileGroup: "mock-compile-group" } + @ClsiManager.deleteAuxFiles = sinon.stub().callsArg(2) + @CompileManager.deleteAuxFiles @project_id, @callback + + it "should look up the compile group to use", -> + @CompileManager.getProjectCompileLimits .calledWith(@project_id) .should.equal true - - it "should call the callback with the lines", -> - @callback - .calledWith(null, @lines) - .should.equal true - - it "should increase the log count metric", -> - @Metrics.inc - .calledWith("editor.raw-logs") + + it "should delete the aux files", -> + @ClsiManager.deleteAuxFiles + .calledWith(@project_id, @limits) .should.equal true + + it "should call the callback", -> + @callback.called.should.equal true describe "_checkIfRecentlyCompiled", -> describe "when the key exists in redis", ->