@bsol-oss/react-datatable5 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +53 -0
- package/dist/index.js +188 -5
- package/dist/index.mjs +200 -0
- package/dist/types/components/DataTable.d.ts +1 -2
- package/dist/types/components/DataTableContext.d.ts +1 -2
- package/dist/types/components/EditFilterButton.d.ts +1 -2
- package/dist/types/components/EditSortingButton.d.ts +1 -2
- package/dist/types/components/EditViewButton.d.ts +1 -2
- package/dist/types/components/PageSizeControl.d.ts +1 -2
- package/dist/types/components/ResetFilteringButton.d.ts +1 -2
- package/dist/types/components/ResetSortingButton.d.ts +1 -2
- package/dist/types/components/Table.d.ts +1 -2
- package/dist/types/components/TableBody.d.ts +1 -2
- package/dist/types/components/TableCardContainer.d.ts +2 -3
- package/dist/types/components/TableCards.d.ts +1 -2
- package/dist/types/components/TableFilter.d.ts +1 -2
- package/dist/types/components/TableFooter.d.ts +0 -1
- package/dist/types/components/TableHeader.d.ts +1 -2
- package/dist/types/components/TablePagination.d.ts +1 -2
- package/dist/types/components/TableSorter.d.ts +1 -2
- package/dist/types/components/TextCell.d.ts +1 -2
- package/dist/types/components/useDataFromUrl.d.ts +3 -4
- package/package.json +10 -3
- package/.cache/storybook/default/dev-server/a5a8bf6e622aef57065c6498611f40c911543d7d-3920d97c51b8ad2521918fb1205babd22b0ed3d7 +0 -1
- package/.cache/storybook/default/dev-server/a5a8bf6e622aef57065c6498611f40c911543d7d-43fdebe5fc35e4e9fabee9a83c7faea931b05ea0 +0 -1
- package/.cache/storybook/default/dev-server/a5a8bf6e622aef57065c6498611f40c911543d7d-f086b87885981c04ce7a583ff90a49313de83de7 +0 -1
- package/.eslintrc.cjs +0 -19
- package/.prettierignore +0 -4
- package/.storybook/main.ts +0 -20
- package/.storybook/preview.ts +0 -14
- package/prettier.json +0 -6
- package/rollup.config.js +0 -10
- package/src/assets/react.svg +0 -1
- package/src/components/DataTable.tsx +0 -112
- package/src/components/DataTableContext.tsx +0 -12
- package/src/components/EditFilterButton.tsx +0 -37
- package/src/components/EditSortingButton.tsx +0 -37
- package/src/components/EditViewButton.tsx +0 -46
- package/src/components/PageSizeControl.tsx +0 -29
- package/src/components/ResetFilteringButton.tsx +0 -18
- package/src/components/ResetSortingButton.tsx +0 -18
- package/src/components/Table.tsx +0 -20
- package/src/components/TableBody.tsx +0 -23
- package/src/components/TableCardContainer.tsx +0 -22
- package/src/components/TableCards.tsx +0 -36
- package/src/components/TableFilter.tsx +0 -34
- package/src/components/TableFooter.tsx +0 -27
- package/src/components/TableHeader.tsx +0 -106
- package/src/components/TablePagination.tsx +0 -58
- package/src/components/TableSorter.tsx +0 -62
- package/src/components/TextCell.tsx +0 -18
- package/src/components/useDataFromUrl.tsx +0 -52
- package/src/components/useDataTable.tsx +0 -7
- package/src/index.tsx +0 -12
- package/src/stories/CardViewShowcase.tsx +0 -103
- package/src/stories/DataTable.stories.tsx +0 -30
- package/src/stories/TableViewShowcase.tsx +0 -105
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -26
- package/tsconfig.node.json +0 -11
- package/vite.config.ts +0 -7
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { Box, Button, Flex, Th, Thead, Tr } from "@chakra-ui/react";
|
|
2
|
-
import { flexRender } from "@tanstack/react-table";
|
|
3
|
-
import { MdFilterListAlt } from "react-icons/md";
|
|
4
|
-
|
|
5
|
-
// import { Box } from "framer-motion";
|
|
6
|
-
import {
|
|
7
|
-
ChevronDownIcon,
|
|
8
|
-
ChevronUpIcon,
|
|
9
|
-
CloseIcon,
|
|
10
|
-
UpDownIcon,
|
|
11
|
-
} from "@chakra-ui/icons";
|
|
12
|
-
import { useDataTable } from "./useDataTable";
|
|
13
|
-
|
|
14
|
-
export interface TableHeaderProps {
|
|
15
|
-
canResize?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const TableHeader = ({ canResize }: TableHeaderProps) => {
|
|
19
|
-
const { table } = useDataTable();
|
|
20
|
-
return (
|
|
21
|
-
<Thead>
|
|
22
|
-
{table.getHeaderGroups().map((headerGroup) => (
|
|
23
|
-
<Tr key={crypto.randomUUID()} style={{ columnSpan: "all" }}>
|
|
24
|
-
{headerGroup.headers.map((header) => {
|
|
25
|
-
const resizeProps = {
|
|
26
|
-
onClick: () => header.column.resetSize(),
|
|
27
|
-
onMouseDown: header.getResizeHandler(),
|
|
28
|
-
onTouchStart: header.getResizeHandler(),
|
|
29
|
-
cursor: "col-resize",
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Th
|
|
34
|
-
padding={"0rem"}
|
|
35
|
-
key={crypto.randomUUID()}
|
|
36
|
-
colSpan={header.colSpan}
|
|
37
|
-
width={`${header.getSize()}px`}
|
|
38
|
-
>
|
|
39
|
-
<Flex alignItems={"center"} gap={"0.5rem"} padding={"0.5rem"}>
|
|
40
|
-
<Box>
|
|
41
|
-
{header.isPlaceholder
|
|
42
|
-
? null
|
|
43
|
-
: flexRender(
|
|
44
|
-
header.column.columnDef.header,
|
|
45
|
-
header.getContext(),
|
|
46
|
-
)}
|
|
47
|
-
</Box>
|
|
48
|
-
{header.column.getCanSort() && (
|
|
49
|
-
<>
|
|
50
|
-
<Button
|
|
51
|
-
onClick={(e) => {
|
|
52
|
-
header.column.toggleSorting();
|
|
53
|
-
}}
|
|
54
|
-
>
|
|
55
|
-
{header.column.getNextSortingOrder() === false && (
|
|
56
|
-
// <Text>To No sort</Text>
|
|
57
|
-
<ChevronUpIcon />
|
|
58
|
-
)}
|
|
59
|
-
{header.column.getNextSortingOrder() === "asc" && (
|
|
60
|
-
// <Text>To asc</Text>
|
|
61
|
-
<UpDownIcon />
|
|
62
|
-
)}
|
|
63
|
-
{header.column.getNextSortingOrder() === "desc" && (
|
|
64
|
-
// <Text>To desc</Text>
|
|
65
|
-
<ChevronDownIcon />
|
|
66
|
-
)}
|
|
67
|
-
</Button>
|
|
68
|
-
|
|
69
|
-
{header.column.getIsSorted() && (
|
|
70
|
-
<Button
|
|
71
|
-
onClick={(e) => {
|
|
72
|
-
header.column.clearSorting();
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
<CloseIcon />
|
|
76
|
-
</Button>
|
|
77
|
-
)}
|
|
78
|
-
</>
|
|
79
|
-
)}
|
|
80
|
-
|
|
81
|
-
{header.column.getIsFiltered() && <MdFilterListAlt />}
|
|
82
|
-
{canResize && (
|
|
83
|
-
<Box
|
|
84
|
-
borderRight={
|
|
85
|
-
header.column.getIsResizing()
|
|
86
|
-
? "0.25rem solid black"
|
|
87
|
-
: "0.25rem solid grey"
|
|
88
|
-
}
|
|
89
|
-
height={"5rem"}
|
|
90
|
-
width={"5px"}
|
|
91
|
-
userSelect={"none"}
|
|
92
|
-
style={{ touchAction: "none" }}
|
|
93
|
-
{...resizeProps}
|
|
94
|
-
></Box>
|
|
95
|
-
)}
|
|
96
|
-
</Flex>
|
|
97
|
-
</Th>
|
|
98
|
-
);
|
|
99
|
-
})}
|
|
100
|
-
</Tr>
|
|
101
|
-
))}
|
|
102
|
-
</Thead>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export default TableHeader;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Button, ButtonGroup, IconButton } from "@chakra-ui/react";
|
|
2
|
-
import {
|
|
3
|
-
MdArrowBack,
|
|
4
|
-
MdArrowForward,
|
|
5
|
-
MdFirstPage,
|
|
6
|
-
MdLastPage,
|
|
7
|
-
} from "react-icons/md";
|
|
8
|
-
import { useDataTable } from "./useDataTable";
|
|
9
|
-
|
|
10
|
-
export interface PaginationProps {}
|
|
11
|
-
|
|
12
|
-
const TablePagination = ({}: PaginationProps) => {
|
|
13
|
-
const {
|
|
14
|
-
firstPage,
|
|
15
|
-
getCanPreviousPage,
|
|
16
|
-
previousPage,
|
|
17
|
-
getState,
|
|
18
|
-
nextPage,
|
|
19
|
-
getCanNextPage,
|
|
20
|
-
lastPage,
|
|
21
|
-
} = useDataTable().table;
|
|
22
|
-
return (
|
|
23
|
-
<ButtonGroup isAttached>
|
|
24
|
-
<IconButton
|
|
25
|
-
icon={<MdFirstPage />}
|
|
26
|
-
onClick={() => firstPage()}
|
|
27
|
-
disabled={!getCanPreviousPage()}
|
|
28
|
-
aria-label={"first-page"}
|
|
29
|
-
></IconButton>
|
|
30
|
-
<IconButton
|
|
31
|
-
icon={<MdArrowBack />}
|
|
32
|
-
onClick={() => previousPage()}
|
|
33
|
-
disabled={!getCanPreviousPage()}
|
|
34
|
-
aria-label={"previous-page"}
|
|
35
|
-
></IconButton>
|
|
36
|
-
<Button onClick={() => {}} disabled={!getCanPreviousPage()}>
|
|
37
|
-
{getState().pagination.pageIndex + 1}
|
|
38
|
-
</Button>
|
|
39
|
-
|
|
40
|
-
<IconButton
|
|
41
|
-
onClick={() => nextPage()}
|
|
42
|
-
disabled={!getCanNextPage()}
|
|
43
|
-
aria-label={"next-page"}
|
|
44
|
-
>
|
|
45
|
-
<MdArrowForward />
|
|
46
|
-
</IconButton>
|
|
47
|
-
<IconButton
|
|
48
|
-
onClick={() => lastPage()}
|
|
49
|
-
disabled={!getCanNextPage()}
|
|
50
|
-
aria-label={"last-page"}
|
|
51
|
-
>
|
|
52
|
-
<MdLastPage />
|
|
53
|
-
</IconButton>
|
|
54
|
-
</ButtonGroup>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default TablePagination;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChevronDownIcon,
|
|
3
|
-
ChevronUpIcon,
|
|
4
|
-
CloseIcon,
|
|
5
|
-
UpDownIcon,
|
|
6
|
-
} from "@chakra-ui/icons";
|
|
7
|
-
import { Button, Flex, Text } from "@chakra-ui/react";
|
|
8
|
-
import { useDataTable } from "./useDataTable";
|
|
9
|
-
|
|
10
|
-
const TableSorter = () => {
|
|
11
|
-
const { table } = useDataTable();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
{table.getHeaderGroups().map((headerGroup) => (
|
|
16
|
-
<>
|
|
17
|
-
{headerGroup.headers.map((header) => {
|
|
18
|
-
return (
|
|
19
|
-
<>
|
|
20
|
-
{header.column.getCanSort() && (
|
|
21
|
-
<Flex alignItems={"center"} gap={"0.5rem"} padding={"0.5rem"}>
|
|
22
|
-
<Text>{header.column.id}</Text>
|
|
23
|
-
<Button
|
|
24
|
-
onClick={(e) => {
|
|
25
|
-
header.column.toggleSorting();
|
|
26
|
-
}}
|
|
27
|
-
>
|
|
28
|
-
{header.column.getNextSortingOrder() === false && (
|
|
29
|
-
// <Text>To No sort</Text>
|
|
30
|
-
<ChevronUpIcon />
|
|
31
|
-
)}
|
|
32
|
-
{header.column.getNextSortingOrder() === "asc" && (
|
|
33
|
-
// <Text>To asc</Text>
|
|
34
|
-
<UpDownIcon />
|
|
35
|
-
)}
|
|
36
|
-
{header.column.getNextSortingOrder() === "desc" && (
|
|
37
|
-
// <Text>To desc</Text>
|
|
38
|
-
<ChevronDownIcon />
|
|
39
|
-
)}
|
|
40
|
-
</Button>
|
|
41
|
-
|
|
42
|
-
{header.column.getIsSorted() && (
|
|
43
|
-
<Button
|
|
44
|
-
onClick={(e) => {
|
|
45
|
-
header.column.clearSorting();
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<CloseIcon />
|
|
49
|
-
</Button>
|
|
50
|
-
)}
|
|
51
|
-
</Flex>
|
|
52
|
-
)}
|
|
53
|
-
</>
|
|
54
|
-
);
|
|
55
|
-
})}
|
|
56
|
-
</>
|
|
57
|
-
))}
|
|
58
|
-
</>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export default TableSorter;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Tooltip, Text } from "@chakra-ui/react";
|
|
2
|
-
|
|
3
|
-
const TextCell = ({ label, children }: any) => {
|
|
4
|
-
return (
|
|
5
|
-
<Tooltip label={label}>
|
|
6
|
-
<Text
|
|
7
|
-
as="span"
|
|
8
|
-
overflow="hidden"
|
|
9
|
-
textOverflow={"ellipsis"}
|
|
10
|
-
noOfLines={[1, 2, 3]}
|
|
11
|
-
>
|
|
12
|
-
{children}
|
|
13
|
-
</Text>
|
|
14
|
-
</Tooltip>
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default TextCell;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
|
-
|
|
4
|
-
interface useDataFromUrlReturn<T> {
|
|
5
|
-
data: T;
|
|
6
|
-
loading: boolean;
|
|
7
|
-
hasError: boolean;
|
|
8
|
-
refreshData: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface useDataFromUrlProps<T> {
|
|
12
|
-
url: string;
|
|
13
|
-
params?: object;
|
|
14
|
-
defaultData: T;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const useDataFromUrl = <T,>({
|
|
18
|
-
url,
|
|
19
|
-
params = {},
|
|
20
|
-
defaultData,
|
|
21
|
-
}: useDataFromUrlProps<T>): useDataFromUrlReturn<T> => {
|
|
22
|
-
const [loading, setLoading] = useState<boolean>(true);
|
|
23
|
-
const [hasError, setHasError] = useState<boolean>(false);
|
|
24
|
-
const [data, setData] = useState<T>(defaultData);
|
|
25
|
-
const refreshData = async () => {
|
|
26
|
-
await getData();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const getData = async () => {
|
|
30
|
-
try {
|
|
31
|
-
setLoading(true);
|
|
32
|
-
const { data } = await axios.get<T>(url, { params: params });
|
|
33
|
-
console.log("get DataFromUrl success", data);
|
|
34
|
-
setLoading(false);
|
|
35
|
-
setData(data);
|
|
36
|
-
} catch (e) {
|
|
37
|
-
console.log(e);
|
|
38
|
-
setLoading(false);
|
|
39
|
-
setHasError(true);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
getData().catch((e) => {
|
|
45
|
-
console.error(e);
|
|
46
|
-
});
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
|
-
return { data, loading, hasError, refreshData };
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default useDataFromUrl;
|
package/src/index.tsx
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from "./components/DataTable";
|
|
2
|
-
export * from "./components/EditViewButton";
|
|
3
|
-
export * from "./components/PageSizeControl";
|
|
4
|
-
export * from "./components/ResetFilteringButton";
|
|
5
|
-
export * from "./components/ResetSortingButton";
|
|
6
|
-
export * from "./components/Table";
|
|
7
|
-
export * from "./components/TableBody";
|
|
8
|
-
export * from "./components/TableFilter";
|
|
9
|
-
export * from "./components/TableFooter";
|
|
10
|
-
export * from "./components/TableHeader";
|
|
11
|
-
export * from "./components/TablePagination";
|
|
12
|
-
export * from "./components/TextCell";
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
// import React from 'react';
|
|
2
|
-
import { ButtonGroup, ChakraProvider, theme } from "@chakra-ui/react";
|
|
3
|
-
import { ColumnDef, createColumnHelper } from "@tanstack/react-table";
|
|
4
|
-
import DataTable from "../components/DataTable";
|
|
5
|
-
import EditFilterButton from "../components/EditFilterButton";
|
|
6
|
-
import EditSortingButton from "../components/EditSortingButton";
|
|
7
|
-
import EditViewButton from "../components/EditViewButton";
|
|
8
|
-
import PageSizeControl from "../components/PageSizeControl";
|
|
9
|
-
import TableCardContainer from "../components/TableCardContainer";
|
|
10
|
-
import TableCards from "../components/TableCards";
|
|
11
|
-
import TablePagination from "../components/TablePagination";
|
|
12
|
-
import TextCell from "../components/TextCell";
|
|
13
|
-
|
|
14
|
-
interface ChatRecord {
|
|
15
|
-
session_id: string;
|
|
16
|
-
last_user_message: string;
|
|
17
|
-
last_system_response: string;
|
|
18
|
-
total_token: number;
|
|
19
|
-
total_prompt_tokens: number;
|
|
20
|
-
total_completion_tokens: number;
|
|
21
|
-
total_normalise_tokens: number;
|
|
22
|
-
chat_type: string;
|
|
23
|
-
model: string;
|
|
24
|
-
created_by: string;
|
|
25
|
-
last_update: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface RowActionsProps {
|
|
29
|
-
row: ChatRecord;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const RowActions = ({ row }: RowActionsProps) => {
|
|
33
|
-
return <>no actions</>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const CardViewShowcase = () => {
|
|
37
|
-
const columnHelper = createColumnHelper<ChatRecord>();
|
|
38
|
-
|
|
39
|
-
const columns: ColumnDef<ChatRecord>[] = [
|
|
40
|
-
// Display Column
|
|
41
|
-
columnHelper.display({
|
|
42
|
-
id: "actions",
|
|
43
|
-
header: () => <span>Actions</span>,
|
|
44
|
-
cell: (props) => <RowActions row={props.row.original} />,
|
|
45
|
-
}),
|
|
46
|
-
|
|
47
|
-
// Grouping Column
|
|
48
|
-
columnHelper.group({
|
|
49
|
-
header: "Information",
|
|
50
|
-
footer: (props) => props.column.id,
|
|
51
|
-
columns: [
|
|
52
|
-
columnHelper.accessor("session_id", {
|
|
53
|
-
cell: (props) => {
|
|
54
|
-
return <TextCell>{props.row.original.session_id}</TextCell>;
|
|
55
|
-
},
|
|
56
|
-
header: () => <span>Session Id</span>,
|
|
57
|
-
footer: (props) => props.column.id,
|
|
58
|
-
}),
|
|
59
|
-
columnHelper.accessor("last_user_message", {
|
|
60
|
-
cell: (props) => {
|
|
61
|
-
return <TextCell>{props.row.original.last_user_message}</TextCell>;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
header: () => <span>User Message</span>,
|
|
65
|
-
footer: (props) => props.column.id,
|
|
66
|
-
}),
|
|
67
|
-
// Accessor Column
|
|
68
|
-
columnHelper.accessor("total_token", {
|
|
69
|
-
cell: (props) => {
|
|
70
|
-
return <TextCell>{props.row.original.total_token}</TextCell>;
|
|
71
|
-
},
|
|
72
|
-
header: () => <span>Total Token</span>,
|
|
73
|
-
footer: (props) => props.column.id,
|
|
74
|
-
sortDescFirst: false,
|
|
75
|
-
}),
|
|
76
|
-
],
|
|
77
|
-
}),
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<ChakraProvider theme={theme}>
|
|
82
|
-
<DataTable
|
|
83
|
-
columns={columns}
|
|
84
|
-
url={"http://localhost:8333/api/v1/gpt/chat/history/all"}
|
|
85
|
-
>
|
|
86
|
-
<TablePagination />
|
|
87
|
-
<ButtonGroup isAttached>
|
|
88
|
-
<EditViewButton />
|
|
89
|
-
<EditFilterButton />
|
|
90
|
-
<EditSortingButton />
|
|
91
|
-
</ButtonGroup>
|
|
92
|
-
|
|
93
|
-
<TableCardContainer>
|
|
94
|
-
<TableCards />
|
|
95
|
-
</TableCardContainer>
|
|
96
|
-
<PageSizeControl />
|
|
97
|
-
<TablePagination />
|
|
98
|
-
</DataTable>
|
|
99
|
-
</ChakraProvider>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export default CardViewShowcase;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import TableViewShowcase from "./TableViewShowcase";
|
|
3
|
-
import CardViewShowcase from "./CardViewShowcase";
|
|
4
|
-
|
|
5
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
6
|
-
const meta = {
|
|
7
|
-
title: "DataTable/TableView",
|
|
8
|
-
component: TableViewShowcase,
|
|
9
|
-
parameters: {
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
argTypes: {
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
} satisfies Meta<typeof TableViewShowcase>;
|
|
16
|
-
|
|
17
|
-
export default meta;
|
|
18
|
-
type Story = StoryObj<typeof meta>;
|
|
19
|
-
|
|
20
|
-
export const TableView: Story = {
|
|
21
|
-
render: () => {
|
|
22
|
-
return <TableViewShowcase />;
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const CardView = {
|
|
27
|
-
render: () => {
|
|
28
|
-
return <CardViewShowcase />;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// import React from 'react';
|
|
2
|
-
import { ChakraProvider, theme } from "@chakra-ui/react";
|
|
3
|
-
import { ColumnDef, createColumnHelper } from "@tanstack/react-table";
|
|
4
|
-
import DataTable from "../components/DataTable";
|
|
5
|
-
import EditViewButton from "../components/EditViewButton";
|
|
6
|
-
import PageSizeControl from "../components/PageSizeControl";
|
|
7
|
-
import ResetFilteringButton from "../components/ResetFilteringButton";
|
|
8
|
-
import ResetSortingButton from "../components/ResetSortingButton";
|
|
9
|
-
import Table from "../components/Table";
|
|
10
|
-
import TableBody from "../components/TableBody";
|
|
11
|
-
import TableFilter from "../components/TableFilter";
|
|
12
|
-
import TableFooter from "../components/TableFooter";
|
|
13
|
-
import TableHeader from "../components/TableHeader";
|
|
14
|
-
import TablePagination from "../components/TablePagination";
|
|
15
|
-
import TextCell from "../components/TextCell";
|
|
16
|
-
|
|
17
|
-
interface ChatRecord {
|
|
18
|
-
session_id: string;
|
|
19
|
-
last_user_message: string;
|
|
20
|
-
last_system_response: string;
|
|
21
|
-
total_token: number;
|
|
22
|
-
total_prompt_tokens: number;
|
|
23
|
-
total_completion_tokens: number;
|
|
24
|
-
total_normalise_tokens: number;
|
|
25
|
-
chat_type: string;
|
|
26
|
-
model: string;
|
|
27
|
-
created_by: string;
|
|
28
|
-
last_update: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface RowActionsProps {
|
|
32
|
-
row: ChatRecord;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const RowActions = ({ row }: RowActionsProps) => {
|
|
36
|
-
return <>has no actions</>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const TableViewShowcase = () => {
|
|
40
|
-
const columnHelper = createColumnHelper<ChatRecord>();
|
|
41
|
-
|
|
42
|
-
const columns: ColumnDef<ChatRecord>[] = [
|
|
43
|
-
// Display Column
|
|
44
|
-
columnHelper.display({
|
|
45
|
-
id: "actions",
|
|
46
|
-
header: () => <span>Actions</span>,
|
|
47
|
-
cell: (props) => <RowActions row={props.row.original} />,
|
|
48
|
-
}),
|
|
49
|
-
|
|
50
|
-
// Grouping Column
|
|
51
|
-
columnHelper.group({
|
|
52
|
-
header: "Information",
|
|
53
|
-
footer: (props) => props.column.id,
|
|
54
|
-
columns: [
|
|
55
|
-
columnHelper.accessor("session_id", {
|
|
56
|
-
cell: (props) => {
|
|
57
|
-
return <TextCell>{props.row.original.session_id}</TextCell>;
|
|
58
|
-
},
|
|
59
|
-
header: () => <span>Session Id</span>,
|
|
60
|
-
footer: (props) => props.column.id,
|
|
61
|
-
}),
|
|
62
|
-
columnHelper.accessor("last_user_message", {
|
|
63
|
-
cell: (props) => {
|
|
64
|
-
return <TextCell>{props.row.original.last_user_message}</TextCell>;
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
header: () => <span>User Message</span>,
|
|
68
|
-
footer: (props) => props.column.id,
|
|
69
|
-
}),
|
|
70
|
-
// Accessor Column
|
|
71
|
-
columnHelper.accessor("total_token", {
|
|
72
|
-
cell: (props) => {
|
|
73
|
-
return <TextCell>{props.row.original.total_token}</TextCell>;
|
|
74
|
-
},
|
|
75
|
-
header: () => <span>Total Token</span>,
|
|
76
|
-
footer: (props) => props.column.id,
|
|
77
|
-
sortDescFirst: false,
|
|
78
|
-
}),
|
|
79
|
-
],
|
|
80
|
-
}),
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<ChakraProvider theme={theme}>
|
|
85
|
-
<DataTable
|
|
86
|
-
columns={columns}
|
|
87
|
-
url={"http://localhost:8333/api/v1/gpt/chat/history/all"}
|
|
88
|
-
>
|
|
89
|
-
<EditViewButton />
|
|
90
|
-
<ResetSortingButton />
|
|
91
|
-
<TableFilter />
|
|
92
|
-
<ResetFilteringButton />
|
|
93
|
-
<Table>
|
|
94
|
-
<TableHeader />
|
|
95
|
-
<TableBody />
|
|
96
|
-
<TableFooter />
|
|
97
|
-
</Table>
|
|
98
|
-
<PageSizeControl />
|
|
99
|
-
<TablePagination />
|
|
100
|
-
</DataTable>
|
|
101
|
-
</ChakraProvider>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default TableViewShowcase;
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"outDir": "./dist/types",
|
|
5
|
-
"target": "ES2020",
|
|
6
|
-
"useDefineForClassFields": true,
|
|
7
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
8
|
-
"module": "ESNext",
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
|
|
11
|
-
/* Bundler mode */
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"isolatedModules": true,
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
"jsx": "react-jsx",
|
|
18
|
-
/* Linting */
|
|
19
|
-
"strict": true,
|
|
20
|
-
"noUnusedLocals": true,
|
|
21
|
-
"noUnusedParameters": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true
|
|
23
|
-
},
|
|
24
|
-
"include": ["src"],
|
|
25
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
26
|
-
}
|
package/tsconfig.node.json
DELETED