aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-09-21 17:08:35 +0000
committerGitHub2020-09-21 17:08:35 +0000
commit8c8487b79300342b4c6dafe9c3691d43b8dc8e37 (patch)
treedef44b1d04e689b1f4e8e25e5ca9c5cff7abe557 /frontend
parent98355cdf838d8c18e9a28176ae7a847770545395 (diff)
parent65f9bb547a24dd851d366f22950cb4301f3e8ae4 (diff)
Merge pull request #17 from therealbobo/file-load
File load
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/views/Upload.js118
-rw-r--r--frontend/yarn.lock41
2 files changed, 136 insertions, 23 deletions
diff --git a/frontend/src/views/Upload.js b/frontend/src/views/Upload.js
index 522afe8..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, FormControl, 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] });
@@ -25,6 +48,30 @@ class Upload extends Component {
bsCustomFileInput.init()
}
+ onFileProcess = () => {
+ const data = {
+ "file": this.state.selectedFile,
+ "flush_all": this.state.flushAll,
+ "delete_original_file": this.state.removeOriginal};
+
+ fetch('/api/pcap/file', {
+ method: 'POST',
+ body: JSON.stringify(data)
+ })
+ .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(
@@ -65,12 +112,31 @@ class Upload extends Component {
>
<Modal.Header>
<Modal.Title id="services-dialog">
- /usr/bin/upload
+ /usr/bin/load_pcap
</Modal.Title>
</Modal.Header>
<Modal.Body>
<Container>
<Row>
+ <Col>
+ --local
+ </Col>
+ <Col>
+ --upload
+ </Col>
+ </Row>
+ <Row>
+ <Col>
+ <Form.Control
+ type="text"
+ id="pcap-upload"
+ className="custom-file"
+ onChange={this.onLocalFileChange}
+ placeholder="local .pcap/.pcapng"
+ custom
+ />
+ </Col>
+ <Col>
<Form.File
type="file"
className="custom-file"
@@ -79,7 +145,54 @@ class Upload extends Component {
id="custom-file"
custom
/>
+ </Col>
+ </Row>
+ <br/>
+ <Row>
+ <Col>
+ <ButtonGroup toggle className="mb-2">
+ <ToggleButton
+ type="checkbox"
+ variant="secondary"
+ checked={this.state.removeOriginal}
+ value={this.state.removeOriginal}
+ onChange={() => this.removeOriginalChanged()}
+ >
+ --remove-original-file
+ </ToggleButton>
+ </ButtonGroup>
+ </Col>
+ <Col>
+ </Col>
+ </Row>
+ <Row>
+ <Col>
+ <ButtonGroup toggle className="mb-2">
+ <ToggleButton
+ type="checkbox"
+ variant="secondary"
+ checked={this.state.flushAll}
+ value={this.state.flushAll}
+ onChange={() => this.flushAllChanged()}
+ >
+ --flush-all
+ </ToggleButton>
+ </ButtonGroup>
+ </Col>
+ <Col>
+ </Col>
+ </Row>
+ <Row>
+ <Col>
+ <br/>
+ <Button variant="blue" onClick={this.onFileProcess}>process_local</Button>
+ </Col>
+ <Col>
+ <br/>
+ <Button variant="green" onClick={this.onFileUpload}>upload</Button>
+ </Col>
</Row>
+ <hr/>
<Row>
<div class="error">
<b>
@@ -95,7 +208,6 @@ class Upload extends Component {
</Modal.Body>
<Modal.Footer className="dialog-footer">
- <Button variant="green" onClick={this.onFileUpload}>upload</Button>
<Button variant="red" onClick={this.props.onHide}>close</Button>
</Modal.Footer>
</Modal>
diff --git a/frontend/yarn.lock b/frontend/yarn.lock
index 7517add..39d346b 100644
--- a/frontend/yarn.lock
+++ b/frontend/yarn.lock
@@ -1691,9 +1691,9 @@
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
"@types/node@*":
- version "14.10.1"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-14.10.1.tgz#cc323bad8e8a533d4822f45ce4e5326f36e42177"
- integrity sha512-aYNbO+FZ/3KGeQCEkNhHFRIzBOUgc7QvcVNKXbfnhDkSfwUv91JsQQa10rDgKSTSLkXZ1UIyPe4FJJNVgw1xWQ==
+ version "14.10.2"
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.10.2.tgz#9b47a2c8e4dabd4db73b57e750b24af689600514"
+ integrity sha512-IzMhbDYCpv26pC2wboJ4MMOa9GKtjplXfcAqrMeNJpUUwpM/2ATt2w1JPUXwS6spu856TvKZL2AOmeU2rAxskw==
"@types/parse-json@^4.0.0":
version "4.0.0"
@@ -2805,6 +2805,7 @@ bs-custom-file-input@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/bs-custom-file-input/-/bs-custom-file-input-1.3.4.tgz#c275cb8d4f1c02ba026324292509fa9a747dbda8"
integrity sha512-NBsQzTnef3OW1MvdKBbMHAYHssCd613MSeJV7z2McXznWtVMnJCy7Ckyc+PwxV6Pk16cu6YBcYWh/ZE0XWNKCA==
+>>>>>>> 98355cdf838d8c18e9a28176ae7a847770545395
bser@2.1.1:
version "2.1.1"
@@ -2983,9 +2984,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001035, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125:
- version "1.0.30001129"
- resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001129.tgz#e6514b94c0ef50f98cf7476daa91228ddd2ef7bc"
- integrity sha512-9945fTVKS810DZITpsAbuhQG7Lam0tEfVbZlsBaCFZaszepbryrArS05PWmJSBQ6mta+v9iz0pUIAbW1eBILIg==
+ version "1.0.30001131"
+ resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001131.tgz#afad8a28fc2b7a0d3ae9407e71085a0ead905d54"
+ integrity sha512-4QYi6Mal4MMfQMSqGIRPGbKIbZygeN83QsWq1ixpUwvtfgAZot5BrCKzGygvZaV+CnELdTwD0S4cqUNozq7/Cw==
capture-exit@^2.0.0:
version "2.0.0"
@@ -4152,9 +4153,9 @@ ee-first@1.1.1:
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.564:
- version "1.3.567"
- resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.567.tgz#7a404288952ac990e447a7a86470d460ea953b8f"
- integrity sha512-1aKkw0Hha1Bw9JA5K5PT5eFXC/TXbkJvUfNSNEciPUMgSIsRJZM1hF2GUEAGZpAbgvd8En21EA+Lv820KOhvqA==
+ version "1.3.570"
+ resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.570.tgz#3f5141cc39b4e3892a276b4889980dabf1d29c7f"
+ integrity sha512-Y6OCoVQgFQBP5py6A/06+yWxUZHDlNr/gNDGatjH8AZqXl8X0tE4LfjLJsXGz/JmWJz8a6K7bR1k+QzZ+k//fg==
elliptic@^6.5.3:
version "6.5.3"
@@ -4305,9 +4306,9 @@ es6-symbol@^3.1.1, es6-symbol@~3.1.3:
ext "^1.1.2"
escalade@^3.0.2:
- version "3.0.2"
- resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.0.2.tgz#6a580d70edb87880f22b4c91d0d56078df6962c4"
- integrity sha512-gPYAU37hYCUhW5euPeR+Y74F7BL+IBsV93j5cvGriSaD1aG6MGsqsV1yamRdrWrb2j3aiZvb0X+UBOWpx3JWtQ==
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.0.tgz#e8e2d7c7a8b76f6ee64c2181d6b8151441602d4e"
+ integrity sha512-mAk+hPSO8fLDkhV7V0dXazH5pDc6MrjBTPyD3VeKzxnVFjH1MIxbCdqGZB9O8+EwWakZs3ZCbDS4IpRt79V1ig==
escape-html@~1.0.3:
version "1.0.3"
@@ -7454,10 +7455,10 @@ no-case@^3.0.3:
lower-case "^2.0.1"
tslib "^1.10.0"
-node-forge@0.9.0:
- version "0.9.0"
- resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579"
- integrity sha512-7ASaDa3pD+lJ3WvXFsxekJQelBKRpne+GOVbLbtHYdd7pFspyeuJHnWfLplGf3SwKGbfs/aYl5V/JCIaHVUKKQ==
+node-forge@^0.10.0:
+ version "0.10.0"
+ resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3"
+ integrity sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==
node-gyp@^3.8.0:
version "3.8.0"
@@ -9958,11 +9959,11 @@ select-hose@^2.0.0:
integrity sha1-Yl2GWPhlr0Psliv8N2o3NZpJlMo=
selfsigned@^1.10.7:
- version "1.10.7"
- resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.10.7.tgz#da5819fd049d5574f28e88a9bcc6dbc6e6f3906b"
- integrity sha512-8M3wBCzeWIJnQfl43IKwOmC4H/RAp50S8DF60znzjW5GVqTcSe2vWclt7hmYVPkKPlHWOu5EaWOMZ2Y6W8ZXTA==
+ version "1.10.8"
+ resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.10.8.tgz#0d17208b7d12c33f8eac85c41835f27fc3d81a30"
+ integrity sha512-2P4PtieJeEwVgTU9QEcwIRDQ/mXJLX8/+I3ur+Pg16nS8oNbrGxEso9NyYWy8NAmXiNl4dlAp5MwoNeCWzON4w==
dependencies:
- node-forge "0.9.0"
+ node-forge "^0.10.0"
"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
version "5.7.1"