From dfd6d543074b4a30c2fc990063ca69ebf8a734e1 Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Wed, 16 Sep 2020 17:49:50 +0200 Subject: Fix body decoding bugs. Improve frontend --- frontend/src/components/ConnectionContent.js | 82 +++++++++++++++++--------- frontend/src/components/ConnectionContent.scss | 20 ++++--- frontend/src/components/MessageAction.js | 31 ++++++---- frontend/src/components/MessageAction.scss | 11 ++-- 4 files changed, 90 insertions(+), 54 deletions(-) (limited to 'frontend') diff --git a/frontend/src/components/ConnectionContent.js b/frontend/src/components/ConnectionContent.js index 51dbb67..20ec92b 100644 --- a/frontend/src/components/ConnectionContent.js +++ b/frontend/src/components/ConnectionContent.js @@ -2,7 +2,6 @@ import React, {Component} from 'react'; import './ConnectionContent.scss'; import {Button, Dropdown, Row} from 'react-bootstrap'; import axios from 'axios'; -import {timestampToDateTime, timestampToTime} from "../utils"; import MessageAction from "./MessageAction"; const classNames = require('classnames'); @@ -15,7 +14,7 @@ class ConnectionContent extends Component { loading: false, connectionContent: null, format: "default", - decoded: false, + tryParse: true, messageActionDialog: null }; @@ -43,16 +42,12 @@ class ConnectionContent extends Component { } } - toggleDecoded() { - this.setState({decoded: !this.state.decoded}); - } - tryParseConnectionMessage(connectionMessage) { if (connectionMessage.metadata == null) { return connectionMessage.content; } if (connectionMessage["is_metadata_continuation"]) { - return already parsed in previous messages; + return **already parsed in previous messages**; } let unrollMap = (obj) => obj == null ? null : Object.entries(obj).map(([key, value]) => @@ -62,16 +57,17 @@ class ConnectionContent extends Component { let m = connectionMessage.metadata; switch (m.type) { case "http-request": - let url = {m.host}{m.url}; + let url = {m.host}{m.url}; return -

{m.method} {url} {m.protocol}

+

{m.method} {url} {m.protocol}

{unrollMap(m.headers)}
{m.body}
{unrollMap(m.trailers)}
; case "http-response": return -

{m.protocol} {m.status}

+

{m.protocol} {m.status}

{unrollMap(m.headers)}
{m.body}
{unrollMap(m.trailers)} @@ -87,9 +83,10 @@ class ConnectionContent extends Component { } return Object.entries(connectionMessage.metadata["reproducers"]).map(([actionName, actionValue]) => - ); @@ -115,8 +112,9 @@ class ConnectionContent extends Component {
{c.from_client ? "client" : "server"}
-
- {this.state.decoded ? this.tryParseConnectionMessage(c) : c.content} +
+ {this.state.tryParse && this.state.format === "default" ? this.tryParseConnectionMessage(c) : c.content}
); @@ -129,25 +127,55 @@ class ConnectionContent extends Component { flow: {this.props.connection.ip_src}:{this.props.connection.port_src} -> {this.props.connection.ip_dst}:{this.props.connection.port_dst} | timestamp: {this.props.connection.started_at} -
- - +
+ + format - plain - hex - hexdump - base32 - base64 - ascii - binary - decimal - octal + plain + hex + hexdump + base32 + base64 + ascii + binary + decimal + octal + + + + + + view_as + + + + default - + + + + + download_as + + + + nl_separated + only_client + only_server +
diff --git a/frontend/src/components/ConnectionContent.scss b/frontend/src/components/ConnectionContent.scss index 6354bee..8ee31ec 100644 --- a/frontend/src/components/ConnectionContent.scss +++ b/frontend/src/components/ConnectionContent.scss @@ -11,6 +11,11 @@ overflow-x: hidden; height: calc(100% - 31px); padding: 0 10px; + + p { + margin: 0; + padding: 0; + } } .connection-message { @@ -45,13 +50,6 @@ padding: 10px; } - .message-parsed { - p { - margin: 0; - padding: 0; - } - } - &:hover .connection-message-actions { display: block; } @@ -96,7 +94,13 @@ .header-info { padding-top: 5px; padding-left: 20px; - font-size: 13px; + font-size: 12px; + } + + .header-actions { + .dropdown { + display: inline-block; + } } } diff --git a/frontend/src/components/MessageAction.js b/frontend/src/components/MessageAction.js index 66350c6..2c85d84 100644 --- a/frontend/src/components/MessageAction.js +++ b/frontend/src/components/MessageAction.js @@ -4,7 +4,21 @@ import {Button, FormControl, InputGroup, Modal} from "react-bootstrap"; class MessageAction extends Component { + constructor(props) { + super(props); + this.state = { + copyButtonText: "copy" + }; + this.actionValue = React.createRef(); + this.copyActionValue = this.copyActionValue.bind(this); + } + copyActionValue() { + this.actionValue.current.select(); + document.execCommand('copy'); + this.setState({copyButtonText: "copied!"}); + setTimeout(() => this.setState({copyButtonText: "copy"}), 3000); + } render() { return ( @@ -21,20 +35,13 @@ class MessageAction extends Component { -
-
-                            {this.props.actionValue}
-                        
-
- - {/**/} - {/* */} - {/**/} + + +
- + diff --git a/frontend/src/components/MessageAction.scss b/frontend/src/components/MessageAction.scss index df3af8d..f3a8772 100644 --- a/frontend/src/components/MessageAction.scss +++ b/frontend/src/components/MessageAction.scss @@ -1,11 +1,8 @@ @import '../colors.scss'; .message-action-value { - pre { - font-size: 13px; - padding: 15px; - background-color: $color-primary-2; - color: $color-primary-4; - } - + font-size: 13px; + padding: 15px; + background-color: $color-primary-2; + color: $color-primary-4; } \ No newline at end of file -- cgit v1.2.3-70-g09d2