Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Add download button on the popup modal during model export
Browse files Browse the repository at this point in the history
Opening a new window tab inside an AJAX request turned out
to be almost impossible without using some non-reliable hacks.
Hence providing a button on the popup modal for user to click.
  • Loading branch information
nandukalidindi committed Aug 8, 2017
1 parent e9d3001 commit 72031a6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions client/src/components/FocusedCrawling.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ class FocusedCrawling extends Component {
function(model_file) {
var url = model_file;
var message = (url.indexOf("_model.zip")==-1)?"Model was not created.":"Model created successfully.";
if(url.indexOf("_model.zip")>-1) window.open(url,'Download');
this.setState({loadingModel:false, disabledCreateModel:false, createModelMessage:message, openMessageModelResult:true,})

this.setState({modelDownloadURL: model_file, loadingModel:false, disabledCreateModel:false, createModelMessage:message, openMessageModelResult:true})
this.forceUpdate();
}.bind(this)
);
Expand All @@ -340,6 +340,11 @@ class FocusedCrawling extends Component {
this.getCreatedModel(this.state.session);
}

downloadExportedModel = (event) => {
if((this.state.modelDownloadURL || "").indexOf("_model.zip") !== -1)
window.open(this.state.modelDownloadURL, 'download')
}

handleCloseModelResult = () => {
this.setState({openMessageModelResult: false});
};
Expand Down Expand Up @@ -552,6 +557,12 @@ class FocusedCrawling extends Component {
onRequestClose={this.handleCloseModelResult.bind(this)}
>
{this.state.createModelMessage}
<RaisedButton
label="Download"
style={{margin: 5}}
labelStyle={{textTransform: "capitalize"}}
onClick={this.downloadExportedModel}
/>
</Dialog>
</div>
</CardText>
Expand Down

0 comments on commit 72031a6

Please sign in to comment.