|
|
@@ -2,23 +2,56 @@
|
|
|
// the <dialog /> element out of index.html and just re-uses that - as only
|
|
|
// one dialog can be shown at a time.
|
|
|
export class ExecutionDialog {
|
|
|
- constructFromJson (json) {
|
|
|
+ show (json) {
|
|
|
this.executionUuid = json
|
|
|
|
|
|
this.dlg = document.querySelector('dialog#execution-results-popup')
|
|
|
|
|
|
- this.domIcon = this.dlg.querySelector('.icon')
|
|
|
- this.domTitle = this.dlg.querySelector('.title')
|
|
|
- this.domStdout = this.dlg.querySelector('.stdout')
|
|
|
- this.domStderr = this.dlg.querySelector('.stderr')
|
|
|
- this.domDatetimeStarted = this.dlg.querySelector('.datetimeStarted')
|
|
|
- this.domDatetimeFinished = this.dlg.querySelector('.datetimeFinished')
|
|
|
- this.domExitCode = this.dlg.querySelector('.exitCode')
|
|
|
- this.domStatus = this.dlg.querySelector('.status')
|
|
|
- }
|
|
|
+ this.domIcon = document.getElementById('execution-dialog-icon')
|
|
|
+ this.domTitle = document.getElementById('execution-dialog-title')
|
|
|
+ this.domStdout = document.getElementById('execution-dialog-stdout')
|
|
|
+ this.domStderr = document.getElementById('execution-dialog-stderr')
|
|
|
+ this.domDatetimeStarted = document.getElementById('execution-dialog-datetime-started')
|
|
|
+ this.domDatetimeFinished = document.getElementById('execution-dialog-datetime-finished')
|
|
|
+ this.domExitCode = document.getElementById('execution-dialog-exit-code')
|
|
|
+ this.domStatus = document.getElementById('execution-dialog-status')
|
|
|
+
|
|
|
+ this.domTitle.innerText = 'Loading...'
|
|
|
+ this.domExitCode.innerText = '?'
|
|
|
+ this.domStatus.className = ''
|
|
|
+ this.domDatetimeStarted.innerText = ''
|
|
|
+ this.domDatetimeFinished.innerText = ''
|
|
|
+ this.domStdout.innerText = ''
|
|
|
+ this.domStderr.innerText = ''
|
|
|
|
|
|
- show () {
|
|
|
this.dlg.showModal()
|
|
|
+
|
|
|
+ this.fetchExecutionResult()
|
|
|
+ }
|
|
|
+
|
|
|
+ fetchExecutionResult () {
|
|
|
+ const executionStatusArgs = {
|
|
|
+ executionUuid: this.executionUuid
|
|
|
+ }
|
|
|
+
|
|
|
+ window.fetch(window.restBaseUrl + 'ExecutionStatus', {
|
|
|
+ method: 'POST',
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ },
|
|
|
+ body: JSON.stringify(executionStatusArgs)
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.ok) {
|
|
|
+ return res.json()
|
|
|
+ } else {
|
|
|
+ throw new Error(res.statusText)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ).then((json) => {
|
|
|
+ this.renderResult(json)
|
|
|
+ }).catch(err => {
|
|
|
+ this.renderError(err)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
renderResult (res) {
|
|
|
@@ -26,15 +59,18 @@ export class ExecutionDialog {
|
|
|
|
|
|
if (res.logEntry.executionFinished) {
|
|
|
this.domStatus.innerText = 'Completed'
|
|
|
+ this.domStatus.classList.add('action-success')
|
|
|
this.domDatetimeFinished.innerText = res.logEntry.datetimeFinished
|
|
|
|
|
|
- if (res.logEntry.blocked) {
|
|
|
- this.domStatus.innerText = 'Blocked'
|
|
|
- }
|
|
|
-
|
|
|
if (res.logEntry.timedOut) {
|
|
|
this.domExitCode.innerText = 'Timed out'
|
|
|
- this.domStatus.innerText = 'Timed out'
|
|
|
+ this.domStatus.classList.add('action-timeout')
|
|
|
+ } else if (res.logEntry.blocked) {
|
|
|
+ this.domStatus.innerText = 'Blocked'
|
|
|
+ this.domStatus.classList.add('action-blocked')
|
|
|
+ } else if (res.logEntry.exitCode !== 0) {
|
|
|
+ this.domStatus.innerText = 'Non-Zero Exit'
|
|
|
+ this.domStatus.classList.add('action-nonzero-exit')
|
|
|
} else {
|
|
|
this.domExitCode.innerText = res.logEntry.exitCode
|
|
|
}
|
|
|
@@ -47,13 +83,14 @@ export class ExecutionDialog {
|
|
|
this.domIcon.innerHTML = res.logEntry.actionIcon
|
|
|
this.domTitle.innerText = res.logEntry.actionTitle
|
|
|
|
|
|
+ this.domStdout.innerText = res.logEntry.stdout
|
|
|
this.domStdout.innerText = res.logEntry.stdout
|
|
|
|
|
|
if (res.logEntry.stderr === '') {
|
|
|
- this.domStderr.parentElement.hidden = true
|
|
|
+ this.domStderr.parentElement.style.display = 'none'
|
|
|
this.domStderr.innerText = res.logEntry.stderr
|
|
|
} else {
|
|
|
- this.domStderr.parentElement.hidden = false
|
|
|
+ this.domStderr.parentElement.style.display = 'block'
|
|
|
this.domStderr.innerText = res.logEntry.stderr
|
|
|
}
|
|
|
|