From 69ccf4872e1f8ecde23ec586d6b9541a1c042d63 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Thu, 3 Feb 2022 23:19:17 -0700 Subject: [PATCH] Added virtualized list to pod logs in operator console (#1517) Also removed some execution time errors Signed-off-by: Benjamin Perez --- .../Tenants/TenantDetails/TenantSummary.tsx | 24 ++++----- .../Tenants/TenantDetails/pods/PodLogs.tsx | 54 ++++++++++++++++--- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantSummary.tsx b/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantSummary.tsx index 64638a117..fe569eaf3 100644 --- a/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantSummary.tsx +++ b/portal-ui/src/screens/Console/Tenants/TenantDetails/TenantSummary.tsx @@ -257,11 +257,11 @@ const TenantSummary = ({ - - + + - + - + - + - - + + - + - + - + - + - + }, ansidefault: { color: "#000", + lineHeight: "16px", }, highlight: { "& span": { @@ -91,6 +94,11 @@ const PodLogs = ({ const [logLines, setLogLines] = useState([]); const [loading, setLoading] = useState(true); + const cache = new CellMeasurerCache({ + minWidth: 5, + fixedHeight: false, + }); + useEffect(() => { if (propLoading) { setLoading(true); @@ -104,6 +112,9 @@ const PodLogs = ({ }, [loadingTenant]); const renderLog = (logMessage: string, index: number) => { + if (!logMessage) { + return null; + } // remove any non ascii characters, exclude any control codes logMessage = logMessage.replace(/([^\x20-\x7F])/g, ""); @@ -144,10 +155,6 @@ const PodLogs = ({ } }; - const renderLines = logLines.map((m, i) => { - return renderLog(m, i); - }); - useEffect(() => { if (loading) { api @@ -166,6 +173,26 @@ const PodLogs = ({ } }, [loading, podName, namespace, tenant, setErrorSnackMessage]); + function cellRenderer({ columnIndex, key, parent, index, style }: any) { + return ( + +
+ {renderLog(logLines[index], index)} +
+
+ ); + } + return ( @@ -193,7 +220,22 @@ const PodLogs = ({ -
{renderLines}
+
+ {logLines.length >= 1 && ( + + {({ width, height }) => ( + cache.rowHeight(item)} + overscanRowCount={15} + rowCount={logLines.length} + rowRenderer={cellRenderer} + width={width} + height={height} + /> + )} + + )} +