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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
import * as React from 'react';
import { FaEyeSlash } from 'react-icons/fa';
import { Doc } from '../../../../../fields/Doc';
import { Docs } from '../../../../documents/Documents';
import { DocumentView } from '../../../nodes/DocumentView';
import { NewLightboxView } from '../../NewLightboxView';
import { getType } from '../../utils';
import './Recommendation.scss';
import { IRecommendation } from './utils';
export const Recommendation = (props: IRecommendation) => {
const { title, data, type, text, transcript, loading, source, previewUrl, related_concepts, distance, docId } = props;
return (
<div
className={`recommendation-container ${loading && 'loading'} ${previewUrl && 'previewUrl'}`}
onClick={() => {
let doc: Doc | null = null;
if (source == 'Dash' && docId) {
const docView = DocumentView.getDocumentViewsById(docId).lastElement();
if (docView) {
doc = docView.Document;
}
} else if (data) {
switch (type) {
case 'YouTube':
console.log('create ', type, 'document');
doc = Docs.Create.VideoDocument(data, { title: title, _width: 400, _height: 315 });
doc.transcript = transcript ? JSON.stringify(transcript) : undefined;
break;
case 'Video':
console.log('create ', type, 'document');
doc = Docs.Create.VideoDocument(data, { title: title, _width: 400, _height: 315 });
doc.transcript = transcript ? JSON.stringify(transcript) : undefined;
break;
case 'Webpage':
console.log('create ', type, 'document');
doc = Docs.Create.WebDocument(data, { title: title, text: text });
break;
case 'HTML':
console.log('create ', type, 'document');
doc = Docs.Create.WebDocument(data, { title: title, text: text });
break;
case 'Text':
console.log('create ', type, 'document');
doc = Docs.Create.TextDocument(data, { title: title, text: text });
break;
case 'PDF':
console.log('create ', type, 'document');
doc = Docs.Create.PdfDocument(data, { title: title, text: text });
break;
}
}
if (doc !== null) NewLightboxView.SetNewLightboxDoc(doc);
}}>
{loading ? <div className={`image-container`}></div> : previewUrl ? <div className={`image-container`}>{<img className={`image`} src={previewUrl}></img>}</div> : null}
<div className={`title`}>{title}</div>
<div className={`info`}>
{!loading && (
<div className={`type-container`}>
<div className={`lb-label`}>Type</div>
<div className={`lb-type`}>{getType(type!)}</div>
</div>
)}
{!loading && (
<div className={`distance-container`}>
<div className={`lb-label`}>Distance</div>
<div className={`lb-distance`}>{distance}</div>
</div>
)}
</div>
<div className={`source`}>
{!loading && (
<div className={`source-container`}>
<div className={`lb-label`}>Source</div>
<div className={`lb-source`}>{source}</div>
</div>
)}
</div>
<div className={`explainer`}>
{!loading && (
<div>
You are seeing this recommendation because this document also explores
<div className={`concepts-container`}>
{related_concepts?.map(val => {
return <div className={'concept'}>{val}</div>;
})}
</div>
</div>
)}
</div>
<div className={`hide-rec`}>
{!loading && (
<>
<div>Hide Recommendation</div>
<div style={{ fontSize: 15, paddingRight: 5 }}>
<FaEyeSlash />
</div>
</>
)}
</div>
</div>
);
};
|