Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions web/src/components/tabs/netflow-table/netflow-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ export const NetflowTable: React.FC<NetflowTableProps> = React.forwardRef(
if (!found) {
return props.flows;
} else {
return props.flows.sort((a: Record, b: Record) => {
return activeSortDirection === 'desc' ? found.sort(a, b, found) : found.sort(b, a, found);
});
return activeSortDirection === 'desc'
? props.flows.sort((a: Record, b: Record) => found.sort(a, b, found))
: props.flows.sort((a: Record, b: Record) => found.sort(b, a, found));
}
}, [activeSortDirection, activeSortId, props.columns, props.flows]);

Expand Down
13 changes: 11 additions & 2 deletions web/src/utils/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ export const getShortColumnName = (col?: Column): string => {
return '';
};

const getFieldSingleValue = (rec: Record, fvFunc: (flow: Record) => ColValue): ColValue => {
const val = fvFunc(rec);
if (Array.isArray(val) && val.length > 0) {
// E.g. for Bytes / Packets columns as they may include drops
return val[0];
}
return val;
};

export const getDefaultColumns = (columnDefs: ColumnConfigDef[], fieldConfigs: FieldConfig[]): Column[] => {
const columns: Column[] = [];

Expand Down Expand Up @@ -241,8 +250,8 @@ export const getDefaultColumns = (columnDefs: ColumnConfigDef[], fieldConfigs: F
if (!col.fieldValue) {
return -1;
}
const valA = col.fieldValue(a);
const valB = col.fieldValue(b);
const valA = getFieldSingleValue(a, col.fieldValue);
const valB = getFieldSingleValue(b, col.fieldValue);
if (typeof valA === 'number' && typeof valB === 'number') {
if (col.id.includes('Port')) {
return comparePorts(valA, valB);
Expand Down
Loading