From 54f55f9ad4af4d50f0fca371b9a14308b1d80c6b Mon Sep 17 00:00:00 2001 From: therealbobo Date: Thu, 17 Sep 2020 14:17:11 +0200 Subject: intial local processing support --- frontend/src/views/Upload.js | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'frontend') diff --git a/frontend/src/views/Upload.js b/frontend/src/views/Upload.js index 522afe8..d3f6bf3 100644 --- a/frontend/src/views/Upload.js +++ b/frontend/src/views/Upload.js @@ -1,6 +1,6 @@ import React, {Component} from 'react'; import './Upload.scss'; -import {Button, ButtonGroup, Col, Container, Form, FormControl, InputGroup, Modal, Row, Table} from "react-bootstrap"; +import {Button, ButtonGroup, Col, Container, Form, FormFile, InputGroup, Modal, Row, Table} from "react-bootstrap"; import bsCustomFileInput from 'bs-custom-file-input' import {createCurlCommand} from '../utils'; @@ -25,6 +25,30 @@ class Upload extends Component { bsCustomFileInput.init() } + onFileProcess = () => { + const formData = new FormData(); + formData.append( + "file", + this.state.selectedFile.name + ); + fetch('/api/pcap/file', { + method: 'POST', + body: formData + }) + .then(response => { + if (response.status === 202 ){ + this.props.onHide(); + } else { + response.json().then(data => { + this.setState( + {errors : data.error.toString()} + ); + }); + } + } + ); + } + onFileUpload = () => { const formData = new FormData(); formData.append( @@ -80,6 +104,17 @@ class Upload extends Component { custom /> +
+ + + +
@@ -95,6 +130,7 @@ class Upload extends Component { + -- cgit v1.2.3-70-g09d2