Added config won't change warning

This commit is contained in:
VakarisZ 2019-12-20 12:12:26 +02:00
parent 34c2ff6bb6
commit 5dc6fffc2a
1 changed files with 8 additions and 14 deletions

View File

@ -30,7 +30,7 @@ class ConfigurePageComponent extends AuthComponent {
lastAction: 'none', lastAction: 'none',
sections: [], sections: [],
selectedSection: 'attack', selectedSection: 'attack',
allMonkeysAreDead: true, monkeysRan: false,
PBAwinFile: [], PBAwinFile: [],
PBAlinuxFile: [], PBAlinuxFile: [],
showAttackAlert: false showAttackAlert: false
@ -363,13 +363,7 @@ class ConfigurePageComponent extends AuthComponent {
this.authFetch('/api') this.authFetch('/api')
.then(res => res.json()) .then(res => res.json())
.then(res => { .then(res => {
// This check is used to prevent unnecessary re-rendering this.setState({monkeysRan: res['completed_steps']['run_monkey']});
let allMonkeysAreDead = (!res['completed_steps']['run_monkey']) || (res['completed_steps']['infection_done']);
if (allMonkeysAreDead !== this.state.allMonkeysAreDead) {
this.setState({
allMonkeysAreDead: allMonkeysAreDead
});
}
}); });
}; };
@ -470,15 +464,15 @@ class ConfigurePageComponent extends AuthComponent {
</div>) </div>)
}; };
renderRunningMonkeysWarning = () => { renderConfigWontChangeWarning = () => {
return (<div> return (<div>
{this.state.allMonkeysAreDead ? {this.state.monkeysRan ?
'' :
<div className="alert alert-warning"> <div className="alert alert-warning">
<i className="glyphicon glyphicon-warning-sign" style={{'marginRight': '5px'}}/> <i className="glyphicon glyphicon-warning-sign" style={{'marginRight': '5px'}}/>
Some monkeys are currently running. Note that changing the configuration will only apply to new Changed configuration will only apply to new infections.
infections. "Start over" to run again with different configuration.
</div> </div>
: ''
} }
</div>) </div>)
}; };
@ -520,7 +514,7 @@ class ConfigurePageComponent extends AuthComponent {
{this.renderAttackAlertModal()} {this.renderAttackAlertModal()}
<h1 className="page-title">Monkey Configuration</h1> <h1 className="page-title">Monkey Configuration</h1>
{this.renderNav()} {this.renderNav()}
{this.renderRunningMonkeysWarning()} {this.renderConfigWontChangeWarning()}
{content} {content}
<div className="text-center"> <div className="text-center">
<button type="submit" onClick={this.onSubmit} className="btn btn-success btn-lg" style={{margin: '5px'}}> <button type="submit" onClick={this.onSubmit} className="btn btn-success btn-lg" style={{margin: '5px'}}>