From ea072e0305562632e12b4e1324fb3f5384abf551 Mon Sep 17 00:00:00 2001 From: Michael Winsauer Date: Sun, 20 Jan 2019 23:38:12 +0100 Subject: [PATCH] Remove old pdf link after submitting new terms --- service-website/src/components/PdfReport.js | 13 ++++------ .../src/components/SentimentAnalysis.js | 25 ++++++++++++------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/service-website/src/components/PdfReport.js b/service-website/src/components/PdfReport.js index 200971a..1674eed 100644 --- a/service-website/src/components/PdfReport.js +++ b/service-website/src/components/PdfReport.js @@ -9,16 +9,12 @@ const PdfReport = ({pdfLink, loading}) => {
- + - - Click to download - - - - Report created successfully + Click to download + Report created successfully
); @@ -32,7 +28,8 @@ const PdfReport = ({pdfLink, loading}) => {
-
); + + ); } else { return null; } diff --git a/service-website/src/components/SentimentAnalysis.js b/service-website/src/components/SentimentAnalysis.js index eef730d..48455ff 100644 --- a/service-website/src/components/SentimentAnalysis.js +++ b/service-website/src/components/SentimentAnalysis.js @@ -18,6 +18,7 @@ class SentimentAnalysis extends Component { this.handleTermChange = this.handleTermChange.bind(this); this.handleAddTerm = this.handleAddTerm.bind(this); this.handleRemoveTerm = this.handleRemoveTerm.bind(this); + this.handleReset = this.handleReset.bind(this); this.addEmptyTerm = this.addEmptyTerm.bind(this); this.emptyTerms = this.emptyTerms.bind(this); this.getNonEmptyTerms = this.getNonEmptyTerms.bind(this); @@ -28,17 +29,13 @@ class SentimentAnalysis extends Component { handleSubmit(event) { event.preventDefault(); - const target = event.target; - console.log(target); - const terms = this.state.terms; - terms.forEach((term) => { - console.log(term); - }); this.setState({ + pdfLink: null, isLoading: true, + }, () => { + this.createPdf(); + this.emptyTerms(); }); - this.createPdf(); - this.emptyTerms(); } handleTermChange(id, value) { @@ -59,6 +56,15 @@ class SentimentAnalysis extends Component { }); } + handleReset(event) { + this.setState({ + terms: new Map().set(0, ''), + nextTermId: 1, + pdfLink: null, + isLoading: false, + }); + } + addEmptyTerm() { const terms = this.state.terms; const termId = this.state.nextTermId; @@ -90,6 +96,7 @@ class SentimentAnalysis extends Component { setPdfLink(url) { this.setState({ pdfLink: url, + isLoading: false, }); } @@ -109,7 +116,7 @@ class SentimentAnalysis extends Component {

- +

-- 2.43.0