First pass at refactoring the output panel views.

This commit is contained in:
Shane Kilkelly 2016-03-22 09:39:33 +00:00
parent f58f1c3795
commit 59b131f251
2 changed files with 102 additions and 96 deletions

View file

@ -32,7 +32,7 @@ div.full-size.pdf(ng-controller="PdfController")
a.log-btn(
href
ng-click="toggleLogs()"
ng-class="{ 'active': (pdf.view == 'logs' || pdf.failure) && !pdf.error && !pdf.timeout && !pdf.uncompiled }"
ng-class="{ 'active': shouldShowLogs == true }"
tooltip="#{translate('logs_and_output_files')}"
tooltip-placement="bottom"
)
@ -75,98 +75,9 @@ div.full-size.pdf(ng-controller="PdfController")
i.split-screen
i.split-screen
// end of toolbar
.pdf-viewer(ng-show="pdf.url && pdf.view == 'pdf' && !pdf.failure && !pdf.timeout && !pdf.error && !pdf.renderingError && !pdf.clsiMaintenance && !pdf.tooRecentlyCompiled")
div(
pdfng
ng-if="settings.pdfViewer == 'pdfjs'"
pdf-src="pdf.url"
key="{{ project_id }}"
resize-on="layout:main:resize,layout:pdf:resize"
highlights="pdf.highlights"
position="pdf.position"
dbl-click-callback="syncToCode"
)
iframe(
ng-src="{{ pdf.url }}"
ng-if="settings.pdfViewer == 'native'"
)
.pdf-uncompiled(ng-show="pdf.uncompiled && !pdf.compiling")
|  
i.fa.fa-level-up.fa-flip-horizontal.fa-2x
|   #{translate('click_here_to_preview_pdf')}
.pdf-errors(ng-show="(pdf.timedout || pdf.error || pdf.renderingError || pdf.clsiMaintenance || pdf.tooRecentlyCompiled) && pdf.view != 'logs'")
.alert.alert-danger(ng-show="pdf.error || pdf.renderingError")
strong #{translate("server_error")}
span #{translate("somthing_went_wrong_compiling")}
.alert.alert-danger(ng-show="pdf.clsiMaintenance")
strong #{translate("server_error")}
span #{translate("clsi_maintenance")}
.alert.alert-danger(ng-show="pdf.tooRecentlyCompiled")
strong #{translate("server_error")}
span #{translate("too_recently_compiled")}
.alert.alert-danger(ng-show="pdf.timedout")
p
strong #{translate("timedout")}.
span #{translate("proj_timed_out_reason")}
p
a.text-info(href="https://www.sharelatex.com/learn/Debugging_Compilation_timeout_errors", target="_blank")
| #{translate("learn_how_to_make_documents_compile_quickly")}
.alert.alert-success(ng-show="pdf.timedout && !hasPremiumCompile")
p(ng-if="project.owner._id == user.id")
strong #{translate("upgrade_for_faster_compiles")}
p(ng-if="project.owner._id != user.id")
strong #{translate("ask_proj_owner_to_upgrade_for_faster_compiles")}
p #{translate("free_accounts_have_timeout_upgrade_to_increase")}
p Plus:
p
ul.list-unstyled
li
i.fa.fa-check  
| #{translate("unlimited_projects")}
li
i.fa.fa-check  
| #{translate("collabs_per_proj", {collabcount:'Multiple'})}
li
i.fa.fa-check  
| #{translate("full_doc_history")}
li
i.fa.fa-check  
| #{translate("sync_to_dropbox")}
li
i.fa.fa-check  
| #{translate("sync_to_github")}
li
i.fa.fa-check  
|#{translate("compile_larger_projects")}
p(ng-controller="FreeTrialModalController", ng-if="project.owner._id == user.id")
a.btn.btn-success.row-spaced-small(
href
ng-class="buttonClass"
sixpack-convert="track_changes_feature_info"
ng-click="startFreeTrial('compile-timeout')"
) #{translate("start_free_trial")}
.pdf-errors(ng-show="pdf.projectTooLarge")
.alert.alert-danger
strong #{translate("project_too_large")}
span #{translate("project_too_large_please_reduce")}
.pdf-logs(ng-show="(pdf.view == 'logs' || pdf.failure) && !pdf.error && !pdf.timeout && !pdf.uncompiled")
// views
.pdf-logs(ng-show="shouldShowLogs")
.alert.alert-success(ng-show="pdf.logEntries.all.length == 0")
| #{translate("no_errors_good_job")}
@ -218,6 +129,92 @@ div.full-size.pdf(ng-controller="PdfController")
span(ng-show="pdf.showRawLog") #{translate("hide_raw_logs")}
pre(ng-bind="pdf.rawLog", ng-show="pdf.showRawLog")
div(ng-show="!shouldShowLogs", ng-switch on="pdf.view")
.pdf-uncompiled(ng-switch-when="uncompiled" ng-show="!pdf.compiling")
|  
i.fa.fa-level-up.fa-flip-horizontal.fa-2x
|   #{translate('click_here_to_preview_pdf')}
.pdf-viewer(ng-switch-when="pdf")
div(
pdfng
ng-if="settings.pdfViewer == 'pdfjs'"
pdf-src="pdf.url"
key="{{ project_id }}"
resize-on="layout:main:resize,layout:pdf:resize"
highlights="pdf.highlights"
position="pdf.position"
dbl-click-callback="syncToCode"
)
iframe(
ng-src="{{ pdf.url }}"
ng-if="settings.pdfViewer == 'native'"
)
.pdf-errors(ng-switch-when="errors")
.alert.alert-danger(ng-show="pdf.error || pdf.renderingError")
strong #{translate("server_error")}
span #{translate("somthing_went_wrong_compiling")}
.alert.alert-danger(ng-show="pdf.clsiMaintenance")
strong #{translate("server_error")}
span #{translate("clsi_maintenance")}
.alert.alert-danger(ng-show="pdf.tooRecentlyCompiled")
strong #{translate("server_error")}
span #{translate("too_recently_compiled")}
.alert.alert-danger(ng-show="pdf.timedout")
p
strong #{translate("timedout")}.
span #{translate("proj_timed_out_reason")}
p
a.text-info(href="https://www.sharelatex.com/learn/Debugging_Compilation_timeout_errors", target="_blank")
| #{translate("learn_how_to_make_documents_compile_quickly")}
.alert.alert-success(ng-show="pdf.timedout && !hasPremiumCompile")
p(ng-if="project.owner._id == user.id")
strong #{translate("upgrade_for_faster_compiles")}
p(ng-if="project.owner._id != user.id")
strong #{translate("ask_proj_owner_to_upgrade_for_faster_compiles")}
p #{translate("free_accounts_have_timeout_upgrade_to_increase")}
p Plus:
p
ul.list-unstyled
li
i.fa.fa-check  
| #{translate("unlimited_projects")}
li
i.fa.fa-check  
| #{translate("collabs_per_proj", {collabcount:'Multiple'})}
li
i.fa.fa-check  
| #{translate("full_doc_history")}
li
i.fa.fa-check  
| #{translate("sync_to_dropbox")}
li
i.fa.fa-check  
| #{translate("sync_to_github")}
li
i.fa.fa-check  
|#{translate("compile_larger_projects")}
p(ng-controller="FreeTrialModalController", ng-if="project.owner._id == user.id")
a.btn.btn-success.row-spaced-small(
href
ng-class="buttonClass"
sixpack-convert="track_changes_feature_info"
ng-click="startFreeTrial('compile-timeout')"
) #{translate("start_free_trial")}
.pdf-logs(ng-switch-when="logs")
// // // //
script(type='text/ng-template', id='clearCacheModalTemplate')
.modal-header

View file

@ -5,6 +5,8 @@ define [
], (App, LogParser, BibLogParser) ->
App.controller "PdfController", ($scope, $http, ide, $modal, synctex, event_tracking, localStorage) ->
autoCompile = true
$scope.pdf.view = 'uncompiled' # uncompiled | pdf | errors
$scope.$on "project:joined", () ->
return if !autoCompile
autoCompile = false
@ -12,6 +14,7 @@ define [
$scope.hasPremiumCompile = $scope.project.features.compileGroup == "priority"
$scope.$on "pdf:error:display", () ->
$scope.pdf.view = 'errors'
$scope.pdf.renderingError = true
$scope.draft = localStorage("draft:#{$scope.project_id}") or false
@ -41,19 +44,26 @@ define [
$scope.pdf.tooRecentlyCompiled = false
if response.status == "timedout"
$scope.pdf.view = 'errors'
$scope.pdf.timedout = true
else if response.status == "autocompile-backoff"
$scope.pdf.view = 'errors'
$scope.pdf.uncompiled = true
else if response.status == "project-too-large"
$scope.pdf.view = 'errors'
$scope.pdf.projectTooLarge = true
else if response.status == "failure"
$scope.pdf.view = 'errors'
$scope.pdf.failure = true
fetchLogs()
else if response.status == 'clsi-maintenance'
$scope.pdf.view = 'errors'
$scope.pdf.clsiMaintenance = true
else if response.status == "too-recently-compiled"
$scope.pdf.view = 'errors'
$scope.pdf.tooRecentlyCompiled = true
else if response.status == "success"
$scope.pdf.view = 'pdf'
# define the base url
$scope.pdf.url = "/project/#{$scope.project_id}/output/output.pdf?cache_bust=#{Date.now()}"
# add a query string parameter for the compile group
@ -176,14 +186,13 @@ define [
"X-Csrf-Token": window.csrfToken
}
$scope.shouldShowLogs = false
$scope.toggleLogs = () ->
if !$scope.pdf.view? or $scope.pdf.view == "pdf"
$scope.pdf.view = "logs"
else
$scope.pdf.view = "pdf"
$scope.shouldShowLogs = !$scope.shouldShowLogs
$scope.showPdf = () ->
$scope.pdf.view = "pdf"
$scope.shouldShowLogs = false
$scope.toggleRawLog = () ->
$scope.pdf.showRawLog = !$scope.pdf.showRawLog