From 44af615b32faf53c04cd38cb63782cf1b1332c94 Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Sat, 26 Sep 2020 12:05:27 +0200 Subject: General refactor --- frontend/src/views/Upload.js | 218 ------------------------------------------- 1 file changed, 218 deletions(-) delete mode 100644 frontend/src/views/Upload.js (limited to 'frontend/src/views/Upload.js') diff --git a/frontend/src/views/Upload.js b/frontend/src/views/Upload.js deleted file mode 100644 index 29d514d..0000000 --- a/frontend/src/views/Upload.js +++ /dev/null @@ -1,218 +0,0 @@ -import React, {Component} from 'react'; -import './Upload.scss'; -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'; - -class Upload extends Component { - - constructor(props) { - super(props); - - 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] }); - - }; - - componentDidMount() { - 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( - "file", - this.state.selectedFile, - this.state.selectedFile.name - ); - fetch('/api/pcap/upload', { - method: 'POST', - body: formData - }) - .then(response => { - if (response.status === 202 ){ - //this.setState({showConfig:false}); - this.props.onHide(); - //this.props.onDone(); - } else { - response.json().then(data => { - this.setState( - {errors : data.error.toString()} - ); - }); - } - } - ); - } - - - render() { - - return ( - - - - /usr/bin/load_pcap - - - - - - - --local - - - --upload - - - - - - - - - - -
- - - - this.removeOriginalChanged()} - > - --remove-original-file - - - - - - - - - - this.flushAllChanged()} - > - --flush-all - - - - - - - - -
- - - -
- - -
-
- -
- -
- {this.state.errors - .split('\n').map((item, key) => { - return {item}
}) - } -
-
-
-
-
- - - - -
- ); - } -} - -export default Upload; -- cgit v1.2.3-70-g09d2