From abd79b36f15466db05a2c1f379260b85e4ae838b Mon Sep 17 00:00:00 2001 From: Geireann Lindfield Roberts <60007097+geireann@users.noreply.github.com> Date: Wed, 7 Jun 2023 11:50:45 -0400 Subject: added doc recommendations to search --- .../RecommendationList/RecommendationList.scss | 14 -------- .../RecommendationList/RecommendationList.tsx | 42 ++++++++++++---------- 2 files changed, 23 insertions(+), 33 deletions(-) (limited to 'src/client/views/newlightbox/RecommendationList') 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
{word} -
{ + } onClick={() => { let kw = keywordsLoc kw.splice(ind) NewLightboxView.SetKeywords(kw) - }}>{}
+ }}/>
})} -- cgit v1.2.3-70-g09d2