Files
OliveTin/webui.dev/js/ExecutionButton.js
2024-02-23 23:52:41 +00:00

35 lines
880 B
JavaScript

import { ExecutionFeedbackButton } from './ExecutionFeedbackButton.js'
class ExecutionButton extends ExecutionFeedbackButton {
constructFromJson (json) {
this.executionTrackingId = json
this.ellapsed = 0
this.appendChild(document.createElement('button'))
this.isWaiting = true
this.setAttribute('id', 'execution-' + json)
this.btn = this.querySelector('button')
this.btn.innerText = 'Executing...'
this.btn.onclick = () => {
this.show()
}
this.domTitle = this.btn
}
show () {
window.executionDialog.reset()
window.executionDialog.show()
window.executionDialog.fetchExecutionResult(this.executionTrackingId)
}
onExecStatusChanged () {
this.domTitle.innerText = this.ellapsed + 's'
this.btn.title = this.ellapsed + ' seconds'
}
}
window.customElements.define('execution-button', ExecutionButton)