From c5434cccee8661de3082c0c777375eb8e6f76865 Mon Sep 17 00:00:00 2001 From: JJ Date: Thu, 18 Jul 2024 17:38:57 -0700 Subject: remove unnecessary jsx stuff --- frontend/src/components/objects/Connection.jsx | 116 --------------------- .../components/objects/ConnectionMatchedRules.jsx | 51 --------- .../src/components/objects/CopyLinkPopover.jsx | 54 ---------- frontend/src/components/objects/LinkPopover.jsx | 51 --------- 4 files changed, 272 deletions(-) delete mode 100644 frontend/src/components/objects/Connection.jsx delete mode 100644 frontend/src/components/objects/ConnectionMatchedRules.jsx delete mode 100644 frontend/src/components/objects/CopyLinkPopover.jsx delete mode 100644 frontend/src/components/objects/LinkPopover.jsx (limited to 'frontend/src/components/objects') diff --git a/frontend/src/components/objects/Connection.jsx b/frontend/src/components/objects/Connection.jsx deleted file mode 100644 index 113ed21..0000000 --- a/frontend/src/components/objects/Connection.jsx +++ /dev/null @@ -1,116 +0,0 @@ -/* - * This file is part of caronte (https://github.com/eciavatta/caronte). - * Copyright (c) 2020 Emiliano Ciavatta. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import React, {Component} from "react"; -import backend from "../../backend"; -import dispatcher from "../../dispatcher"; -import {dateTimeToTime, durationBetween, formatSize} from "../../utils"; -import CommentDialog from "../dialogs/CommentDialog"; -import ButtonField from "../fields/ButtonField"; -import TextField from "../fields/TextField"; -import "./Connection.scss"; -import CopyLinkPopover from "./CopyLinkPopover"; -import LinkPopover from "./LinkPopover"; - -import classNames from 'classnames'; - -class Connection extends Component { - - state = { - update: false - }; - - handleAction = (name, comment) => { - if (name === "mark") { - const marked = this.props.data.marked; - backend.post(`/api/connections/${this.props.data.id}/${marked ? "unmark" : "mark"}`) - .then((_) => { - this.props.onMarked(!marked); - this.setState({update: true}); - }); - } else if (name === "comment") { - this.props.onCommented(comment); - this.setState({showCommentDialog: false}); - } - }; - - render() { - let conn = this.props.data; - let serviceName = "/dev/null"; - let serviceColor = "#0f192e"; - if (this.props.services[conn["port_dst"]]) { - const service = this.props.services[conn["port_dst"]]; - serviceName = service.name; - serviceColor = service.color; - } - let startedAt = new Date(conn["started_at"]); - let closedAt = new Date(conn["closed_at"]); - let processedAt = new Date(conn["processed_at"]); - let timeInfo =
- Started at {startedAt.toLocaleDateString() + " " + startedAt.toLocaleTimeString()}
- Processed at {processedAt.toLocaleDateString() + " " + processedAt.toLocaleTimeString()}
- Closed at {closedAt.toLocaleDateString() + " " + closedAt.toLocaleTimeString()} -
; - - const commentPopoverContent =
- Click to {conn.comment ? "edit" : "add"} comment - {conn.comment && } -
; - - return ( - 0})}> - - - dispatcher.dispatch("connections_filters", - {"service_port": conn["port_dst"].toString()})}/> - - - {conn["ip_src"]} - {conn["port_src"]} - {conn["ip_dst"]} - {conn["port_dst"]} - - - - {durationBetween(startedAt, closedAt)} - {formatSize(conn["client_bytes"])} - {formatSize(conn["server_bytes"])} - - this.handleAction("mark")}>!!} - content={Mark this connection} placement="right"/> - this.setState({showCommentDialog: true})}>@} - content={commentPopoverContent} placement="right"/> - - { - this.state.showCommentDialog && - this.handleAction("comment", comment)} - initialComment={conn.comment} connectionId={conn.id}/> - } - - - - ); - } - -} - -export default Connection; diff --git a/frontend/src/components/objects/ConnectionMatchedRules.jsx b/frontend/src/components/objects/ConnectionMatchedRules.jsx deleted file mode 100644 index a69cad8..0000000 --- a/frontend/src/components/objects/ConnectionMatchedRules.jsx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of caronte (https://github.com/eciavatta/caronte). - * Copyright (c) 2020 Emiliano Ciavatta. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import React, {Component} from "react"; -import {withRouter} from "react-router-dom"; -import dispatcher from "../../dispatcher"; -import ButtonField from "../fields/ButtonField"; -import "./ConnectionMatchedRules.scss"; - -class ConnectionMatchedRules extends Component { - - onMatchedRulesSelected = (id) => { - const params = new URLSearchParams(this.props.location.search); - const rules = params.getAll("matched_rules"); - if (!rules.includes(id)) { - rules.push(id); - dispatcher.dispatch("connections_filters", {"matched_rules": rules}); - } - }; - - render() { - const matchedRules = this.props.matchedRules.map((mr) => { - const rule = this.props.rules.find((r) => r.id === mr); - return this.onMatchedRulesSelected(rule.id)} name={rule.name} - color={rule.color} small/>; - }); - - return ( - - matched_rules: - {matchedRules} - - ); - } -} - -export default withRouter(ConnectionMatchedRules); diff --git a/frontend/src/components/objects/CopyLinkPopover.jsx b/frontend/src/components/objects/CopyLinkPopover.jsx deleted file mode 100644 index b951603..0000000 --- a/frontend/src/components/objects/CopyLinkPopover.jsx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of caronte (https://github.com/eciavatta/caronte). - * Copyright (c) 2020 Emiliano Ciavatta. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import React, {Component} from "react"; -import TextField from "../fields/TextField"; -import LinkPopover from "./LinkPopover"; - -class CopyLinkPopover extends Component { - - state = {}; - - constructor(props) { - super(props); - - this.copyTextarea = React.createRef(); - } - - handleClick = () => { - this.copyTextarea.current.select(); - document.execCommand("copy"); - this.setState({copiedMessage: true}); - setTimeout(() => this.setState({copiedMessage: false}), 3000); - }; - - render() { - const copyPopoverContent =
- {this.state.copiedMessage ? Copied! : - Click to copy} - -
; - - return ( - {this.props.text}} - content={copyPopoverContent} placement="right"/> - ); - } -} - -export default CopyLinkPopover; diff --git a/frontend/src/components/objects/LinkPopover.jsx b/frontend/src/components/objects/LinkPopover.jsx deleted file mode 100644 index 551a819..0000000 --- a/frontend/src/components/objects/LinkPopover.jsx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of caronte (https://github.com/eciavatta/caronte). - * Copyright (c) 2020 Emiliano Ciavatta. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import React, {Component} from "react"; -import {OverlayTrigger, Popover} from "react-bootstrap"; -import {randomClassName} from "../../utils"; -import "./LinkPopover.scss"; - -class LinkPopover extends Component { - - constructor(props) { - super(props); - - this.id = `link-overlay-${randomClassName()}`; - } - - render() { - const popover = ( - - {this.props.title && {this.props.title}} - - {this.props.content} - - - ); - - return (this.props.content ? - - {this.props.text} - : - {this.props.text} - ); - } -} - -export default LinkPopover; -- cgit v1.2.3-70-g09d2