add clear button

pull/1/head
yann300 7 years ago
parent 08cbeaa41a
commit ece69c52f4
  1. 25
      src/app/tabs/run-tab.js
  2. 3
      src/recorder.js

@ -9,6 +9,7 @@ var modalDialogCustom = require('../ui/modal-dialog-custom')
var executionContext = require('../../execution-context') var executionContext = require('../../execution-context')
var copyToClipboard = require('../ui/copy-to-clipboard') var copyToClipboard = require('../ui/copy-to-clipboard')
var Recorder = require('../../recorder') var Recorder = require('../../recorder')
var EventManager = require('remix-lib').EventManager
// -------------- styling ---------------------- // -------------- styling ----------------------
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
@ -172,6 +173,7 @@ var noInstancesText = yo`<div class="${css.noInstancesText}">0 contract Instance
var pendingTxsText = yo`<div class="${css.pendingTxsText}"></div>` var pendingTxsText = yo`<div class="${css.pendingTxsText}"></div>`
function runTab (container, appAPI, appEvents, opts) { function runTab (container, appAPI, appEvents, opts) {
var events = new EventManager()
var pendingTxsContainer = yo` var pendingTxsContainer = yo`
<div class="${css.pendingTxsContainer}"> <div class="${css.pendingTxsContainer}">
${pendingTxsText} ${pendingTxsText}
@ -180,7 +182,7 @@ function runTab (container, appAPI, appEvents, opts) {
var el = yo` var el = yo`
<div class="${css.runTabView}" id="runTabView"> <div class="${css.runTabView}" id="runTabView">
${settings(appAPI, appEvents)} ${settings(appAPI, appEvents)}
${contractDropdown(appAPI, appEvents, instanceContainer)} ${contractDropdown(events, appAPI, appEvents, instanceContainer)}
${pendingTxsContainer} ${pendingTxsContainer}
${instanceContainer} ${instanceContainer}
</div> </div>
@ -200,11 +202,8 @@ 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()
}) })
instanceContainer.innerHTML = '' // clear the instances list
noInstancesText.style.display = 'block'
instanceContainer.appendChild(noInstancesText)
}) })
selectExEnv.value = executionContext.getProvider() selectExEnv.value = executionContext.getProvider()
fillAccountsList(appAPI, el) fillAccountsList(appAPI, el)
@ -212,6 +211,13 @@ function runTab (container, appAPI, appEvents, opts) {
updateAccountBalances(container, appAPI) updateAccountBalances(container, appAPI)
updatePendingTxs(container, appAPI) updatePendingTxs(container, appAPI)
}, 500) }, 500)
var clearInstance = function () {
instanceContainer.innerHTML = '' // clear the instances list
noInstancesText.style.display = 'block'
instanceContainer.appendChild(noInstancesText)
events.trigger('clearInstance', [])
}
} }
function fillAccountsList (appAPI, container) { function fillAccountsList (appAPI, container) {
@ -244,11 +250,12 @@ function updateAccountBalances (container, appAPI) {
/* ------------------------------------------------ /* ------------------------------------------------
RECORDER RECORDER
------------------------------------------------ */ ------------------------------------------------ */
function makeRecorder (appAPI, appEvents) { function makeRecorder (events, appAPI, appEvents) {
var recorder = new Recorder({ var recorder = new Recorder({
events: { events: {
udapp: appEvents.udapp, udapp: appEvents.udapp,
executioncontext: executionContext.event executioncontext: executionContext.event,
runtab: events
}, },
api: appAPI api: appAPI
}) })
@ -323,7 +330,7 @@ function makeRecorder (appAPI, appEvents) {
section CONTRACT DROPDOWN and BUTTONS section CONTRACT DROPDOWN and BUTTONS
------------------------------------------------ */ ------------------------------------------------ */
function contractDropdown (appAPI, appEvents, instanceContainer) { function contractDropdown (events, appAPI, appEvents, instanceContainer) {
instanceContainer.appendChild(noInstancesText) instanceContainer.appendChild(noInstancesText)
var compFails = yo`<i title="Contract compilation failed. Please check the compile tab for more information." class="fa fa-thumbs-down ${css.errorIcon}" ></i>` var compFails = yo`<i title="Contract compilation failed. Please check the compile tab for more information." class="fa fa-thumbs-down ${css.errorIcon}" ></i>`
appEvents.compiler.register('compilationFinished', function (success, data, source) { appEvents.compiler.register('compilationFinished', function (success, data, source) {
@ -364,7 +371,7 @@ function contractDropdown (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(appAPI, appEvents)}</div> <div class=${css.buttons}>${makeRecorder(events, appAPI, appEvents)}</div>
</div> </div>
</div> </div>
` `

@ -21,6 +21,9 @@ class Recorder {
opts.events.executioncontext.register('contextChanged', () => { opts.events.executioncontext.register('contextChanged', () => {
self.clearAll() self.clearAll()
}) })
opts.events.runtab.register('clearInstances', () => {
self.clearAll()
})
opts.events.udapp.register('initiatingTransaction', (timestamp, tx, payLoad) => { opts.events.udapp.register('initiatingTransaction', (timestamp, tx, payLoad) => {
if (tx.useCall) return if (tx.useCall) return

Loading…
Cancel
Save