diff --git a/src/components/gui/table-cell/generic-cell.tsx b/src/components/gui/table-cell/generic-cell.tsx index c43e9dd7..13c9db7e 100644 --- a/src/components/gui/table-cell/generic-cell.tsx +++ b/src/components/gui/table-cell/generic-cell.tsx @@ -110,6 +110,50 @@ function ForeignKeyColumnSnippet(props: SneakpeakProps) { ); } +function BlobCellValue({ + value, + vector, +}: { + value: Uint8Array | ArrayBuffer | number[]; + vector?: boolean; +}) { + if (vector) { + const floatArray = [...new Float32Array(new Uint8Array(value).buffer)].join( + ", " + ); + + return ( +
+
+ + vec + +
+
[{floatArray}]
+
+ ); + } else { + const sliceByte = value.slice(0, 64); + const base64Text = btoa( + new Uint8Array(sliceByte).reduce( + (data, byte) => data + String.fromCharCode(byte), + "" + ) + ); + + return ( +
+
+ + blob + +
+
{base64Text}
+
+ ); + } +} + export default function GenericCell({ value, onFocus, @@ -189,29 +233,21 @@ export default function GenericCell({ ); } - if (value instanceof ArrayBuffer || value instanceof Uint8Array) { - const sliceByte = value.slice(0, 64); - const base64Text = btoa( - new Uint8Array(sliceByte).reduce( - (data, byte) => data + String.fromCharCode(byte), - "" - ) - ); - + if ( + value instanceof ArrayBuffer || + value instanceof Uint8Array || + Array.isArray(value) + ) { return ( -
-
- - blob - -
-
{base64Text}
-
+ ); } return {value.toString()}; - }, [value, textBaseStyle, isChanged]); + }, [value, textBaseStyle, isChanged, header]); return (
headers.reduce((a, b, idx) => { - a[b.name] = r[idx]; + const cellValue = r[idx]; + if (cellValue instanceof Uint8Array) { + a[b.name] = Array.from(cellValue); + } else { + a[b.name] = r[idx]; + } return a; }, {} as DatabaseRow) );