From e6c7e83ac07707dd32430e25e8bf511f3ea2313e Mon Sep 17 00:00:00 2001 From: Michael Winsauer Date: Sat, 19 Jan 2019 15:26:38 +0100 Subject: [PATCH] Add camunda service --- service-website/src/components/PdfReport.js | 2 +- .../src/components/SentimentAnalysis.js | 20 ++-------- .../src/services/CamundaService.js | 37 +++++++++++++++++++ 3 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 service-website/src/services/CamundaService.js diff --git a/service-website/src/components/PdfReport.js b/service-website/src/components/PdfReport.js index c0ca230..691ec2a 100644 --- a/service-website/src/components/PdfReport.js +++ b/service-website/src/components/PdfReport.js @@ -14,7 +14,7 @@ const PdfReport = ({pdfLink}) => { }; PdfReport.propTypes = { - pdfLink: PropTypes.string.isRequired, + pdfLink: PropTypes.string, }; export default PdfReport; diff --git a/service-website/src/components/SentimentAnalysis.js b/service-website/src/components/SentimentAnalysis.js index 944cc51..88b41c7 100644 --- a/service-website/src/components/SentimentAnalysis.js +++ b/service-website/src/components/SentimentAnalysis.js @@ -1,8 +1,8 @@ import React, {Component} from "react"; -import axios from "axios"; import {Map} from "immutable"; import PdfReport from "./PdfReport"; import SearchTermsInput from "./SearchTermsInput"; +import CamundaService from "../services/CamundaService"; class SentimentAnalysis extends Component { constructor(props, context) { @@ -12,6 +12,7 @@ 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); @@ -68,22 +69,7 @@ class SentimentAnalysis extends Component { } createPdf() { - axios - .post('https://jsonplaceholder.typicode.com/posts', { - title: 'foo', - body: 'bar', - userId: 1, - }) - .then(response => { - const data = response.data; - console.log(data); - this.setState({ - pdfLink: 'https://google.at', - }); - }) - .catch(error => { - console.log(error); - }); + this.camundaService.submitPdfForm(null); } render() { diff --git a/service-website/src/services/CamundaService.js b/service-website/src/services/CamundaService.js new file mode 100644 index 0000000..c2010c6 --- /dev/null +++ b/service-website/src/services/CamundaService.js @@ -0,0 +1,37 @@ +import axios from "axios"; + +class CamundaService { + constructor() { + this.axiosInstance = axios.create({ + baseURL: 'http://localhost:8085/engine-rest/', + headers: { + 'Access-Control-Allow-Origin': '*', + }, + }); + this.submitPdfForm = this.submitPdfForm.bind(this); + } + + submitPdfForm(terms) { + terms = [{term: "abc"}, {term: "def"}]; + const submitFormUrl = 'process-definition/key/sentiment-analysis/submit-form'; + const data = { + variables: { + terms: { + value: JSON.stringify(terms), + type: "Json" + } + } + }; + this.axiosInstance + .post(submitFormUrl, data) + .then(response => { + const data = response.data; + console.log(data); + }) + .catch(error => { + console.log(error); + }) + } +} + +export default CamundaService; -- 2.43.0