From 8b6f962275efdddb5c844e4b7a4b81d9c68258a6 Mon Sep 17 00:00:00 2001 From: James Allen Date: Mon, 30 Jun 2014 12:36:17 +0100 Subject: [PATCH] Allow clearing of aux files --- .../web/app/views/project/editor/pdf.jade | 22 ++++++++++++- .../ide/pdf/controllers/PdfController.coffee | 33 ++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index 49aa59d164..b2b7fc9df2 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/services/web/app/views/project/editor/pdf.jade @@ -79,7 +79,8 @@ div.full-size(ng-controller="PdfController") href, tooltip="Clear cached files", tooltip-placement="top", - tooltip-append-to-body="true" + tooltip-append-to-body="true", + ng-click="openClearCacheModal()" ) i.fa.fa-trash-o |   @@ -102,3 +103,22 @@ div.full-size(ng-controller="PdfController") span(ng-show="pdf.showRawLog") Hide Raw Logs pre(ng-bind="pdf.rawLog", ng-show="pdf.showRawLog") + +script(type='text/ng-template', id='clearCacheModalTemplate') + .modal-header + h3 Clear cache? + .modal-body + p This will clear all hidden LaTeX files (.aux, .bbl, etc) from our compile server. + | You generally don't need to do this unless you're having trouble with references. + p Your project files will not be deleted or changed. + .modal-footer + button.btn.btn-default( + ng-click="cancel()" + ng-disabled="state.inflight" + ) Cancel + button.btn.btn-info( + ng-click="clear()" + ng-disabled="state.inflight" + ) + span(ng-show="!state.inflight") Clear cache + span(ng-show="state.inflight") Clearing... diff --git a/services/web/public/coffee/app/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/app/ide/pdf/controllers/PdfController.coffee index f3dc9d485d..6e31ee603f 100644 --- a/services/web/public/coffee/app/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/app/ide/pdf/controllers/PdfController.coffee @@ -2,7 +2,7 @@ define [ "base" "libs/latex-log-parser" ], (App, LogParser) -> - App.controller "PdfController", ["$scope", "$http", "ide", ($scope, $http, ide) -> + App.controller "PdfController", ["$scope", "$http", "ide", "$modal", ($scope, $http, ide, $modal) -> $scope.pdf = url: null # Pdf Url error: false # Server error @@ -100,6 +100,14 @@ define [ $scope.pdf.compiling = false $scope.pdf.error = true + $scope.clearCache = () -> + $http { + url: "/project/#{$scope.project_id}/output" + method: "DELETE" + headers: + "X-Csrf-Token": window.csrfToken + } + $scope.toggleLogs = () -> if !$scope.pdf.view? or $scope.pdf.view == "pdf" $scope.pdf.view = "logs" @@ -114,4 +122,27 @@ define [ $scope.openOutputFile = (file) -> window.open("/project/#{$scope.project_id}/output/#{file.path}") + + $scope.openClearCacheModal = () -> + modalInstance = $modal.open( + templateUrl: "clearCacheModalTemplate" + controller: "ClearCacheModalController" + scope: $scope + ) + ] + + App.controller 'ClearCacheModalController', ["$scope", "$modalInstance", ($scope, $modalInstance) -> + $scope.state = + inflight: false + + $scope.clear = () -> + $scope.state.inflight = true + $scope + .clearCache() + .then () -> + $scope.state.inflight = false + $modalInstance.close() + + $scope.cancel = () -> + $modalInstance.dismiss('cancel') ] \ No newline at end of file