diff --git a/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js b/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js index b0e6ba0b9..c9934d619 100644 --- a/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js +++ b/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js @@ -5,13 +5,14 @@ import {Icon} from 'react-fa'; import {Link} from "react-router-dom"; class RunMonkeyPageComponent extends React.Component { + constructor(props) { super(props); this.state = { ips: [], selectedIp: '0.0.0.0', - isRunningOnIsland: false, - isRunningLocally: false, + runningOnIslandState: "not_running", + runningOnClientState: "not_running", selectedSection: "windows-32" }; } @@ -25,15 +26,23 @@ class RunMonkeyPageComponent extends React.Component { fetch('/api/local-monkey') .then(res => res.json()) - .then(res => this.setState({ - isRunningOnIsland: res['is_running'] - })); + .then(res =>{ + if (res['is_running']) { + this.setState({runningOnIslandState: "running"}); + } else { + this.setState({runningOnIslandState: "not_running"}); + } + }); fetch('/api/client-monkey') .then(res => res.json()) - .then(res => this.setState({ - isRunningLocally: res['is_running'] - })); + .then(res => { + if (res['is_running']) { + this.setState({runningOnClientState: "running"}); + } else { + this.setState({runningOnClientState: "not_running"}); + } + }); this.props.onStatusChange(); } @@ -57,9 +66,16 @@ class RunMonkeyPageComponent extends React.Component { }) .then(res => res.json()) .then(res => { - this.setState({ - isRunningOnIsland: res['is_running'] - }); + if (res['is_running']) { + this.setState({ + runningOnIslandState: "installing" + }); + } else { + this.setState({ + runningOnIslandState: "not_running" + }); + } + this.props.onStatusChange(); }); }; @@ -93,6 +109,16 @@ class RunMonkeyPageComponent extends React.Component { }); }; + renderIconByState(state) { + if (state === "running") { + return + } else if (state == "installing") { + return + } else { + return ''; + } + } + render() { return ( @@ -104,20 +130,16 @@ class RunMonkeyPageComponent extends React.Component {

Download and run locally - { this.state.isRunningLocally ? - - : ''} + { this.renderIconByState(this.state.runningOnClientState) }