Skip to content

Commit

Permalink
Add button for stop crawl in the user interface (Closes #139)
Browse files Browse the repository at this point in the history
  • Loading branch information
aecio committed Nov 2, 2017
1 parent fb3f1cc commit 958e94f
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions ache-dashboard/src/StartCrawl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class StartCrawl extends React.Component {
if(response.crawlerRunning === true) {
this.setState({
crawlerRunning: true,
crawlerState: response.crawlerState,
serverMessage: "Crawler is running. Open \"Monitoring\" tab for crawl details."
});
} else {
Expand Down Expand Up @@ -71,14 +72,27 @@ class StartCrawl extends React.Component {
api.post("/startCrawl", config).then(this.updateResponse.bind(this));
}

stopCrawl(event) {
//this.setState({starting: true});
var config = {
mode: 'cors'
};
api.get("/stopCrawl", config).then(this.updateResponse.bind(this));
}

updateResponse(response) {
if('FETCH_ERROR' === response) {
this.setState({
serverError: true,
serverMessage: "Failed to connect to server to start the crawler."
});
} else {
if(response.crawlerStarted === false) {
if(response.shutdownInitiated === true) {
this.setState({
stopping: true,
serverMessage: response.message
});
} else if(response.crawlerStarted === false) {
this.setState({
starting: false,
serverError: true,
Expand Down Expand Up @@ -145,11 +159,20 @@ class StartCrawl extends React.Component {
);
}

// render crawker running message
// render crawler running message
if (this.state.crawlerRunning === true) {
return (
<div className="alert alert-success message">
<span className="glyphicon glyphicon-ok-circle" aria-hidden="true"></span>&nbsp;{this.state.serverMessage}
<div className="row">
<div className="row">
<div className="alert alert-success message">
<span className="glyphicon glyphicon-ok-circle" aria-hidden="true"></span>&nbsp;{this.state.serverMessage}
</div>
</div>
<div className="row">
<div className="col-md-6 col-md-offset-3">
<button type="button" className="btn btn-block btn-default btn-lg" onClick={(e)=>this.stopCrawl(e)}>Stop Crawler</button>
</div>
</div>
</div>
);
}
Expand Down

0 comments on commit 958e94f

Please sign in to comment.