diff --git a/CHANGELOG.md b/CHANGELOG.md index b3d572103..98e3ec488 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). - A bug where bogus users were collected by Mimikatz and added to the config. #1860 - A bug where windows executable was not self deleting. #1763 - Incorrect line number in the telemetry overview window on the Map page. #1850 +- Automatic jumping to the bottom in the telemetry overview windows. #1850 ### Security - Change SSH exploiter so that it does not set the permissions of the agent diff --git a/monkey/monkey_island/cc/ui/src/components/map/TelemetryLog.tsx b/monkey/monkey_island/cc/ui/src/components/map/TelemetryLog.tsx index 1fea52388..7c7f8ae1f 100644 --- a/monkey/monkey_island/cc/ui/src/components/map/TelemetryLog.tsx +++ b/monkey/monkey_island/cc/ui/src/components/map/TelemetryLog.tsx @@ -12,11 +12,11 @@ const TelemetryLog = (props: { onStatusChange: Function }) => { let [telemetryUpdateInProgress, setTelemetryUpdateInProgress] = useState(false); let [telemetry, setTelemetry] = useState([]); let [lastTelemetryTimestamp, setLastTelemetryTimestamp] = useState(null); - let [isScrolledUp, setIsScrolledUp] = useState(false); + let isScrolledUp = useRef(false); let [telemetryLines, setTelemetryLines] = useState(0); let [telemetryCurrentLine, setTelemetryCurrentLine] = useState(0); - let scrollTop = 0; + let scrollTop = useRef(0); const telemetryConsole = useRef(null); useEffect(() => { @@ -44,9 +44,11 @@ const TelemetryLog = (props: { onStatusChange: Function }) => { props.onStatusChange(); let telemConsoleRef = telemetryConsole.current; - if (!isScrolledUp) { + // we handle the lines again so if we have scrolled, we will have updated counter + handleTemeletryLine(telemConsoleRef); + if (!isScrolledUp.current) { telemConsoleRef.scrollTop = telemConsoleRef.scrollHeight - telemConsoleRef.clientHeight; - scrollTop = telemConsoleRef.scrollTop; + scrollTop.current = telemConsoleRef.scrollTop; } } }); @@ -54,11 +56,14 @@ const TelemetryLog = (props: { onStatusChange: Function }) => { function handleScroll(e) { let element = e.target; + isScrolledUp.current = element.scrollTop < scrollTop.current; + handleTemeletryLine(element); + } + function handleTemeletryLine(element) { let telemetryStyle = window.getComputedStyle(element); let telemetryLineHeight = parseInt((telemetryStyle.lineHeight).replace('px', '')); - setIsScrolledUp((element.scrollTop < scrollTop)); // Zooming in or out doesn't change the number of lines that are visible at once i.e. 5. setTelemetryCurrentLine(Math.trunc(element.scrollTop / telemetryLineHeight) + 5); setTelemetryLines(Math.trunc(element.scrollHeight / telemetryLineHeight));