Skip to content

Commit 69ccf48

Browse files
authored
Added virtualized list to pod logs in operator console (#1517)
Also removed some execution time errors Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent 1c31aff commit 69ccf48

File tree

2 files changed

+60
-18
lines changed

2 files changed

+60
-18
lines changed

portal-ui/src/screens/Console/Tenants/TenantDetails/TenantSummary.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ const TenantSummary = ({
257257
<StorageSummary tenant={tenant} classes={classes} />
258258

259259
<Grid container>
260-
<Grid xs={12} sm={12} md={8} container>
261-
<Grid xs={12}>
260+
<Grid item xs={12} sm={12} md={8}>
261+
<Grid item xs={12}>
262262
<LabelValuePair label={"State:"} value={tenant?.currentState} />
263263
</Grid>
264-
<Grid xs={12}>
264+
<Grid item xs={12}>
265265
<LabelValuePair
266266
label="MinIO:"
267267
value={
@@ -281,7 +281,7 @@ const TenantSummary = ({
281281
}
282282
/>
283283
</Grid>
284-
<Grid xs={12}>
284+
<Grid item xs={12}>
285285
<LabelValuePair
286286
label={"Endpoint:"}
287287
value={
@@ -296,7 +296,7 @@ const TenantSummary = ({
296296
}
297297
/>
298298
</Grid>
299-
<Grid xs={12}>
299+
<Grid item xs={12}>
300300
<LabelValuePair
301301
label={"Console:"}
302302
value={
@@ -312,11 +312,11 @@ const TenantSummary = ({
312312
/>
313313
</Grid>
314314
</Grid>
315-
<Grid xs={12} sm={12} md={4} container>
316-
<Grid xs={12}>
315+
<Grid item xs={12} sm={12} md={4}>
316+
<Grid item xs={12}>
317317
<LabelValuePair label={"Instances:"} value={instances} />
318318
</Grid>
319-
<Grid xs={12}>
319+
<Grid item xs={12}>
320320
<LabelValuePair
321321
label={"Clusters:"}
322322
value={poolCount}
@@ -327,7 +327,7 @@ const TenantSummary = ({
327327
}}
328328
/>
329329
</Grid>
330-
<Grid xs={12}>
330+
<Grid item xs={12}>
331331
<LabelValuePair
332332
label="Total Drives:"
333333
value={volumes}
@@ -338,15 +338,15 @@ const TenantSummary = ({
338338
}}
339339
/>
340340
</Grid>
341-
<Grid xs={12}>
341+
<Grid item xs={12}>
342342
<LabelValuePair
343343
label={"Write Quorum:"}
344344
value={
345345
tenant?.status?.write_quorum ? tenant?.status?.write_quorum : 0
346346
}
347347
/>
348348
</Grid>
349-
<Grid xs={12}>
349+
<Grid item xs={12}>
350350
<LabelValuePair
351351
label={"Drives Online:"}
352352
value={
@@ -361,7 +361,7 @@ const TenantSummary = ({
361361
}}
362362
/>
363363
</Grid>
364-
<Grid xs={12}>
364+
<Grid item xs={12}>
365365
<LabelValuePair
366366
label={"Drives Offline:"}
367367
value={

portal-ui/src/screens/Console/Tenants/TenantDetails/pods/PodLogs.tsx

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
import React, { useEffect, useState } from "react";
1818
import { connect } from "react-redux";
1919
import { Theme } from "@mui/material/styles";
20+
import { CellMeasurer, CellMeasurerCache, List } from "react-virtualized";
2021
import createStyles from "@mui/styles/createStyles";
2122
import withStyles from "@mui/styles/withStyles";
2223
import { TextField } from "@mui/material";
2324
import Grid from "@mui/material/Grid";
2425
import Paper from "@mui/material/Paper";
2526
import InputAdornment from "@mui/material/InputAdornment";
2627
import api from "../../../../../common/api";
28+
import SearchIcon from "../../../../../icons/SearchIcon";
2729
import {
2830
actionsTray,
2931
buttonsStyles,
@@ -33,7 +35,7 @@ import {
3335
import { setErrorSnackMessage } from "../../../../../actions";
3436
import { ErrorResponseHandler } from "../../../../../common/types";
3537
import { AppState } from "../../../../../store";
36-
import SearchIcon from "../../../../../icons/SearchIcon";
38+
import { AutoSizer } from "react-virtualized";
3739

3840
interface IPodLogsProps {
3941
classes: any;
@@ -69,6 +71,7 @@ const styles = (theme: Theme) =>
6971
},
7072
ansidefault: {
7173
color: "#000",
74+
lineHeight: "16px",
7275
},
7376
highlight: {
7477
"& span": {
@@ -91,6 +94,11 @@ const PodLogs = ({
9194
const [logLines, setLogLines] = useState<string[]>([]);
9295
const [loading, setLoading] = useState<boolean>(true);
9396

97+
const cache = new CellMeasurerCache({
98+
minWidth: 5,
99+
fixedHeight: false,
100+
});
101+
94102
useEffect(() => {
95103
if (propLoading) {
96104
setLoading(true);
@@ -104,6 +112,9 @@ const PodLogs = ({
104112
}, [loadingTenant]);
105113

106114
const renderLog = (logMessage: string, index: number) => {
115+
if (!logMessage) {
116+
return null;
117+
}
107118
// remove any non ascii characters, exclude any control codes
108119
logMessage = logMessage.replace(/([^\x20-\x7F])/g, "");
109120

@@ -144,10 +155,6 @@ const PodLogs = ({
144155
}
145156
};
146157

147-
const renderLines = logLines.map((m, i) => {
148-
return renderLog(m, i);
149-
});
150-
151158
useEffect(() => {
152159
if (loading) {
153160
api
@@ -166,6 +173,26 @@ const PodLogs = ({
166173
}
167174
}, [loading, podName, namespace, tenant, setErrorSnackMessage]);
168175

176+
function cellRenderer({ columnIndex, key, parent, index, style }: any) {
177+
return (
178+
<CellMeasurer
179+
cache={cache}
180+
columnIndex={columnIndex}
181+
key={key}
182+
parent={parent}
183+
rowIndex={index}
184+
>
185+
<div
186+
style={{
187+
...style,
188+
}}
189+
>
190+
{renderLog(logLines[index], index)}
191+
</div>
192+
</CellMeasurer>
193+
);
194+
}
195+
169196
return (
170197
<React.Fragment>
171198
<Grid item xs={12} className={classes.actionsTray}>
@@ -193,7 +220,22 @@ const PodLogs = ({
193220
</Grid>
194221
<Grid item xs={12}>
195222
<Paper>
196-
<div className={classes.logList}>{renderLines}</div>
223+
<div className={classes.logList}>
224+
{logLines.length >= 1 && (
225+
<AutoSizer>
226+
{({ width, height }) => (
227+
<List
228+
rowHeight={(item) => cache.rowHeight(item)}
229+
overscanRowCount={15}
230+
rowCount={logLines.length}
231+
rowRenderer={cellRenderer}
232+
width={width}
233+
height={height}
234+
/>
235+
)}
236+
</AutoSizer>
237+
)}
238+
</div>
197239
</Paper>
198240
</Grid>
199241
</React.Fragment>

0 commit comments

Comments
 (0)