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/src') 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 From 65f9bb547a24dd851d366f22950cb4301f3e8ae4 Mon Sep 17 00:00:00 2001 From: therealbobo Date: Thu, 17 Sep 2020 18:36:47 +0200 Subject: full support to upload/load --- frontend/src/views/Upload.js | 112 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 94 insertions(+), 18 deletions(-) (limited to 'frontend/src') diff --git a/frontend/src/views/Upload.js b/frontend/src/views/Upload.js index d3f6bf3..29d514d 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, FormFile, InputGroup, Modal, Row, Table} from "react-bootstrap"; +import {Button, ButtonGroup, ToggleButton, Col, Container, Form, FormFile, InputGroup, Modal, Row, Table} from "react-bootstrap"; import bsCustomFileInput from 'bs-custom-file-input' import {createCurlCommand} from '../utils'; @@ -11,11 +11,34 @@ class Upload extends Component { this.state = { selectedFile: null, + removeOriginal: false, + flushAll: false, errors: "" }; + this.flushAllChanged = this.flushAllChanged.bind(this); + this.removeOriginalChanged = this.removeOriginalChanged.bind(this); + + + } + + flushAllChanged() { + this.setState({flushAll: !this.value}); + this.checked = !this.checked; + this.value = !this.value; + } + + removeOriginalChanged() { + this.setState({removeOriginal: !this.value}); + this.checked = !this.checked; + this.value = !this.value; } + onLocalFileChange = event => { + this.setState({ selectedFile: event.target.value }); + + }; + onFileChange = event => { this.setState({ selectedFile: event.target.files[0] }); @@ -26,14 +49,14 @@ class Upload extends Component { } onFileProcess = () => { - const formData = new FormData(); - formData.append( - "file", - this.state.selectedFile.name - ); + const data = { + "file": this.state.selectedFile, + "flush_all": this.state.flushAll, + "delete_original_file": this.state.removeOriginal}; + fetch('/api/pcap/file', { method: 'POST', - body: formData + body: JSON.stringify(data) }) .then(response => { if (response.status === 202 ){ @@ -89,12 +112,31 @@ class Upload extends Component { > - /usr/bin/upload + /usr/bin/load_pcap + + --local + + + --upload + + + + + + + + -
+
- + + + this.removeOriginalChanged()} + > + --remove-original-file + + + + + + + + + + this.flushAllChanged()} + > + --flush-all + + + + + + + + +
+ + + +
+ +

@@ -130,8 +208,6 @@ class Upload extends Component {
- - -- cgit v1.2.3-70-g09d2