Improve error handling and visibility of error for simulation

This commit is contained in:
Ivan Danyliuk 2018-10-19 16:41:16 +02:00
parent 163d58dd2b
commit 19d5087adf
No known key found for this signature in database
GPG Key ID: 97ED33CE024E1DBF
6 changed files with 157 additions and 87 deletions

View File

@ -128,12 +128,11 @@ func (p *Page) onNetworkChange(network *Network) {
}
// startSimulation is called on the end of each simulation round.
func (p *Page) startSimulation() {
func (p *Page) startSimulation() error {
backend := p.simulationWidget.Address()
sim, err := p.runSimulation(backend)
if err != nil {
// TODO(divan): handle error
return
return err
}
// calculate stats and update stats widget
@ -143,6 +142,7 @@ func (p *Page) startSimulation() {
p.simulation = sim
p.replaySimulation()
return nil
}
// replaySimulation animates last simulation.

View File

@ -22,11 +22,11 @@ type Simulation struct {
func (p *Page) runSimulation(address string) (*Simulation, error) {
payload := p.currentNetworkJSON()
buf := bytes.NewBuffer(payload)
url := "http://" + address + "/"
resp, err := http.Post(url, "application/json", buf)
host := "http://" + address + "/"
resp, err := http.Post(host, "application/json", buf)
if err != nil {
fmt.Println("[ERROR] POST request to simulation backend:", err)
return nil, fmt.Errorf("backend error: %v", err)
return nil, fmt.Errorf("Backend error. Did you run backend?")
}
var plog propagation.Log

View File

@ -78216,14 +78216,13 @@ $packages["github.com/status-im/whispervis/jsapi"] = (function() {
return $pkg;
})();
$packages["github.com/status-im/whispervis/widgets"] = (function() {
var $pkg = {}, $init, fmt, layout, vecty, elem, event, prop, propagation, stats, jsapi, sync, time, ForceEditor, ForcesConfig, ForceInput, Loader, Range, Simulation, Stats, UploadWidget, sliceType, sliceType$1, sliceType$2, ptrType, ptrType$1, sliceType$3, ptrType$2, ptrType$3, ptrType$4, ptrType$5, ptrType$6, ptrType$7, ptrType$8, funcType, ptrType$9, ptrType$10, ptrType$11, sliceType$4, funcType$1, NewForceEditor, NewForceInput, NewLoader, NewRange, NewSimulation, NewStats, NewUploadWidget;
var $pkg = {}, $init, fmt, layout, vecty, elem, event, prop, stats, jsapi, sync, time, ForceEditor, ForcesConfig, ForceInput, Loader, Range, Simulation, Stats, UploadWidget, sliceType, sliceType$1, sliceType$2, ptrType, ptrType$1, sliceType$3, sliceType$4, ptrType$2, ptrType$3, ptrType$4, ptrType$5, ptrType$6, ptrType$7, funcType, funcType$1, ptrType$8, ptrType$9, ptrType$10, sliceType$5, funcType$2, NewForceEditor, NewForceInput, NewLoader, NewRange, NewSimulation, NewStats, NewUploadWidget;
fmt = $packages["fmt"];
layout = $packages["github.com/divan/graphx/layout"];
vecty = $packages["github.com/gopherjs/vecty"];
elem = $packages["github.com/gopherjs/vecty/elem"];
event = $packages["github.com/gopherjs/vecty/event"];
prop = $packages["github.com/gopherjs/vecty/prop"];
propagation = $packages["github.com/status-im/simulation/propagation"];
stats = $packages["github.com/status-im/simulation/stats"];
jsapi = $packages["github.com/status-im/whispervis/jsapi"];
sync = $packages["sync"];
@ -78298,27 +78297,29 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
this.title = title_;
this.value = value_;
});
Simulation = $pkg.Simulation = $newType(0, $kindStruct, "widgets.Simulation", true, "github.com/status-im/whispervis/widgets", true, function(Core_, startSimulation_, replay_, address_, plog_) {
Simulation = $pkg.Simulation = $newType(0, $kindStruct, "widgets.Simulation", true, "github.com/status-im/whispervis/widgets", true, function(Core_, startSimulation_, replay_, address_, errMsg_, hasResults_) {
this.$val = this;
if (arguments.length === 0) {
this.Core = new vecty.Core.ptr($ifaceNil, $ifaceNil, false, false);
this.startSimulation = $throwNilPointerError;
this.replay = $throwNilPointerError;
this.address = "";
this.plog = ptrType$2.nil;
this.errMsg = "";
this.hasResults = false;
return;
}
this.Core = Core_;
this.startSimulation = startSimulation_;
this.replay = replay_;
this.address = address_;
this.plog = plog_;
this.errMsg = errMsg_;
this.hasResults = hasResults_;
});
Stats = $pkg.Stats = $newType(0, $kindStruct, "widgets.Stats", true, "github.com/status-im/whispervis/widgets", true, function(Core_, stats_) {
this.$val = this;
if (arguments.length === 0) {
this.Core = new vecty.Core.ptr($ifaceNil, $ifaceNil, false, false);
this.stats = ptrType$3.nil;
this.stats = ptrType$2.nil;
return;
}
this.Core = Core_;
@ -78340,19 +78341,20 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
ptrType = $ptrType(ForceInput);
ptrType$1 = $ptrType(Range);
sliceType$3 = $sliceType($emptyInterface);
ptrType$2 = $ptrType(propagation.Log);
ptrType$3 = $ptrType(stats.Stats);
ptrType$4 = $ptrType(stats.Histogram);
ptrType$5 = $ptrType(ForceEditor);
ptrType$6 = $ptrType(vecty.Event);
ptrType$7 = $ptrType(Loader);
ptrType$8 = $ptrType(Simulation);
funcType = $funcType([], [], false);
ptrType$9 = $ptrType(vecty.HTML);
ptrType$10 = $ptrType(Stats);
ptrType$11 = $ptrType(UploadWidget);
sliceType$4 = $sliceType($Uint8);
funcType$1 = $funcType([sliceType$4], [], false);
sliceType$4 = $sliceType(vecty.ComponentOrHTML);
ptrType$2 = $ptrType(stats.Stats);
ptrType$3 = $ptrType(stats.Histogram);
ptrType$4 = $ptrType(ForceEditor);
ptrType$5 = $ptrType(vecty.Event);
ptrType$6 = $ptrType(Loader);
ptrType$7 = $ptrType(Simulation);
funcType = $funcType([], [$error], false);
funcType$1 = $funcType([], [], false);
ptrType$8 = $ptrType(vecty.HTML);
ptrType$9 = $ptrType(Stats);
ptrType$10 = $ptrType(UploadWidget);
sliceType$5 = $sliceType($Uint8);
funcType$2 = $funcType([sliceType$5], [], false);
ForceEditor.ptr.prototype.Render = function() {
var _arg, _arg$1, _r, _r$1, _r$2, _r$3, l, x, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _arg = $f._arg; _arg$1 = $f._arg$1; _r = $f._r; _r$1 = $f._r$1; _r$2 = $f._r$2; _r$3 = $f._r$3; l = $f.l; x = $f.x; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
@ -78584,12 +78586,12 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
if (address === "") {
address = "http://localhost:8084";
}
return new Simulation.ptr(new vecty.Core.ptr($ifaceNil, $ifaceNil, false, false), startSimulation, replay, address, ptrType$2.nil);
return new Simulation.ptr(new vecty.Core.ptr($ifaceNil, $ifaceNil, false, false), startSimulation, replay, address, "", false);
};
$pkg.NewSimulation = NewSimulation;
Simulation.ptr.prototype.Render = function() {
var _arg, _arg$1, _arg$10, _arg$11, _arg$12, _arg$2, _arg$3, _arg$4, _arg$5, _arg$6, _arg$7, _arg$8, _arg$9, _r, _r$1, _r$10, _r$11, _r$2, _r$3, _r$4, _r$5, _r$6, _r$7, _r$8, _r$9, s, x, x$1, x$2, x$3, x$4, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _arg = $f._arg; _arg$1 = $f._arg$1; _arg$10 = $f._arg$10; _arg$11 = $f._arg$11; _arg$12 = $f._arg$12; _arg$2 = $f._arg$2; _arg$3 = $f._arg$3; _arg$4 = $f._arg$4; _arg$5 = $f._arg$5; _arg$6 = $f._arg$6; _arg$7 = $f._arg$7; _arg$8 = $f._arg$8; _arg$9 = $f._arg$9; _r = $f._r; _r$1 = $f._r$1; _r$10 = $f._r$10; _r$11 = $f._r$11; _r$2 = $f._r$2; _r$3 = $f._r$3; _r$4 = $f._r$4; _r$5 = $f._r$5; _r$6 = $f._r$6; _r$7 = $f._r$7; _r$8 = $f._r$8; _r$9 = $f._r$9; s = $f.s; x = $f.x; x$1 = $f.x$1; x$2 = $f.x$2; x$3 = $f.x$3; x$4 = $f.x$4; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
var _arg, _arg$1, _arg$10, _arg$11, _arg$12, _arg$13, _arg$14, _arg$15, _arg$16, _arg$17, _arg$18, _arg$19, _arg$2, _arg$20, _arg$21, _arg$22, _arg$3, _arg$4, _arg$5, _arg$6, _arg$7, _arg$8, _arg$9, _r, _r$1, _r$10, _r$11, _r$12, _r$13, _r$14, _r$15, _r$16, _r$17, _r$2, _r$3, _r$4, _r$5, _r$6, _r$7, _r$8, _r$9, s, x, x$1, x$2, x$3, x$4, x$5, x$6, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _arg = $f._arg; _arg$1 = $f._arg$1; _arg$10 = $f._arg$10; _arg$11 = $f._arg$11; _arg$12 = $f._arg$12; _arg$13 = $f._arg$13; _arg$14 = $f._arg$14; _arg$15 = $f._arg$15; _arg$16 = $f._arg$16; _arg$17 = $f._arg$17; _arg$18 = $f._arg$18; _arg$19 = $f._arg$19; _arg$2 = $f._arg$2; _arg$20 = $f._arg$20; _arg$21 = $f._arg$21; _arg$22 = $f._arg$22; _arg$3 = $f._arg$3; _arg$4 = $f._arg$4; _arg$5 = $f._arg$5; _arg$6 = $f._arg$6; _arg$7 = $f._arg$7; _arg$8 = $f._arg$8; _arg$9 = $f._arg$9; _r = $f._r; _r$1 = $f._r$1; _r$10 = $f._r$10; _r$11 = $f._r$11; _r$12 = $f._r$12; _r$13 = $f._r$13; _r$14 = $f._r$14; _r$15 = $f._r$15; _r$16 = $f._r$16; _r$17 = $f._r$17; _r$2 = $f._r$2; _r$3 = $f._r$3; _r$4 = $f._r$4; _r$5 = $f._r$5; _r$6 = $f._r$6; _r$7 = $f._r$7; _r$8 = $f._r$8; _r$9 = $f._r$9; s = $f.s; x = $f.x; x$1 = $f.x$1; x$2 = $f.x$2; x$3 = $f.x$3; x$4 = $f.x$4; x$5 = $f.x$5; x$6 = $f.x$6; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
s = this;
_r = vecty.Text("Simulation backend:", new sliceType([])); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
_r$1 = elem.Heading3(new sliceType([_r])); /* */ $s = 2; case 2: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; }
@ -78602,22 +78604,38 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
_arg$4 = _r$3;
_r$4 = elem.Input(new sliceType([(x$2 = vecty.Markup(new sliceType$2([prop.Value(s.address), event.Input($methodVal(s, "onEditInput")), vecty.Class(new sliceType$1(["pure-input-1-3"])), vecty.Style("float", "right"), vecty.Style("margin-right", "10px"), vecty.Style("text-align", "right")])), new x$2.constructor.elem(x$2))])); /* */ $s = 5; case 5: if($c) { $c = false; _r$4 = _r$4.$blk(); } if (_r$4 && _r$4.$blk !== undefined) { break s; }
_arg$5 = _r$4;
_r$5 = elem.Break(new sliceType([])); /* */ $s = 6; case 6: if($c) { $c = false; _r$5 = _r$5.$blk(); } if (_r$5 && _r$5.$blk !== undefined) { break s; }
_r$5 = elem.Div(new sliceType([_arg, _arg$1, _arg$4, _arg$5])); /* */ $s = 6; case 6: if($c) { $c = false; _r$5 = _r$5.$blk(); } if (_r$5 && _r$5.$blk !== undefined) { break s; }
_arg$6 = _r$5;
_arg$7 = (x$3 = vecty.Markup(new sliceType$2([vecty.Class(new sliceType$1(["pure-button"])), vecty.Style("background", "rgb(28, 184, 65)"), vecty.Style("color", "white"), vecty.Style("border-radius", "4px"), event.Click($methodVal(s, "onSimulateClick"))])), new x$3.constructor.elem(x$3));
_arg$7 = (x$3 = vecty.Markup(new sliceType$2([vecty.Class(new sliceType$1(["pure-markup-group", "pure-u-1"]))])), new x$3.constructor.elem(x$3));
_arg$8 = (x$4 = vecty.Markup(new sliceType$2([vecty.Class(new sliceType$1(["pure-button"])), vecty.Class(new sliceType$1(["pure-u-1-2"])), vecty.Style("background", "rgb(28, 184, 65)"), vecty.Style("color", "white"), vecty.Style("border-radius", "4px"), event.Click($methodVal(s, "onSimulateClick"))])), new x$4.constructor.elem(x$4));
_r$6 = vecty.Text("Start simulation", new sliceType([])); /* */ $s = 7; case 7: if($c) { $c = false; _r$6 = _r$6.$blk(); } if (_r$6 && _r$6.$blk !== undefined) { break s; }
_arg$8 = _r$6;
_r$7 = elem.Button(new sliceType([_arg$7, _arg$8])); /* */ $s = 8; case 8: if($c) { $c = false; _r$7 = _r$7.$blk(); } if (_r$7 && _r$7.$blk !== undefined) { break s; }
_arg$9 = _r$7;
_arg$10 = (x$4 = vecty.Markup(new sliceType$2([vecty.Class(new sliceType$1(["pure-button"])), vecty.Style("background", "rgb(28, 184, 65)"), vecty.Style("color", "white"), vecty.Style("border-radius", "4px"), event.Click($methodVal(s, "onRestartClick"))])), new x$4.constructor.elem(x$4));
_arg$9 = _r$6;
_r$7 = elem.Button(new sliceType([_arg$8, _arg$9])); /* */ $s = 8; case 8: if($c) { $c = false; _r$7 = _r$7.$blk(); } if (_r$7 && _r$7.$blk !== undefined) { break s; }
_arg$10 = _r$7;
_arg$11 = s.hasResults;
_arg$12 = (x$5 = vecty.Markup(new sliceType$2([vecty.Class(new sliceType$1(["pure-button"])), vecty.Class(new sliceType$1(["pure-u-1-3"])), vecty.Style("background", "rgb(28, 184, 65)"), vecty.Style("color", "white"), vecty.Style("margin", "10px"), vecty.Style("border-radius", "4px"), event.Click($methodVal(s, "onRestartClick"))])), new x$5.constructor.elem(x$5));
_r$8 = vecty.Text("Replay", new sliceType([])); /* */ $s = 9; case 9: if($c) { $c = false; _r$8 = _r$8.$blk(); } if (_r$8 && _r$8.$blk !== undefined) { break s; }
_arg$11 = _r$8;
_r$9 = elem.Button(new sliceType([_arg$10, _arg$11])); /* */ $s = 10; case 10: if($c) { $c = false; _r$9 = _r$9.$blk(); } if (_r$9 && _r$9.$blk !== undefined) { break s; }
_arg$12 = _r$9;
_r$10 = elem.Div(new sliceType([_arg, _arg$1, _arg$4, _arg$5, _arg$6, _arg$9, _arg$12])); /* */ $s = 11; case 11: if($c) { $c = false; _r$10 = _r$10.$blk(); } if (_r$10 && _r$10.$blk !== undefined) { break s; }
_r$11 = elem.Div(new sliceType([_r$10])); /* */ $s = 12; case 12: if($c) { $c = false; _r$11 = _r$11.$blk(); } if (_r$11 && _r$11.$blk !== undefined) { break s; }
$s = -1; return _r$11;
/* */ } return; } if ($f === undefined) { $f = { $blk: Simulation.ptr.prototype.Render }; } $f._arg = _arg; $f._arg$1 = _arg$1; $f._arg$10 = _arg$10; $f._arg$11 = _arg$11; $f._arg$12 = _arg$12; $f._arg$2 = _arg$2; $f._arg$3 = _arg$3; $f._arg$4 = _arg$4; $f._arg$5 = _arg$5; $f._arg$6 = _arg$6; $f._arg$7 = _arg$7; $f._arg$8 = _arg$8; $f._arg$9 = _arg$9; $f._r = _r; $f._r$1 = _r$1; $f._r$10 = _r$10; $f._r$11 = _r$11; $f._r$2 = _r$2; $f._r$3 = _r$3; $f._r$4 = _r$4; $f._r$5 = _r$5; $f._r$6 = _r$6; $f._r$7 = _r$7; $f._r$8 = _r$8; $f._r$9 = _r$9; $f.s = s; $f.x = x; $f.x$1 = x$1; $f.x$2 = x$2; $f.x$3 = x$3; $f.x$4 = x$4; $f.$s = $s; $f.$r = $r; return $f;
_arg$13 = _r$8;
_r$9 = elem.Button(new sliceType([_arg$12, _arg$13])); /* */ $s = 10; case 10: if($c) { $c = false; _r$9 = _r$9.$blk(); } if (_r$9 && _r$9.$blk !== undefined) { break s; }
_arg$14 = _r$9;
_r$10 = vecty.If(_arg$11, new sliceType$4([_arg$14])); /* */ $s = 11; case 11: if($c) { $c = false; _r$10 = _r$10.$blk(); } if (_r$10 && _r$10.$blk !== undefined) { break s; }
_arg$15 = _r$10;
_r$11 = elem.Break(new sliceType([])); /* */ $s = 12; case 12: if($c) { $c = false; _r$11 = _r$11.$blk(); } if (_r$11 && _r$11.$blk !== undefined) { break s; }
_arg$16 = _r$11;
_arg$17 = !(s.errMsg === "");
_arg$18 = (x$6 = vecty.Markup(new sliceType$2([vecty.Style("background", "rgb(202, 60, 60)"), vecty.Style("color", "white"), vecty.Style("border-radius", "4px"), vecty.Style("margin-right", "5px"), vecty.Style("padding", "5px")])), new x$6.constructor.elem(x$6));
_r$12 = vecty.Text(s.errMsg, new sliceType([])); /* */ $s = 13; case 13: if($c) { $c = false; _r$12 = _r$12.$blk(); } if (_r$12 && _r$12.$blk !== undefined) { break s; }
_arg$19 = _r$12;
_r$13 = elem.Paragraph(new sliceType([_arg$18, _arg$19])); /* */ $s = 14; case 14: if($c) { $c = false; _r$13 = _r$13.$blk(); } if (_r$13 && _r$13.$blk !== undefined) { break s; }
_arg$20 = _r$13;
_r$14 = vecty.If(_arg$17, new sliceType$4([_arg$20])); /* */ $s = 15; case 15: if($c) { $c = false; _r$14 = _r$14.$blk(); } if (_r$14 && _r$14.$blk !== undefined) { break s; }
_r$15 = elem.Div(new sliceType([_r$14])); /* */ $s = 16; case 16: if($c) { $c = false; _r$15 = _r$15.$blk(); } if (_r$15 && _r$15.$blk !== undefined) { break s; }
_arg$21 = _r$15;
_r$16 = elem.Div(new sliceType([_arg$7, _arg$10, _arg$15, _arg$16, _arg$21])); /* */ $s = 17; case 17: if($c) { $c = false; _r$16 = _r$16.$blk(); } if (_r$16 && _r$16.$blk !== undefined) { break s; }
_arg$22 = _r$16;
_r$17 = elem.Div(new sliceType([_arg$6, _arg$22])); /* */ $s = 18; case 18: if($c) { $c = false; _r$17 = _r$17.$blk(); } if (_r$17 && _r$17.$blk !== undefined) { break s; }
$s = -1; return _r$17;
/* */ } return; } if ($f === undefined) { $f = { $blk: Simulation.ptr.prototype.Render }; } $f._arg = _arg; $f._arg$1 = _arg$1; $f._arg$10 = _arg$10; $f._arg$11 = _arg$11; $f._arg$12 = _arg$12; $f._arg$13 = _arg$13; $f._arg$14 = _arg$14; $f._arg$15 = _arg$15; $f._arg$16 = _arg$16; $f._arg$17 = _arg$17; $f._arg$18 = _arg$18; $f._arg$19 = _arg$19; $f._arg$2 = _arg$2; $f._arg$20 = _arg$20; $f._arg$21 = _arg$21; $f._arg$22 = _arg$22; $f._arg$3 = _arg$3; $f._arg$4 = _arg$4; $f._arg$5 = _arg$5; $f._arg$6 = _arg$6; $f._arg$7 = _arg$7; $f._arg$8 = _arg$8; $f._arg$9 = _arg$9; $f._r = _r; $f._r$1 = _r$1; $f._r$10 = _r$10; $f._r$11 = _r$11; $f._r$12 = _r$12; $f._r$13 = _r$13; $f._r$14 = _r$14; $f._r$15 = _r$15; $f._r$16 = _r$16; $f._r$17 = _r$17; $f._r$2 = _r$2; $f._r$3 = _r$3; $f._r$4 = _r$4; $f._r$5 = _r$5; $f._r$6 = _r$6; $f._r$7 = _r$7; $f._r$8 = _r$8; $f._r$9 = _r$9; $f.s = s; $f.x = x; $f.x$1 = x$1; $f.x$2 = x$2; $f.x$3 = x$3; $f.x$4 = x$4; $f.x$5 = x$5; $f.x$6 = x$6; $f.$s = $s; $f.$r = $r; return $f;
};
Simulation.prototype.Render = function() { return this.$val.Render(); };
Simulation.ptr.prototype.onEditInput = function(event$1) {
@ -78636,7 +78654,25 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
Simulation.ptr.prototype.onSimulateClick = function(e) {
var e, s;
s = this;
$go(s.startSimulation, []);
$go((function $b() {
var _r, _r$1, err, $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; err = $f.err; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
s.errMsg = "";
s.hasResults = false;
$r = vecty.Rerender(s); /* */ $s = 1; case 1: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
_r = s.startSimulation(); /* */ $s = 2; case 2: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
err = _r;
/* */ if (!($interfaceIsEqual(err, $ifaceNil))) { $s = 3; continue; }
/* */ $s = 4; continue;
/* if (!($interfaceIsEqual(err, $ifaceNil))) { */ case 3:
_r$1 = err.Error(); /* */ $s = 5; case 5: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; }
s.errMsg = _r$1;
/* } */ case 4:
s.hasResults = $interfaceIsEqual(err, $ifaceNil);
$r = vecty.Rerender(s); /* */ $s = 6; case 6: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$s = -1; return;
/* */ } return; } if ($f === undefined) { $f = { $blk: $b }; } $f._r = _r; $f._r$1 = _r$1; $f.err = err; $f.$s = $s; $f.$r = $r; return $f;
}), []);
};
Simulation.prototype.onSimulateClick = function(e) { return this.$val.onSimulateClick(e); };
Simulation.ptr.prototype.onRestartClick = function(e) {
@ -78646,7 +78682,7 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
};
Simulation.prototype.onRestartClick = function(e) { return this.$val.onRestartClick(e); };
NewStats = function() {
return new Stats.ptr(new vecty.Core.ptr($ifaceNil, $ifaceNil, false, false), new stats.Stats.ptr(false, $clone(stats.NewCoverage(100, 200), stats.Coverage), $clone(stats.NewCoverage(100, 200), stats.Coverage), ptrType$4.nil, ptrType$4.nil, ptrType$4.nil, new time.Duration(0, 1234000000)));
return new Stats.ptr(new vecty.Core.ptr($ifaceNil, $ifaceNil, false, false), new stats.Stats.ptr(false, $clone(stats.NewCoverage(100, 200), stats.Coverage), $clone(stats.NewCoverage(100, 200), stats.Coverage), ptrType$3.nil, ptrType$3.nil, ptrType$3.nil, new time.Duration(0, 1234000000)));
};
$pkg.NewStats = NewStats;
Stats.ptr.prototype.Update = function(stats$1) {
@ -78663,9 +78699,9 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
var _arg, _arg$1, _arg$2, _arg$3, _arg$4, _arg$5, _arg$6, _r, _r$1, _r$2, _r$3, _r$4, _r$5, _r$6, _r$7, _r$8, _r$9, s, x, $s, $r;
/* */ $s = 0; var $f, $c = false; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; _arg = $f._arg; _arg$1 = $f._arg$1; _arg$2 = $f._arg$2; _arg$3 = $f._arg$3; _arg$4 = $f._arg$4; _arg$5 = $f._arg$5; _arg$6 = $f._arg$6; _r = $f._r; _r$1 = $f._r$1; _r$2 = $f._r$2; _r$3 = $f._r$3; _r$4 = $f._r$4; _r$5 = $f._r$5; _r$6 = $f._r$6; _r$7 = $f._r$7; _r$8 = $f._r$8; _r$9 = $f._r$9; s = $f.s; x = $f.x; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
s = this;
/* */ if (s.stats === ptrType$3.nil) { $s = 1; continue; }
/* */ if (s.stats === ptrType$2.nil) { $s = 1; continue; }
/* */ $s = 2; continue;
/* if (s.stats === ptrType$3.nil) { */ case 1:
/* if (s.stats === ptrType$2.nil) { */ case 1:
_r = elem.Div(new sliceType([])); /* */ $s = 3; case 3: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
$s = -1; return _r;
/* } */ case 2:
@ -78744,21 +78780,21 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
}), []);
};
UploadWidget.prototype.onUploadClick = function(e) { return this.$val.onUploadClick(e); };
ptrType$5.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "Config", name: "Config", pkg: "", typ: $funcType([], [ForcesConfig], false)}];
ptrType.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "onEditInput", name: "onEditInput", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$6], [], false)}, {prop: "Value", name: "Value", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Changed", name: "Changed", pkg: "", typ: $funcType([], [$Bool], false)}];
ptrType$7.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "Inc", name: "Inc", pkg: "", typ: $funcType([], [], false)}, {prop: "Steps", name: "Steps", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Reset", name: "Reset", pkg: "", typ: $funcType([], [], false)}, {prop: "SetSteps", name: "SetSteps", pkg: "", typ: $funcType([$Int], [], false)}, {prop: "Progress", name: "Progress", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "text", name: "text", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([], [$String], false)}];
ptrType$1.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "Value", name: "Value", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Changed", name: "Changed", pkg: "", typ: $funcType([], [$Bool], false)}, {prop: "onChange", name: "onChange", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$6], [], false)}];
ptrType$8.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "onEditInput", name: "onEditInput", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$6], [], false)}, {prop: "Address", name: "Address", pkg: "", typ: $funcType([], [$String], false)}, {prop: "onSimulateClick", name: "onSimulateClick", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$6], [], false)}, {prop: "onRestartClick", name: "onRestartClick", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$6], [], false)}];
ptrType$10.methods = [{prop: "Update", name: "Update", pkg: "", typ: $funcType([ptrType$3], [], false)}, {prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "tableRow", name: "tableRow", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([$String, $emptyInterface], [ptrType$9], false)}];
ptrType$11.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "onUploadClick", name: "onUploadClick", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$6], [], false)}];
ptrType$4.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "Config", name: "Config", pkg: "", typ: $funcType([], [ForcesConfig], false)}];
ptrType.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "onEditInput", name: "onEditInput", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$5], [], false)}, {prop: "Value", name: "Value", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "Changed", name: "Changed", pkg: "", typ: $funcType([], [$Bool], false)}];
ptrType$6.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "Inc", name: "Inc", pkg: "", typ: $funcType([], [], false)}, {prop: "Steps", name: "Steps", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Reset", name: "Reset", pkg: "", typ: $funcType([], [], false)}, {prop: "SetSteps", name: "SetSteps", pkg: "", typ: $funcType([$Int], [], false)}, {prop: "Progress", name: "Progress", pkg: "", typ: $funcType([], [$Float64], false)}, {prop: "text", name: "text", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([], [$String], false)}];
ptrType$1.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "Value", name: "Value", pkg: "", typ: $funcType([], [$Int], false)}, {prop: "Changed", name: "Changed", pkg: "", typ: $funcType([], [$Bool], false)}, {prop: "onChange", name: "onChange", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$5], [], false)}];
ptrType$7.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "onEditInput", name: "onEditInput", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$5], [], false)}, {prop: "Address", name: "Address", pkg: "", typ: $funcType([], [$String], false)}, {prop: "onSimulateClick", name: "onSimulateClick", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$5], [], false)}, {prop: "onRestartClick", name: "onRestartClick", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$5], [], false)}];
ptrType$9.methods = [{prop: "Update", name: "Update", pkg: "", typ: $funcType([ptrType$2], [], false)}, {prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "tableRow", name: "tableRow", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([$String, $emptyInterface], [ptrType$8], false)}];
ptrType$10.methods = [{prop: "Render", name: "Render", pkg: "", typ: $funcType([], [vecty.ComponentOrHTML], false)}, {prop: "onUploadClick", name: "onUploadClick", pkg: "github.com/status-im/whispervis/widgets", typ: $funcType([ptrType$5], [], false)}];
ForceEditor.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "config", name: "config", embedded: false, exported: false, typ: ForcesConfig, tag: ""}, {prop: "repelling", name: "repelling", embedded: false, exported: false, typ: ptrType, tag: ""}, {prop: "spring", name: "spring", embedded: false, exported: false, typ: ptrType, tag: ""}, {prop: "drag", name: "drag", embedded: false, exported: false, typ: ptrType, tag: ""}, {prop: "steps", name: "steps", embedded: false, exported: false, typ: ptrType$1, tag: ""}]);
ForcesConfig.init("", [{prop: "Config", name: "Config", embedded: true, exported: true, typ: layout.Config, tag: ""}, {prop: "Steps", name: "Steps", embedded: false, exported: true, typ: $Int, tag: ""}]);
ForceInput.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "changed", name: "changed", embedded: false, exported: false, typ: $Bool, tag: ""}, {prop: "title", name: "title", embedded: false, exported: false, typ: $String, tag: ""}, {prop: "value", name: "value", embedded: false, exported: false, typ: $Float64, tag: ""}]);
Loader.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "mx", name: "mx", embedded: false, exported: false, typ: sync.RWMutex, tag: ""}, {prop: "steps", name: "steps", embedded: false, exported: false, typ: $Int, tag: ""}, {prop: "current", name: "current", embedded: false, exported: false, typ: $Int, tag: ""}]);
Range.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "changed", name: "changed", embedded: false, exported: false, typ: $Bool, tag: ""}, {prop: "title", name: "title", embedded: false, exported: false, typ: $String, tag: ""}, {prop: "value", name: "value", embedded: false, exported: false, typ: $Int, tag: ""}]);
Simulation.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "startSimulation", name: "startSimulation", embedded: false, exported: false, typ: funcType, tag: ""}, {prop: "replay", name: "replay", embedded: false, exported: false, typ: funcType, tag: ""}, {prop: "address", name: "address", embedded: false, exported: false, typ: $String, tag: ""}, {prop: "plog", name: "plog", embedded: false, exported: false, typ: ptrType$2, tag: ""}]);
Stats.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "stats", name: "stats", embedded: false, exported: false, typ: ptrType$3, tag: ""}]);
UploadWidget.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "handler", name: "handler", embedded: false, exported: false, typ: funcType$1, tag: ""}]);
Simulation.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "startSimulation", name: "startSimulation", embedded: false, exported: false, typ: funcType, tag: ""}, {prop: "replay", name: "replay", embedded: false, exported: false, typ: funcType$1, tag: ""}, {prop: "address", name: "address", embedded: false, exported: false, typ: $String, tag: ""}, {prop: "errMsg", name: "errMsg", embedded: false, exported: false, typ: $String, tag: ""}, {prop: "hasResults", name: "hasResults", embedded: false, exported: false, typ: $Bool, tag: ""}]);
Stats.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "stats", name: "stats", embedded: false, exported: false, typ: ptrType$2, tag: ""}]);
UploadWidget.init("github.com/status-im/whispervis/widgets", [{prop: "Core", name: "Core", embedded: true, exported: true, typ: vecty.Core, tag: ""}, {prop: "handler", name: "handler", embedded: false, exported: false, typ: funcType$2, tag: ""}]);
$init = function() {
$pkg.$init = function() {};
/* */ var $f, $c = false, $s = 0, $r; if (this !== undefined && this.$blk !== undefined) { $f = this; $c = true; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
@ -78768,12 +78804,11 @@ $packages["github.com/status-im/whispervis/widgets"] = (function() {
$r = elem.$init(); /* */ $s = 4; case 4: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = event.$init(); /* */ $s = 5; case 5: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = prop.$init(); /* */ $s = 6; case 6: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = propagation.$init(); /* */ $s = 7; case 7: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = stats.$init(); /* */ $s = 8; case 8: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = jsapi.$init(); /* */ $s = 9; case 9: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = sync.$init(); /* */ $s = 10; case 10: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = time.$init(); /* */ $s = 11; case 11: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$pkg.DefaultForcesConfig = new ForcesConfig.ptr($clone(layout.DefaultConfig, layout.Config), 100);
$r = stats.$init(); /* */ $s = 7; case 7: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = jsapi.$init(); /* */ $s = 8; case 8: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = sync.$init(); /* */ $s = 9; case 9: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$r = time.$init(); /* */ $s = 10; case 10: if($c) { $c = false; $r = $r.$blk(); } if ($r && $r.$blk !== undefined) { break s; }
$pkg.DefaultForcesConfig = new ForcesConfig.ptr($clone(layout.DefaultConfig, layout.Config), 10);
/* */ } return; } if ($f === undefined) { $f = { $blk: $init }; } $f.$s = $s; $f.$r = $r; return $f;
};
$pkg.$init = $init;
@ -163353,13 +163388,13 @@ $packages["github.com/status-im/whispervis"] = (function() {
sim = _tuple[0];
err = _tuple[1];
if (!($interfaceIsEqual(err, $ifaceNil))) {
$s = -1; return;
$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; }
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;
$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;
};
Page.prototype.startSimulation = function() { return this.$val.startSimulation(); };
@ -163458,15 +163493,15 @@ $packages["github.com/status-im/whispervis"] = (function() {
};
WebGLScene.prototype.InitControls = function() { return this.$val.InitControls(); };
Page.ptr.prototype.runSimulation = function(address) {
var _r, _r$1, _r$2, _r$3, _r$4, _r$5, _r$6, _tuple, address, buf, err, p, payload, plog, resp, url, $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; _r$2 = $f._r$2; _r$3 = $f._r$3; _r$4 = $f._r$4; _r$5 = $f._r$5; _r$6 = $f._r$6; _tuple = $f._tuple; address = $f.address; buf = $f.buf; err = $f.err; p = $f.p; payload = $f.payload; plog = $f.plog; resp = $f.resp; url = $f.url; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
var _r, _r$1, _r$2, _r$3, _r$4, _r$5, _r$6, _tuple, address, buf, err, host, p, payload, plog, resp, $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; _r$2 = $f._r$2; _r$3 = $f._r$3; _r$4 = $f._r$4; _r$5 = $f._r$5; _r$6 = $f._r$6; _tuple = $f._tuple; address = $f.address; buf = $f.buf; err = $f.err; host = $f.host; p = $f.p; payload = $f.payload; plog = $f.plog; resp = $f.resp; $s = $f.$s; $r = $f.$r; } s: while (true) { switch ($s) { case 0:
plog = [plog];
p = this;
_r = p.currentNetworkJSON(); /* */ $s = 1; case 1: if($c) { $c = false; _r = _r.$blk(); } if (_r && _r.$blk !== undefined) { break s; }
payload = _r;
buf = bytes.NewBuffer(payload);
url = "http://" + address + "/";
_r$1 = http.Post(url, "application/json", buf); /* */ $s = 2; case 2: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; }
host = "http://" + address + "/";
_r$1 = http.Post(host, "application/json", buf); /* */ $s = 2; case 2: if($c) { $c = false; _r$1 = _r$1.$blk(); } if (_r$1 && _r$1.$blk !== undefined) { break s; }
_tuple = _r$1;
resp = _tuple[0];
err = _tuple[1];
@ -163475,7 +163510,7 @@ $packages["github.com/status-im/whispervis"] = (function() {
/* if (!($interfaceIsEqual(err, $ifaceNil))) { */ case 3:
_r$2 = fmt.Println(new sliceType$1([new $String("[ERROR] POST request to simulation backend:"), err])); /* */ $s = 5; case 5: if($c) { $c = false; _r$2 = _r$2.$blk(); } if (_r$2 && _r$2.$blk !== undefined) { break s; }
_r$2;
_r$3 = fmt.Errorf("backend error: %v", new sliceType$1([err])); /* */ $s = 6; case 6: if($c) { $c = false; _r$3 = _r$3.$blk(); } if (_r$3 && _r$3.$blk !== undefined) { break s; }
_r$3 = fmt.Errorf("Backend error. Did you run backend?", new sliceType$1([])); /* */ $s = 6; case 6: if($c) { $c = false; _r$3 = _r$3.$blk(); } if (_r$3 && _r$3.$blk !== undefined) { break s; }
$s = -1; return [ptrType$24.nil, _r$3];
/* } */ case 4:
plog[0] = new propagation.Log.ptr(sliceType$12.nil, sliceType$13.nil, sliceType$13.nil);
@ -163490,7 +163525,7 @@ $packages["github.com/status-im/whispervis"] = (function() {
$s = -1; return [ptrType$24.nil, _r$6];
/* } */ case 9:
$s = -1; return [new Simulation.ptr(plog[0], ptrType$29.nil), $ifaceNil];
/* */ } return; } if ($f === undefined) { $f = { $blk: Page.ptr.prototype.runSimulation }; } $f._r = _r; $f._r$1 = _r$1; $f._r$2 = _r$2; $f._r$3 = _r$3; $f._r$4 = _r$4; $f._r$5 = _r$5; $f._r$6 = _r$6; $f._tuple = _tuple; $f.address = address; $f.buf = buf; $f.err = err; $f.p = p; $f.payload = payload; $f.plog = plog; $f.resp = resp; $f.url = url; $f.$s = $s; $f.$r = $r; return $f;
/* */ } return; } if ($f === undefined) { $f = { $blk: Page.ptr.prototype.runSimulation }; } $f._r = _r; $f._r$1 = _r$1; $f._r$2 = _r$2; $f._r$3 = _r$3; $f._r$4 = _r$4; $f._r$5 = _r$5; $f._r$6 = _r$6; $f._tuple = _tuple; $f.address = address; $f.buf = buf; $f.err = err; $f.host = host; $f.p = p; $f.payload = payload; $f.plog = plog; $f.resp = resp; $f.$s = $s; $f.$r = $r; return $f;
};
Page.prototype.runSimulation = function(address) { return this.$val.runSimulation(address); };
Page.ptr.prototype.currentNetworkJSON = function() {
@ -163644,7 +163679,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([], [], 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([], [], 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

View File

@ -9,7 +9,7 @@ import (
// DefaultForcesConfig specifies default configuration for physics simulation.
var DefaultForcesConfig = ForcesConfig{
Config: layout.DefaultConfig,
Steps: 100,
Steps: 10,
}
// ForceEditor represents forces and physics simulation configuration widget.

View File

@ -5,22 +5,23 @@ import (
"github.com/gopherjs/vecty/elem"
"github.com/gopherjs/vecty/event"
"github.com/gopherjs/vecty/prop"
"github.com/status-im/simulation/propagation"
)
// Simulation represents configuration panel for propagation simulation.
type Simulation struct {
vecty.Core
startSimulation func()
startSimulation func() error
replay func()
address string // backend host address
plog *propagation.Log // last simulation result
address string // backend host address
errMsg string
hasResults bool
}
// NewSimulation creates new simulation configuration panel. If simulation
// backend host address is not specified, it'll use 'localhost:8084' as a default.
func NewSimulation(address string, startSimulation, replay func()) *Simulation {
func NewSimulation(address string, startSimulation func() error, replay func()) *Simulation {
if address == "" {
address = "http://localhost:8084"
}
@ -55,10 +56,15 @@ func (s *Simulation) Render() vecty.ComponentOrHTML {
vecty.Style("text-align", "right"),
),
),
elem.Break(),
),
elem.Div(
vecty.Markup(
vecty.Class("pure-markup-group", "pure-u-1"),
),
elem.Button(
vecty.Markup(
vecty.Class("pure-button"),
vecty.Class("pure-u-1-2"),
vecty.Style("background", "rgb(28, 184, 65)"),
vecty.Style("color", "white"),
vecty.Style("border-radius", "4px"),
@ -66,15 +72,32 @@ func (s *Simulation) Render() vecty.ComponentOrHTML {
),
vecty.Text("Start simulation"),
),
elem.Button(
vecty.Markup(
vecty.Class("pure-button"),
vecty.Style("background", "rgb(28, 184, 65)"),
vecty.Style("color", "white"),
vecty.Style("border-radius", "4px"),
event.Click(s.onRestartClick),
vecty.If(s.hasResults,
elem.Button(
vecty.Markup(
vecty.Class("pure-button"),
vecty.Class("pure-u-1-3"),
vecty.Style("background", "rgb(28, 184, 65)"),
vecty.Style("color", "white"),
vecty.Style("margin", "10px"),
vecty.Style("border-radius", "4px"),
event.Click(s.onRestartClick),
),
vecty.Text("Replay"),
),
vecty.Text("Replay"),
),
elem.Break(),
elem.Div(
vecty.If(s.errMsg != "", elem.Paragraph(
vecty.Markup(
vecty.Style("background", "rgb(202, 60, 60)"),
vecty.Style("color", "white"),
vecty.Style("border-radius", "4px"),
vecty.Style("margin-right", "5px"),
vecty.Style("padding", "5px"),
),
vecty.Text(s.errMsg),
)),
),
),
)
@ -92,7 +115,19 @@ func (s *Simulation) Address() string {
}
func (s *Simulation) onSimulateClick(e *vecty.Event) {
go s.startSimulation()
go func() {
s.errMsg = ""
s.hasResults = false
vecty.Rerender(s)
err := s.startSimulation()
if err != nil {
s.errMsg = err.Error()
}
s.hasResults = err == nil
vecty.Rerender(s)
}()
}
func (s *Simulation) onRestartClick(e *vecty.Event) {