slick-table 1.2.2 → 1.2.4
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.cjs.js +103 -103
- package/dist/index.es.js +8071 -7815
- package/dist/styles/icons.scss +1 -1
- package/dist/types/entities/drawer-run-query/index.d.ts +3 -0
- package/dist/types/entities/drawer-run-query/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/grouping/getGroupLabel.d.ts +8 -0
- package/dist/types/entities/drawer-run-query/lib/grouping/getGroupLabel.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/grouping/groupQueriesByDate.d.ts +4 -0
- package/dist/types/entities/drawer-run-query/lib/grouping/groupQueriesByDate.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/grouping/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/lib/grouping/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/hooks/index.d.ts +3 -0
- package/dist/types/entities/drawer-run-query/lib/hooks/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/hooks/useResizeCanvas.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/lib/hooks/useResizeCanvas.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/hooks/useSubscribeToEvent.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/index.d.ts +4 -0
- package/dist/types/entities/drawer-run-query/lib/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/table/getColumsHash.d.ts +3 -0
- package/dist/types/entities/drawer-run-query/lib/table/getColumsHash.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/table/index.d.ts +3 -0
- package/dist/types/entities/drawer-run-query/lib/table/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/lib/table/tableQuery.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/model/consts/consts.d.ts +4 -0
- package/dist/types/entities/drawer-run-query/model/consts/consts.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/model/consts/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/model/consts/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/model/index.d.ts +3 -0
- package/dist/types/entities/drawer-run-query/model/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/model/types/IQueryGroup.d.ts +6 -0
- package/dist/types/entities/drawer-run-query/model/types/IQueryGroup.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/model/types/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/model/types/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/ButtonExecuteQuery/ButtonExecuteQuery.d.ts +8 -0
- package/dist/types/entities/drawer-run-query/ui/ButtonExecuteQuery/ButtonExecuteQuery.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/ButtonExecuteQuery/ButtonExecuteQuery.style.d.ts +9 -0
- package/dist/types/entities/drawer-run-query/ui/ButtonExecuteQuery/ButtonExecuteQuery.style.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/ButtonExecuteQuery/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/ButtonExecuteQuery/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/ColumnTags/ColumnTags.d.ts +11 -0
- package/dist/types/entities/drawer-run-query/ui/ColumnTags/ColumnTags.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/ColumnTags/ColumnTags.style.d.ts +13 -0
- package/dist/types/entities/drawer-run-query/ui/ColumnTags/ColumnTags.style.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/ColumnTags/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/ColumnTags/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/DrawerRunQuery.d.ts +7 -0
- package/dist/types/entities/drawer-run-query/ui/DrawerRunQuery.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/DrawerRunQuery.style.d.ts +24 -0
- package/dist/types/entities/drawer-run-query/ui/DrawerRunQuery.style.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonClose/IconButtonClose.d.ts +7 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonClose/IconButtonClose.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonClose/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonClose/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonCollapse/IconButtonCollapse.d.ts +8 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonCollapse/IconButtonCollapse.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonCollapse/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonCollapse/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonExpand/IconButtonExpand.d.ts +8 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonExpand/IconButtonExpand.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonExpand/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/IconButtonExpand/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/QueryHistory/QueryHistory.d.ts +9 -0
- package/dist/types/entities/drawer-run-query/ui/QueryHistory/QueryHistory.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/QueryHistory/QueryHistory.style.d.ts +23 -0
- package/dist/types/entities/drawer-run-query/ui/QueryHistory/QueryHistory.style.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/QueryHistory/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/QueryHistory/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/TextAreaQuery/TextAreaQuery.d.ts +10 -0
- package/dist/types/entities/drawer-run-query/ui/TextAreaQuery/TextAreaQuery.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/TextAreaQuery/TextAreaQuery.style.d.ts +19 -0
- package/dist/types/entities/drawer-run-query/ui/TextAreaQuery/TextAreaQuery.style.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/TextAreaQuery/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/TextAreaQuery/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/Title/Title.d.ts +3 -0
- package/dist/types/entities/drawer-run-query/ui/Title/Title.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/Title/Title.style.d.ts +9 -0
- package/dist/types/entities/drawer-run-query/ui/Title/Title.style.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/Title/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/Title/index.d.ts.map +1 -0
- package/dist/types/entities/drawer-run-query/ui/index.d.ts +2 -0
- package/dist/types/entities/drawer-run-query/ui/index.d.ts.map +1 -0
- package/dist/types/entities/popup-summary/ui/PopupSummary.style.d.ts +1 -1
- package/dist/types/features/column-filters/ui/ButtonReset/ButtonReset.style.d.ts +1 -1
- package/dist/types/features/context-menu/ui/ButtonQuery/ui/ButtonQuery.d.ts.map +1 -1
- package/dist/types/features/header-context-menu/lib/visibility/getHidableColumnIds.d.ts.map +1 -1
- package/dist/types/features/header-context-menu/ui/Item/Item.style.d.ts +1 -1
- package/dist/types/features/header-context-menu/ui/Title/Title.style.d.ts +3 -3
- package/dist/types/features/header-context-menu/ui/Title/Title.style.d.ts.map +1 -1
- package/dist/types/shared/lib/localStrore/model/classes/Queries.d.ts +7 -0
- package/dist/types/shared/lib/localStrore/model/classes/Queries.d.ts.map +1 -0
- package/dist/types/shared/lib/localStrore/model/classes/index.d.ts +1 -0
- package/dist/types/shared/lib/localStrore/model/classes/index.d.ts.map +1 -1
- package/dist/types/shared/lib/localStrore/model/enums/EStorageKey.d.ts +2 -1
- package/dist/types/shared/lib/localStrore/model/enums/EStorageKey.d.ts.map +1 -1
- package/dist/types/shared/lib/localStrore/model/localStore.d.ts +2 -1
- package/dist/types/shared/lib/localStrore/model/localStore.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/index.d.ts +1 -1
- package/dist/types/shared/lib/slickgrid/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/events/{eventQuery.d.ts → eventRunQuery.d.ts} +3 -5
- package/dist/types/shared/lib/slickgrid/model/events/eventRunQuery.d.ts.map +1 -0
- package/dist/types/shared/lib/slickgrid/model/events/index.d.ts +1 -1
- package/dist/types/shared/lib/slickgrid/model/events/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/model/index.d.ts +1 -1
- package/dist/types/shared/lib/slickgrid/model/index.d.ts.map +1 -1
- package/dist/types/shared/lib/slickgrid/ui/columns/columnIsEdited/ui/columnIsEdited.d.ts.map +1 -1
- package/dist/types/shared/model/consts/columnId.d.ts +1 -0
- package/dist/types/shared/model/consts/columnId.d.ts.map +1 -1
- package/dist/types/shared/model/consts/index.d.ts +1 -1
- package/dist/types/shared/model/consts/index.d.ts.map +1 -1
- package/dist/types/shared/model/types/IRecentQuery.d.ts +5 -0
- package/dist/types/shared/model/types/IRecentQuery.d.ts.map +1 -0
- package/dist/types/shared/model/types/index.d.ts +1 -0
- package/dist/types/shared/model/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app/styles/icons.scss +1 -1
- package/src/entities/drawer-run-query/index.ts +2 -0
- package/src/entities/drawer-run-query/lib/grouping/getGroupLabel.spec.ts +46 -0
- package/src/entities/drawer-run-query/lib/grouping/getGroupLabel.ts +26 -0
- package/src/entities/drawer-run-query/lib/grouping/groupQueriesByDate.spec.ts +54 -0
- package/src/entities/drawer-run-query/lib/grouping/groupQueriesByDate.ts +37 -0
- package/src/entities/drawer-run-query/lib/grouping/index.ts +1 -0
- package/src/entities/{popup-query → drawer-run-query}/lib/hooks/index.ts +1 -0
- package/src/entities/drawer-run-query/lib/hooks/useResizeCanvas.ts +13 -0
- package/src/entities/{popup-query → drawer-run-query}/lib/hooks/useSubscribeToEvent.ts +4 -8
- package/src/entities/drawer-run-query/lib/index.ts +3 -0
- package/src/entities/drawer-run-query/lib/table/getColumsHash.ts +18 -0
- package/src/entities/drawer-run-query/lib/table/index.ts +2 -0
- package/src/entities/drawer-run-query/lib/table/tableQuery.ts +5 -0
- package/src/entities/drawer-run-query/model/consts/consts.ts +3 -0
- package/src/entities/drawer-run-query/model/consts/index.ts +1 -0
- package/src/entities/drawer-run-query/model/index.ts +2 -0
- package/src/entities/drawer-run-query/model/types/IQueryGroup.ts +6 -0
- package/src/entities/drawer-run-query/model/types/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/ButtonExecuteQuery/ButtonExecuteQuery.style.ts +13 -0
- package/src/entities/drawer-run-query/ui/ButtonExecuteQuery/ButtonExecuteQuery.tsx +21 -0
- package/src/entities/drawer-run-query/ui/ButtonExecuteQuery/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/ColumnTags/ColumnTags.style.ts +18 -0
- package/src/entities/drawer-run-query/ui/ColumnTags/ColumnTags.tsx +44 -0
- package/src/entities/drawer-run-query/ui/ColumnTags/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/DrawerRunQuery.style.ts +76 -0
- package/src/entities/drawer-run-query/ui/DrawerRunQuery.tsx +153 -0
- package/src/entities/drawer-run-query/ui/IconButtonClose/IconButtonClose.tsx +14 -0
- package/src/entities/drawer-run-query/ui/IconButtonClose/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/IconButtonCollapse/IconButtonCollapse.tsx +24 -0
- package/src/entities/drawer-run-query/ui/IconButtonCollapse/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/IconButtonExpand/IconButtonExpand.tsx +21 -0
- package/src/entities/drawer-run-query/ui/IconButtonExpand/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/QueryHistory/QueryHistory.style.ts +53 -0
- package/src/entities/drawer-run-query/ui/QueryHistory/QueryHistory.tsx +62 -0
- package/src/entities/drawer-run-query/ui/QueryHistory/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/TextAreaQuery/TextAreaQuery.style.ts +30 -0
- package/src/entities/drawer-run-query/ui/TextAreaQuery/TextAreaQuery.tsx +50 -0
- package/src/entities/drawer-run-query/ui/TextAreaQuery/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/Title/Title.style.ts +13 -0
- package/src/entities/drawer-run-query/ui/Title/Title.tsx +9 -0
- package/src/entities/drawer-run-query/ui/Title/index.ts +1 -0
- package/src/entities/drawer-run-query/ui/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonQuery/ui/ButtonQuery.tsx +7 -5
- package/src/features/header-context-menu/lib/visibility/getHidableColumnIds.ts +2 -1
- package/src/features/header-context-menu/ui/Title/Title.style.ts +3 -4
- package/src/features/header-context-menu/ui/Title/Title.tsx +3 -3
- package/src/shared/lib/localStrore/model/classes/Queries.ts +40 -0
- package/src/shared/lib/localStrore/model/classes/index.ts +1 -0
- package/src/shared/lib/localStrore/model/enums/EStorageKey.ts +1 -0
- package/src/shared/lib/localStrore/model/localStore.ts +8 -1
- package/src/shared/lib/slickgrid/index.ts +1 -1
- package/src/shared/lib/slickgrid/model/events/{eventQuery.ts → eventRunQuery.ts} +2 -4
- package/src/shared/lib/slickgrid/model/events/index.ts +1 -1
- package/src/shared/lib/slickgrid/model/index.ts +1 -1
- package/src/shared/lib/slickgrid/ui/SlickgridTable/ui/SlickgridTable.tsx +2 -2
- package/src/shared/lib/slickgrid/ui/columns/columnIsEdited/ui/columnIsEdited.ts +3 -2
- package/src/shared/model/consts/columnId.ts +1 -0
- package/src/shared/model/consts/index.ts +1 -1
- package/src/shared/model/types/IRecentQuery.ts +4 -0
- package/src/shared/model/types/index.ts +1 -0
- package/dist/types/entities/popup-query/index.d.ts +0 -2
- package/dist/types/entities/popup-query/index.d.ts.map +0 -1
- package/dist/types/entities/popup-query/lib/hooks/index.d.ts +0 -2
- package/dist/types/entities/popup-query/lib/hooks/index.d.ts.map +0 -1
- package/dist/types/entities/popup-query/lib/hooks/useSubscribeToEvent.d.ts.map +0 -1
- package/dist/types/entities/popup-query/lib/index.d.ts +0 -3
- package/dist/types/entities/popup-query/lib/index.d.ts.map +0 -1
- package/dist/types/entities/popup-query/lib/table/index.d.ts +0 -2
- package/dist/types/entities/popup-query/lib/table/index.d.ts.map +0 -1
- package/dist/types/entities/popup-query/lib/table/tableQuery.d.ts.map +0 -1
- package/dist/types/entities/popup-query/model/consts/id.d.ts +0 -2
- package/dist/types/entities/popup-query/model/consts/id.d.ts.map +0 -1
- package/dist/types/entities/popup-query/model/consts/index.d.ts +0 -2
- package/dist/types/entities/popup-query/model/consts/index.d.ts.map +0 -1
- package/dist/types/entities/popup-query/model/index.d.ts +0 -3
- package/dist/types/entities/popup-query/model/index.d.ts.map +0 -1
- package/dist/types/entities/popup-query/model/types/ITotal.d.ts +0 -10
- package/dist/types/entities/popup-query/model/types/ITotal.d.ts.map +0 -1
- package/dist/types/entities/popup-query/model/types/index.d.ts +0 -2
- package/dist/types/entities/popup-query/model/types/index.d.ts.map +0 -1
- package/dist/types/entities/popup-query/ui/PopupQuery.d.ts +0 -7
- package/dist/types/entities/popup-query/ui/PopupQuery.d.ts.map +0 -1
- package/dist/types/entities/popup-query/ui/PopupQuery.style.d.ts +0 -29
- package/dist/types/entities/popup-query/ui/PopupQuery.style.d.ts.map +0 -1
- package/dist/types/entities/popup-query/ui/index.d.ts +0 -2
- package/dist/types/entities/popup-query/ui/index.d.ts.map +0 -1
- package/dist/types/shared/lib/slickgrid/model/events/eventQuery.d.ts.map +0 -1
- package/src/entities/popup-query/index.ts +0 -1
- package/src/entities/popup-query/lib/index.ts +0 -2
- package/src/entities/popup-query/lib/table/index.ts +0 -1
- package/src/entities/popup-query/lib/table/tableQuery.ts +0 -3
- package/src/entities/popup-query/model/consts/id.ts +0 -1
- package/src/entities/popup-query/model/consts/index.ts +0 -1
- package/src/entities/popup-query/model/index.ts +0 -2
- package/src/entities/popup-query/model/types/ITotal.ts +0 -23
- package/src/entities/popup-query/model/types/index.ts +0 -1
- package/src/entities/popup-query/ui/PopupQuery.style.ts +0 -95
- package/src/entities/popup-query/ui/PopupQuery.tsx +0 -160
- package/src/entities/popup-query/ui/index.ts +0 -1
- /package/dist/types/entities/{popup-query → drawer-run-query}/lib/hooks/useSubscribeToEvent.d.ts +0 -0
- /package/dist/types/entities/{popup-query → drawer-run-query}/lib/table/tableQuery.d.ts +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Box, Drawer, IconButton, styled } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
import { doNotForwardProps } from "shared/lib/dom";
|
|
4
|
+
|
|
5
|
+
import { TRANSITION_MS } from "../model";
|
|
6
|
+
|
|
7
|
+
const HEIGHT_EXPANDED = "90vh";
|
|
8
|
+
const HEIGHT_COLLAPSED_EM = 11;
|
|
9
|
+
|
|
10
|
+
const StyledDrawer = styled(Drawer, {
|
|
11
|
+
shouldForwardProp: doNotForwardProps(["isExpanded"]),
|
|
12
|
+
})<{ isExpanded: boolean }>(({ isExpanded }) => ({
|
|
13
|
+
zIndex: 1300,
|
|
14
|
+
"& .MuiDrawer-paper": {
|
|
15
|
+
borderTopLeftRadius: "10px",
|
|
16
|
+
borderTopRightRadius: "10px",
|
|
17
|
+
columnGap: "1em",
|
|
18
|
+
display: "grid",
|
|
19
|
+
gridTemplateColumns: "25% 1fr",
|
|
20
|
+
transition: `${TRANSITION_MS / 1000}s`,
|
|
21
|
+
height: isExpanded ? HEIGHT_EXPANDED : `${HEIGHT_COLLAPSED_EM}em`,
|
|
22
|
+
padding: "1em",
|
|
23
|
+
},
|
|
24
|
+
"& div.MuiBackdrop-root": {
|
|
25
|
+
opacity: "0 !important",
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const Header = styled(Box)({
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
display: "flex",
|
|
32
|
+
justifyContent: "space-between",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const RowsNumber = styled(Box)({
|
|
36
|
+
color: "#1E456F",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const ClearButton = styled(IconButton)({
|
|
40
|
+
color: "#808080",
|
|
41
|
+
padding: "4px",
|
|
42
|
+
"& .sgi": {
|
|
43
|
+
display: "block",
|
|
44
|
+
},
|
|
45
|
+
"&:hover": {
|
|
46
|
+
backgroundColor: "#E8F4FE",
|
|
47
|
+
color: "#235B95",
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const ContainerInput = styled(Box)({
|
|
52
|
+
display: "flex",
|
|
53
|
+
columnGap: "0.5em",
|
|
54
|
+
marginTop: "1em",
|
|
55
|
+
width: "100%",
|
|
56
|
+
marginBottom: "1em",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const ContainerTable = styled(Box, {
|
|
60
|
+
shouldForwardProp: doNotForwardProps(["isExpanded"]),
|
|
61
|
+
})<{ isExpanded: boolean }>(({ isExpanded }) => ({
|
|
62
|
+
overflowY: "auto",
|
|
63
|
+
transition: `${TRANSITION_MS / 1000}s`,
|
|
64
|
+
height: isExpanded
|
|
65
|
+
? `calc(${HEIGHT_EXPANDED} - ${HEIGHT_COLLAPSED_EM + 2}em)`
|
|
66
|
+
: "0vh",
|
|
67
|
+
}));
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
ClearButton,
|
|
71
|
+
ContainerInput,
|
|
72
|
+
ContainerTable,
|
|
73
|
+
Drawer: StyledDrawer,
|
|
74
|
+
Header,
|
|
75
|
+
RowsNumber,
|
|
76
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Box } from "@mui/material";
|
|
2
|
+
import { GvizTable } from "myworkql";
|
|
3
|
+
import { FC, useRef, useState } from "react";
|
|
4
|
+
import { SlickDataView } from "slickgrid";
|
|
5
|
+
|
|
6
|
+
import { localStore } from "shared/lib/localStrore";
|
|
7
|
+
import { SlickgridTable, eventRunQuery } from "shared/lib/slickgrid";
|
|
8
|
+
import { IColumn } from "shared/model/types";
|
|
9
|
+
|
|
10
|
+
import { Title } from "features/header-context-menu/ui/Title";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
getColumsHash,
|
|
14
|
+
tableQuery,
|
|
15
|
+
useResizeCanvas,
|
|
16
|
+
useSubscribeToEvent,
|
|
17
|
+
} from "../lib";
|
|
18
|
+
import { ButtonExecuteQuery } from "./ButtonExecuteQuery";
|
|
19
|
+
import { ColumnTags } from "./ColumnTags";
|
|
20
|
+
import { IconButtonClose } from "./IconButtonClose";
|
|
21
|
+
import { IconButtonCollapse } from "./IconButtonCollapse";
|
|
22
|
+
import { IconButtonExpand } from "./IconButtonExpand";
|
|
23
|
+
import { QueryHistory } from "./QueryHistory";
|
|
24
|
+
import { TextAreaQuery } from "./TextAreaQuery";
|
|
25
|
+
|
|
26
|
+
import Styled from "./DrawerRunQuery.style";
|
|
27
|
+
|
|
28
|
+
export const DrawerRunQuery: FC<Props> = ({ tableId }) => {
|
|
29
|
+
const [query, setQuery] = useState("");
|
|
30
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
31
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
32
|
+
const [items, setItems] = useState<Record<string, any>[]>([]);
|
|
33
|
+
const [columns, setColumns] = useState<IColumn[]>([]);
|
|
34
|
+
const queryInputRef = useRef<HTMLTextAreaElement>(null);
|
|
35
|
+
const columnsHash = getColumsHash();
|
|
36
|
+
|
|
37
|
+
function closeDrawer() {
|
|
38
|
+
eventRunQuery.open = false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function clearQuery() {
|
|
42
|
+
const input = queryInputRef.current;
|
|
43
|
+
setQuery("");
|
|
44
|
+
requestAnimationFrame(() => input?.focus());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function executeQuery(query: string) {
|
|
48
|
+
const table = eventRunQuery.table;
|
|
49
|
+
if (!table) return;
|
|
50
|
+
const grid = table.grid;
|
|
51
|
+
if (!grid) return;
|
|
52
|
+
const dataView: SlickDataView = grid.getData();
|
|
53
|
+
const items = dataView.getItems();
|
|
54
|
+
const itemsCopy = [];
|
|
55
|
+
const fields = Object.keys(columnsHash);
|
|
56
|
+
for (const item of items) {
|
|
57
|
+
const newItem: Record<string, string | number | boolean> = {};
|
|
58
|
+
for (const field of fields) {
|
|
59
|
+
newItem[field] = item[field];
|
|
60
|
+
}
|
|
61
|
+
itemsCopy.push(newItem);
|
|
62
|
+
}
|
|
63
|
+
const gvizTable = new GvizTable(itemsCopy);
|
|
64
|
+
const run = gvizTable.query(query);
|
|
65
|
+
const newItems = run.toObjects();
|
|
66
|
+
setItems(newItems);
|
|
67
|
+
setColumns(
|
|
68
|
+
Object.keys(newItems[0] || {}).map(
|
|
69
|
+
(key): IColumn => ({
|
|
70
|
+
cssClass: columnsHash[key].cssClass,
|
|
71
|
+
field: columnsHash[key].field,
|
|
72
|
+
id: columnsHash[key].id,
|
|
73
|
+
formatter: columnsHash[key].formatter,
|
|
74
|
+
forPrint: columnsHash[key].forPrint,
|
|
75
|
+
name: columnsHash[key].name,
|
|
76
|
+
printer: columnsHash[key].printer,
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
79
|
+
);
|
|
80
|
+
setIsExpanded(true);
|
|
81
|
+
localStore.queries.set(tableId, query);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
useSubscribeToEvent(setIsOpened, tableId);
|
|
85
|
+
useResizeCanvas(isExpanded);
|
|
86
|
+
|
|
87
|
+
if (!isOpened) return null;
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<Styled.Drawer
|
|
91
|
+
anchor={"bottom"}
|
|
92
|
+
disablePortal
|
|
93
|
+
id={"query-drawer"}
|
|
94
|
+
isExpanded={isExpanded}
|
|
95
|
+
onClose={closeDrawer}
|
|
96
|
+
open={isOpened}
|
|
97
|
+
>
|
|
98
|
+
<QueryHistory
|
|
99
|
+
executeQuery={executeQuery}
|
|
100
|
+
query={query}
|
|
101
|
+
setQuery={setQuery}
|
|
102
|
+
/>
|
|
103
|
+
<Box>
|
|
104
|
+
<Styled.Header>
|
|
105
|
+
<Title />
|
|
106
|
+
<Box>
|
|
107
|
+
<IconButtonCollapse
|
|
108
|
+
isExpanded={isExpanded}
|
|
109
|
+
setIsExpanded={setIsExpanded}
|
|
110
|
+
/>
|
|
111
|
+
<IconButtonExpand
|
|
112
|
+
isExpanded={isExpanded}
|
|
113
|
+
setIsExpanded={setIsExpanded}
|
|
114
|
+
/>
|
|
115
|
+
<IconButtonClose closeDrawer={closeDrawer} />
|
|
116
|
+
</Box>
|
|
117
|
+
</Styled.Header>
|
|
118
|
+
<Styled.ContainerInput className={"query-drawer-textfield"}>
|
|
119
|
+
<TextAreaQuery
|
|
120
|
+
clearQuery={clearQuery}
|
|
121
|
+
query={query}
|
|
122
|
+
queryInputRef={queryInputRef}
|
|
123
|
+
setQuery={setQuery}
|
|
124
|
+
/>
|
|
125
|
+
<ButtonExecuteQuery executeQuery={executeQuery} query={query} />
|
|
126
|
+
</Styled.ContainerInput>
|
|
127
|
+
<ColumnTags
|
|
128
|
+
columnsHash={columnsHash}
|
|
129
|
+
query={query}
|
|
130
|
+
queryInputRef={queryInputRef}
|
|
131
|
+
setQuery={setQuery}
|
|
132
|
+
/>
|
|
133
|
+
<Styled.ContainerTable
|
|
134
|
+
isExpanded={isExpanded}
|
|
135
|
+
className={"query-drawer-table-container"}
|
|
136
|
+
>
|
|
137
|
+
{!!columns.length && (
|
|
138
|
+
<SlickgridTable
|
|
139
|
+
assignIds={true}
|
|
140
|
+
columns={columns}
|
|
141
|
+
items={items}
|
|
142
|
+
table={tableQuery}
|
|
143
|
+
/>
|
|
144
|
+
)}
|
|
145
|
+
</Styled.ContainerTable>
|
|
146
|
+
</Box>
|
|
147
|
+
</Styled.Drawer>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
interface Props {
|
|
152
|
+
tableId: string;
|
|
153
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IconButton } from "@mui/material";
|
|
2
|
+
import { FC } from "react";
|
|
3
|
+
|
|
4
|
+
export const IconButtonClose: FC<Props> = ({ closeDrawer }) => {
|
|
5
|
+
return (
|
|
6
|
+
<IconButton onClick={closeDrawer}>
|
|
7
|
+
<span className={"sgi sgi-close"}></span>
|
|
8
|
+
</IconButton>
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
closeDrawer(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IconButtonClose } from "./IconButtonClose";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IconButton } from "@mui/material";
|
|
2
|
+
import { Dispatch, FC, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
export const IconButtonCollapse: FC<Props> = ({
|
|
5
|
+
isExpanded,
|
|
6
|
+
setIsExpanded,
|
|
7
|
+
}) => {
|
|
8
|
+
function collapse() {
|
|
9
|
+
setIsExpanded(false);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (!isExpanded) return null;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<IconButton onClick={collapse}>
|
|
16
|
+
<span className={"sgi sgi-minus"}></span>
|
|
17
|
+
</IconButton>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
isExpanded: boolean;
|
|
23
|
+
setIsExpanded: Dispatch<SetStateAction<boolean>>;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IconButtonCollapse } from "./IconButtonCollapse";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IconButton } from "@mui/material";
|
|
2
|
+
import { Dispatch, FC, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
export const IconButtonExpand: FC<Props> = ({ isExpanded, setIsExpanded }) => {
|
|
5
|
+
function expand() {
|
|
6
|
+
setIsExpanded(true);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (isExpanded) return null;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<IconButton onClick={expand}>
|
|
13
|
+
<span className={"sgi sgi-arrow-expand"}></span>
|
|
14
|
+
</IconButton>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
isExpanded: boolean;
|
|
20
|
+
setIsExpanded: Dispatch<SetStateAction<boolean>>;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IconButtonExpand } from "./IconButtonExpand";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { Box, Typography } from "@mui/material";
|
|
3
|
+
|
|
4
|
+
const Wrapper = styled(Box)({
|
|
5
|
+
backgroundColor: "#F8F8FA",
|
|
6
|
+
borderRadius: "10px",
|
|
7
|
+
padding: "10px",
|
|
8
|
+
overflowY: "auto",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const GroupLabel = styled(Typography)({
|
|
12
|
+
color: "#BBBDBF",
|
|
13
|
+
fontSize: "0.75rem",
|
|
14
|
+
fontWeight: 400,
|
|
15
|
+
letterSpacing: "-2%",
|
|
16
|
+
lineHeight: "100%",
|
|
17
|
+
margin: "1.5em 0 0.75em",
|
|
18
|
+
padding: "0 8px",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const Item = styled(Box)({
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
borderRadius: "8px",
|
|
24
|
+
color: "#333333",
|
|
25
|
+
cursor: "pointer",
|
|
26
|
+
display: "flex",
|
|
27
|
+
justifyContent: "space-between",
|
|
28
|
+
marginBottom: "2px",
|
|
29
|
+
padding: "8px 10px",
|
|
30
|
+
textAlign: "left",
|
|
31
|
+
userSelect: "none",
|
|
32
|
+
width: "100%",
|
|
33
|
+
"&:hover": {
|
|
34
|
+
backgroundColor: "#E8F4FE",
|
|
35
|
+
},
|
|
36
|
+
"&.active": {
|
|
37
|
+
backgroundColor: "#E8F4FE",
|
|
38
|
+
color: "#235B95",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const Title = styled("span")({
|
|
43
|
+
display: "-webkit-box",
|
|
44
|
+
fontSize: "0.75rem",
|
|
45
|
+
fontWeight: 400,
|
|
46
|
+
letterSpacing: "-2%",
|
|
47
|
+
lineHeight: "100%",
|
|
48
|
+
overflow: "hidden",
|
|
49
|
+
WebkitBoxOrient: "vertical",
|
|
50
|
+
WebkitLineClamp: 3,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export default { Wrapper, GroupLabel, Item, Title };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IconButton, Tooltip } from "@mui/material";
|
|
2
|
+
import { Dispatch, FC, Fragment, SetStateAction, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { localStore } from "shared/lib/localStrore";
|
|
5
|
+
import { eventRunQuery } from "shared/lib/slickgrid";
|
|
6
|
+
|
|
7
|
+
import { groupQueriesByDate } from "../../lib";
|
|
8
|
+
|
|
9
|
+
import Styled from "./QueryHistory.style";
|
|
10
|
+
|
|
11
|
+
export const QueryHistory: FC<Props> = ({ executeQuery, query, setQuery }) => {
|
|
12
|
+
const [count, setCount] = useState(0);
|
|
13
|
+
const tableId = eventRunQuery.table?.id || "";
|
|
14
|
+
const history = localStore.queries.get(tableId);
|
|
15
|
+
const groups = groupQueriesByDate(history ?? []);
|
|
16
|
+
|
|
17
|
+
function useQuery(recentQuery: string) {
|
|
18
|
+
setQuery(recentQuery);
|
|
19
|
+
executeQuery(recentQuery);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Styled.Wrapper className={"query-drawer-history"}>
|
|
24
|
+
{groups.map(({ label, queries }) => (
|
|
25
|
+
<Fragment key={label}>
|
|
26
|
+
<Styled.GroupLabel>{label}</Styled.GroupLabel>
|
|
27
|
+
{queries.map((recentQuery) => (
|
|
28
|
+
<Styled.Item
|
|
29
|
+
key={recentQuery.time}
|
|
30
|
+
className={recentQuery.query === query ? "active" : ""}
|
|
31
|
+
onClick={() => {
|
|
32
|
+
if (recentQuery.query === query) return;
|
|
33
|
+
useQuery(recentQuery.query);
|
|
34
|
+
}}
|
|
35
|
+
title={recentQuery.query}
|
|
36
|
+
>
|
|
37
|
+
<Styled.Title>{recentQuery.query}</Styled.Title>
|
|
38
|
+
<Tooltip title={"Delete from history"}>
|
|
39
|
+
<IconButton
|
|
40
|
+
onClick={(event) => {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
localStore.queries.reset(tableId, recentQuery.query);
|
|
43
|
+
// refresh history
|
|
44
|
+
setCount(count + 1);
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<span className="sgi sgi-close"></span>
|
|
48
|
+
</IconButton>
|
|
49
|
+
</Tooltip>
|
|
50
|
+
</Styled.Item>
|
|
51
|
+
))}
|
|
52
|
+
</Fragment>
|
|
53
|
+
))}
|
|
54
|
+
</Styled.Wrapper>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
interface Props {
|
|
59
|
+
executeQuery(query: string): void;
|
|
60
|
+
query: string;
|
|
61
|
+
setQuery: Dispatch<SetStateAction<string>>;
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { QueryHistory } from "./QueryHistory";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { IconButton, InputAdornment, TextField } from "@mui/material";
|
|
3
|
+
|
|
4
|
+
const StyledTextField = styled(TextField)({
|
|
5
|
+
width: "100%",
|
|
6
|
+
"& .MuiInputBase-root": {
|
|
7
|
+
borderRadius: "10px",
|
|
8
|
+
padding: "11px 14px",
|
|
9
|
+
color: "#235B95",
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const EndAdornment = styled(InputAdornment)({
|
|
14
|
+
alignSelf: "flex-start",
|
|
15
|
+
marginTop: "-2px",
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const IconButtonClear = styled(IconButton)({
|
|
19
|
+
color: "#808080",
|
|
20
|
+
padding: "4px",
|
|
21
|
+
"& .sgi": {
|
|
22
|
+
display: "block",
|
|
23
|
+
},
|
|
24
|
+
"&:hover": {
|
|
25
|
+
backgroundColor: "#E8F4FE",
|
|
26
|
+
color: "#235B95",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export default { TextField: StyledTextField, EndAdornment, IconButtonClear };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Tooltip } from "@mui/material";
|
|
2
|
+
import { ChangeEvent, Dispatch, FC, RefObject, SetStateAction } from "react";
|
|
3
|
+
|
|
4
|
+
import Styled from "./TextAreaQuery.style";
|
|
5
|
+
|
|
6
|
+
export const TextAreaQuery: FC<Props> = ({
|
|
7
|
+
clearQuery,
|
|
8
|
+
query,
|
|
9
|
+
queryInputRef,
|
|
10
|
+
setQuery,
|
|
11
|
+
}) => {
|
|
12
|
+
function updateQuery(event: ChangeEvent<HTMLTextAreaElement>) {
|
|
13
|
+
setQuery(event.target.value);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Styled.TextField
|
|
18
|
+
label="Query"
|
|
19
|
+
maxRows={10}
|
|
20
|
+
multiline
|
|
21
|
+
onChange={updateQuery}
|
|
22
|
+
inputRef={queryInputRef}
|
|
23
|
+
slotProps={{
|
|
24
|
+
input: {
|
|
25
|
+
endAdornment: !!query && (
|
|
26
|
+
<Styled.EndAdornment position={"end"}>
|
|
27
|
+
<Tooltip title={"Clear query"}>
|
|
28
|
+
<Styled.IconButtonClear
|
|
29
|
+
aria-label={"Clear query"}
|
|
30
|
+
onClick={clearQuery}
|
|
31
|
+
size={"small"}
|
|
32
|
+
>
|
|
33
|
+
<span className={"sgi sgi-close"}></span>
|
|
34
|
+
</Styled.IconButtonClear>
|
|
35
|
+
</Tooltip>
|
|
36
|
+
</Styled.EndAdornment>
|
|
37
|
+
),
|
|
38
|
+
},
|
|
39
|
+
}}
|
|
40
|
+
value={query}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
interface Props {
|
|
46
|
+
clearQuery(): void;
|
|
47
|
+
query: string;
|
|
48
|
+
queryInputRef: RefObject<HTMLTextAreaElement>;
|
|
49
|
+
setQuery: Dispatch<SetStateAction<string>>;
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextAreaQuery } from "./TextAreaQuery";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import styled from "@emotion/styled";
|
|
2
|
+
import { Typography } from "@mui/material";
|
|
3
|
+
|
|
4
|
+
const Title = styled(Typography)({
|
|
5
|
+
color: "#235B95",
|
|
6
|
+
marginBottom: "0.5em",
|
|
7
|
+
fontWeight: "600",
|
|
8
|
+
fontSize: "16px",
|
|
9
|
+
letterSpacing: "-2%",
|
|
10
|
+
minWidth: "14em",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default { Title };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Title } from "./Title";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DrawerRunQuery } from "./DrawerRunQuery";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Dispatch, FC, SetStateAction } from "react";
|
|
2
2
|
|
|
3
|
-
import { eventContextMenu,
|
|
3
|
+
import { eventContextMenu, eventRunQuery } from "shared/lib/slickgrid";
|
|
4
|
+
|
|
5
|
+
import { TABLE_QUERY_ID } from "entities/drawer-run-query";
|
|
4
6
|
|
|
5
7
|
import Styled from "../../ContextMenu.style";
|
|
6
8
|
|
|
@@ -9,12 +11,12 @@ export const ButtonQuery: FC<Props> = ({ setIsOpened }) => {
|
|
|
9
11
|
|
|
10
12
|
function openModalWindow() {
|
|
11
13
|
setIsOpened(false);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
eventQuery.x = eventContextMenu.x;
|
|
15
|
-
eventQuery.y = eventContextMenu.y;
|
|
14
|
+
eventRunQuery.table = table;
|
|
15
|
+
eventRunQuery.open = true;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
if (table?.id === TABLE_QUERY_ID) return null;
|
|
19
|
+
|
|
18
20
|
return (
|
|
19
21
|
<Styled.Li onClick={openModalWindow}>
|
|
20
22
|
<Styled.Icon className={"sgi sgi-table-large"}></Styled.Icon>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { IS_EDITED } from "shared/model/consts";
|
|
1
2
|
import { IColumn, ISlickTable } from "shared/model/types";
|
|
2
3
|
|
|
3
4
|
export function getHideableColumns(table: ISlickTable): IColumn[] {
|
|
4
5
|
if (!table?.columnPicker) return [];
|
|
5
6
|
return table.columnPicker
|
|
6
7
|
.getInitialColumns()
|
|
7
|
-
.filter(({ id }) => id !== "_checkbox_selector" && id !==
|
|
8
|
+
.filter(({ id }) => id !== "_checkbox_selector" && id !== IS_EDITED);
|
|
8
9
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Typography, styled } from "@mui/material";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const StyledTypography = styled(Typography)({
|
|
4
4
|
color: "#1e456f",
|
|
5
|
-
marginBottom: "0.6em",
|
|
6
5
|
fontSize: "1rem",
|
|
7
6
|
});
|
|
8
7
|
|
|
9
|
-
export default {
|
|
8
|
+
export default { Typography: StyledTypography };
|
|
@@ -4,8 +4,8 @@ import Styled from "./Title.style";
|
|
|
4
4
|
|
|
5
5
|
export const Title: FC = () => {
|
|
6
6
|
return (
|
|
7
|
-
<Styled.
|
|
8
|
-
|
|
9
|
-
</Styled.
|
|
7
|
+
<Styled.Typography className={"query-drawer-title"} variant={"h5"}>
|
|
8
|
+
Run query across table data
|
|
9
|
+
</Styled.Typography>
|
|
10
10
|
);
|
|
11
11
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IRecentQuery } from "shared/model/types";
|
|
2
|
+
|
|
3
|
+
import { getFromStorage, updateStorage } from "../../lib";
|
|
4
|
+
import { EStorageKey } from "../enums";
|
|
5
|
+
|
|
6
|
+
const MAX_QUERIES = 10;
|
|
7
|
+
|
|
8
|
+
export class Queries {
|
|
9
|
+
get(tableId: string): IRecentQuery[] {
|
|
10
|
+
const queries = getFromStorage(EStorageKey.queries);
|
|
11
|
+
return queries[tableId];
|
|
12
|
+
}
|
|
13
|
+
reset(tableId: string, query: string): void {
|
|
14
|
+
const queries = getFromStorage(EStorageKey.queries);
|
|
15
|
+
const recentQueries = queries[tableId];
|
|
16
|
+
if (!recentQueries) return;
|
|
17
|
+
queries[tableId] = recentQueries.filter(
|
|
18
|
+
(recent: IRecentQuery) => recent.query !== query,
|
|
19
|
+
);
|
|
20
|
+
updateStorage(EStorageKey.queries, queries);
|
|
21
|
+
}
|
|
22
|
+
set(tableId: string, query: string): void {
|
|
23
|
+
const queryTrimed = query.trim();
|
|
24
|
+
if (!queryTrimed) return;
|
|
25
|
+
const queries: Record<string, IRecentQuery[]> =
|
|
26
|
+
getFromStorage(EStorageKey.queries) || {};
|
|
27
|
+
const otherQueries = (queries[tableId] || []).filter(
|
|
28
|
+
(item) => item.query !== queryTrimed,
|
|
29
|
+
);
|
|
30
|
+
const recentQuery: IRecentQuery = {
|
|
31
|
+
query: queryTrimed,
|
|
32
|
+
time: new Date().toISOString(),
|
|
33
|
+
};
|
|
34
|
+
const updatedQueries = [recentQuery, ...otherQueries].slice(0, MAX_QUERIES);
|
|
35
|
+
updateStorage(EStorageKey.queries, {
|
|
36
|
+
...queries,
|
|
37
|
+
[tableId]: updatedQueries,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ColumnFilters,
|
|
3
|
+
ColumnWidths,
|
|
4
|
+
HiddenColumns,
|
|
5
|
+
Queries,
|
|
6
|
+
Sorting,
|
|
7
|
+
} from "./classes";
|
|
2
8
|
|
|
3
9
|
class LocalStore {
|
|
4
10
|
columnFilters = new ColumnFilters();
|
|
5
11
|
columnWidths = new ColumnWidths();
|
|
6
12
|
hiddenColumns = new HiddenColumns();
|
|
13
|
+
queries = new Queries();
|
|
7
14
|
sorting = new Sorting();
|
|
8
15
|
}
|
|
9
16
|
|