From c3c010443f5dc9c81372baece2bc64ebe0023a81 Mon Sep 17 00:00:00 2001 From: James Read Date: Sun, 17 Dec 2023 04:19:48 +0000 Subject: [PATCH] feature: Better UI for execution buttons (#195) --- webui/index.html | 3 --- webui/js/ActionButton.js | 4 +--- webui/js/ExecutionButton.js | 18 +++++---------- webui/style.css | 45 ++++++++++++++++--------------------- 4 files changed, 26 insertions(+), 44 deletions(-) diff --git a/webui/index.html b/webui/index.html index 0a9cc26..60f7324 100644 --- a/webui/index.html +++ b/webui/index.html @@ -143,9 +143,6 @@ diff --git a/webui/js/ActionButton.js b/webui/js/ActionButton.js index 92f8315..889eed4 100644 --- a/webui/js/ActionButton.js +++ b/webui/js/ActionButton.js @@ -85,9 +85,7 @@ class ActionButton extends window.HTMLElement { const btnExecution = document.createElement('execution-button') btnExecution.constructFromJson(startActionArgs.uuid) - this.querySelector('.executions').appendChild(btnExecution) - - this.querySelector('summary').innerText = (this.querySelector('.executions').children.length - 1) + ' executions.' + this.querySelector('.action-button-footer').prepend(btnExecution) window.fetch(this.actionCallUrl, { method: 'POST', diff --git a/webui/js/ExecutionButton.js b/webui/js/ExecutionButton.js index a05aa3f..6f7b33d 100644 --- a/webui/js/ExecutionButton.js +++ b/webui/js/ExecutionButton.js @@ -3,6 +3,7 @@ import { ExecutionDialog } from './ExecutionDialog.js' class ExecutionButton extends window.HTMLElement { constructFromJson (json) { this.executionUuid = json + this.ellapsed = 0 this.appendChild(document.createElement('button')) this.isWaiting = true @@ -56,30 +57,23 @@ class ExecutionButton extends window.HTMLElement { } else if (LogEntry.exitCode !== 0) { this.onActionResult('action-nonzero-exit', 'Exit code ' + LogEntry.exitCode) } else { + console.log(LogEntry) + this.ellapsed = Math.ceil(new Date(LogEntry.datetimeFinished) - new Date(LogEntry.datetimeStarted)) / 1000 this.onActionResult('action-success', 'Success!') } } onActionResult (cssClass, temporaryStatusMessage) { - this.temporaryStatusMessage = '[ ' + temporaryStatusMessage + ' ]' + this.temporaryStatusMessage = '[' + temporaryStatusMessage + ']' this.updateDom() this.btn.classList.add(cssClass) - - setTimeout(() => { - this.btn.classList.remove(cssClass) - }, 1000) } onActionError (err) { console.error('callback error', err) - this.btn.disabled = false this.isWaiting = false this.updateDom() this.btn.classList.add('action-failed') - - setTimeout(() => { - this.btn.classList.remove('action-failed') - }, 1000) } updateDom () { @@ -87,7 +81,6 @@ class ExecutionButton extends window.HTMLElement { this.btn.innerText = this.temporaryStatusMessage this.btn.classList.add('temporary-status-message') this.isWaiting = false - this.disabled = false setTimeout(() => { this.temporaryStatusMessage = null @@ -97,7 +90,8 @@ class ExecutionButton extends window.HTMLElement { } else if (this.isWaiting) { this.btn.innerText = 'Waiting...' } else { - this.btn.innerText = 'Finished' + this.btn.innerText = this.ellapsed + 's' + this.btn.title = this.ellapsed + ' seconds' } } } diff --git a/webui/style.css b/webui/style.css index 82a06aa..b44a41b 100644 --- a/webui/style.css +++ b/webui/style.css @@ -226,15 +226,22 @@ action-button details summary div span:first-child { } .action-button-footer { - display: block; + display: flex; text-align: left; font-size: smaller; - padding: 0.2em; background-color: #efefef; border-top: 0; border-left: 1px solid #666; border-right: 1px solid #666; border-bottom: 1px solid #666; + overflow: scroll; +} + +execution-button { + display: inline-block; + margin-right: .2em; + margin-left: .2em; + margin-top: .2em; } execution-button button { @@ -266,43 +273,29 @@ input[type="submit"]:disabled { /* Button animations */ .action-failed { - animation: kf-action-failed 1s; -} - -@keyframes kf-action-failed { - 20% { background-color: red; } + transition: 1s; + background-color: red; } .action-success { - animation: kf-action-success 1s; -} - -@keyframes kf-action-success { - 20% { background-color: limegreen; } + transition: 1s; + background-color: limegreen; } .action-nonzero-exit { animation: kf-action-nonzero-exit 1s; -} - -@keyframes kf-action-nonzero-exit { - 20% { background-color: orange; } + transition: 1s; + background-color: orange; } .action-timeout { - animation: kf-action-timeout 1s; -} - -@keyframes kf-action-timeout { - 20% { background-color: cyan; } + transition: 1s; + background-color: cyan; } .action-blocked { - animation: kf-action-blocked 1s; -} - -@keyframes kf-action-blocked { - 20% { background-color: purple; } + transition: 1s; + background-color: purple; } img.logo {