Bringing up to date with head
This commit is contained in:
parent
8ecaf33b1a
commit
fd04922e59
|
|
@ -51,6 +51,7 @@
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<template id = "tplArgumentForm">
|
<template id = "tplArgumentForm">
|
||||||
|
<form>
|
||||||
<div class = "wrapper">
|
<div class = "wrapper">
|
||||||
<div>
|
<div>
|
||||||
<span class = "icon" role = "icon"></span>
|
<span class = "icon" role = "icon"></span>
|
||||||
|
|
@ -64,11 +65,14 @@
|
||||||
<button name = "cancel">Cancel</button>
|
<button name = "cancel">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id = "tplActionButton">
|
<template id = "tplActionButton">
|
||||||
<span role = "icon" title = "button icon" class = "icon">💩</span>
|
<button>
|
||||||
|
<span role = "img" title = "button icon" class = "icon">💩</span>
|
||||||
<p role = "title" class = "title">Untitled Button</p>
|
<p role = "title" class = "title">Untitled Button</p>
|
||||||
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id = "tplLogRow">
|
<template id = "tplLogRow">
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,18 @@
|
||||||
import { marshalLogsJsonToHtml } from './marshaller.js'
|
import { marshalLogsJsonToHtml } from './marshaller.js'
|
||||||
import './ArgumentForm.js'
|
import './ArgumentForm.js'
|
||||||
|
|
||||||
class ActionButton extends window.HTMLButtonElement {
|
class ActionButton extends window.HTMLElement {
|
||||||
constructFromJson (json) {
|
constructFromJson (json) {
|
||||||
this.updateIterationTimestamp = 0
|
this.updateIterationTimestamp = 0
|
||||||
|
|
||||||
this.title = json.title
|
this.constructDomFromTemplate()
|
||||||
|
|
||||||
|
// DOM Attributes
|
||||||
|
this.btn.title = json.title
|
||||||
|
this.btn.onclick = () => { this.startAction() }
|
||||||
|
|
||||||
|
// Class attributes
|
||||||
|
this.actionCallUrl = window.restBaseUrl + 'StartAction?actionName=' + json.title
|
||||||
this.temporaryStatusMessage = null
|
this.temporaryStatusMessage = null
|
||||||
this.isWaiting = false
|
this.isWaiting = false
|
||||||
this.actionCallUrl = window.restBaseUrl + 'StartAction'
|
this.actionCallUrl = window.restBaseUrl + 'StartAction'
|
||||||
|
|
@ -28,6 +35,12 @@ class ActionButton extends window.HTMLButtonElement {
|
||||||
this.constructTemplate()
|
this.constructTemplate()
|
||||||
|
|
||||||
this.updateHtml()
|
this.updateHtml()
|
||||||
|
=======
|
||||||
|
|
||||||
|
this.updateFromJson(json)
|
||||||
|
|
||||||
|
this.updateDom()
|
||||||
|
>>>>>>> 40cfb1f (progress so far)
|
||||||
|
|
||||||
this.setAttribute('id', 'actionButton_' + json.id)
|
this.setAttribute('id', 'actionButton_' + json.id)
|
||||||
}
|
}
|
||||||
|
|
@ -47,10 +60,10 @@ class ActionButton extends window.HTMLButtonElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
startAction (actionArgs) {
|
startAction (actionArgs) {
|
||||||
this.disabled = true
|
this.btn.disabled = true
|
||||||
this.isWaiting = true
|
this.isWaiting = true
|
||||||
this.updateHtml()
|
this.updateDom()
|
||||||
this.classList = [] // Removes old animation classes
|
this.btn.classList = [] // Removes old animation classes
|
||||||
|
|
||||||
if (actionArgs === undefined) {
|
if (actionArgs === undefined) {
|
||||||
actionArgs = []
|
actionArgs = []
|
||||||
|
|
@ -93,27 +106,27 @@ class ActionButton extends window.HTMLButtonElement {
|
||||||
|
|
||||||
onActionResult (cssClass, temporaryStatusMessage) {
|
onActionResult (cssClass, temporaryStatusMessage) {
|
||||||
this.temporaryStatusMessage = '[ ' + temporaryStatusMessage + ' ]'
|
this.temporaryStatusMessage = '[ ' + temporaryStatusMessage + ' ]'
|
||||||
this.updateHtml()
|
this.updateDom()
|
||||||
this.classList.add(cssClass)
|
this.btn.classList.add(cssClass)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.classList.remove(cssClass)
|
this.btn.classList.remove(cssClass)
|
||||||
}, 1000)
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
onActionError (err) {
|
onActionError (err) {
|
||||||
console.log('callback error', err)
|
console.log('callback error', err)
|
||||||
this.disabled = false
|
this.btn.disabled = false
|
||||||
this.isWaiting = false
|
this.isWaiting = false
|
||||||
this.updateHtml()
|
this.updateDom()
|
||||||
this.classList.add('actionFailed')
|
this.btn.classList.add('actionFailed')
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.classList.remove('actionFailed')
|
this.btn.classList.remove('actionFailed')
|
||||||
}, 1000)
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructTemplate () {
|
constructDomFromTemplate () {
|
||||||
const tpl = document.getElementById('tplActionButton')
|
const tpl = document.getElementById('tplActionButton')
|
||||||
const content = tpl.content.cloneNode(true)
|
const content = tpl.content.cloneNode(true)
|
||||||
|
|
||||||
|
|
@ -124,11 +137,14 @@ class ActionButton extends window.HTMLButtonElement {
|
||||||
|
|
||||||
this.appendChild(content)
|
this.appendChild(content)
|
||||||
|
|
||||||
this.domTitle = this.querySelector('.title')
|
this.btn = this.querySelector('button')
|
||||||
this.domIcon = this.querySelector('.icon')
|
this.domTitle = this.btn.querySelector('.title')
|
||||||
|
this.domIcon = this.btn.querySelector('.icon')
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHtml () {
|
updateDom () {
|
||||||
|
console.log(this.querySelector("button"))
|
||||||
|
|
||||||
if (this.temporaryStatusMessage != null) {
|
if (this.temporaryStatusMessage != null) {
|
||||||
this.domTitle.innerText = this.temporaryStatusMessage
|
this.domTitle.innerText = this.temporaryStatusMessage
|
||||||
this.domTitle.classList.add('temporaryStatusMessage')
|
this.domTitle.classList.add('temporaryStatusMessage')
|
||||||
|
|
@ -138,16 +154,16 @@ class ActionButton extends window.HTMLButtonElement {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.temporaryStatusMessage = null
|
this.temporaryStatusMessage = null
|
||||||
this.domTitle.classList.remove('temporaryStatusMessage')
|
this.domTitle.classList.remove('temporaryStatusMessage')
|
||||||
this.updateHtml()
|
this.updateDom()
|
||||||
}, 2000)
|
}, 2000)
|
||||||
} else if (this.isWaiting) {
|
} else if (this.isWaiting) {
|
||||||
this.domTitle.innerText = 'Waiting...'
|
this.domTitle.innerText = 'Waiting...'
|
||||||
} else {
|
} else {
|
||||||
this.domTitle.innerText = this.title
|
this.domTitle.innerText = this.btn.title
|
||||||
}
|
}
|
||||||
|
|
||||||
this.domIcon.innerHTML = this.unicodeIcon
|
this.domIcon.innerHTML = this.unicodeIcon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.customElements.define('action-button', ActionButton, { extends: 'button' })
|
window.customElements.define('action-button', ActionButton)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
class ArgumentForm extends window.HTMLFormElement {
|
class ArgumentForm extends window.HTMLElement {
|
||||||
setup (json, callback) {
|
setup (json, callback) {
|
||||||
this.setAttribute('class', 'actionArguments')
|
this.setAttribute('class', 'actionArguments')
|
||||||
|
|
||||||
|
|
@ -140,4 +140,4 @@ class ArgumentForm extends window.HTMLFormElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.customElements.define('argument-form', ArgumentForm, { extends: 'form' })
|
window.customElements.define('argument-form', ArgumentForm)
|
||||||
|
|
|
||||||
|
|
@ -7,21 +7,22 @@ export function marshalActionButtonsJsonToHtml (json) {
|
||||||
let htmlButton = document.querySelector('#actionButton_' + jsonButton.id)
|
let htmlButton = document.querySelector('#actionButton_' + jsonButton.id)
|
||||||
|
|
||||||
if (htmlButton == null) {
|
if (htmlButton == null) {
|
||||||
htmlButton = document.createElement('button', { is: 'action-button' })
|
htmlButton = document.createElement('action-button')
|
||||||
htmlButton.constructFromJson(jsonButton)
|
htmlButton.constructFromJson(jsonButton)
|
||||||
|
|
||||||
document.getElementById('rootGroup').appendChild(htmlButton)
|
document.getElementById('rootGroup').appendChild(htmlButton)
|
||||||
} else {
|
} else {
|
||||||
htmlButton.updateFromJson(jsonButton)
|
htmlButton.updateFromJson(jsonButton)
|
||||||
htmlButton.updateHtml()
|
htmlButton.updateDom()
|
||||||
}
|
}
|
||||||
|
|
||||||
htmlButton.updateIterationTimestamp = currentIterationTimestamp
|
htmlButton.updateIterationTimestamp = currentIterationTimestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const existingButton of document.querySelector('#contentActions').querySelectorAll('button')) {
|
// Remove existing, but stale buttons (that were not updated in this round)
|
||||||
if (existingButton.updateIterationTimestamp !== currentIterationTimestamp) {
|
for (const existingButton of document.querySelector('#contentActions').querySelectorAll('action-button')) {
|
||||||
existingButton.remove()
|
if (existingButton.updateIterationTimestamp != currentIterationTimestamp) {
|
||||||
|
existingButton.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,33 @@ fieldset#rootGroup {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset#switcher {
|
||||||
|
border: 0;
|
||||||
|
text-align: right;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset#switcher button {
|
||||||
|
padding: 1em;
|
||||||
|
color: black;
|
||||||
|
display: table-cell;
|
||||||
|
text-align: center;
|
||||||
|
border: 1px solid #999;
|
||||||
|
background-color: white;
|
||||||
|
box-shadow: 0 0 6px 0 #aaa;
|
||||||
|
user-select: none;
|
||||||
|
background-color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset#switcher button:first-child{
|
||||||
|
border-radius: 1em 0em 0em 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset#switcher button:last-child{
|
||||||
|
border-radius: 0 1em 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
|
@ -94,7 +121,6 @@ button,
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
color: black;
|
color: black;
|
||||||
display: table-cell;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border: 1px solid #999;
|
border: 1px solid #999;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue