mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-13 01:25:45 +00:00
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
export class ActionStatusDisplay {
|
|
constructor (parentElement) {
|
|
this.exitCodeElement = document.createElement('span')
|
|
this.statusElement = document.createElement('span')
|
|
this.statusElement.innerText = 'unknown'
|
|
|
|
parentElement.innerText = ''
|
|
parentElement.appendChild(this.statusElement)
|
|
parentElement.appendChild(this.exitCodeElement)
|
|
}
|
|
|
|
getText () {
|
|
return this.statusElement.innerText
|
|
}
|
|
|
|
update (logEntry) {
|
|
this.statusElement.classList.remove(...this.statusElement.classList)
|
|
this.statusElement.classList.add('action-status')
|
|
|
|
if (logEntry.executionFinished) {
|
|
this.statusElement.innerText = 'Completed'
|
|
this.exitCodeElement.innerText = ' Exit code: ' + logEntry.exitCode
|
|
|
|
if (logEntry.exitCode === 0) {
|
|
this.statusElement.classList.add('action-success')
|
|
} else if (logEntry.blocked) {
|
|
this.statusElement.innerText = 'Blocked'
|
|
this.statusElement.classList.add('action-blocked')
|
|
this.exitCodeElement.innerText = ''
|
|
} else if (logEntry.timedOut) {
|
|
this.statusElement.innerText = 'Timed out'
|
|
this.statusElement.classList.add('action-timeout')
|
|
this.exitCodeElement.innerText = ''
|
|
} else {
|
|
this.statusElement.classList.add('action-nonzero-exit')
|
|
}
|
|
} else {
|
|
this.statusElement.innerText = 'Still running...'
|
|
this.exitCodeElement.innerText = ''
|
|
}
|
|
}
|
|
}
|