-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(console): multi optimizations of ui and interactive (#1262)
* chore: multi optimizations of ui and interactive * fix: all runs selector not work * fix: dataset version selector not work * feat: support text viewer 1. fix auth error when children empty * fix: lint error
- Loading branch information
Showing
16 changed files
with
162 additions
and
77 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
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
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,54 @@ | ||
import classNames from 'classnames' | ||
import React, { useEffect } from 'react' | ||
import { createUseStyles } from 'react-jss' | ||
import { StatefulTooltip } from 'baseui/tooltip' | ||
|
||
const useStyles = createUseStyles({ | ||
wrapper: { | ||
display: 'flex', | ||
placeItems: 'center', | ||
textOverflow: 'hidden', | ||
}, | ||
text: { | ||
padding: '20px', | ||
}, | ||
}) | ||
|
||
type IImageViewerProps = { | ||
isZoom?: boolean | ||
data: { | ||
src: string | ||
} | ||
} | ||
|
||
const utf8Decoder = new TextDecoder('utf-8') | ||
|
||
export default function TextViewer({ isZoom = false, data }: IImageViewerProps) { | ||
const [text, setText] = React.useState('') | ||
const styles = useStyles() | ||
|
||
useEffect(() => { | ||
if (!data.src) return | ||
fetch(data.src) | ||
.then((response) => response.arrayBuffer()) | ||
.then((buffer) => { | ||
setText(utf8Decoder.decode(buffer)) | ||
}) | ||
}, [data, setText]) | ||
|
||
if (!isZoom) { | ||
return ( | ||
<div className={classNames(styles.wrapper, 'fullsize')}> | ||
<StatefulTooltip content={() => <p style={{ maxWidth: '300px' }}>{text ?? ''}</p>} placement='bottom'> | ||
<p className='text-ellipsis'>{text}</p> | ||
</StatefulTooltip> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<div className='fullsize' style={{ height: '100%' }}> | ||
<p className={styles.text}>{text}</p> | ||
</div> | ||
) | ||
} |
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
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
Oops, something went wrong.