balibabu
commited on
Commit
·
0a903c7
1
Parent(s):
c5ea37c
feat: add SelectFiles and add KnowledgeTesting (#60)
Browse files* feat: add KnowledgeTesting
* feat: add SelectFiles
- web/src/assets/svg/navigation-pointer.svg +12 -0
- web/src/assets/svg/selected-files-collapse.svg +5 -0
- web/src/constants/knowledge.ts +1 -0
- web/src/less/variable.less +1 -0
- web/src/pages/add-knowledge/components/knowledge-sidebar/index.tsx +28 -19
- web/src/pages/add-knowledge/components/knowledge-testing/index.less +5 -0
- web/src/pages/add-knowledge/components/knowledge-testing/index.tsx +16 -0
- web/src/pages/add-knowledge/components/knowledge-testing/testing-control/index.less +26 -0
- web/src/pages/add-knowledge/components/knowledge-testing/testing-control/index.tsx +92 -0
- web/src/pages/add-knowledge/components/knowledge-testing/testing-result/index.less +16 -0
- web/src/pages/add-knowledge/components/knowledge-testing/testing-result/index.tsx +54 -0
- web/src/pages/add-knowledge/components/knowledge-testing/testing-result/select-files.tsx +82 -0
- web/src/pages/add-knowledge/constant.ts +1 -0
- web/src/routes.ts +4 -0
web/src/assets/svg/navigation-pointer.svg
ADDED
|
web/src/assets/svg/selected-files-collapse.svg
ADDED
|
web/src/constants/knowledge.ts
CHANGED
@@ -2,6 +2,7 @@ export enum KnowledgeRouteKey {
|
|
2 |
Dataset = 'dataset',
|
3 |
Testing = 'testing',
|
4 |
Configuration = 'configuration',
|
|
|
5 |
}
|
6 |
|
7 |
export enum RunningStatus {
|
|
|
2 |
Dataset = 'dataset',
|
3 |
Testing = 'testing',
|
4 |
Configuration = 'configuration',
|
5 |
+
TempTesting = 'tempTesting',
|
6 |
}
|
7 |
|
8 |
export enum RunningStatus {
|
web/src/less/variable.less
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
@fontWeight600: 600;
|
2 |
@fontWeight700: 700;
|
3 |
|
|
|
4 |
@gray2: rgba(29, 25, 41, 1);
|
5 |
@gray3: rgba(52, 48, 62, 1);
|
6 |
@gray8: rgba(165, 163, 169, 1);
|
|
|
1 |
@fontWeight600: 600;
|
2 |
@fontWeight700: 700;
|
3 |
|
4 |
+
@grayBackground: rgba(247, 248, 250, 1);
|
5 |
@gray2: rgba(29, 25, 41, 1);
|
6 |
@gray3: rgba(52, 48, 62, 1);
|
7 |
@gray8: rgba(165, 163, 169, 1);
|
web/src/pages/add-knowledge/components/knowledge-sidebar/index.tsx
CHANGED
@@ -6,7 +6,7 @@ import { getWidth } from '@/utils';
|
|
6 |
import { AntDesignOutlined } from '@ant-design/icons';
|
7 |
import { Avatar, Menu, MenuProps, Space } from 'antd';
|
8 |
import classNames from 'classnames';
|
9 |
-
import { useEffect, useMemo, useState } from 'react';
|
10 |
import { useNavigate, useSelector } from 'umi';
|
11 |
import { KnowledgeRouteKey, routeMap } from '../../constant';
|
12 |
import styles from './index.less';
|
@@ -26,23 +26,27 @@ const KnowledgeSidebar = () => {
|
|
26 |
|
27 |
type MenuItem = Required<MenuProps>['items'][number];
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
const items: MenuItem[] = useMemo(() => {
|
47 |
return [
|
48 |
getItem(
|
@@ -60,8 +64,13 @@ const KnowledgeSidebar = () => {
|
|
60 |
KnowledgeRouteKey.Configuration,
|
61 |
<ConfigrationIcon />,
|
62 |
),
|
|
|
|
|
|
|
|
|
|
|
63 |
];
|
64 |
-
}, [
|
65 |
|
66 |
useEffect(() => {
|
67 |
if (windowWidth.width > 957) {
|
|
|
6 |
import { AntDesignOutlined } from '@ant-design/icons';
|
7 |
import { Avatar, Menu, MenuProps, Space } from 'antd';
|
8 |
import classNames from 'classnames';
|
9 |
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
10 |
import { useNavigate, useSelector } from 'umi';
|
11 |
import { KnowledgeRouteKey, routeMap } from '../../constant';
|
12 |
import styles from './index.less';
|
|
|
26 |
|
27 |
type MenuItem = Required<MenuProps>['items'][number];
|
28 |
|
29 |
+
const getItem = useCallback(
|
30 |
+
(
|
31 |
+
label: React.ReactNode,
|
32 |
+
key: React.Key,
|
33 |
+
icon?: React.ReactNode,
|
34 |
+
disabled?: boolean,
|
35 |
+
children?: MenuItem[],
|
36 |
+
type?: 'group',
|
37 |
+
): MenuItem => {
|
38 |
+
return {
|
39 |
+
key,
|
40 |
+
icon,
|
41 |
+
children,
|
42 |
+
label,
|
43 |
+
type,
|
44 |
+
disabled,
|
45 |
+
} as MenuItem;
|
46 |
+
},
|
47 |
+
[],
|
48 |
+
);
|
49 |
+
|
50 |
const items: MenuItem[] = useMemo(() => {
|
51 |
return [
|
52 |
getItem(
|
|
|
64 |
KnowledgeRouteKey.Configuration,
|
65 |
<ConfigrationIcon />,
|
66 |
),
|
67 |
+
getItem(
|
68 |
+
routeMap[KnowledgeRouteKey.TempTesting],
|
69 |
+
KnowledgeRouteKey.TempTesting,
|
70 |
+
<TestingIcon />,
|
71 |
+
),
|
72 |
];
|
73 |
+
}, [getItem]);
|
74 |
|
75 |
useEffect(() => {
|
76 |
if (windowWidth.width > 957) {
|
web/src/pages/add-knowledge/components/knowledge-testing/index.less
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.testingWrapper {
|
2 |
+
flex: 1;
|
3 |
+
background-color: @grayBackground;
|
4 |
+
height: 100%;
|
5 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-testing/index.tsx
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Flex } from 'antd';
|
2 |
+
import TestingControl from './testing-control';
|
3 |
+
import TestingResult from './testing-result';
|
4 |
+
|
5 |
+
import styles from './index.less';
|
6 |
+
|
7 |
+
const KnowledgeTesting = () => {
|
8 |
+
return (
|
9 |
+
<Flex className={styles.testingWrapper} gap={16}>
|
10 |
+
<TestingControl></TestingControl>
|
11 |
+
<TestingResult></TestingResult>
|
12 |
+
</Flex>
|
13 |
+
);
|
14 |
+
};
|
15 |
+
|
16 |
+
export default KnowledgeTesting;
|
web/src/pages/add-knowledge/components/knowledge-testing/testing-control/index.less
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.testingControlWrapper {
|
2 |
+
width: 350px;
|
3 |
+
background-color: white;
|
4 |
+
padding: 30px 20px;
|
5 |
+
.historyTitle {
|
6 |
+
padding: 30px 0 20px;
|
7 |
+
}
|
8 |
+
.historyIcon {
|
9 |
+
vertical-align: middle;
|
10 |
+
}
|
11 |
+
.historyCardWrapper {
|
12 |
+
width: 100%;
|
13 |
+
}
|
14 |
+
.historyCard {
|
15 |
+
width: 100%;
|
16 |
+
:global(.ant-card-body) {
|
17 |
+
padding: 10px;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
.historyText {
|
21 |
+
overflow: hidden;
|
22 |
+
text-overflow: ellipsis;
|
23 |
+
white-space: nowrap;
|
24 |
+
flex: 1;
|
25 |
+
}
|
26 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-testing/testing-control/index.tsx
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
Button,
|
3 |
+
Card,
|
4 |
+
Divider,
|
5 |
+
Flex,
|
6 |
+
Input,
|
7 |
+
Slider,
|
8 |
+
SliderSingleProps,
|
9 |
+
Space,
|
10 |
+
Tag,
|
11 |
+
} from 'antd';
|
12 |
+
|
13 |
+
import { DeleteOutlined, HistoryOutlined } from '@ant-design/icons';
|
14 |
+
import styles from './index.less';
|
15 |
+
|
16 |
+
const list = [1, 2, 3];
|
17 |
+
|
18 |
+
const marks: SliderSingleProps['marks'] = {
|
19 |
+
0: '0°C',
|
20 |
+
26: '26°C',
|
21 |
+
37: '37°C',
|
22 |
+
100: {
|
23 |
+
style: {
|
24 |
+
color: '#f50',
|
25 |
+
},
|
26 |
+
label: <strong>100°C</strong>,
|
27 |
+
},
|
28 |
+
};
|
29 |
+
|
30 |
+
const TestingControl = () => {
|
31 |
+
return (
|
32 |
+
<section className={styles.testingControlWrapper}>
|
33 |
+
<p>
|
34 |
+
<b>Retrieval testing</b>
|
35 |
+
</p>
|
36 |
+
<p>xxxx</p>
|
37 |
+
<Divider></Divider>
|
38 |
+
<section>
|
39 |
+
<Slider range marks={marks} defaultValue={[26, 37]} />
|
40 |
+
<Slider range marks={marks} defaultValue={[26, 37]} />
|
41 |
+
<Card
|
42 |
+
size="small"
|
43 |
+
title="Test text"
|
44 |
+
extra={
|
45 |
+
<Button type="primary" ghost>
|
46 |
+
Semantic Search
|
47 |
+
</Button>
|
48 |
+
}
|
49 |
+
>
|
50 |
+
<Input.TextArea autoSize={{ minRows: 8 }}></Input.TextArea>
|
51 |
+
<Flex justify={'space-between'}>
|
52 |
+
<Tag>10/200</Tag>
|
53 |
+
<Button type="primary" size="small">
|
54 |
+
Testing
|
55 |
+
</Button>
|
56 |
+
</Flex>
|
57 |
+
</Card>
|
58 |
+
</section>
|
59 |
+
<section>
|
60 |
+
<p className={styles.historyTitle}>
|
61 |
+
<Space size={'middle'}>
|
62 |
+
<HistoryOutlined className={styles.historyIcon} />
|
63 |
+
<b>Test history</b>
|
64 |
+
</Space>
|
65 |
+
</p>
|
66 |
+
<Space
|
67 |
+
direction="vertical"
|
68 |
+
size={'middle'}
|
69 |
+
className={styles.historyCardWrapper}
|
70 |
+
>
|
71 |
+
{list.map((x) => (
|
72 |
+
<Card className={styles.historyCard} key={x}>
|
73 |
+
<Flex justify={'space-between'} gap={'small'}>
|
74 |
+
<span>{x}</span>
|
75 |
+
<div className={styles.historyText}>
|
76 |
+
content dcjsjl snldsh svnodvn svnodrfn svjdoghdtbnhdo
|
77 |
+
sdvhodhbuid sldghdrlh
|
78 |
+
</div>
|
79 |
+
<Flex gap={'small'}>
|
80 |
+
<span>time</span>
|
81 |
+
<DeleteOutlined></DeleteOutlined>
|
82 |
+
</Flex>
|
83 |
+
</Flex>
|
84 |
+
</Card>
|
85 |
+
))}
|
86 |
+
</Space>
|
87 |
+
</section>
|
88 |
+
</section>
|
89 |
+
);
|
90 |
+
};
|
91 |
+
|
92 |
+
export default TestingControl;
|
web/src/pages/add-knowledge/components/knowledge-testing/testing-result/index.less
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.testingResultWrapper {
|
2 |
+
flex: 1;
|
3 |
+
background-color: white;
|
4 |
+
padding: 30px 20px;
|
5 |
+
|
6 |
+
.selectFilesCollapse {
|
7 |
+
:global(.ant-collapse-header) {
|
8 |
+
padding-left: 22px;
|
9 |
+
}
|
10 |
+
margin-bottom: 32px;
|
11 |
+
}
|
12 |
+
|
13 |
+
.selectFilesTitle {
|
14 |
+
padding-right: 10px;
|
15 |
+
}
|
16 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-testing/testing-result/index.tsx
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ReactComponent as SelectedFilesCollapseIcon } from '@/assets/svg/selected-files-collapse.svg';
|
2 |
+
import { Card, Collapse, Flex, Space } from 'antd';
|
3 |
+
import SelectFiles from './select-files';
|
4 |
+
|
5 |
+
import styles from './index.less';
|
6 |
+
|
7 |
+
const list = [1, 2, 3, 4];
|
8 |
+
|
9 |
+
const TestingResult = () => {
|
10 |
+
return (
|
11 |
+
<section className={styles.testingResultWrapper}>
|
12 |
+
<Collapse
|
13 |
+
expandIcon={() => (
|
14 |
+
<SelectedFilesCollapseIcon></SelectedFilesCollapseIcon>
|
15 |
+
)}
|
16 |
+
className={styles.selectFilesCollapse}
|
17 |
+
items={[
|
18 |
+
{
|
19 |
+
key: '1',
|
20 |
+
label: (
|
21 |
+
<Flex
|
22 |
+
justify={'space-between'}
|
23 |
+
align="center"
|
24 |
+
className={styles.selectFilesTitle}
|
25 |
+
>
|
26 |
+
<span>4/25 Files Selected</span>
|
27 |
+
<Space size={52}>
|
28 |
+
<b>Hits</b>
|
29 |
+
<b>View</b>
|
30 |
+
</Space>
|
31 |
+
</Flex>
|
32 |
+
),
|
33 |
+
children: (
|
34 |
+
<div>
|
35 |
+
<SelectFiles></SelectFiles>
|
36 |
+
</div>
|
37 |
+
),
|
38 |
+
},
|
39 |
+
]}
|
40 |
+
/>
|
41 |
+
<Flex gap={'large'} vertical>
|
42 |
+
{list.map((x) => (
|
43 |
+
<Card key={x} title="Default size card" extra={<a href="#">More</a>}>
|
44 |
+
<p>Card content</p>
|
45 |
+
<p>Card content</p>
|
46 |
+
<p>Card content</p>
|
47 |
+
</Card>
|
48 |
+
))}
|
49 |
+
</Flex>
|
50 |
+
</section>
|
51 |
+
);
|
52 |
+
};
|
53 |
+
|
54 |
+
export default TestingResult;
|
web/src/pages/add-knowledge/components/knowledge-testing/testing-result/select-files.tsx
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ReactComponent as NavigationPointerIcon } from '@/assets/svg/navigation-pointer.svg';
|
2 |
+
import { Table, TableProps } from 'antd';
|
3 |
+
|
4 |
+
interface DataType {
|
5 |
+
key: string;
|
6 |
+
name: string;
|
7 |
+
hits: number;
|
8 |
+
address: string;
|
9 |
+
tags: string[];
|
10 |
+
}
|
11 |
+
|
12 |
+
const SelectFiles = () => {
|
13 |
+
const columns: TableProps<DataType>['columns'] = [
|
14 |
+
{
|
15 |
+
title: 'Name',
|
16 |
+
dataIndex: 'name',
|
17 |
+
key: 'name',
|
18 |
+
render: (text) => <p>{text}</p>,
|
19 |
+
},
|
20 |
+
|
21 |
+
{
|
22 |
+
title: 'Hits',
|
23 |
+
dataIndex: 'hits',
|
24 |
+
key: 'hits',
|
25 |
+
width: 80,
|
26 |
+
},
|
27 |
+
{
|
28 |
+
title: 'View',
|
29 |
+
key: 'view',
|
30 |
+
width: 50,
|
31 |
+
render: () => <NavigationPointerIcon />,
|
32 |
+
},
|
33 |
+
];
|
34 |
+
|
35 |
+
const rowSelection = {
|
36 |
+
onChange: (selectedRowKeys: React.Key[], selectedRows: DataType[]) => {
|
37 |
+
console.log(
|
38 |
+
`selectedRowKeys: ${selectedRowKeys}`,
|
39 |
+
'selectedRows: ',
|
40 |
+
selectedRows,
|
41 |
+
);
|
42 |
+
},
|
43 |
+
getCheckboxProps: (record: DataType) => ({
|
44 |
+
disabled: record.name === 'Disabled User', // Column configuration not to be checked
|
45 |
+
name: record.name,
|
46 |
+
}),
|
47 |
+
};
|
48 |
+
|
49 |
+
const data: DataType[] = [
|
50 |
+
{
|
51 |
+
key: '1',
|
52 |
+
name: 'John Brown',
|
53 |
+
hits: 32,
|
54 |
+
address: 'New York No. 1 Lake Park',
|
55 |
+
tags: ['nice', 'developer'],
|
56 |
+
},
|
57 |
+
{
|
58 |
+
key: '2',
|
59 |
+
name: 'Jim Green',
|
60 |
+
hits: 42,
|
61 |
+
address: 'London No. 1 Lake Park',
|
62 |
+
tags: ['loser'],
|
63 |
+
},
|
64 |
+
{
|
65 |
+
key: '3',
|
66 |
+
name: 'Joe Black',
|
67 |
+
hits: 32,
|
68 |
+
address: 'Sydney No. 1 Lake Park',
|
69 |
+
tags: ['cool', 'teacher'],
|
70 |
+
},
|
71 |
+
];
|
72 |
+
return (
|
73 |
+
<Table
|
74 |
+
columns={columns}
|
75 |
+
dataSource={data}
|
76 |
+
showHeader={false}
|
77 |
+
rowSelection={rowSelection}
|
78 |
+
/>
|
79 |
+
);
|
80 |
+
};
|
81 |
+
|
82 |
+
export default SelectFiles;
|
web/src/pages/add-knowledge/constant.ts
CHANGED
@@ -4,6 +4,7 @@ export const routeMap = {
|
|
4 |
[KnowledgeRouteKey.Dataset]: 'Dataset',
|
5 |
[KnowledgeRouteKey.Testing]: 'Retrieval testing',
|
6 |
[KnowledgeRouteKey.Configuration]: 'Configuration',
|
|
|
7 |
};
|
8 |
|
9 |
export enum KnowledgeDatasetRouteKey {
|
|
|
4 |
[KnowledgeRouteKey.Dataset]: 'Dataset',
|
5 |
[KnowledgeRouteKey.Testing]: 'Retrieval testing',
|
6 |
[KnowledgeRouteKey.Configuration]: 'Configuration',
|
7 |
+
[KnowledgeRouteKey.TempTesting]: 'Testing',
|
8 |
};
|
9 |
|
10 |
export enum KnowledgeDatasetRouteKey {
|
web/src/routes.ts
CHANGED
@@ -46,6 +46,10 @@ const routes = [
|
|
46 |
path: '/knowledge/testing',
|
47 |
component: '@/pages/add-knowledge/components/knowledge-search',
|
48 |
},
|
|
|
|
|
|
|
|
|
49 |
],
|
50 |
},
|
51 |
{
|
|
|
46 |
path: '/knowledge/testing',
|
47 |
component: '@/pages/add-knowledge/components/knowledge-search',
|
48 |
},
|
49 |
+
{
|
50 |
+
path: '/knowledge/tempTesting',
|
51 |
+
component: '@/pages/add-knowledge/components/knowledge-testing',
|
52 |
+
},
|
53 |
],
|
54 |
},
|
55 |
{
|