make dropdownlist use treeview

pull/7/head
yann300 8 years ago
parent 5dc187e510
commit b36fe448bf
  1. 2
      src/ui/CalldataPanel.js
  2. 2
      src/ui/CallstackPanel.js
  3. 5
      src/ui/CodeListView.js
  4. 57
      src/ui/DropdownPanel.js
  5. 2
      src/ui/FullStoragesChanges.js
  6. 2
      src/ui/MemoryPanel.js
  7. 2
      src/ui/SolidityLocals.js
  8. 2
      src/ui/SolidityState.js
  9. 2
      src/ui/StackPanel.js
  10. 2
      src/ui/StepDetail.js
  11. 2
      src/ui/StoragePanel.js
  12. 2
      src/ui/TxBrowser.js
  13. 2
      src/ui/VmDebugger.js

@ -5,7 +5,7 @@ var yo = require('yo-yo')
function CalldataPanel (_parent, _traceManager) { function CalldataPanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Call Data') this.basicPanel = new DropdownPanel('Call Data', {json: true})
this.init() this.init()
} }

@ -5,7 +5,7 @@ var yo = require('yo-yo')
function CallstackPanel (_parent, _traceManager) { function CallstackPanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Call Stack') this.basicPanel = new DropdownPanel('Call Stack', {json: true})
this.init() this.init()
} }

@ -11,7 +11,7 @@ function CodeListView (_parent, _codeManager) {
this.address this.address
this.codeView this.codeView
this.itemSelected this.itemSelected
this.basicPanel = new DropdownPanel('Instructions', true) this.basicPanel = new DropdownPanel('Instructions', {json: false})
this.init() this.init()
} }
@ -51,8 +51,7 @@ CodeListView.prototype.changed = function (code, address, index) {
this.code = code this.code = code
this.address = address this.address = address
this.codeView = this.renderAssemblyItems() this.codeView = this.renderAssemblyItems()
this.basicPanel.data = this.codeView this.basicPanel.setContent(this.codeView)
this.basicPanel.update()
} }
this.indexChanged(index) this.indexChanged(index)
} }

@ -3,49 +3,40 @@ var yo = require('yo-yo')
var ui = require('../helpers/ui') var ui = require('../helpers/ui')
var styleDropdown = require('./styles/dropdownPanel') var styleDropdown = require('./styles/dropdownPanel')
var basicStyles = require('./styles/basicStyles') var basicStyles = require('./styles/basicStyles')
var TreeView = require('./TreeView')
function DropdownPanel (_name, _raw) { function DropdownPanel (_name, _opts) {
this.data if (!_opts) {
_opts = {}
}
this.name = _name this.name = _name
this.json = _opts.json
if (this.json) {
this.treeView = new TreeView(_opts)
}
this.view this.view
_raw = _raw === undefined ? false : _raw
this.raw = _raw
} }
DropdownPanel.prototype.update = function (_data) { DropdownPanel.prototype.update = function (_data) {
if (!this.view) { if (this.view) {
return this.view.querySelector('.dropdownpanel .dropdownrawcontent').innerText = JSON.stringify(_data, null, '\t')
}
if (_data) {
this.data = _data
}
this.view.querySelector('.dropdownpanel div.dropdowncontent').innerHTML = ''
if (!this.raw) {
var data = JSON.stringify(this.data, null, '\t')
if (!this.data || data === '[]' || data === '{}') {
this.data = ['Empty']
}
var div = document.createElement('div')
if (Array.isArray(this.data)) {
this.data.map(function (item, i) {
div.appendChild(yo`<div>${item}</div>`)
})
} else {
for (var k in this.data) {
var content = typeof this.data[k] === 'string' ? this.data[k] : JSON.stringify(this.data[k])
div.appendChild(yo`<div><div title=${k} style=${ui.formatCss(basicStyles.truncate, {display: 'inline-block', 'width': '10%'})} >${k}</div><div title=${content} style=${ui.formatCss(basicStyles.truncate, {display: 'inline-block', 'width': '78%'})} >${content}</div></div>`)
}
}
this.view.querySelector('.dropdownpanel div.dropdowncontent').appendChild(div)
this.view.querySelector('.dropdownpanel button.btn').style.display = 'block' this.view.querySelector('.dropdownpanel button.btn').style.display = 'block'
this.view.querySelector('.dropdownpanel .dropdownrawcontent').innerText = data if (this.json) {
} else { this.treeView.update(_data)
this.view.querySelector('.dropdownpanel div.dropdowncontent').appendChild(this.data) }
this.view.querySelector('.dropdownpanel button.btn').style.display = 'none'
} }
} }
DropdownPanel.prototype.setContent = function (node) {
var parent = this.view.querySelector('.dropdownpanel div.dropdowncontent')
parent.replaceChild(node, parent.firstElementChild)
}
DropdownPanel.prototype.render = function (overridestyle) { DropdownPanel.prototype.render = function (overridestyle) {
var content = yo`<div>Empty</div>`
if (this.json) {
content = this.treeView.render({})
}
overridestyle === undefined ? {} : overridestyle overridestyle === undefined ? {} : overridestyle
var self = this var self = this
var view = yo`<div> var view = yo`<div>
@ -55,7 +46,7 @@ DropdownPanel.prototype.render = function (overridestyle) {
<div class='dropdownpanel' style=${ui.formatCss(styleDropdown.content)} style='display:none'> <div class='dropdownpanel' style=${ui.formatCss(styleDropdown.content)} style='display:none'>
<button onclick=${function () { self.toggleRaw() }} style=${ui.formatCss(basicStyles.button, styleDropdown.copyBtn)} title='raw' class="btn fa fa-eye" type="button"> <button onclick=${function () { self.toggleRaw() }} style=${ui.formatCss(basicStyles.button, styleDropdown.copyBtn)} title='raw' class="btn fa fa-eye" type="button">
</button> </button>
<div style=${ui.formatCss(styleDropdown.inner, overridestyle)} class='dropdowncontent'><div>Empty</div></div> <div style=${ui.formatCss(styleDropdown.inner, overridestyle)} class='dropdowncontent'>${content}</div>
<div style=${ui.formatCss(styleDropdown.inner, overridestyle)} class='dropdownrawcontent' style='display:none'></div> <div style=${ui.formatCss(styleDropdown.inner, overridestyle)} class='dropdownrawcontent' style='display:none'></div>
</div> </div>
</div>` </div>`

@ -8,7 +8,7 @@ function FullStoragesChanges (_parent, _traceManager) {
this.addresses = [] this.addresses = []
this.view this.view
this.traceLength this.traceLength
this.basicPanel = new DropdownPanel('Full Storages Changes') this.basicPanel = new DropdownPanel('Full Storages Changes', {json: true})
this.init() this.init()
} }

@ -6,7 +6,7 @@ var yo = require('yo-yo')
function MemoryPanel (_parent, _traceManager) { function MemoryPanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Memory') this.basicPanel = new DropdownPanel('Memory', {json: true})
this.init() this.init()
} }

@ -9,7 +9,7 @@ class SolidityLocals {
this.parent = _parent this.parent = _parent
this.internalTreeCall = internalTreeCall this.internalTreeCall = internalTreeCall
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Solidity Locals') this.basicPanel = new DropdownPanel('Solidity Locals', {json: true})
this.init() this.init()
} }

@ -8,7 +8,7 @@ function SolidityState (_parent, _traceManager, _codeManager, _solidityProxy) {
this.traceManager = _traceManager this.traceManager = _traceManager
this.codeManager = _codeManager this.codeManager = _codeManager
this.solidityProxy = _solidityProxy this.solidityProxy = _solidityProxy
this.basicPanel = new DropdownPanel('Solidity State') this.basicPanel = new DropdownPanel('Solidity State', {json: true})
this.init() this.init()
} }

@ -6,7 +6,7 @@ var yo = require('yo-yo')
function StackPanel (_parent, _traceManager) { function StackPanel (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Stack') this.basicPanel = new DropdownPanel('Stack', {json: true})
this.init() this.init()
} }

@ -6,7 +6,7 @@ function StepDetail (_parent, _traceManager) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Step detail') this.basicPanel = new DropdownPanel('Step detail', {json: true})
this.detail = initDetail() this.detail = initDetail()
this.view this.view

@ -5,7 +5,7 @@ var yo = require('yo-yo')
function StoragePanel (_parent, _traceManager, _address) { function StoragePanel (_parent, _traceManager, _address) {
this.parent = _parent this.parent = _parent
this.traceManager = _traceManager this.traceManager = _traceManager
this.basicPanel = new DropdownPanel('Storage Changes') this.basicPanel = new DropdownPanel('Storage Changes', {json: true})
this.address = _address this.address = _address
this.init() this.init()
this.disabled = false this.disabled = false

@ -14,7 +14,7 @@ function TxBrowser (_parent) {
this.txNumber this.txNumber
this.view this.view
this.displayConnectionSetting = true this.displayConnectionSetting = true
this.basicPanel = new DropdownPanel('Transaction') this.basicPanel = new DropdownPanel('Transaction', {json: true})
this.basicPanel.data = {} this.basicPanel.data = {}
var self = this var self = this
_parent.event.register('providerChanged', this, function (provider) { _parent.event.register('providerChanged', this, function (provider) {

@ -24,7 +24,7 @@ function VmDebugger (_parent, _traceManager, _codeManager, _solidityProxy, _call
this.solidityLocals = new SolidityLocals(_parent, _traceManager, _callTree) this.solidityLocals = new SolidityLocals(_parent, _traceManager, _callTree)
/* Return values - */ /* Return values - */
this.returnValuesPanel = new DropdownPanel('Return Value') this.returnValuesPanel = new DropdownPanel('Return Value', {json: true})
this.returnValuesPanel.data = {} this.returnValuesPanel.data = {}
_parent.event.register('indexChanged', this.returnValuesPanel, function (index) { _parent.event.register('indexChanged', this.returnValuesPanel, function (index) {
var self = this var self = this

Loading…
Cancel
Save