Allow clearing of aux files

This commit is contained in:
James Allen 2014-06-30 12:36:17 +01:00
parent aee7b5477b
commit 8b6f962275
2 changed files with 53 additions and 2 deletions

View file

@ -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...

View file

@ -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')
]