PdfController.coffee 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. define [
  2. "base"
  3. "ace/ace"
  4. "ide/human-readable-logs/HumanReadableLogs"
  5. "libs/bib-log-parser"
  6. "services/log-hints-feedback"
  7. ], (App, Ace, HumanReadableLogs, BibLogParser) ->
  8. App.controller "PdfController", ($scope, $http, ide, $modal, synctex, event_tracking, logHintsFeedback, localStorage) ->
  9. # enable per-user containers by default
  10. perUserCompile = true
  11. autoCompile = true
  12. # pdf.view = uncompiled | pdf | errors
  13. $scope.pdf.view = if $scope?.pdf?.url then 'pdf' else 'uncompiled'
  14. $scope.shouldShowLogs = false
  15. $scope.wikiEnabled = window.wikiEnabled;
  16. # view logic to check whether the files dropdown should "drop up" or "drop down"
  17. $scope.shouldDropUp = false
  18. logsContainerEl = document.querySelector ".pdf-logs"
  19. filesDropdownEl = logsContainerEl?.querySelector ".files-dropdown"
  20. # get the top coordinate of the files dropdown as a ratio (to the logs container height)
  21. # logs container supports scrollable content, so it's possible that ratio > 1.
  22. getFilesDropdownTopCoordAsRatio = () ->
  23. filesDropdownEl?.getBoundingClientRect().top / logsContainerEl?.getBoundingClientRect().height
  24. $scope.$watch "shouldShowLogs", (shouldShow) ->
  25. if shouldShow
  26. $scope.$applyAsync () ->
  27. $scope.shouldDropUp = getFilesDropdownTopCoordAsRatio() > 0.65
  28. # log hints tracking
  29. $scope.logHintsNegFeedbackValues = logHintsFeedback.feedbackOpts
  30. $scope.trackLogHintsLearnMore = () ->
  31. event_tracking.sendMB "logs-hints-learn-more"
  32. trackLogHintsFeedback = (isPositive, hintId) ->
  33. event_tracking.send "log-hints", (if isPositive then "feedback-positive" else "feedback-negative"), hintId
  34. event_tracking.sendMB (if isPositive then "log-hints-feedback-positive" else "log-hints-feedback-negative"), { hintId }
  35. $scope.trackLogHintsNegFeedbackDetails = (hintId, feedbackOpt, feedbackOtherVal) ->
  36. logHintsFeedback.submitFeedback hintId, feedbackOpt, feedbackOtherVal
  37. $scope.trackLogHintsPositiveFeedback = (hintId) -> trackLogHintsFeedback true, hintId
  38. $scope.trackLogHintsNegativeFeedback = (hintId) -> trackLogHintsFeedback false, hintId
  39. if ace.require("ace/lib/useragent").isMac
  40. $scope.modifierKey = "Cmd"
  41. else
  42. $scope.modifierKey = "Ctrl"
  43. # utility for making a query string from a hash, could use jquery $.param
  44. createQueryString = (args) ->
  45. qs_args = ("#{k}=#{v}" for k, v of args)
  46. if qs_args.length then "?" + qs_args.join("&") else ""
  47. $scope.stripHTMLFromString = (htmlStr) ->
  48. tmp = document.createElement("DIV")
  49. tmp.innerHTML = htmlStr
  50. return tmp.textContent || tmp.innerText || ""
  51. $scope.$on "project:joined", () ->
  52. return if !autoCompile
  53. autoCompile = false
  54. $scope.recompile(isAutoCompile: true)
  55. $scope.hasPremiumCompile = $scope.project.features.compileGroup == "priority"
  56. $scope.$on "pdf:error:display", () ->
  57. $scope.pdf.view = 'errors'
  58. $scope.pdf.renderingError = true
  59. # abort compile if syntax checks fail
  60. $scope.stop_on_validation_error = localStorage("stop_on_validation_error:#{$scope.project_id}")
  61. $scope.stop_on_validation_error ?= true # turn on for all users by default
  62. $scope.$watch "stop_on_validation_error", (new_value, old_value) ->
  63. if new_value? and old_value != new_value
  64. localStorage("stop_on_validation_error:#{$scope.project_id}", new_value)
  65. $scope.draft = localStorage("draft:#{$scope.project_id}") or false
  66. $scope.$watch "draft", (new_value, old_value) ->
  67. if new_value? and old_value != new_value
  68. localStorage("draft:#{$scope.project_id}", new_value)
  69. sendCompileRequest = (options = {}) ->
  70. url = "/project/#{$scope.project_id}/compile"
  71. params = {}
  72. if options.isAutoCompile
  73. params["auto_compile"]=true
  74. # if the previous run was a check, clear the error logs
  75. $scope.pdf.logEntries = [] if $scope.check
  76. # keep track of whether this is a compile or check
  77. $scope.check = if options.check then true else false
  78. event_tracking.sendMB "syntax-check-request" if options.check
  79. # send appropriate check type to clsi
  80. checkType = switch
  81. when $scope.check then "validate" # validate only
  82. when options.try then "silent" # allow use to try compile once
  83. when $scope.stop_on_validation_error then "error" # try to compile
  84. else "silent" # ignore errors
  85. return $http.post url, {
  86. rootDoc_id: options.rootDocOverride_id or null
  87. draft: $scope.draft
  88. check: checkType
  89. _csrf: window.csrfToken
  90. }, {params: params}
  91. parseCompileResponse = (response) ->
  92. # keep last url
  93. last_pdf_url = $scope.pdf.url
  94. # Reset everything
  95. $scope.pdf.error = false
  96. $scope.pdf.timedout = false
  97. $scope.pdf.failure = false
  98. $scope.pdf.url = null
  99. $scope.pdf.clsiMaintenance = false
  100. $scope.pdf.tooRecentlyCompiled = false
  101. $scope.pdf.renderingError = false
  102. $scope.pdf.projectTooLarge = false
  103. $scope.pdf.compileTerminated = false
  104. $scope.pdf.compileExited = false
  105. $scope.pdf.failedCheck = false
  106. # make a cache to look up files by name
  107. fileByPath = {}
  108. if response?.outputFiles?
  109. for file in response?.outputFiles
  110. fileByPath[file.path] = file
  111. # prepare query string
  112. qs = {}
  113. # add a query string parameter for the compile group
  114. if response.compileGroup?
  115. ide.compileGroup = qs.compileGroup = response.compileGroup
  116. # add a query string parameter for the clsi server id
  117. if response.clsiServerId?
  118. ide.clsiServerId = qs.clsiserverid = response.clsiServerId
  119. if response.status == "timedout"
  120. $scope.pdf.view = 'errors'
  121. $scope.pdf.timedout = true
  122. fetchLogs(fileByPath)
  123. else if response.status == "terminated"
  124. $scope.pdf.view = 'errors'
  125. $scope.pdf.compileTerminated = true
  126. fetchLogs(fileByPath)
  127. else if response.status in ["validation-fail", "validation-pass"]
  128. $scope.pdf.view = 'pdf'
  129. $scope.pdf.url = last_pdf_url
  130. $scope.shouldShowLogs = true
  131. $scope.pdf.failedCheck = true if response.status is "validation-fail"
  132. event_tracking.sendMB "syntax-check-#{response.status}"
  133. fetchLogs(fileByPath, { validation: true })
  134. else if response.status == "exited"
  135. $scope.pdf.view = 'pdf'
  136. $scope.pdf.compileExited = true
  137. $scope.pdf.url = last_pdf_url
  138. $scope.shouldShowLogs = true
  139. fetchLogs(fileByPath)
  140. else if response.status == "autocompile-backoff"
  141. $scope.pdf.view = 'uncompiled'
  142. else if response.status == "project-too-large"
  143. $scope.pdf.view = 'errors'
  144. $scope.pdf.projectTooLarge = true
  145. else if response.status == "failure"
  146. $scope.pdf.view = 'errors'
  147. $scope.pdf.failure = true
  148. $scope.shouldShowLogs = true
  149. fetchLogs(fileByPath)
  150. else if response.status == 'clsi-maintenance'
  151. $scope.pdf.view = 'errors'
  152. $scope.pdf.clsiMaintenance = true
  153. else if response.status == "too-recently-compiled"
  154. $scope.pdf.view = 'errors'
  155. $scope.pdf.tooRecentlyCompiled = true
  156. else if response.status == "validation-problems"
  157. $scope.pdf.view = "validation-problems"
  158. $scope.pdf.validation = response.validationProblems
  159. else if response.status == "success"
  160. $scope.pdf.view = 'pdf'
  161. $scope.shouldShowLogs = false
  162. # define the base url. if the pdf file has a build number, pass it to the clsi in the url
  163. if fileByPath['output.pdf']?.url?
  164. $scope.pdf.url = fileByPath['output.pdf'].url
  165. else if fileByPath['output.pdf']?.build?
  166. build = fileByPath['output.pdf'].build
  167. $scope.pdf.url = "/project/#{$scope.project_id}/build/#{build}/output/output.pdf"
  168. else
  169. $scope.pdf.url = "/project/#{$scope.project_id}/output/output.pdf"
  170. # check if we need to bust cache (build id is unique so don't need it in that case)
  171. if not fileByPath['output.pdf']?.build?
  172. qs.cache_bust = "#{Date.now()}"
  173. # convert the qs hash into a query string and append it
  174. $scope.pdf.url += createQueryString qs
  175. # Save all downloads as files
  176. qs.popupDownload = true
  177. $scope.pdf.downloadUrl = "/project/#{$scope.project_id}/output/output.pdf" + createQueryString(qs)
  178. fetchLogs(fileByPath)
  179. IGNORE_FILES = ["output.fls", "output.fdb_latexmk"]
  180. $scope.pdf.outputFiles = []
  181. if !response.outputFiles?
  182. return
  183. # prepare list of output files for download dropdown
  184. qs = {}
  185. if response.clsiServerId?
  186. qs.clsiserverid = response.clsiServerId
  187. for file in response.outputFiles
  188. if IGNORE_FILES.indexOf(file.path) == -1
  189. isOutputFile = file.path.match(/^output\./)
  190. $scope.pdf.outputFiles.push {
  191. # Turn 'output.blg' into 'blg file'.
  192. name: if isOutputFile then "#{file.path.replace(/^output\./, "")} file" else file.path
  193. url: "/project/#{project_id}/output/#{file.path}" + createQueryString qs
  194. main: if isOutputFile then true else false
  195. }
  196. # sort the output files into order, main files first, then others
  197. $scope.pdf.outputFiles.sort (a,b) -> (b.main - a.main) || a.name.localeCompare(b.name)
  198. fetchLogs = (fileByPath, options) ->
  199. if options?.validation
  200. chktexFile = fileByPath['output.chktex']
  201. else
  202. logFile = fileByPath['output.log']
  203. blgFile = fileByPath['output.blg']
  204. getFile = (name, file) ->
  205. opts =
  206. method:"GET"
  207. params:
  208. compileGroup:ide.compileGroup
  209. clsiserverid:ide.clsiServerId
  210. if file?.url? # FIXME clean this up when we have file.urls out consistently
  211. opts.url = file.url
  212. else if file?.build?
  213. opts.url = "/project/#{$scope.project_id}/build/#{file.build}/output/#{name}"
  214. else
  215. opts.url = "/project/#{$scope.project_id}/output/#{name}"
  216. # check if we need to bust cache (build id is unique so don't need it in that case)
  217. if not file?.build?
  218. opts.params.cache_bust = "#{Date.now()}"
  219. return $http(opts)
  220. # accumulate the log entries
  221. logEntries =
  222. all: []
  223. errors: []
  224. warnings: []
  225. accumulateResults = (newEntries) ->
  226. for key in ['all', 'errors', 'warnings']
  227. if newEntries.type?
  228. entry.type = newEntries.type for entry in newEntries[key]
  229. logEntries[key] = logEntries[key].concat newEntries[key]
  230. # use the parsers for each file type
  231. processLog = (log) ->
  232. $scope.pdf.rawLog = log
  233. {errors, warnings, typesetting} = HumanReadableLogs.parse(log, ignoreDuplicates: true)
  234. all = [].concat errors, warnings, typesetting
  235. accumulateResults {all, errors, warnings}
  236. processChkTex = (log) ->
  237. errors = []
  238. warnings = []
  239. for line in log.split("\n")
  240. if m = line.match /^(\S+):(\d+):(\d+): (Error|Warning): (.*)/
  241. result = { file:m[1], line:m[2], column:m[3], level:m[4].toLowerCase(), message: "#{m[4]}: #{m[5]}"}
  242. if result.level is 'error'
  243. errors.push result
  244. else
  245. warnings.push result
  246. all = [].concat errors, warnings
  247. logHints = HumanReadableLogs.parse {type: "Syntax", all, errors, warnings}
  248. event_tracking.sendMB "syntax-check-return-count", {errors:errors.length, warnings:warnings.length}
  249. accumulateResults logHints
  250. processBiber = (log) ->
  251. {errors, warnings} = BibLogParser.parse(log, {})
  252. all = [].concat errors, warnings
  253. accumulateResults {type: "BibTeX", all, errors, warnings}
  254. # output the results
  255. handleError = () ->
  256. $scope.pdf.logEntries = []
  257. $scope.pdf.rawLog = ""
  258. annotateFiles = () ->
  259. $scope.pdf.logEntries = logEntries
  260. $scope.pdf.logEntryAnnotations = {}
  261. for entry in logEntries.all
  262. if entry.file?
  263. entry.file = normalizeFilePath(entry.file)
  264. entity = ide.fileTreeManager.findEntityByPath(entry.file)
  265. if entity?
  266. $scope.pdf.logEntryAnnotations[entity.id] ||= []
  267. $scope.pdf.logEntryAnnotations[entity.id].push {
  268. row: entry.line - 1
  269. type: if entry.level == "error" then "error" else "warning"
  270. text: entry.message
  271. }
  272. # retrieve the logfile and process it
  273. if logFile?
  274. response = getFile('output.log', logFile)
  275. .then (response) -> processLog(response.data)
  276. if blgFile? # retrieve the blg file if present
  277. response = response.then () ->
  278. getFile('output.blg', blgFile)
  279. .then(
  280. (response) -> processBiber(response.data),
  281. () -> true # ignore errors in biber file
  282. )
  283. if response?
  284. response.catch handleError
  285. else
  286. handleError()
  287. if chktexFile?
  288. getChkTex = () ->
  289. getFile('output.chktex', chktexFile)
  290. .then (response) -> processChkTex(response.data)
  291. # always retrieve the chktex file if present
  292. if response?
  293. response = response.then getChkTex, getChkTex
  294. else
  295. response = getChkTex()
  296. # display the combined result
  297. response.finally annotateFiles
  298. getRootDocOverride_id = () ->
  299. doc = ide.editorManager.getCurrentDocValue()
  300. return null if !doc?
  301. for line in doc.split("\n")
  302. match = line.match /^[^%]*\\documentclass/
  303. if match
  304. return ide.editorManager.getCurrentDocId()
  305. return null
  306. normalizeFilePath = (path) ->
  307. path = path.replace(/^(.*)\/compiles\/[0-9a-f]{24}(-[0-9a-f]{24})?\/(\.\/)?/, "")
  308. path = path.replace(/^\/compile\//, "")
  309. rootDocDirname = ide.fileTreeManager.getRootDocDirname()
  310. if rootDocDirname?
  311. path = path.replace(/^\.\//, rootDocDirname + "/")
  312. return path
  313. $scope.recompile = (options = {}) ->
  314. return if $scope.pdf.compiling
  315. event_tracking.sendMBSampled "editor-recompile-sampled", options
  316. $scope.pdf.compiling = true
  317. if options?.force
  318. # for forced compile, turn off validation check and ignore errors
  319. $scope.stop_on_validation_error = false
  320. $scope.shouldShowLogs = false # hide the logs while compiling
  321. event_tracking.sendMB "syntax-check-turn-off-checking"
  322. if options?.try
  323. $scope.shouldShowLogs = false # hide the logs while compiling
  324. event_tracking.sendMB "syntax-check-try-compile-anyway"
  325. ide.$scope.$broadcast("flush-changes")
  326. options.rootDocOverride_id = getRootDocOverride_id()
  327. sendCompileRequest(options)
  328. .success (data) ->
  329. $scope.pdf.view = "pdf"
  330. $scope.pdf.compiling = false
  331. parseCompileResponse(data)
  332. .error (err, status) ->
  333. if status == 429
  334. $scope.pdf.rateLimited = true
  335. $scope.pdf.compiling = false
  336. $scope.pdf.renderingError = false
  337. $scope.pdf.error = true
  338. $scope.pdf.view = 'errors'
  339. # This needs to be public.
  340. ide.$scope.recompile = $scope.recompile
  341. # This method is a simply wrapper and exists only for tracking purposes.
  342. ide.$scope.recompileViaKey = () ->
  343. $scope.recompile { keyShortcut: true }
  344. $scope.stop = () ->
  345. return if !$scope.pdf.compiling
  346. $http {
  347. url: "/project/#{$scope.project_id}/compile/stop"
  348. method: "POST"
  349. params:
  350. clsiserverid:ide.clsiServerId
  351. headers:
  352. "X-Csrf-Token": window.csrfToken
  353. }
  354. $scope.clearCache = () ->
  355. $http {
  356. url: "/project/#{$scope.project_id}/output"
  357. method: "DELETE"
  358. params:
  359. clsiserverid:ide.clsiServerId
  360. headers:
  361. "X-Csrf-Token": window.csrfToken
  362. }
  363. $scope.toggleLogs = () ->
  364. $scope.shouldShowLogs = !$scope.shouldShowLogs
  365. event_tracking.sendMBOnce "ide-open-logs-once" if $scope.shouldShowLogs
  366. $scope.showPdf = () ->
  367. $scope.pdf.view = "pdf"
  368. $scope.shouldShowLogs = false
  369. $scope.toggleRawLog = () ->
  370. $scope.pdf.showRawLog = !$scope.pdf.showRawLog
  371. event_tracking.sendMB "logs-view-raw" if $scope.pdf.showRawLog
  372. $scope.openClearCacheModal = () ->
  373. modalInstance = $modal.open(
  374. templateUrl: "clearCacheModalTemplate"
  375. controller: "ClearCacheModalController"
  376. scope: $scope
  377. )
  378. $scope.syncToCode = (position) ->
  379. synctex
  380. .syncToCode(position)
  381. .then (data) ->
  382. {doc, line} = data
  383. ide.editorManager.openDoc(doc, gotoLine: line)
  384. $scope.switchToFlatLayout = () ->
  385. $scope.ui.pdfLayout = 'flat'
  386. $scope.ui.view = 'pdf'
  387. ide.localStorage "pdf.layout", "flat"
  388. $scope.switchToSideBySideLayout = () ->
  389. $scope.ui.pdfLayout = 'sideBySide'
  390. $scope.ui.view = 'editor'
  391. localStorage "pdf.layout", "split"
  392. if pdfLayout = localStorage("pdf.layout")
  393. $scope.switchToSideBySideLayout() if pdfLayout == "split"
  394. $scope.switchToFlatLayout() if pdfLayout == "flat"
  395. else
  396. $scope.switchToSideBySideLayout()
  397. $scope.startFreeTrial = (source) ->
  398. ga?('send', 'event', 'subscription-funnel', 'compile-timeout', source)
  399. event_tracking.sendMB "subscription-start-trial", { source }
  400. window.open("/user/subscription/new?planCode=#{$scope.startTrialPlanCode}")
  401. $scope.startedFreeTrial = true
  402. App.factory "synctex", ["ide", "$http", "$q", (ide, $http, $q) ->
  403. # enable per-user containers by default
  404. perUserCompile = true
  405. synctex =
  406. syncToPdf: (cursorPosition) ->
  407. deferred = $q.defer()
  408. doc_id = ide.editorManager.getCurrentDocId()
  409. if !doc_id?
  410. deferred.reject()
  411. return deferred.promise
  412. doc = ide.fileTreeManager.findEntityById(doc_id)
  413. if !doc?
  414. deferred.reject()
  415. return deferred.promise
  416. path = ide.fileTreeManager.getEntityPath(doc)
  417. if !path?
  418. deferred.reject()
  419. return deferred.promise
  420. # If the root file is folder/main.tex, then synctex sees the
  421. # path as folder/./main.tex
  422. rootDocDirname = ide.fileTreeManager.getRootDocDirname()
  423. if rootDocDirname? and rootDocDirname != ""
  424. path = path.replace(RegExp("^#{rootDocDirname}"), "#{rootDocDirname}/.")
  425. {row, column} = cursorPosition
  426. $http({
  427. url: "/project/#{ide.project_id}/sync/code",
  428. method: "GET",
  429. params: {
  430. file: path
  431. line: row + 1
  432. column: column
  433. clsiserverid:ide.clsiServerId
  434. }
  435. })
  436. .success (data) ->
  437. deferred.resolve(data.pdf or [])
  438. .error (error) ->
  439. deferred.reject(error)
  440. return deferred.promise
  441. syncToCode: (position, options = {}) ->
  442. deferred = $q.defer()
  443. if !position?
  444. deferred.reject()
  445. return deferred.promise
  446. # FIXME: this actually works better if it's halfway across the
  447. # page (or the visible part of the page). Synctex doesn't
  448. # always find the right place in the file when the point is at
  449. # the edge of the page, it sometimes returns the start of the
  450. # next paragraph instead.
  451. h = position.offset.left
  452. # Compute the vertical position to pass to synctex, which
  453. # works with coordinates increasing from the top of the page
  454. # down. This matches the browser's DOM coordinate of the
  455. # click point, but the pdf position is measured from the
  456. # bottom of the page so we need to invert it.
  457. if options.fromPdfPosition and position.pageSize?.height?
  458. v = (position.pageSize.height - position.offset.top) or 0 # measure from pdf point (inverted)
  459. else
  460. v = position.offset.top or 0 # measure from html click position
  461. # It's not clear exactly where we should sync to if it wasn't directly
  462. # clicked on, but a little bit down from the very top seems best.
  463. if options.includeVisualOffset
  464. v += 72 # use the same value as in pdfViewer highlighting visual offset
  465. $http({
  466. url: "/project/#{ide.project_id}/sync/pdf",
  467. method: "GET",
  468. params: {
  469. page: position.page + 1
  470. h: h.toFixed(2)
  471. v: v.toFixed(2)
  472. clsiserverid:ide.clsiServerId
  473. }
  474. })
  475. .success (data) ->
  476. if data.code? and data.code.length > 0
  477. doc = ide.fileTreeManager.findEntityByPath(data.code[0].file)
  478. return if !doc?
  479. deferred.resolve({doc: doc, line: data.code[0].line})
  480. .error (error) ->
  481. deferred.reject(error)
  482. return deferred.promise
  483. return synctex
  484. ]
  485. App.controller "PdfSynctexController", ["$scope", "synctex", "ide", ($scope, synctex, ide) ->
  486. @cursorPosition = null
  487. ide.$scope.$on "cursor:editor:update", (event, @cursorPosition) =>
  488. $scope.syncToPdf = () =>
  489. return if !@cursorPosition?
  490. synctex
  491. .syncToPdf(@cursorPosition)
  492. .then (highlights) ->
  493. $scope.pdf.highlights = highlights
  494. $scope.syncToCode = () ->
  495. synctex
  496. .syncToCode($scope.pdf.position, includeVisualOffset: true, fromPdfPosition: true)
  497. .then (data) ->
  498. {doc, line} = data
  499. ide.editorManager.openDoc(doc, gotoLine: line)
  500. ]
  501. App.controller "PdfLogEntryController", ["$scope", "ide", "event_tracking", ($scope, ide, event_tracking) ->
  502. $scope.openInEditor = (entry) ->
  503. event_tracking.sendMBOnce "logs-jump-to-location-once"
  504. entity = ide.fileTreeManager.findEntityByPath(entry.file)
  505. return if !entity? or entity.type != "doc"
  506. if entry.line?
  507. line = entry.line
  508. if entry.column?
  509. column = entry.column
  510. ide.editorManager.openDoc(entity, gotoLine: line, gotoColumn: column)
  511. ]
  512. App.controller 'ClearCacheModalController', ["$scope", "$modalInstance", ($scope, $modalInstance) ->
  513. $scope.state =
  514. inflight: false
  515. $scope.clear = () ->
  516. $scope.state.inflight = true
  517. $scope
  518. .clearCache()
  519. .then () ->
  520. $scope.state.inflight = false
  521. $modalInstance.close()
  522. $scope.cancel = () ->
  523. $modalInstance.dismiss('cancel')
  524. ]