display pending transaction count in terminal

pull/3094/head
yann300 6 years ago
parent 8cc7ede8d1
commit 7c5986c020
  1. 14
      src/app/panels/editor-panel.js
  2. 11
      src/app/panels/terminal.js
  3. 4
      src/universal-dapp.js

@ -26,7 +26,8 @@ class EditorPanel {
self._deps = { self._deps = {
config: self._components.registry.get('config').api, config: self._components.registry.get('config').api,
txlistener: self._components.registry.get('txlistener').api, txlistener: self._components.registry.get('txlistener').api,
fileManager: self._components.registry.get('filemanager').api fileManager: self._components.registry.get('filemanager').api,
udapp: self._components.registry.get('udapp').api
} }
self.data = { self.data = {
_FILE_SCROLL_DELTA: 200, _FILE_SCROLL_DELTA: 200,
@ -46,9 +47,11 @@ class EditorPanel {
contextualListener: contextualListener, contextualListener: contextualListener,
contextView: new ContextView({contextualListener: contextualListener, editor: editor}), contextView: new ContextView({contextualListener: contextualListener, editor: editor}),
terminal: new Terminal({ terminal: new Terminal({
api: { udapp: self._deps.udapp,
cmdInterpreter: new CommandInterpreter(), // @TODO: put into editorpanel cmdInterpreter: new CommandInterpreter()
getPosition (event) { },
{
getPosition: (event) => {
var limitUp = 36 var limitUp = 36
var limitDown = 20 var limitDown = 20
var height = window.innerHeight var height = window.innerHeight
@ -56,8 +59,7 @@ class EditorPanel {
newpos = (newpos < height - limitDown) ? newpos : height - limitDown newpos = (newpos < height - limitDown) ? newpos : height - limitDown
return newpos return newpos
} }
} })
})
} }
self._components.terminal.event.register('filterChanged', (type, value) => { self._components.terminal.event.register('filterChanged', (type, value) => {

@ -24,9 +24,11 @@ function register (api) { KONSOLES.push(api) }
var ghostbar = yo`<div class=${css.ghostbar}></div>` var ghostbar = yo`<div class=${css.ghostbar}></div>`
class Terminal { class Terminal {
constructor (opts = { auto: true }) { constructor (opts, api) {
var self = this var self = this
self.event = new EventManager() self.event = new EventManager()
self._api = api
self._opts = opts
self.data = { self.data = {
lineLength: opts.lineLength || 80, lineLength: opts.lineLength || 80,
session: [], session: [],
@ -72,7 +74,7 @@ class Terminal {
self.registerCommand('script', function execute (args, scopedCommands, append) { self.registerCommand('script', function execute (args, scopedCommands, append) {
var script = String(args[0]) var script = String(args[0])
scopedCommands.log(`> ${script}`) scopedCommands.log(`> ${script}`)
if (self._api.cmdInterpreter && self._api.cmdInterpreter.interpret(script)) return if (self._opts.cmdInterpreter && self.opts.cmdInterpreter.interpret(script)) return
self._shell(script, scopedCommands, function (error, output) { self._shell(script, scopedCommands, function (error, output) {
if (error) scopedCommands.error(error) if (error) scopedCommands.error(error)
else scopedCommands.log(output) else scopedCommands.log(output)
@ -110,7 +112,7 @@ class Terminal {
self._view.dragbar = yo` self._view.dragbar = yo`
<div onmousedown=${mousedown} class=${css.dragbarHorizontal}></div>` <div onmousedown=${mousedown} class=${css.dragbarHorizontal}></div>`
self._view.dropdown = self._components.dropdown.render() self._view.dropdown = self._components.dropdown.render()
self._view.pendingTxCount = yo`<div class=${css.pendingTx} title='Pending Transactions'>${self._view.pendingTxCount}</div>` self._view.pendingTxCount = yo`<div class=${css.pendingTx} title='Pending Transactions'>0</div>`
self._view.bar = yo` self._view.bar = yo`
<div class=${css.bar}> <div class=${css.bar}>
${self._view.dragbar} ${self._view.dragbar}
@ -134,6 +136,9 @@ class Terminal {
</div> </div>
</div> </div>
` `
setInterval(() => {
self._view.pendingTxCount.innerHTML = self._opts.udapp.pendingTransactionsCount()
}, 1000)
function listenOnNetwork (ev) { function listenOnNetwork (ev) {
self.event.trigger('listenOnNetWork', [ev.currentTarget.checked]) self.event.trigger('listenOnNetWork', [ev.currentTarget.checked])

@ -182,6 +182,10 @@ UniversalDApp.prototype.pendingTransactions = function () {
return this.txRunner.pendingTxs return this.txRunner.pendingTxs
} }
UniversalDApp.prototype.pendingTransactionsCount = function () {
return Object.keys(this.txRunner.pendingTxs).length
}
UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly, outputCb) { UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly, outputCb) {
const self = this const self = this
var logMsg var logMsg

Loading…
Cancel
Save