-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ryjiang <[email protected]>
- Loading branch information
1 parent
3e60eb5
commit 921f7cf
Showing
5 changed files
with
50 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Typography } from '@mui/material'; | ||
import MediaPreview from '../MediaPreview/MediaPreview'; | ||
|
||
const DataView = (props: { type: string; value: any }) => { | ||
const { type, value } = props; | ||
|
||
switch (type) { | ||
case 'VarChar': | ||
return <MediaPreview value={value} />; | ||
case 'JSON': | ||
case 'Array': | ||
case 'SparseFloatVector': | ||
case 'BFloat16Vector': | ||
case 'FloatVector': | ||
case 'Float16Vector': | ||
const stringValue = JSON.stringify(value, null, 2); | ||
// remove escape characters | ||
const formattedValue = stringValue | ||
.replace(/\\n/g, '\n') | ||
.replace(/\\t/g, '\t') | ||
.replace(/\\"/g, '"'); | ||
|
||
// remove first and last double quotes if present | ||
const trimmedValue = formattedValue.replace(/^"|"$/g, ''); | ||
return <Typography title={trimmedValue}>{trimmedValue}</Typography>; | ||
|
||
default: | ||
return <Typography title={value}>{value}</Typography>; | ||
} | ||
}; | ||
|
||
export default DataView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters