feature: Allow rendering output as HTML (#544)
This commit is contained in:
parent
8d4e335dda
commit
709d6ac2ad
|
|
@ -77,10 +77,13 @@ func getActionID(action *Action) string {
|
||||||
return action.ID
|
return action.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gocyclo:ignore
|
||||||
func sanitizePopupOnStart(raw string, cfg *Config) string {
|
func sanitizePopupOnStart(raw string, cfg *Config) string {
|
||||||
switch raw {
|
switch raw {
|
||||||
case "execution-dialog":
|
case "execution-dialog":
|
||||||
return raw
|
return raw
|
||||||
|
case "execution-dialog-output-html":
|
||||||
|
return raw
|
||||||
case "execution-dialog-stdout-only":
|
case "execution-dialog-stdout-only":
|
||||||
return raw
|
return raw
|
||||||
case "execution-button":
|
case "execution-button":
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id = "execution-dialog-xterm"></div>
|
<div id = "execution-dialog-xterm"></div>
|
||||||
|
<div id = "execution-dialog-output-html" class = "padded-content"></div>
|
||||||
|
|
||||||
<div class = "buttons padded-content">
|
<div class = "buttons padded-content">
|
||||||
<button name = "rerun" title = "Rerun" id = "execution-dialog-rerun-action">Rerun</button>
|
<button name = "rerun" title = "Rerun" id = "execution-dialog-rerun-action">Rerun</button>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export class ExecutionDialog {
|
||||||
this.domIcon = document.getElementById('execution-dialog-icon')
|
this.domIcon = document.getElementById('execution-dialog-icon')
|
||||||
this.domTitle = document.getElementById('execution-dialog-title')
|
this.domTitle = document.getElementById('execution-dialog-title')
|
||||||
this.domOutput = document.getElementById('execution-dialog-xterm')
|
this.domOutput = document.getElementById('execution-dialog-xterm')
|
||||||
|
this.domOutputHtml = document.getElementById('execution-dialog-output-html')
|
||||||
this.domOutputToggleBig = document.getElementById('execution-dialog-toggle-size')
|
this.domOutputToggleBig = document.getElementById('execution-dialog-toggle-size')
|
||||||
this.domOutputToggleBig.onclick = () => {
|
this.domOutputToggleBig.onclick = () => {
|
||||||
this.toggleSize()
|
this.toggleSize()
|
||||||
|
|
@ -197,7 +198,17 @@ export class ExecutionDialog {
|
||||||
|
|
||||||
clearInterval(window.executionDialogTicker)
|
clearInterval(window.executionDialogTicker)
|
||||||
|
|
||||||
this.domOutput.hidden = false
|
if ("type" in res && res.type == "execution-dialog-output-html") {
|
||||||
|
this.domOutputHtml.hidden = false
|
||||||
|
this.domOutput.hidden = true
|
||||||
|
this.domOutputHtml.innerHTML = res.logEntry.output
|
||||||
|
this.domOutputHtml.hidden = false
|
||||||
|
this.hideDetailsonResult = true
|
||||||
|
} else {
|
||||||
|
this.domOutput.hidden = false
|
||||||
|
this.domOutputHtml.innerHTML = ''
|
||||||
|
this.domOutputHtml.hidden = true
|
||||||
|
}
|
||||||
|
|
||||||
if (this.hideDetailsOnResult) {
|
if (this.hideDetailsOnResult) {
|
||||||
this.domExecutionDetails.hidden = true
|
this.domExecutionDetails.hidden = true
|
||||||
|
|
@ -218,6 +229,7 @@ export class ExecutionDialog {
|
||||||
|
|
||||||
this.updateDuration(res.logEntry)
|
this.updateDuration(res.logEntry)
|
||||||
|
|
||||||
|
|
||||||
window.terminal.reset()
|
window.terminal.reset()
|
||||||
window.terminal.write(res.logEntry.output, () => {
|
window.terminal.write(res.logEntry.output, () => {
|
||||||
window.terminal.fit()
|
window.terminal.fit()
|
||||||
|
|
|
||||||
|
|
@ -158,28 +158,31 @@ function onExecutionFinished (evt) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let feedbackButton = actionButton;
|
||||||
|
|
||||||
switch (actionButton.popupOnStart) {
|
switch (actionButton.popupOnStart) {
|
||||||
case 'execution-button':
|
case 'execution-button':
|
||||||
if (document.querySelector('execution-button#execution-' + logEntry.executionTrackingId) !== null) { // If the button was created in our instance
|
let executionButton = document.querySelector('execution-button#execution-' + logEntry.executionTrackingId)
|
||||||
document.querySelector('execution-button#execution-' + logEntry.executionTrackingId).onExecutionFinished(logEntry)
|
|
||||||
}
|
if (executionButton != null) {
|
||||||
|
feedbackButton = executionButton
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
|
case 'execution-dialog-output-html':
|
||||||
case 'execution-dialog-stdout-only':
|
case 'execution-dialog-stdout-only':
|
||||||
case 'execution-dialog':
|
case 'execution-dialog':
|
||||||
actionButton.onExecutionFinished(logEntry)
|
|
||||||
|
|
||||||
// We don't need to fetch the logEntry for the dialog because we already
|
// We don't need to fetch the logEntry for the dialog because we already
|
||||||
// have it, so we open the dialog and it will get updated below.
|
// have it, so we open the dialog and it will get updated below.
|
||||||
|
|
||||||
window.executionDialog.show()
|
window.executionDialog.show()
|
||||||
window.executionDialog.executionTrackingId = logEntry.uuid
|
window.executionDialog.executionTrackingId = logEntry.uuid
|
||||||
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
actionButton.onExecutionFinished(logEntry)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
feedbackButton.onExecutionFinished(logEntry)
|
||||||
|
|
||||||
marshalLogsJsonToHtml({
|
marshalLogsJsonToHtml({
|
||||||
logs: [logEntry]
|
logs: [logEntry]
|
||||||
})
|
})
|
||||||
|
|
@ -187,7 +190,8 @@ function onExecutionFinished (evt) {
|
||||||
// If the current execution dialog is open, update that too
|
// If the current execution dialog is open, update that too
|
||||||
if (window.executionDialog.dlg.open && window.executionDialog.executionUuid === logEntry.uuid) {
|
if (window.executionDialog.dlg.open && window.executionDialog.executionUuid === logEntry.uuid) {
|
||||||
window.executionDialog.renderExecutionResult({
|
window.executionDialog.renderExecutionResult({
|
||||||
logEntry: logEntry
|
logEntry: logEntry,
|
||||||
|
type: actionButton.popupOnStart,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue