From 62702f0322212e8308c36ab2ce9372f1cb901212 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Thu, 21 Sep 2017 17:06:34 +0300 Subject: [PATCH] Made map refresh periodically --- .../cc/ui/src/components/pages/MapPage.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/monkey_island/cc/ui/src/components/pages/MapPage.js b/monkey_island/cc/ui/src/components/pages/MapPage.js index c26c8288d..224cb299f 100644 --- a/monkey_island/cc/ui/src/components/pages/MapPage.js +++ b/monkey_island/cc/ui/src/components/pages/MapPage.js @@ -75,6 +75,15 @@ class MapPageComponent extends React.Component { } componentDidMount() { + this.updateMapFromServer(); + this.interval = setInterval(this.updateMapFromServer, 1000); + } + + componentWillUnmount() { + clearInterval(this.interval); + } + + updateMapFromServer = () => { fetch('/api/netmap') .then(res => res.json()) .then(res => { @@ -84,7 +93,7 @@ class MapPageComponent extends React.Component { this.setState({graph: res}); this.props.onStatusChange(); }); - } + }; selectionChanged(event) { if (event.nodes.length === 1) { @@ -110,13 +119,13 @@ class MapPageComponent extends React.Component { console.log('selection cleared.'); // eslint-disable-line no-console this.setState({selected: null, selectedType: null}); } - } + }; killAllMonkeys = () => { fetch('/api?action=killall') .then(res => res.json()) - .then(res => this.setState({killPressed: (res.status=="OK")})); - } + .then(res => this.setState({killPressed: (res.status==="OK")})); + }; render() { return ( @@ -135,7 +144,7 @@ class MapPageComponent extends React.Component {
Monkey Telemetry