import React, {Component} from 'react'; import './PcapPane.scss'; import Table from "react-bootstrap/Table"; import backend from "../../backend"; import {createCurlCommand, formatSize, timestampToTime2} from "../../utils"; import {Button, Col, Container, Form, Row} from "react-bootstrap"; import InputField from "../fields/InputField"; import CheckField from "../fields/CheckField"; import TextField from "../fields/TextField"; class PcapPane extends Component { constructor(props) { super(props); this.state = { sessions: [], isFileValid: true, isFileFocused: false, selectedFile: null, uploadFlushAll: false, uploadStatusCode: null, uploadOutput: null }; this.loadSessions = this.loadSessions.bind(this); this.handleFileChange = this.handleFileChange.bind(this); this.handleUploadPcap = this.handleUploadPcap.bind(this); } componentDidMount() { this.loadSessions(); } loadSessions() { backend.get("/api/pcap/sessions").then(res => this.setState({sessions: res})); } handleFileChange(file) { this.setState({ isFileValid: file != null && file.type.endsWith("pcap"), isFileFocused: false, selectedFile: file }); } handleUploadPcap() { if (this.state.selectedFile == null || !this.state.isFileValid) { this.setState({isFileFocused: true}); return; } const formData = new FormData(); formData.append( "file", this.state.selectedFile ); backend.postFile("/api/pcap/upload", formData).then(response => response.json().then(result => this.setState({ uploadStatusCode: response.status + " " + response.statusText, uploadOutput: JSON.stringify(result) })) ); } render() { let sessions = this.state.sessions.map(s =>
id | started_at | duration | size | processed_packets | invalid_packets | packets_per_service | actions |
---|