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