Fix stats widget visibility

This commit is contained in:
Ivan Danyliuk 2018-10-19 18:37:58 +02:00
parent 19d5087adf
commit 16c8778680
No known key found for this signature in database
GPG Key ID: 97ED33CE024E1DBF
4 changed files with 25 additions and 31 deletions

View File

@ -136,9 +136,10 @@ func (p *Page) startSimulation() error {
}
// calculate stats and update stats widget
p.RecalculateStats()
p.statsWidget.Update(sim.stats)
stats := p.RecalculateStats(sim.plog)
p.statsWidget.Update(stats)
sim.stats = stats
p.simulation = sim
p.replaySimulation()

View File

@ -1,17 +1,14 @@
package main
import "github.com/status-im/simulation/stats"
func (p *Page) RecalculateStats() {
sim := p.simulation
if sim == nil || sim.plog == nil {
return
}
import (
"github.com/status-im/simulation/propagation"
"github.com/status-im/simulation/stats"
)
func (p *Page) RecalculateStats(plog *propagation.Log) *stats.Stats {
net := p.network.current
nodes := len(net.Data.Nodes())
links := len(net.Data.Links())
stats := stats.Analyze(sim.plog, nodes, links)
p.simulation.stats = stats
return stats.Analyze(plog, nodes, links)
}

View File

@ -163379,8 +163379,8 @@ $packages["github.com/status-im/whispervis"] = (function() {
};
Page.prototype.onNetworkChange = function(network) { return this.$val.onNetworkChange(network); };
Page.ptr.prototype.startSimulation = function() {
var _r, _tuple, backend, err, p, sim, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _tuple = $f._tuple; backend = $f.backend; err = $f.err; p = $f.p; sim = $f.sim; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
var _r, _r$1, _tuple, backend, err, p, sim, stats$1, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; _r$1 = $f._r$1; _tuple = $f._tuple; backend = $f.backend; err = $f.err; p = $f.p; sim = $f.sim; stats$1 = $f.stats$1; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
p = this;
backend = p.simulationWidget.Address();
_r = p.runSimulation(backend); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
@ -163390,12 +163390,14 @@ $packages["github.com/status-im/whispervis"] = (function() {
if (!($interfaceIsEqual(err, $ifaceNil))) {
$s = -1; return err;
}
$r = p.RecalculateStats(); /* */ $s = 2; case 2: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = p.statsWidget.Update(sim.stats); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
_r$1 = p.RecalculateStats(sim.plog); /* */ $s = 2; case 2: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; }
stats$1 = _r$1;
$r = p.statsWidget.Update(stats$1); /* */ $s = 3; case 3: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
sim.stats = stats$1;
p.simulation = sim;
$r = p.replaySimulation(); /* */ $s = 4; case 4: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return $ifaceNil;
/* */ } return; } if ($f === undefined) { $f = { $blk: Page.ptr.prototype.startSimulation }; } $f._r = _r; $f._tuple = _tuple; $f.backend = backend; $f.err = err; $f.p = p; $f.sim = sim; $f.$s = $s; $f.$r = $r; return $f;
/* */ } return; } if ($f === undefined) { $f = { $blk: Page.ptr.prototype.startSimulation }; } $f._r = _r; $f._r$1 = _r$1; $f._tuple = _tuple; $f.backend = backend; $f.err = err; $f.p = p; $f.sim = sim; $f.stats$1 = stats$1; $f.$s = $s; $f.$r = $r; return $f;
};
Page.prototype.startSimulation = function() { return this.$val.startSimulation(); };
Page.ptr.prototype.replaySimulation = function() {
@ -163548,24 +163550,18 @@ $packages["github.com/status-im/whispervis"] = (function() {
/* */ } return; } if ($f === undefined) { $f = { $blk: Page.ptr.prototype.currentNetworkJSON }; } $f._r = _r; $f._r$1 = _r$1; $f.buf = buf; $f.err = err; $f.net = net; $f.p = p; $f.$s = $s; $f.$r = $r; return $f;
};
Page.prototype.currentNetworkJSON = function() { return this.$val.currentNetworkJSON(); };
Page.ptr.prototype.RecalculateStats = function() {
var _r, links, net, nodes, p, sim, stats$1, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; links = $f.links; net = $f.net; nodes = $f.nodes; p = $f.p; sim = $f.sim; stats$1 = $f.stats$1; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
Page.ptr.prototype.RecalculateStats = function(plog) {
var _r, links, net, nodes, p, plog, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; links = $f.links; net = $f.net; nodes = $f.nodes; p = $f.p; plog = $f.plog; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
p = this;
sim = p.simulation;
if (sim === ptrType$24.nil || sim.plog === ptrType$28.nil) {
$s = -1; return;
}
net = p.network.current;
nodes = net.Data.Nodes().$length;
links = net.Data.Links().$length;
_r = stats.Analyze(sim.plog, nodes, links); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
stats$1 = _r;
p.simulation.stats = stats$1;
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: Page.ptr.prototype.RecalculateStats }; } $f._r = _r; $f.links = links; $f.net = net; $f.nodes = nodes; $f.p = p; $f.sim = sim; $f.stats$1 = stats$1; $f.$s = $s; $f.$r = $r; return $f;
_r = stats.Analyze(plog, nodes, links); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
$s = -1; return _r;
/* */ } return; } if ($f === undefined) { $f = { $blk: Page.ptr.prototype.RecalculateStats }; } $f._r = _r; $f.links = links; $f.net = net; $f.nodes = nodes; $f.p = p; $f.plog = plog; $f.$s = $s; $f.$r = $r; return $f;
};
Page.prototype.RecalculateStats = function() { return this.$val.RecalculateStats(); };
Page.prototype.RecalculateStats = function(plog) { return this.$val.RecalculateStats(plog); };
Page.ptr.prototype.VisibilityListener = function(e) {
var _r, document, e, hidden, p, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _r = $f._r; document = $f.document; e = $f.e; hidden = $f.hidden; p = $f.p; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
@ -163679,7 +163675,7 @@ $packages["github.com/status-im/whispervis"] = (function() {
TrackBallControl.methods = [{prop: "Update", name: "Update", pkg: "", typ: $funcType([], [], false)}];
ptrType$5.methods = [{prop: "String", name: "String", pkg: "", typ: $funcType([], [$String], false)}, {prop: "NodesCount", name: "NodesCount", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "LinksCount", name: "LinksCount", pkg: "", typ: $funcType([], [$Int], false)}];
ptrType$21.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "descriptionBlock", name: "descriptionBlock", pkg: "github.com/status-im/whispervis", typ: $funcType([], [ptrType$31], false)}, {prop: "networkOptions", name: "networkOptions", pkg: "github.com/status-im/whispervis", typ: $funcType([], [vecty.List], false)}, {prop: "onChange", name: "onChange", pkg: "github.com/status-im/whispervis", typ: $funcType([ptrType$32], [], false)}, {prop: "onUpload", name: "onUpload", pkg: "github.com/status-im/whispervis", typ: $funcType([sliceType], [], false)}, {prop: "setCurrentNetwork", name: "setCurrentNetwork", pkg: "github.com/status-im/whispervis", typ: $funcType([ptrType$5], [], false)}];
ptrType$33.methods = [{prop: "UpdateGraph", name: "UpdateGraph", pkg: "", typ: $funcType([], [], false)}, {prop: "KeyListener", name: "KeyListener", pkg: "", typ: $funcType([ptrType$32], [], false)}, {prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "updateButton", name: "updateButton", pkg: "github.com/status-im/whispervis", typ: $funcType([], [ptrType$31], false)}, {prop: "onUpdateClick", name: "onUpdateClick", pkg: "github.com/status-im/whispervis", typ: $funcType([ptrType$32], [], false)}, {prop: "onNetworkChange", name: "onNetworkChange", pkg: "github.com/status-im/whispervis", typ: $funcType([ptrType$5], [], false)}, {prop: "startSimulation", name: "startSimulation", pkg: "github.com/status-im/whispervis", typ: $funcType([], [$error], false)}, {prop: "replaySimulation", name: "replaySimulation", pkg: "github.com/status-im/whispervis", typ: $funcType([], [], false)}, {prop: "runSimulation", name: "runSimulation", pkg: "github.com/status-im/whispervis", typ: $funcType([$String], [ptrType$24, $error], false)}, {prop: "currentNetworkJSON", name: "currentNetworkJSON", pkg: "github.com/status-im/whispervis", typ: $funcType([], [sliceType], false)}, {prop: "RecalculateStats", name: "RecalculateStats", pkg: "", typ: $funcType([], [], false)}, {prop: "VisibilityListener", name: "VisibilityListener", pkg: "", typ: $funcType([ptrType$32], [], false)}];
ptrType$33.methods = [{prop: "UpdateGraph", name: "UpdateGraph", pkg: "", typ: $funcType([], [], false)}, {prop: "KeyListener", name: "KeyListener", pkg: "", typ: $funcType([ptrType$32], [], false)}, {prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "updateButton", name: "updateButton", pkg: "github.com/status-im/whispervis", typ: $funcType([], [ptrType$31], false)}, {prop: "onUpdateClick", name: "onUpdateClick", pkg: "github.com/status-im/whispervis", typ: $funcType([ptrType$32], [], false)}, {prop: "onNetworkChange", name: "onNetworkChange", pkg: "github.com/status-im/whispervis", typ: $funcType([ptrType$5], [], false)}, {prop: "startSimulation", name: "startSimulation", pkg: "github.com/status-im/whispervis", typ: $funcType([], [$error], false)}, {prop: "replaySimulation", name: "replaySimulation", pkg: "github.com/status-im/whispervis", typ: $funcType([], [], false)}, {prop: "runSimulation", name: "runSimulation", pkg: "github.com/status-im/whispervis", typ: $funcType([$String], [ptrType$24, $error], false)}, {prop: "currentNetworkJSON", name: "currentNetworkJSON", pkg: "github.com/status-im/whispervis", typ: $funcType([], [sliceType], false)}, {prop: "RecalculateStats", name: "RecalculateStats", pkg: "", typ: $funcType([ptrType$28], [ptrType$29], false)}, {prop: "VisibilityListener", name: "VisibilityListener", pkg: "", typ: $funcType([ptrType$32], [], false)}];
ptrType$18.methods = [{prop: "animate", name: "animate", pkg: "github.com/status-im/whispervis", typ: $funcType([], [], false)}, {prop: "ToggleAutoRotation", name: "ToggleAutoRotation", pkg: "", typ: $funcType([], [], false)}, {prop: "ToggleWobbling", name: "ToggleWobbling", pkg: "", typ: $funcType([], [], false)}, {prop: "BlinkNode", name: "BlinkNode", pkg: "", typ: $funcType([$Int], [], false)}, {prop: "BlinkEdge", name: "BlinkEdge", pkg: "", typ: $funcType([$Int], [], false)}, {prop: "AnimatePropagation", name: "AnimatePropagation", pkg: "", typ: $funcType([ptrType$28], [], false)}, {prop: "CreateObjects", name: "CreateObjects", pkg: "", typ: $funcType([mapType$2, sliceType$14], [], false)}, {prop: "createNodes", name: "createNodes", pkg: "github.com/status-im/whispervis", typ: $funcType([], [], false)}, {prop: "createEdges", name: "createEdges", pkg: "github.com/status-im/whispervis", typ: $funcType([sliceType$14], [], false)}, {prop: "updatePositions", name: "updatePositions", pkg: "github.com/status-im/whispervis", typ: $funcType([], [], false)}, {prop: "RemoveObjects", name: "RemoveObjects", pkg: "", typ: $funcType([], [], false)}, {prop: "init", name: "init", pkg: "github.com/status-im/whispervis", typ: $funcType([ptrType], [], false)}, {prop: "shutdown", name: "shutdown", pkg: "github.com/status-im/whispervis", typ: $funcType([ptrType], [], false)}, {prop: "Reset", name: "Reset", pkg: "", typ: $funcType([], [], false)}, {prop: "InitScene", name: "InitScene", pkg: "", typ: $funcType([$Float64, $Float64], [], false)}, {prop: "InitLights", name: "InitLights", pkg: "", typ: $funcType([], [], false)}, {prop: "InitControls", name: "InitControls", pkg: "", typ: $funcType([], [], false)}];
ptrType$27.methods = [{prop: "Animate", name: "Animate", pkg: "", typ: $funcType([], [], false)}, {prop: "wobbleNodes", name: "wobbleNodes", pkg: "github.com/status-im/whispervis", typ: $funcType([], [], false)}, {prop: "changeDirection", name: "changeDirection", pkg: "github.com/status-im/whispervis", typ: $funcType([], [], false)}];
ptrType$30.methods = [{prop: "Reverse", name: "Reverse", pkg: "", typ: $funcType([], [ptrType$30], false)}];

File diff suppressed because one or more lines are too long