mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-15 18:45:33 +00:00
Msot recent execution output on the dashboard. (#238)
* feature: Support for most recent action output on dashboard * feature: Support for most recent action output on dashboard
This commit is contained in:
@@ -199,6 +199,50 @@ function marshalLink (item, fieldset) {
|
||||
fieldset.appendChild(btn)
|
||||
}
|
||||
|
||||
function marshalMreOutput (dashboardComponent, fieldset) {
|
||||
const pre = document.createElement('pre')
|
||||
pre.classList.add('mre-output')
|
||||
pre.innerHTML = 'Waiting...'
|
||||
|
||||
const executionStatus = {
|
||||
actionId: dashboardComponent.title
|
||||
}
|
||||
|
||||
window.fetch(window.restBaseUrl + 'ExecutionStatus', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(executionStatus)
|
||||
}).then((res) => {
|
||||
if (res.ok) {
|
||||
return res.json()
|
||||
} else {
|
||||
pre.innerHTML = 'error'
|
||||
|
||||
throw new Error(res.statusText)
|
||||
}
|
||||
}).then((json) => {
|
||||
updateMre(pre, json.logEntry)
|
||||
})
|
||||
|
||||
const updateMre = (pre, json) => {
|
||||
pre.innerHTML = json.stdout
|
||||
}
|
||||
|
||||
window.addEventListener('ExecutionFinished', (e) => {
|
||||
// The dashboard component "title" field is used for lots of things
|
||||
// and in this context for MreOutput it's just to refer an an actionId.
|
||||
//
|
||||
// So this is not a typo.
|
||||
if (e.payload.actionId === dashboardComponent.title) {
|
||||
updateMre(pre, e.payload)
|
||||
}
|
||||
})
|
||||
|
||||
fieldset.appendChild(pre)
|
||||
}
|
||||
|
||||
function marshalContainerContents (json, section, fieldset, parentDashboard) {
|
||||
for (const item of json.contents) {
|
||||
switch (item.type) {
|
||||
@@ -212,6 +256,9 @@ function marshalContainerContents (json, section, fieldset, parentDashboard) {
|
||||
case 'display':
|
||||
marshalDisplay(item, fieldset)
|
||||
break
|
||||
case 'stdout-most-recent-execution':
|
||||
marshalMreOutput(item, fieldset)
|
||||
break
|
||||
case 'link':
|
||||
marshalLink(item, fieldset)
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user