Recorder fix ui

pull/3094/head
yann300 7 years ago
parent f4fa44a982
commit 7714c01c96
  1. 59
      src/app/tabs/run-tab.js
  2. 2
      src/recorder.js

@ -177,6 +177,13 @@ var css = csjs`
.networkItem { .networkItem {
margin-right: 5px; margin-right: 5px;
} }
.clearinstance {
font-size: 20px;
cursor: pointer;
margin-right: 10px;
}
.transactionActions {
float: right;
` `
module.exports = runTab module.exports = runTab
@ -184,13 +191,26 @@ module.exports = runTab
var instanceContainer = yo`<div class="${css.instanceContainer}"></div>` var instanceContainer = yo`<div class="${css.instanceContainer}"></div>`
var noInstancesText = yo`<div class="${css.noInstancesText}">0 contract Instances</div>` var noInstancesText = yo`<div class="${css.noInstancesText}">0 contract Instances</div>`
var pendingTxsText = yo`<div class="${css.pendingTxsText}"></div>` var pendingTxsText = yo`<span></span>`
function runTab (container, appAPI, appEvents, opts) { function runTab (container, appAPI, appEvents, opts) {
var events = new EventManager() var events = new EventManager()
var clearInstanceElement = yo`<i class="fa fa-minus-square-o ${css.clearinstance}" title="Clear Instances List" aria-hidden="true"></i>`
clearInstanceElement.addEventListener('click', () => {
events.trigger('clearInstance', [])
})
var recorderInterface = makeRecorder(events, appAPI, appEvents)
var pendingTxsContainer = yo` var pendingTxsContainer = yo`
<div class="${css.pendingTxsContainer}"> <div class="${css.pendingTxsContainer}">
<div class="${css.pendingTxsText}">
${pendingTxsText} ${pendingTxsText}
<span class="${css.transactionActions}">
${clearInstanceElement}
${recorderInterface.recordButton}
${recorderInterface.runButton}
</span>
</div>
</div>` </div>`
var el = yo` var el = yo`
@ -216,7 +236,7 @@ function runTab (container, appAPI, appEvents, opts) {
// set the final context. Cause it is possible that this is not the one we've originaly selected // set the final context. Cause it is possible that this is not the one we've originaly selected
selectExEnv.value = executionContext.getProvider() selectExEnv.value = executionContext.getProvider()
fillAccountsList(appAPI, el) fillAccountsList(appAPI, el)
clearInstance() events.trigger('clearInstance', [])
}) })
}) })
selectExEnv.value = executionContext.getProvider() selectExEnv.value = executionContext.getProvider()
@ -226,12 +246,11 @@ function runTab (container, appAPI, appEvents, opts) {
updatePendingTxs(container, appAPI) updatePendingTxs(container, appAPI)
}, 500) }, 500)
var clearInstance = function () { events.register('clearInstance', () => {
instanceContainer.innerHTML = '' // clear the instances list instanceContainer.innerHTML = '' // clear the instances list
noInstancesText.style.display = 'block' noInstancesText.style.display = 'block'
instanceContainer.appendChild(noInstancesText) instanceContainer.appendChild(noInstancesText)
events.trigger('clearInstance', []) })
}
} }
function fillAccountsList (appAPI, container) { function fillAccountsList (appAPI, container) {
@ -275,29 +294,21 @@ function makeRecorder (events, appAPI, appEvents) {
}) })
var css2 = csjs` var css2 = csjs`
.container { .container {
margin: 10px;
display: flex;
justify-content: space-evenly;
width: 100%;
} }
.recorder { .recorder {
${styles.button} font-size: 20px;
width: 135px; cursor: pointer;
} }
.runTxs { .runTxs {
${styles.button}
margin-left: 10px; margin-left: 10px;
width: 135px; font-size: 20px;
cursor: pointer;
} }
` `
var recordButton = yo`<button class="${css.transaction} savetransaction">save transactions</button>`
var runButton = yo`<button class="${css.transaction} runtransaction">run transactions</button>` var recordButton = yo`<i class="fa fa-floppy-o savetransaction ${css2.recorder}" title="Save Transactions" aria-hidden="true"></i>`
var el = yo` var runButton = yo`<i class="fa fa-play runtransaction ${css2.runTxs}" title="Run Transactions" aria-hidden="true"></i>`
<div class=${css2.container}>
${recordButton}
${runButton}
</div>
`
recordButton.onclick = () => { recordButton.onclick = () => {
var txJSON = JSON.stringify(recorder.getAll(), null, 2) var txJSON = JSON.stringify(recorder.getAll(), null, 2)
var path = appAPI.currentPath() var path = appAPI.currentPath()
@ -335,10 +346,10 @@ function makeRecorder (events, appAPI, appEvents) {
}) })
} }
} else { } else {
modalDialogCustom.alert('Scenario File require JSON type') modalDialogCustom.alert('A Scenario File is required. The file must be of type JSON. Use the "Save Transactions" Button to generate a new Scenario File.')
} }
} }
return el return { recordButton, runButton }
} }
/* ------------------------------------------------ /* ------------------------------------------------
section CONTRACT DROPDOWN and BUTTONS section CONTRACT DROPDOWN and BUTTONS
@ -371,6 +382,7 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) {
return null return null
} }
appAPI.getSelectedContract = getSelectedContract appAPI.getSelectedContract = getSelectedContract
var el = yo` var el = yo`
<div class="${css.container}"> <div class="${css.container}">
<div class="${css.subcontainer}"> <div class="${css.subcontainer}">
@ -385,7 +397,6 @@ function contractDropdown (events, appAPI, appEvents, instanceContainer) {
${atAddressButtonInput} ${atAddressButtonInput}
<div class="${css.atAddress}" onclick=${function () { loadFromAddress(appAPI) }}>At Address</div> <div class="${css.atAddress}" onclick=${function () { loadFromAddress(appAPI) }}>At Address</div>
</div> </div>
<div class=${css.buttons}>${makeRecorder(events, appAPI, appEvents)}</div>
</div> </div>
</div> </div>
` `

@ -21,7 +21,7 @@ class Recorder {
opts.events.executioncontext.register('contextChanged', () => { opts.events.executioncontext.register('contextChanged', () => {
self.clearAll() self.clearAll()
}) })
opts.events.runtab.register('clearInstances', () => { opts.events.runtab.register('clearInstance', () => {
self.clearAll() self.clearAll()
}) })

Loading…
Cancel
Save