From 7027ba917789fe2e3f88f00dec32232de6d78299 Mon Sep 17 00:00:00 2001 From: Michael Winsauer Date: Sun, 20 Jan 2019 03:32:13 +0100 Subject: [PATCH] Retrieve pdf download url --- .../src/components/SentimentAnalysis.js | 9 +++++- .../src/services/CamundaService.js | 29 +++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/service-website/src/components/SentimentAnalysis.js b/service-website/src/components/SentimentAnalysis.js index 5d3235a..2e7df19 100644 --- a/service-website/src/components/SentimentAnalysis.js +++ b/service-website/src/components/SentimentAnalysis.js @@ -13,7 +13,6 @@ class SentimentAnalysis extends Component { nextTermId: 1, pdfLink: null, }; - this.camundaService = new CamundaService(); this.handleSubmit = this.handleSubmit.bind(this); this.handleTermChange = this.handleTermChange.bind(this); this.handleAddTerm = this.handleAddTerm.bind(this); @@ -22,6 +21,8 @@ class SentimentAnalysis extends Component { this.emptyTerms = this.emptyTerms.bind(this); this.getNonEmptyTerms = this.getNonEmptyTerms.bind(this); this.createPdf = this.createPdf.bind(this); + this.setPdfLink = this.setPdfLink.bind(this); + this.camundaService = new CamundaService(this.setPdfLink); } handleSubmit(event) { @@ -82,6 +83,12 @@ class SentimentAnalysis extends Component { } } + setPdfLink(url) { + this.setState({ + pdfLink: url, + }); + } + render() { return (
diff --git a/service-website/src/services/CamundaService.js b/service-website/src/services/CamundaService.js index c249ec8..ee15bba 100644 --- a/service-website/src/services/CamundaService.js +++ b/service-website/src/services/CamundaService.js @@ -1,11 +1,15 @@ import axios from "axios"; class CamundaService { - constructor() { + constructor(callback) { + this.callback = callback; + this.baseUrl = 'http://localhost:8085/engine-rest/'; this.axiosInstance = axios.create({ - baseURL: 'http://localhost:8085/engine-rest/', + baseURL: this.baseUrl, }); this.submitPdfForm = this.submitPdfForm.bind(this); + this.getPdfDownloadLink = this.getPdfDownloadLink.bind(this); + this.completeTask = this.completeTask.bind(this); } submitPdfForm(terms) { @@ -25,6 +29,27 @@ class CamundaService { }; this.axiosInstance .post(submitFormUrl, data) + .then(response => { + const data = response.data; + console.log(data); + const id = data['id']; + this.getPdfDownloadLink(id) + }) + .catch(error => { + console.log(error); + }) + } + + getPdfDownloadLink(id) { + const downloadUrl = this.baseUrl + 'process-instance/' + id + '/variables/reportPDF/data'; + console.log('download: ' + downloadUrl); + this.callback(downloadUrl); + } + + completeTask(id) { + const completeTaskUrl = 'task/' + id + '/complete'; + this.axiosInstance + .post(completeTaskUrl) .then(response => { const data = response.data; console.log(data); -- 2.43.0