balibabu
commited on
Commit
·
af41fbc
1
Parent(s):
d6e0c08
Feat: Add DatasetTable #3221 (#3743)
Browse files### What problem does this PR solve?
Feat: Add DatasetTable #3221
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/components/ui/switch.tsx
CHANGED
@@ -11,7 +11,7 @@ const Switch = React.forwardRef<
|
|
11 |
>(({ className, ...props }, ref) => (
|
12 |
<SwitchPrimitives.Root
|
13 |
className={cn(
|
14 |
-
'peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-
|
15 |
className,
|
16 |
)}
|
17 |
{...props}
|
@@ -19,7 +19,7 @@ const Switch = React.forwardRef<
|
|
19 |
>
|
20 |
<SwitchPrimitives.Thumb
|
21 |
className={cn(
|
22 |
-
'pointer-events-none block h-5 w-5 rounded-full bg-
|
23 |
)}
|
24 |
/>
|
25 |
</SwitchPrimitives.Root>
|
|
|
11 |
>(({ className, ...props }, ref) => (
|
12 |
<SwitchPrimitives.Root
|
13 |
className={cn(
|
14 |
+
'peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-colors-background-core-standard data-[state=unchecked]:bg-colors-background-inverse-standard',
|
15 |
className,
|
16 |
)}
|
17 |
{...props}
|
|
|
19 |
>
|
20 |
<SwitchPrimitives.Thumb
|
21 |
className={cn(
|
22 |
+
'pointer-events-none block h-5 w-5 rounded-full bg-colors-text-neutral-strong shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0',
|
23 |
)}
|
24 |
/>
|
25 |
</SwitchPrimitives.Root>
|
web/src/layouts/next.tsx
CHANGED
@@ -3,7 +3,7 @@ import { Header } from './next-header';
|
|
3 |
|
4 |
export default function NextLayout() {
|
5 |
return (
|
6 |
-
<section>
|
7 |
<Header></Header>
|
8 |
<Outlet />
|
9 |
</section>
|
|
|
3 |
|
4 |
export default function NextLayout() {
|
5 |
return (
|
6 |
+
<section className="h-full flex flex-col">
|
7 |
<Header></Header>
|
8 |
<Outlet />
|
9 |
</section>
|
web/src/pages/dataset/dataset/dataset-table.tsx
CHANGED
@@ -12,7 +12,7 @@ import {
|
|
12 |
getSortedRowModel,
|
13 |
useReactTable,
|
14 |
} from '@tanstack/react-table';
|
15 |
-
import { ArrowUpDown, MoreHorizontal } from 'lucide-react';
|
16 |
import * as React from 'react';
|
17 |
|
18 |
import { Button } from '@/components/ui/button';
|
@@ -25,6 +25,7 @@ import {
|
|
25 |
DropdownMenuSeparator,
|
26 |
DropdownMenuTrigger,
|
27 |
} from '@/components/ui/dropdown-menu';
|
|
|
28 |
import {
|
29 |
Table,
|
30 |
TableBody,
|
@@ -35,6 +36,7 @@ import {
|
|
35 |
} from '@/components/ui/table';
|
36 |
import { RunningStatus } from '@/constants/knowledge';
|
37 |
import { IDocumentInfo } from '@/interfaces/database/document';
|
|
|
38 |
|
39 |
const data: IDocumentInfo[] = [
|
40 |
{
|
@@ -68,97 +70,6 @@ const data: IDocumentInfo[] = [
|
|
68 |
},
|
69 |
];
|
70 |
|
71 |
-
export const columns: ColumnDef<IDocumentInfo>[] = [
|
72 |
-
{
|
73 |
-
id: 'select',
|
74 |
-
header: ({ table }) => (
|
75 |
-
<Checkbox
|
76 |
-
checked={
|
77 |
-
table.getIsAllPageRowsSelected() ||
|
78 |
-
(table.getIsSomePageRowsSelected() && 'indeterminate')
|
79 |
-
}
|
80 |
-
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
81 |
-
aria-label="Select all"
|
82 |
-
/>
|
83 |
-
),
|
84 |
-
cell: ({ row }) => (
|
85 |
-
<Checkbox
|
86 |
-
checked={row.getIsSelected()}
|
87 |
-
onCheckedChange={(value) => row.toggleSelected(!!value)}
|
88 |
-
aria-label="Select row"
|
89 |
-
/>
|
90 |
-
),
|
91 |
-
enableSorting: false,
|
92 |
-
enableHiding: false,
|
93 |
-
},
|
94 |
-
{
|
95 |
-
accessorKey: 'status',
|
96 |
-
header: 'Status',
|
97 |
-
cell: ({ row }) => (
|
98 |
-
<div className="capitalize">{row.getValue('status')}</div>
|
99 |
-
),
|
100 |
-
},
|
101 |
-
{
|
102 |
-
accessorKey: 'email',
|
103 |
-
header: ({ column }) => {
|
104 |
-
return (
|
105 |
-
<Button
|
106 |
-
variant="ghost"
|
107 |
-
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
108 |
-
>
|
109 |
-
Email
|
110 |
-
<ArrowUpDown />
|
111 |
-
</Button>
|
112 |
-
);
|
113 |
-
},
|
114 |
-
cell: ({ row }) => <div className="lowercase">{row.getValue('email')}</div>,
|
115 |
-
},
|
116 |
-
{
|
117 |
-
accessorKey: 'amount',
|
118 |
-
header: () => <div className="text-right">Amount</div>,
|
119 |
-
cell: ({ row }) => {
|
120 |
-
const amount = parseFloat(row.getValue('amount'));
|
121 |
-
|
122 |
-
// Format the amount as a dollar amount
|
123 |
-
const formatted = new Intl.NumberFormat('en-US', {
|
124 |
-
style: 'currency',
|
125 |
-
currency: 'USD',
|
126 |
-
}).format(amount);
|
127 |
-
|
128 |
-
return <div className="text-right font-medium">{formatted}</div>;
|
129 |
-
},
|
130 |
-
},
|
131 |
-
{
|
132 |
-
id: 'actions',
|
133 |
-
enableHiding: false,
|
134 |
-
cell: ({ row }) => {
|
135 |
-
const payment = row.original;
|
136 |
-
|
137 |
-
return (
|
138 |
-
<DropdownMenu>
|
139 |
-
<DropdownMenuTrigger asChild>
|
140 |
-
<Button variant="ghost" className="h-8 w-8 p-0">
|
141 |
-
<span className="sr-only">Open menu</span>
|
142 |
-
<MoreHorizontal />
|
143 |
-
</Button>
|
144 |
-
</DropdownMenuTrigger>
|
145 |
-
<DropdownMenuContent align="end">
|
146 |
-
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
147 |
-
<DropdownMenuItem
|
148 |
-
onClick={() => navigator.clipboard.writeText(payment.id)}
|
149 |
-
>
|
150 |
-
Copy payment ID
|
151 |
-
</DropdownMenuItem>
|
152 |
-
<DropdownMenuSeparator />
|
153 |
-
<DropdownMenuItem>View customer</DropdownMenuItem>
|
154 |
-
<DropdownMenuItem>View payment details</DropdownMenuItem>
|
155 |
-
</DropdownMenuContent>
|
156 |
-
</DropdownMenu>
|
157 |
-
);
|
158 |
-
},
|
159 |
-
},
|
160 |
-
];
|
161 |
-
|
162 |
export function DatasetTable() {
|
163 |
const [sorting, setSorting] = React.useState<SortingState>([]);
|
164 |
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
@@ -167,6 +78,119 @@ export function DatasetTable() {
|
|
167 |
const [columnVisibility, setColumnVisibility] =
|
168 |
React.useState<VisibilityState>({});
|
169 |
const [rowSelection, setRowSelection] = React.useState({});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
const table = useReactTable({
|
172 |
data,
|
|
|
12 |
getSortedRowModel,
|
13 |
useReactTable,
|
14 |
} from '@tanstack/react-table';
|
15 |
+
import { ArrowUpDown, MoreHorizontal, Pencil } from 'lucide-react';
|
16 |
import * as React from 'react';
|
17 |
|
18 |
import { Button } from '@/components/ui/button';
|
|
|
25 |
DropdownMenuSeparator,
|
26 |
DropdownMenuTrigger,
|
27 |
} from '@/components/ui/dropdown-menu';
|
28 |
+
import { Switch } from '@/components/ui/switch';
|
29 |
import {
|
30 |
Table,
|
31 |
TableBody,
|
|
|
36 |
} from '@/components/ui/table';
|
37 |
import { RunningStatus } from '@/constants/knowledge';
|
38 |
import { IDocumentInfo } from '@/interfaces/database/document';
|
39 |
+
import { useTranslation } from 'react-i18next';
|
40 |
|
41 |
const data: IDocumentInfo[] = [
|
42 |
{
|
|
|
70 |
},
|
71 |
];
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
export function DatasetTable() {
|
74 |
const [sorting, setSorting] = React.useState<SortingState>([]);
|
75 |
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
|
|
78 |
const [columnVisibility, setColumnVisibility] =
|
79 |
React.useState<VisibilityState>({});
|
80 |
const [rowSelection, setRowSelection] = React.useState({});
|
81 |
+
const { t } = useTranslation('translation', {
|
82 |
+
keyPrefix: 'knowledgeDetails',
|
83 |
+
});
|
84 |
+
|
85 |
+
const columns: ColumnDef<IDocumentInfo>[] = [
|
86 |
+
{
|
87 |
+
id: 'select',
|
88 |
+
header: ({ table }) => (
|
89 |
+
<Checkbox
|
90 |
+
checked={
|
91 |
+
table.getIsAllPageRowsSelected() ||
|
92 |
+
(table.getIsSomePageRowsSelected() && 'indeterminate')
|
93 |
+
}
|
94 |
+
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
95 |
+
aria-label="Select all"
|
96 |
+
/>
|
97 |
+
),
|
98 |
+
cell: ({ row }) => (
|
99 |
+
<Checkbox
|
100 |
+
checked={row.getIsSelected()}
|
101 |
+
onCheckedChange={(value) => row.toggleSelected(!!value)}
|
102 |
+
aria-label="Select row"
|
103 |
+
/>
|
104 |
+
),
|
105 |
+
enableSorting: false,
|
106 |
+
enableHiding: false,
|
107 |
+
},
|
108 |
+
{
|
109 |
+
accessorKey: 'name',
|
110 |
+
header: ({ column }) => {
|
111 |
+
return (
|
112 |
+
<Button
|
113 |
+
variant="ghost"
|
114 |
+
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
115 |
+
>
|
116 |
+
{t('name')}
|
117 |
+
<ArrowUpDown />
|
118 |
+
</Button>
|
119 |
+
);
|
120 |
+
},
|
121 |
+
cell: ({ row }) => (
|
122 |
+
<div className="capitalize">{row.getValue('name')}</div>
|
123 |
+
),
|
124 |
+
},
|
125 |
+
{
|
126 |
+
accessorKey: 'create_time',
|
127 |
+
header: ({ column }) => {
|
128 |
+
return (
|
129 |
+
<Button
|
130 |
+
variant="ghost"
|
131 |
+
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
132 |
+
>
|
133 |
+
{t('uploadDate')}
|
134 |
+
<ArrowUpDown />
|
135 |
+
</Button>
|
136 |
+
);
|
137 |
+
},
|
138 |
+
cell: ({ row }) => (
|
139 |
+
<div className="lowercase">{row.getValue('create_time')}</div>
|
140 |
+
),
|
141 |
+
},
|
142 |
+
{
|
143 |
+
accessorKey: 'parser_id',
|
144 |
+
header: t('chunkMethod'),
|
145 |
+
cell: ({ row }) => (
|
146 |
+
<div className="capitalize">{row.getValue('parser_id')}</div>
|
147 |
+
),
|
148 |
+
},
|
149 |
+
{
|
150 |
+
accessorKey: 'run',
|
151 |
+
header: t('parsingStatus'),
|
152 |
+
cell: ({ row }) => (
|
153 |
+
<Button variant="destructive" size={'sm'}>
|
154 |
+
{row.getValue('run')}
|
155 |
+
</Button>
|
156 |
+
),
|
157 |
+
},
|
158 |
+
{
|
159 |
+
id: 'actions',
|
160 |
+
header: t('action'),
|
161 |
+
enableHiding: false,
|
162 |
+
cell: ({ row }) => {
|
163 |
+
const payment = row.original;
|
164 |
+
|
165 |
+
return (
|
166 |
+
<section className="flex gap-4 items-center">
|
167 |
+
<Switch id="airplane-mode" />
|
168 |
+
<Button variant="secondary" size={'icon'}>
|
169 |
+
<Pencil />
|
170 |
+
</Button>
|
171 |
+
<DropdownMenu>
|
172 |
+
<DropdownMenuTrigger asChild>
|
173 |
+
<Button variant="secondary" size={'icon'}>
|
174 |
+
<MoreHorizontal />
|
175 |
+
</Button>
|
176 |
+
</DropdownMenuTrigger>
|
177 |
+
<DropdownMenuContent align="end">
|
178 |
+
<DropdownMenuLabel>Actions</DropdownMenuLabel>
|
179 |
+
<DropdownMenuItem
|
180 |
+
onClick={() => navigator.clipboard.writeText(payment.id)}
|
181 |
+
>
|
182 |
+
Copy payment ID
|
183 |
+
</DropdownMenuItem>
|
184 |
+
<DropdownMenuSeparator />
|
185 |
+
<DropdownMenuItem>View customer</DropdownMenuItem>
|
186 |
+
<DropdownMenuItem>View payment details</DropdownMenuItem>
|
187 |
+
</DropdownMenuContent>
|
188 |
+
</DropdownMenu>
|
189 |
+
</section>
|
190 |
+
);
|
191 |
+
},
|
192 |
+
},
|
193 |
+
];
|
194 |
|
195 |
const table = useReactTable({
|
196 |
data,
|
web/src/pages/dataset/index.tsx
CHANGED
@@ -3,7 +3,7 @@ import { SideBar } from './sidebar';
|
|
3 |
|
4 |
export default function DatasetWrapper() {
|
5 |
return (
|
6 |
-
<div className="text-foreground flex">
|
7 |
<SideBar></SideBar>
|
8 |
<div className="flex-1">
|
9 |
<Outlet />
|
|
|
3 |
|
4 |
export default function DatasetWrapper() {
|
5 |
return (
|
6 |
+
<div className="text-foreground flex flex-1">
|
7 |
<SideBar></SideBar>
|
8 |
<div className="flex-1">
|
9 |
<Outlet />
|
web/src/pages/dataset/sidebar/index.tsx
CHANGED
@@ -2,7 +2,7 @@ import { Button } from '@/components/ui/button';
|
|
2 |
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
3 |
import { useSecondPathName } from '@/hooks/route-hook';
|
4 |
import { cn } from '@/lib/utils';
|
5 |
-
import { Banknote, LayoutGrid, User } from 'lucide-react';
|
6 |
import { useHandleMenuClick } from './hooks';
|
7 |
|
8 |
const items = [
|
@@ -29,7 +29,7 @@ export function SideBar() {
|
|
29 |
const { handleMenuClick } = useHandleMenuClick();
|
30 |
|
31 |
return (
|
32 |
-
<aside className="w-[303px]">
|
33 |
<div className="p-6 space-y-2 border-b">
|
34 |
<div
|
35 |
className="w-[70px] h-[70px] rounded-xl bg-cover"
|
@@ -61,6 +61,13 @@ export function SideBar() {
|
|
61 |
);
|
62 |
})}
|
63 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
</aside>
|
65 |
);
|
66 |
}
|
|
|
2 |
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
3 |
import { useSecondPathName } from '@/hooks/route-hook';
|
4 |
import { cn } from '@/lib/utils';
|
5 |
+
import { Banknote, LayoutGrid, Trash2, User } from 'lucide-react';
|
6 |
import { useHandleMenuClick } from './hooks';
|
7 |
|
8 |
const items = [
|
|
|
29 |
const { handleMenuClick } = useHandleMenuClick();
|
30 |
|
31 |
return (
|
32 |
+
<aside className="w-[303px] relative">
|
33 |
<div className="p-6 space-y-2 border-b">
|
34 |
<div
|
35 |
className="w-[70px] h-[70px] rounded-xl bg-cover"
|
|
|
61 |
);
|
62 |
})}
|
63 |
</div>
|
64 |
+
<Button
|
65 |
+
variant="outline"
|
66 |
+
className="absolute bottom-6 left-6 right-6 text-colors-text-functional-danger border-colors-text-functional-danger"
|
67 |
+
>
|
68 |
+
<Trash2 />
|
69 |
+
Delete dataset
|
70 |
+
</Button>
|
71 |
</aside>
|
72 |
);
|
73 |
}
|
web/tailwind.config.js
CHANGED
@@ -33,6 +33,7 @@ module.exports = {
|
|
33 |
'colors-text-core-standard': 'var(--colors-text-core-standard)',
|
34 |
'colors-text-neutral-strong': 'var(--colors-text-neutral-strong)',
|
35 |
'colors-text-neutral-standard': 'var(--colors-text-neutral-standard)',
|
|
|
36 |
|
37 |
primary: {
|
38 |
DEFAULT: 'hsl(var(--primary))',
|
|
|
33 |
'colors-text-core-standard': 'var(--colors-text-core-standard)',
|
34 |
'colors-text-neutral-strong': 'var(--colors-text-neutral-strong)',
|
35 |
'colors-text-neutral-standard': 'var(--colors-text-neutral-standard)',
|
36 |
+
'colors-text-functional-danger': 'var(--colors-text-functional-danger)',
|
37 |
|
38 |
primary: {
|
39 |
DEFAULT: 'hsl(var(--primary))',
|
web/tailwind.css
CHANGED
@@ -46,6 +46,7 @@
|
|
46 |
--colors-text-core-standard: rgba(127, 105, 255, 1);
|
47 |
--colors-text-neutral-strong: rgb(130, 121, 121);
|
48 |
--colors-text-neutral-standard: rgba(230, 227, 246, 1);
|
|
|
49 |
}
|
50 |
|
51 |
.dark {
|
@@ -122,6 +123,7 @@
|
|
122 |
--colors-text-core-standard: rgba(137, 126, 255, 1);
|
123 |
--colors-text-neutral-strong: rgba(255, 255, 255, 1);
|
124 |
--colors-text-neutral-standard: rgba(230, 227, 246, 1);
|
|
|
125 |
}
|
126 |
}
|
127 |
|
|
|
46 |
--colors-text-core-standard: rgba(127, 105, 255, 1);
|
47 |
--colors-text-neutral-strong: rgb(130, 121, 121);
|
48 |
--colors-text-neutral-standard: rgba(230, 227, 246, 1);
|
49 |
+
--colors-text-functional-danger: rgba(255, 81, 81, 1);
|
50 |
}
|
51 |
|
52 |
.dark {
|
|
|
123 |
--colors-text-core-standard: rgba(137, 126, 255, 1);
|
124 |
--colors-text-neutral-strong: rgba(255, 255, 255, 1);
|
125 |
--colors-text-neutral-standard: rgba(230, 227, 246, 1);
|
126 |
+
--colors-text-functional-danger: rgba(255, 81, 81, 1);
|
127 |
}
|
128 |
}
|
129 |
|