From 5c9fc40970f35e399a1bcd899174054a0c5d9fa2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 2 Jul 2018 16:55:15 +0200 Subject: [PATCH] display pending transaction count in terminal --- src/app/panels/editor-panel.js | 14 ++++++++------ src/app/panels/terminal.js | 11 ++++++++--- src/universal-dapp.js | 4 ++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/app/panels/editor-panel.js b/src/app/panels/editor-panel.js index 5f9c62cbc0..5def14fd02 100644 --- a/src/app/panels/editor-panel.js +++ b/src/app/panels/editor-panel.js @@ -26,7 +26,8 @@ class EditorPanel { self._deps = { config: self._components.registry.get('config').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 = { _FILE_SCROLL_DELTA: 200, @@ -46,9 +47,11 @@ class EditorPanel { contextualListener: contextualListener, contextView: new ContextView({contextualListener: contextualListener, editor: editor}), terminal: new Terminal({ - api: { - cmdInterpreter: new CommandInterpreter(), // @TODO: put into editorpanel - getPosition (event) { + udapp: self._deps.udapp, + cmdInterpreter: new CommandInterpreter() + }, + { + getPosition: (event) => { var limitUp = 36 var limitDown = 20 var height = window.innerHeight @@ -56,8 +59,7 @@ class EditorPanel { newpos = (newpos < height - limitDown) ? newpos : height - limitDown return newpos } - } - }) + }) } self._components.terminal.event.register('filterChanged', (type, value) => { diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index 2c375674c0..25b2c01c74 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -24,9 +24,11 @@ function register (api) { KONSOLES.push(api) } var ghostbar = yo`
` class Terminal { - constructor (opts = { auto: true }) { + constructor (opts, api) { var self = this self.event = new EventManager() + self._api = api + self._opts = opts self.data = { lineLength: opts.lineLength || 80, session: [], @@ -72,7 +74,7 @@ class Terminal { self.registerCommand('script', function execute (args, scopedCommands, append) { var script = String(args[0]) 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) { if (error) scopedCommands.error(error) else scopedCommands.log(output) @@ -110,7 +112,7 @@ class Terminal { self._view.dragbar = yo`
` self._view.dropdown = self._components.dropdown.render() - self._view.pendingTxCount = yo`
${self._view.pendingTxCount}
` + self._view.pendingTxCount = yo`
0
` self._view.bar = yo`
${self._view.dragbar} @@ -134,6 +136,9 @@ class Terminal {
` + setInterval(() => { + self._view.pendingTxCount.innerHTML = self._opts.udapp.pendingTransactionsCount() + }, 1000) function listenOnNetwork (ev) { self.event.trigger('listenOnNetWork', [ev.currentTarget.checked]) diff --git a/src/universal-dapp.js b/src/universal-dapp.js index 7008cbb47e..48b9fc2829 100644 --- a/src/universal-dapp.js +++ b/src/universal-dapp.js @@ -182,6 +182,10 @@ UniversalDApp.prototype.pendingTransactions = function () { return this.txRunner.pendingTxs } +UniversalDApp.prototype.pendingTransactionsCount = function () { + return Object.keys(this.txRunner.pendingTxs).length +} + UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly, outputCb) { const self = this var logMsg