1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
| import { getRoot } from "mobx-state-tree";
| import { AnnotationPreview } from "../Common/AnnotationPreview/AnnotationPreview";
|
| const imgDefaultProps = { crossOrigin: "anonymous" };
|
| export const ImageCell = (column) => {
| const {
| original,
| value,
| column: { alias },
| } = column;
| const root = getRoot(original);
|
| const renderImagePreview = original.total_annotations === 0 || !root.showPreviews;
| const imgSrc = Array.isArray(value) ? value[0] : value;
|
| if (!imgSrc) return null;
|
| return renderImagePreview ? (
| <img
| {...imgDefaultProps}
| key={imgSrc}
| src={imgSrc}
| alt="Data"
| style={{
| maxHeight: "100%",
| maxWidth: "100px",
| objectFit: "contain",
| borderRadius: 3,
| }}
| />
| ) : (
| <AnnotationPreview
| task={original}
| annotation={original.annotations[0]}
| config={getRoot(original).SDK}
| name={alias}
| variant="120x120"
| fallbackImage={value}
| style={{
| maxHeight: "100%",
| maxWidth: "100px",
| objectFit: "contain",
| borderRadius: 3,
| }}
| />
| );
| };
|
|