diff options
| author | Geireann Lindfield Roberts <60007097+geireann@users.noreply.github.com> | 2023-06-07 11:50:45 -0400 |
|---|---|---|
| committer | Geireann Lindfield Roberts <60007097+geireann@users.noreply.github.com> | 2023-06-07 11:50:45 -0400 |
| commit | abd79b36f15466db05a2c1f379260b85e4ae838b (patch) | |
| tree | 6d1c7b0e4d46ea7f3457d674ffe625c6b5fe859a /src/client/views/newlightbox/RecommendationList | |
| parent | cb4fbf58fb30b3ea863f5107674dd366566e39a7 (diff) | |
added doc recommendations to search
Diffstat (limited to 'src/client/views/newlightbox/RecommendationList')
| -rw-r--r-- | src/client/views/newlightbox/RecommendationList/RecommendationList.scss | 14 | ||||
| -rw-r--r-- | src/client/views/newlightbox/RecommendationList/RecommendationList.tsx | 42 |
2 files changed, 23 insertions, 33 deletions
diff --git a/src/client/views/newlightbox/RecommendationList/RecommendationList.scss b/src/client/views/newlightbox/RecommendationList/RecommendationList.scss index e59834353..40dd47e47 100644 --- a/src/client/views/newlightbox/RecommendationList/RecommendationList.scss +++ b/src/client/views/newlightbox/RecommendationList/RecommendationList.scss @@ -101,20 +101,6 @@ min-width: 70px; height: 21.5px; } - - .remove { - cursor: pointer; - display: flex; - justify-content: center; - align-items: center; - color: $text-color-lm; - padding: 1.5px; - border-radius: 2px; - - &:hover { - background: $gray-l1; - } - } } } diff --git a/src/client/views/newlightbox/RecommendationList/RecommendationList.tsx b/src/client/views/newlightbox/RecommendationList/RecommendationList.tsx index 674a501a7..9f3c32e4e 100644 --- a/src/client/views/newlightbox/RecommendationList/RecommendationList.tsx +++ b/src/client/views/newlightbox/RecommendationList/RecommendationList.tsx @@ -12,6 +12,8 @@ import { IBounds } from '../ExploreView/utils'; import { List } from '../../../../fields/List'; import { Id } from '../../../../fields/FieldSymbols'; import { LightboxView } from '../../LightboxView'; +import { IconButton, Size, Type } from 'browndash-components'; +import { Colors } from '../../global/globalEnums'; export const RecommendationList = (props: IRecommendationList) => { const {loading, keywords} = props @@ -31,8 +33,9 @@ export const RecommendationList = (props: IRecommendationList) => { React.useEffect(() => { const getKeywords = async () => { let text = StrCast(LightboxView.LightboxDoc?.text) - console.log('fetching keywords w/: ', text) + console.log('[1] fetching keywords') const response = await fetchKeywords(text, 5, true) + console.log('[2] response:', response) const kw = response.keywords; console.log(kw); NewLightboxView.SetKeywords(kw); @@ -59,30 +62,30 @@ export const RecommendationList = (props: IRecommendationList) => { React.useEffect(() => { const getRecommendations = async () => { console.log('fetching recommendations') - let query = undefined + let query = 'undefined' if (keywordsLoc) query = keywordsLoc.join(',') let src = StrCast(NewLightboxView.LightboxDoc?.text) let dashDocs:IDocRequest[] = []; // get linked docs let linkedDocs = DocListCast(NewLightboxView.LightboxDoc?.links) console.log("linked docs", linkedDocs) - // get context docs - let contextDocs: Doc[] = DocListCast(DocCast(NewLightboxView.LightboxDoc?.context).data) - let docId = NewLightboxView.LightboxDoc && NewLightboxView.LightboxDoc[Id] - console.log("context docs", contextDocs) - contextDocs.forEach((doc: Doc) => { - if (docId !== doc[Id]){ - dashDocs.push({ - title: StrCast(doc.title), - text: StrCast(doc.text), - id: doc[Id], - type: StrCast(doc.type) - }) - } - }) + // get context docs (docs that are also in the collection) + // let contextDocs: Doc[] = DocListCast(DocCast(LightboxView.LightboxDoc?.context).data) + // let docId = LightboxView.LightboxDoc && LightboxView.LightboxDoc[Id] + // console.log("context docs", contextDocs) + // contextDocs.forEach((doc: Doc) => { + // if (docId !== doc[Id]){ + // dashDocs.push({ + // title: StrCast(doc.title), + // text: StrCast(doc.text), + // id: doc[Id], + // type: StrCast(doc.type) + // }) + // } + // }) console.log("dash docs", dashDocs) if (query !== undefined) { - const response = await fetchRecommendations(src, query, dashDocs, true) + const response = await fetchRecommendations(src, query, [], true) const num_recs = response.num_recommendations const recs = response.recommendations const keywords = response.keywords @@ -131,6 +134,7 @@ export const RecommendationList = (props: IRecommendationList) => { return a.distance - b.distance } else return 0 }) + console.log("[rec]: ", recommendations) NewLightboxView.SetRecs(recommendations) setRecs(recommendations) } @@ -160,11 +164,11 @@ export const RecommendationList = (props: IRecommendationList) => { {keywordsLoc && keywordsLoc.map((word, ind) => { return <div className={`keyword`}> {word} - <div className={`remove`} onClick={() => { + <IconButton type={Type.PRIM} size={Size.XSMALL} color={Colors.DARK_GRAY} icon={<GrClose/>} onClick={() => { let kw = keywordsLoc kw.splice(ind) NewLightboxView.SetKeywords(kw) - }}>{<GrClose/>}</div> + }}/> </div> })} </div> |
