balibabu commited on
Commit
712affb
·
1 Parent(s): 52a51dc

feat: When the mindmap data is empty, it will not be displayed on the search page #2247 (#2414)

Browse files

### What problem does this PR solve?

feat: When the mindmap data is empty, it will not be displayed on the
search page #2247
### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)

web/src/interfaces/database/knowledge.ts CHANGED
@@ -101,6 +101,7 @@ export interface ITestingChunk {
101
  vector_similarity: number;
102
  highlight: string;
103
  positions: number[][];
 
104
  }
105
 
106
  export interface ITestingDocument {
 
101
  vector_similarity: number;
102
  highlight: string;
103
  positions: number[][];
104
+ docnm_kwd: string;
105
  }
106
 
107
  export interface ITestingDocument {
web/src/pages/search/index.less CHANGED
@@ -3,7 +3,6 @@
3
  background-size: cover;
4
  .card {
5
  width: 100%;
6
- cursor: pointer;
7
  :global(.ant-card-body) {
8
  padding: 14px;
9
  }
@@ -101,6 +100,9 @@
101
  font-style: normal;
102
  }
103
  }
 
 
 
104
  }
105
  .answerWrapper {
106
  margin-top: 16px;
 
3
  background-size: cover;
4
  .card {
5
  width: 100%;
 
6
  :global(.ant-card-body) {
7
  padding: 14px;
8
  }
 
100
  font-style: normal;
101
  }
102
  }
103
+ .documentReference {
104
+ cursor: pointer;
105
+ }
106
  }
107
  .answerWrapper {
108
  margin-top: 16px;
web/src/pages/search/index.tsx CHANGED
@@ -1,3 +1,4 @@
 
1
  import HightLightMarkdown from '@/components/highlight-markdown';
2
  import { ImageWithPopover } from '@/components/image';
3
  import IndentedTree from '@/components/indented-tree/indented-tree';
@@ -56,7 +57,6 @@ const SearchPage = () => {
56
  sendingLoading,
57
  relatedQuestions,
58
  mindMap,
59
- mindMapLoading,
60
  searchStr,
61
  loading,
62
  isFirstRender,
@@ -74,11 +74,10 @@ const SearchPage = () => {
74
 
75
  const isMindMapEmpty = useMemo(() => {
76
  return (
77
- !mindMapLoading &&
78
- ((Array.isArray(mindMap?.children) && mindMap.children.length === 0) ||
79
- !Array.isArray(mindMap?.children))
80
  );
81
- }, [mindMap, mindMapLoading]);
82
 
83
  const InputSearch = (
84
  <Search
@@ -160,34 +159,46 @@ const SearchPage = () => {
160
  className={styles.chunks}
161
  renderItem={(item) => (
162
  <List.Item>
163
- <Card
164
- className={styles.card}
165
- onClick={() =>
166
- clickDocumentButton(item.doc_id, item as any)
167
- }
168
- >
169
  <Space>
170
  <ImageWithPopover
171
  id={item.img_id}
172
  ></ImageWithPopover>
173
- <Popover
174
- content={
175
- <div className={styles.popupMarkdown}>
176
- <HightLightMarkdown>
177
- {item.content_with_weight}
178
- </HightLightMarkdown>
179
- </div>
180
- }
181
- >
182
- <div
183
- dangerouslySetInnerHTML={{
184
- __html: DOMPurify.sanitize(
185
- item.highlight,
186
- ),
187
- }}
188
- className={styles.highlightContent}
189
- ></div>
190
- </Popover>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  </Space>
192
  </Card>
193
  </List.Item>
@@ -220,15 +231,11 @@ const SearchPage = () => {
220
  <section
221
  className={isMindMapEmpty ? styles.hide : styles.graph}
222
  >
223
- {mindMapLoading ? (
224
- <Skeleton active />
225
- ) : (
226
- <IndentedTree
227
- data={mindMap}
228
- show
229
- style={{ width: '100%', height: '100%' }}
230
- ></IndentedTree>
231
- )}
232
  </section>
233
  </Flex>
234
  )}
 
1
+ import FileIcon from '@/components/file-icon';
2
  import HightLightMarkdown from '@/components/highlight-markdown';
3
  import { ImageWithPopover } from '@/components/image';
4
  import IndentedTree from '@/components/indented-tree/indented-tree';
 
57
  sendingLoading,
58
  relatedQuestions,
59
  mindMap,
 
60
  searchStr,
61
  loading,
62
  isFirstRender,
 
74
 
75
  const isMindMapEmpty = useMemo(() => {
76
  return (
77
+ (Array.isArray(mindMap?.children) && mindMap.children.length === 0) ||
78
+ !Array.isArray(mindMap?.children)
 
79
  );
80
+ }, [mindMap]);
81
 
82
  const InputSearch = (
83
  <Search
 
159
  className={styles.chunks}
160
  renderItem={(item) => (
161
  <List.Item>
162
+ <Card className={styles.card}>
 
 
 
 
 
163
  <Space>
164
  <ImageWithPopover
165
  id={item.img_id}
166
  ></ImageWithPopover>
167
+ <Flex vertical gap={10}>
168
+ <Popover
169
+ content={
170
+ <div className={styles.popupMarkdown}>
171
+ <HightLightMarkdown>
172
+ {item.content_with_weight}
173
+ </HightLightMarkdown>
174
+ </div>
175
+ }
176
+ >
177
+ <div
178
+ dangerouslySetInnerHTML={{
179
+ __html: DOMPurify.sanitize(
180
+ `${item.highlight}...`,
181
+ ),
182
+ }}
183
+ className={styles.highlightContent}
184
+ ></div>
185
+ </Popover>
186
+ <Space
187
+ className={styles.documentReference}
188
+ onClick={() =>
189
+ clickDocumentButton(
190
+ item.doc_id,
191
+ item as any,
192
+ )
193
+ }
194
+ >
195
+ <FileIcon
196
+ id={item.img_id}
197
+ name={item.docnm_kwd}
198
+ ></FileIcon>
199
+ {item.docnm_kwd}
200
+ </Space>
201
+ </Flex>
202
  </Space>
203
  </Card>
204
  </List.Item>
 
231
  <section
232
  className={isMindMapEmpty ? styles.hide : styles.graph}
233
  >
234
+ <IndentedTree
235
+ data={mindMap}
236
+ show
237
+ style={{ width: '100%', height: '100%' }}
238
+ ></IndentedTree>
 
 
 
 
239
  </section>
240
  </Flex>
241
  )}