Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

FIX: Sidebar Collapse Button and Logs Component UI/UX Improvements (#1175)

Tahier Hussainb69331bef6af
diff --git a/frontend/src/components/logs-and-notifications/DisplayLogsAndNotifications.jsx b/frontend/src/components/logs-and-notifications/DisplayLogsAndNotifications.jsx
index 52baca3d8..229406b30 100644
--- a/frontend/src/components/logs-and-notifications/DisplayLogsAndNotifications.jsx
+++ b/frontend/src/components/logs-and-notifications/DisplayLogsAndNotifications.jsx
@@ -1,4 +1,5 @@
import { useState, useRef, useCallback, useEffect } from "react";
+
import { LogsHeader } from "./LogsHeader";
import "./DisplayLogsAndNotifications.css";
import { LogsAndNotificationsTable } from "./LogsAndNotificationsTable";
@@ -29,7 +30,6 @@ export function DisplayLogsAndNotifications() {
if (window.getComputedStyle(parent).position === "static") {
parent.style.position = "relative";
}
- parent.style.overflow = "hidden";
}
}, []);
@@ -57,23 +57,44 @@ export function DisplayLogsAndNotifications() {
return parent ? parent.getBoundingClientRect().height : 0;
}, []);
+ // Minimizes the logs (height = 0).
const minimize = useCallback(() => {
setContentHeight(0);
}, []);
+ // Sets the logs height to "semi" (30% of parent minus 40).
const semiExpand = useCallback(() => {
const parentHeight = getParentHeight();
- const semiHeight = 0.3 * parentHeight;
- const newHeight = Math.max(0, semiHeight - 40);
+ const height = 0.3 * parentHeight;
+ const semiHeight = height - 40;
+ const newHeight = Math.max(0, semiHeight);
setContentHeight(newHeight);
}, [getParentHeight]);
+ // Sets the logs height to "full" (parent minus 40).
const fullExpand = useCallback(() => {
const parentHeight = getParentHeight();
const newHeight = Math.max(0, parentHeight - 40);
setContentHeight(newHeight);
}, [getParentHeight]);
+ const handleToggleExpand = useCallback(() => {
+ const parentHeight = getParentHeight();
+ const height = 0.3 * parentHeight;
+ const semiHeight = height - 40;
+ const fullHeight = parentHeight - 40;
+
+ const isCurrentlyFull = contentHeight >= fullHeight - 1;
+
+ if (isCurrentlyFull) {
+ semiExpand();
+ } else if (contentHeight < semiHeight) {
+ semiExpand();
+ } else {
+ fullExpand();
+ }
+ }, [contentHeight, getParentHeight, semiExpand, fullExpand]);
+
const onMouseDown = useCallback(
(e) => {
draggingRef.current = true;
@@ -101,7 +122,11 @@ export function DisplayLogsAndNotifications() {
draggingRef.current = false;
document.removeEventListener("mousemove", onMouseMove);
document.removeEventListener("mouseup", onMouseUp);
- }, [onMouseMove, getParentHeight, contentHeight]);
+ }, [onMouseMove]);
+
+ const parentHeight = getParentHeight();
+ const fullHeight = parentHeight - 40;
+ const isFull = contentHeight >= fullHeight - 1; // a small tolerance
return (
<div
@@ -112,9 +137,9 @@ export function DisplayLogsAndNotifications() {
<div className="logs-handle" onMouseDown={onMouseDown}>
<LogsHeader
isMinimized={contentHeight === 0}
+ isFull={isFull}
errorCount={errorCount}
- onSemiExpand={semiExpand}
- onFullExpand={fullExpand}
+ onToggleExpand={handleToggleExpand}
onMinimize={minimize}
/>
</div>
diff --git a/frontend/src/components/logs-and-notifications/LogsHeader.jsx b/frontend/src/components/logs-and-notifications/LogsHeader.jsx
index 4e43797b8..49ebd43a9 100644
--- a/frontend/src/components/logs-and-notifications/LogsHeader.jsx
+++ b/frontend/src/components/logs-and-notifications/LogsHeader.jsx
@@ -1,21 +1,17 @@
import { memo } from "react";
import PropTypes from "prop-types";
-import {
- CloseOutlined,
- FullscreenOutlined,
- ShrinkOutlined,
-} from "@ant-design/icons";
+import { CloseOutlined, DownOutlined, UpOutlined } from "@ant-design/icons";
import { Button, Space, Tag, Typography } from "antd";
export const LogsHeader = memo(function LogsHeader({
isMinimized,
+ isFull,
errorCount,
- onSemiExpand,
- onFullExpand,
+ onToggleExpand,
onMinimize,
}) {
- const semiIcon = <ShrinkOutlined />;
- const fullIcon = <FullscreenOutlined />;
+ const expandCollapseIcon = isFull ? <DownOutlined /> : <UpOutlined />;
+
const minimizeIcon = <CloseOutlined />;
return (
@@ -25,18 +21,10 @@ export const LogsHeader = memo(function LogsHeader({
{isMinimized && errorCount > 0 && <Tag color="red">{errorCount}</Tag>}
</Space>
<Space>
- <Button
- type="text"
- size="small"
- icon={semiIcon}
- onClick={onSemiExpand}
- />
- <Button
- type="text"
- size="small"
- icon={fullIcon}
- onClick={onFullExpand}
- />
+ <Button type="text" size="small" onClick={onToggleExpand}>
+ {expandCollapseIcon}
+ </Button>
+
<Button
type="text"
size="small"
@@ -50,8 +38,8 @@ export const LogsHeader = memo(function LogsHeader({
LogsHeader.propTypes = {
isMinimized: PropTypes.bool.isRequired,
+ isFull: PropTypes.bool.isRequired,
errorCount: PropTypes.number.isRequired,
- onSemiExpand: PropTypes.func.isRequired,
- onFullExpand: PropTypes.func.isRequired,
+ onToggleExpand: PropTypes.func.isRequired,
onMinimize: PropTypes.func.isRequired,
};
diff --git a/frontend/src/layouts/page-layout/PageLayout.css b/frontend/src/layouts/page-layout/PageLayout.css
index f72da70c4..b4261dd90 100644
--- a/frontend/src/layouts/page-layout/PageLayout.css
+++ b/frontend/src/layouts/page-layout/PageLayout.css
@@ -21,4 +21,5 @@
position: absolute;
margin-left: -10px;
margin-top: -10px;
+ z-index: 1000;
}
diff --git a/frontend/src/store/socket-logs-store.js b/frontend/src/store/socket-logs-store.js
index f4cd62a22..d90ad7644 100644
--- a/frontend/src/store/socket-logs-store.js
+++ b/frontend/src/store/socket-logs-store.js
@@ -1,7 +1,7 @@
import { create } from "zustand";
+import axios from "axios";
import { useSessionStore } from "./session-store";
-import axios from "axios";
const STORE_VARIABLES = {
logs: [],
@@ -50,10 +50,10 @@ const useSocketLogsStore = create((setState, getState) => ({
}
});
- // Remove the previous logs if the length exceeds 1000
+ // Remove the previous logs if the length exceeds 200
const logsDataLength = logsData?.length;
- if (logsDataLength > 1000) {
- const index = logsDataLength - 1000;
+ if (logsDataLength > 200) {
+ const index = logsDataLength - 200;
logsData = logsData.slice(index);
}