From 678a14e2b875e76c587ed3db8928588b9180f022 Mon Sep 17 00:00:00 2001 From: AlexeyOplachko <45398541+AlexeyOplachko@users.noreply.github.com> Date: Tue, 23 Apr 2024 21:29:50 +0300 Subject: [PATCH] Feat/ux improvements (#66) * feat: added copying from all fields in modal feat: added copying from all fields in modal * feat: Filter / Export visibility improvements * feat: added disabling/enabling whole category of filters * feat: fixed Simple mode feat: fixed Simple mode * feat: improved naming scheme and descriptions for settings * chore: new version * fix: conditions for export button * feat: added filter tooltips, callid filtering and checking if any filters exist before showing menu * feat: added tooltip to "simple mode" switch * fix: added missing line * fix: removed part of tooltip that got added by mistake * fix: updated tooltip to be consistent with other ones * feat: redo eth/ip/tcp/udp packet encoders in .ts * fix: checkbox styling in filter * fix: aligned checkboxes inside "collapse" with checkbox in "collapse" title * feat: extraction of exporter functions from SimplePanel.tsx to separate files and proper typing for them * feat: extraction of formatting, sorting and filtering functions from simple to separate files with proper types * feat: revised filter tooltip visuals * fix: ipv6 with middle segments missing * fix: incorrect payload length + removal of accidentally setting flow label * chore: cleanup --- .../ngx-flow/src/lib/ngx-flow.component.ts | 9 +- .../ngx-flow/src/models/flow.model.ts | 4 +- .../flow-item/flow-item.component.html | 11 +- ngx-flow/src/app/app.component.ts | 2 +- package.json | 2 +- src/components/CopyText/CopyText.tsx | 33 + src/components/FilterPanel/FilterPanel.tsx | 127 +- src/components/SimplePanel.tsx | 328 +-- src/helpers/dataProcessors/filterFlowItems.ts | 60 + .../dataProcessors/formatAndSortFlowItems.ts | 79 + src/helpers/dataProcessors/index.ts | 1 + src/helpers/exporters/index.ts | 3 + src/helpers/exporters/pcapExporter.ts | 87 + src/helpers/exporters/textExporter.ts | 36 + src/helpers/labelFormatter.ts | 13 + src/helpers/packets/ethernetPacket.ts | 22 + src/helpers/packets/ipPacket.ts | 90 + src/helpers/packets/tcpPacket.ts | 29 + src/helpers/packets/udpPacket.ts | 50 + src/libs/packets.js | 2328 ----------------- src/module.ts | 41 +- 21 files changed, 717 insertions(+), 2638 deletions(-) create mode 100644 src/components/CopyText/CopyText.tsx create mode 100644 src/helpers/dataProcessors/filterFlowItems.ts create mode 100644 src/helpers/dataProcessors/formatAndSortFlowItems.ts create mode 100644 src/helpers/dataProcessors/index.ts create mode 100644 src/helpers/exporters/index.ts create mode 100644 src/helpers/exporters/pcapExporter.ts create mode 100644 src/helpers/exporters/textExporter.ts create mode 100644 src/helpers/labelFormatter.ts create mode 100644 src/helpers/packets/ethernetPacket.ts create mode 100644 src/helpers/packets/ipPacket.ts create mode 100644 src/helpers/packets/tcpPacket.ts create mode 100644 src/helpers/packets/udpPacket.ts delete mode 100644 src/libs/packets.js diff --git a/ngx-flow/projects/ngx-flow/src/lib/ngx-flow.component.ts b/ngx-flow/projects/ngx-flow/src/lib/ngx-flow.component.ts index c42e7d1..38d1b8c 100644 --- a/ngx-flow/projects/ngx-flow/src/lib/ngx-flow.component.ts +++ b/ngx-flow/projects/ngx-flow/src/lib/ngx-flow.component.ts @@ -87,14 +87,13 @@ export class NgxFlowComponent implements OnInit { description: i.aboveArrow || '', destination_ip: dist.ip, destination_port: dist.port, - diff: ' ', - diff_absolute: i.subTitle || '', - diff_num: ' ', + details: i.details, dstAlias: DIST, id: 0, info_date: i.belowArrow || '... ', - info_date_absolute: i.subTitle || '... ', + info_date_absolute: i.details || '... ', ipDirection: SRC + ' > ' + DIST, + line: i.line, messageData: null, method: ' ', method_text: i.title || i.messageID, @@ -110,7 +109,7 @@ export class NgxFlowComponent implements OnInit { srcAlias: SRC, typeItem: "SIP", - hash: i.hash + hash: i.hash, } } diff --git a/ngx-flow/projects/ngx-flow/src/models/flow.model.ts b/ngx-flow/projects/ngx-flow/src/models/flow.model.ts index caf8c14..28de49e 100644 --- a/ngx-flow/projects/ngx-flow/src/models/flow.model.ts +++ b/ngx-flow/projects/ngx-flow/src/models/flow.model.ts @@ -8,7 +8,7 @@ export interface FlowItem { destination: string; title?: string; - subTitle?: string; + details?: string; // hidden in Simplified mode aboveArrow?: string; @@ -27,7 +27,7 @@ export interface ArrowStyling { } export interface TextColors { title?: string; - subTitle?: string; + details?: string; // hidden in Simplified mode aboveArrow?: string; diff --git a/ngx-flow/projects/ngx-flow/src/tab-flow/flow-item/flow-item.component.html b/ngx-flow/projects/ngx-flow/src/tab-flow/flow-item/flow-item.component.html index 77ac933..1cb58f6 100644 --- a/ngx-flow/projects/ngx-flow/src/tab-flow/flow-item/flow-item.component.html +++ b/ngx-flow/projects/ngx-flow/src/tab-flow/flow-item/flow-item.component.html @@ -100,11 +100,12 @@
{{ - isAbsolute - ? item.diff_absolute - : item.diff - ? item.diff - : "+0.00ms" + item.details + }} +
+
+ {{ + item.line }}
diff --git a/ngx-flow/src/app/app.component.ts b/ngx-flow/src/app/app.component.ts index 9f72ba7..4b10ed5 100644 --- a/ngx-flow/src/app/app.component.ts +++ b/ngx-flow/src/app/app.component.ts @@ -53,7 +53,7 @@ export class AppComponent { { messageID: 'some unique Id as string 1', title: 'Title', - subTitle: 'subTitle', + details: 'details', aboveArrow: 'aboveArrow', belowArrow: 'belowArrow', source: 'B', diff --git a/package.json b/package.json index 877401d..d6a68cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qxip-flow-panel", - "version": "10.1.0", + "version": "10.1.1", "description": "Plugin providing Flow diagram for Grafana", "scripts": { "build:component": "cd ./ngx-flow && npm run build:component", diff --git a/src/components/CopyText/CopyText.tsx b/src/components/CopyText/CopyText.tsx new file mode 100644 index 0000000..2982930 --- /dev/null +++ b/src/components/CopyText/CopyText.tsx @@ -0,0 +1,33 @@ +import React, { FC, useRef, useState } from 'react'; +import { IconButton } from '@grafana/ui'; + + +export const CopyText: FC<{ text: string }> = ({ text }) => { + const [copied, setCopied] = useState(false); + const textAreaRef: any = useRef(null); + const copy = () => { + if (navigator && navigator.clipboard) { + navigator.clipboard.writeText(text); + setCopied(true); + } else { + if (textAreaRef && textAreaRef.current) { + textAreaRef.current.focus(); + textAreaRef.current.select(); + document.execCommand('copy'); + } + setCopied(false); + } + }; + return ( + <> +