Wiki source code of WikiCreationJobStatusService
Last modified by shahzad kazama on 2023/12/18 18:57
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{velocity}} | ||
| 2 | #if($xcontext.action == 'get' && "$!{request.outputSyntax}" == 'plain') | ||
| 3 | #set($wikiId = $request.wikiId) | ||
| 4 | #set($status = $services.wiki.creationjob.getJobStatus($wikiId)) | ||
| 5 | #set($lastError = $status.logTail.getLastLogEvent('ERROR')) | ||
| 6 | #set($hasErrorLog = false) | ||
| 7 | #if ($lastError) | ||
| 8 | #set($hasErrorLog = true) | ||
| 9 | #end | ||
| 10 | #set($errorMessage = "") | ||
| 11 | #if ($status.error) | ||
| 12 | ## The last error log is what actually stopped the job | ||
| 13 | #set($errorMessage = $lastError.getFormattedMessage()) | ||
| 14 | #end | ||
| 15 | ## Log | ||
| 16 | #template('logging_macros.vm') | ||
| 17 | #template('extension.vm') | ||
| 18 | ## Hack to be able to use macros from extension.vm that are supposed to be used inside Extension Manager | ||
| 19 | #set ($olddoc = $doc) | ||
| 20 | #set ($doc = $xwiki.getDocument('XWiki.AddExtensions')) | ||
| 21 | ## Note: it's important for the state to be the same when calling `printLogs` and for the `status` field of $map, | ||
| 22 | ## otherwise if the state is changed to FINISHED while `printLogs` is called, a spinner will be displayed on the last | ||
| 23 | ## item, even tough the job is finished. | ||
| 24 | #set ($state = $status.state) | ||
| 25 | #set ($loading = $state != 'FINISHED') | ||
| 26 | #set ($logs = "#printLogs($status.logTail $loading)") | ||
| 27 | #set ($doc = $olddoc) | ||
| 28 | #set ($map = { | ||
| 29 | 'wikiId': $wikiId, | ||
| 30 | 'progress': $status.progress.offset, | ||
| 31 | 'status': $state, | ||
| 32 | 'error': $errorMessage, | ||
| 33 | 'hasErrorLog': $hasErrorLog, | ||
| 34 | 'logs': $logs | ||
| 35 | }) | ||
| 36 | #jsonResponse($map) | ||
| 37 | #end | ||
| 38 | {{/velocity}} |