Skip to content

Commit

Permalink
fix fields types (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau authored Feb 13, 2024
1 parent 2a021a8 commit f59f82b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions web/src/api/ipfix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ export interface Record {
}

export const getRecordValue = (record: Record, fieldOrLabel: string, defaultValue?: string | number) => {
/* TODO: fix following behavior:
* Check if field exists first since /flow endpoint return fields as labels when using filters
* This is mandatory to ensure fields types
*/
if (record.fields[fieldOrLabel as keyof Fields] !== undefined) {
return record.fields[fieldOrLabel as keyof Fields];
}
// check if label exists
if (record.labels[fieldOrLabel as keyof Labels] !== undefined) {
return record.labels[fieldOrLabel as keyof Labels];
}
// check if field exists
if (record.fields[fieldOrLabel as keyof Fields] !== undefined) {
return record.fields[fieldOrLabel as keyof Fields];
}
// fallback on default
return defaultValue;
};
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/netflow-record/record-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export const RecordPanel: React.FC<RecordDrawerProps> = ({
}, [record.labels._RecordType, t]);

const getSortedJSON = React.useCallback(() => {
const flat = { ...record.fields, ...record.labels };
const flat = { ...record.labels, ...record.fields };
return JSON.stringify(flat, Object.keys(flat).sort(), 2);
}, [record]);

Expand Down

0 comments on commit f59f82b

Please sign in to comment.