@asaleh37/ui-base 1.0.9 → 1.1.0
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.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/App.tsx +31 -0
- package/src/components/admin/AttachmentGrid.tsx +116 -0
- package/src/components/admin/AuthorityGrid.tsx +88 -0
- package/src/components/admin/BluePrintGrid.tsx +55 -0
- package/src/components/admin/BluePrintPageGrid.tsx +85 -0
- package/src/components/admin/BluePrintPointGrid.tsx +85 -0
- package/src/components/admin/DashboardGrid.tsx +95 -0
- package/src/components/admin/DashboardWidgetGrid.tsx +75 -0
- package/src/components/admin/DataQueryGrid.tsx +75 -0
- package/src/components/admin/DataQueryParameterGrid.tsx +98 -0
- package/src/components/admin/DatasourceConnectionGrid.tsx +98 -0
- package/src/components/admin/EmployeeGrid.tsx +105 -0
- package/src/components/admin/EntityParameterGrid.tsx +125 -0
- package/src/components/admin/ExcelUploaderDetailGrid.tsx +78 -0
- package/src/components/admin/ExcelUploaderHeaderGrid.tsx +78 -0
- package/src/components/admin/LookupGrid.tsx +95 -0
- package/src/components/admin/MailAttachmentGrid.tsx +65 -0
- package/src/components/admin/MailBodyGrid.tsx +105 -0
- package/src/components/admin/MailNotificationQueueGrid.tsx +131 -0
- package/src/components/admin/MailRecipientGrid.tsx +75 -0
- package/src/components/admin/MailTemplateGrid.tsx +145 -0
- package/src/components/admin/NewTableGrid.tsx +65 -0
- package/src/components/admin/NotificationGrid.tsx +115 -0
- package/src/components/admin/NotificationQueueGrid.tsx +125 -0
- package/src/components/admin/OrganizationApplicationGrid.tsx +81 -0
- package/src/components/admin/OrganizationGrid.tsx +65 -0
- package/src/components/admin/OrganizationRankGrid.tsx +85 -0
- package/src/components/admin/OrganizationUnitGrid.tsx +85 -0
- package/src/components/admin/OrganizationUserGrid.tsx +75 -0
- package/src/components/admin/OrganizationUserRoleGrid.tsx +98 -0
- package/src/components/admin/ReportGrid.tsx +155 -0
- package/src/components/admin/ReportParameterGrid.tsx +95 -0
- package/src/components/admin/RoleAuthorityGrid.tsx +65 -0
- package/src/components/admin/RoleGrid.tsx +78 -0
- package/src/components/admin/UserAccountGrid.tsx +65 -0
- package/src/components/admin/UserRequestGrid.tsx +145 -0
- package/src/components/admin/WidgetGrid.tsx +175 -0
- package/src/components/admin/WorkflowDocumentActionGrid.tsx +111 -0
- package/src/components/admin/WorkflowDocumentActionHistoryGrid.tsx +111 -0
- package/src/components/admin/WorkflowDocumentActionMailGrid.tsx +71 -0
- package/src/components/admin/WorkflowDocumentGrid.tsx +185 -0
- package/src/components/admin/WorkflowDocumentMailLogGrid.tsx +141 -0
- package/src/components/admin/WorkflowDocumentStatusGrid.tsx +121 -0
- package/src/components/common/Home.tsx +31 -0
- package/src/components/common/LanguageSwitcher.tsx +25 -0
- package/src/components/common/LayoutHandlers.tsx +12 -0
- package/src/components/common/LoadingMask.tsx +19 -0
- package/src/components/common/Login.tsx +183 -0
- package/src/components/templates/DataEntryTemplates/DataEntryTypes.ts +288 -0
- package/src/components/templates/DataEntryTemplates/DataEntryUtil.ts +201 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormAction.tsx +60 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementField.tsx +194 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementGroup.tsx +98 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/CheckBox.tsx +64 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx +94 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/Datefield.tsx +65 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/DatetimeField.tsx +64 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/FiltersPanel.tsx +237 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/TemplateTextField.tsx +9 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/TemplateForm.tsx +256 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx +188 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid.tsx +844 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridMultiRecordAction.tsx +89 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridRecordAction.tsx +92 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridTopBar.tsx +228 -0
- package/src/components/templates/DataEntryTemplates/useApiActions.ts +125 -0
- package/src/components/templates/TransferList.tsx +250 -0
- package/src/components/templates/Window/ConfirmationWindow.tsx +55 -0
- package/src/components/templates/visuals/TemplateDashboard.tsx +126 -0
- package/src/components/templates/visuals/charts/TemplateBarChart.tsx +16 -0
- package/src/components/templates/visuals/charts/TemplateDataCard.tsx +60 -0
- package/src/components/templates/visuals/charts/TemplateGauge.tsx +16 -0
- package/src/components/templates/visuals/charts/TemplateLineChart.tsx +16 -0
- package/src/components/templates/visuals/charts/TemplateLineProgress.tsx +40 -0
- package/src/components/templates/visuals/charts/TemplatePieChart.tsx +25 -0
- package/src/hooks/UseConfirmationWindow.tsx +54 -0
- package/src/hooks/UseMobile.tsx +13 -0
- package/src/hooks/UseSession.tsx +26 -0
- package/src/hooks/UseWindow.tsx +106 -0
- package/src/hooks/useAxios.tsx +271 -0
- package/src/hooks/useLoadingMask.tsx +16 -0
- package/src/layout/DrawerHeader.tsx +10 -0
- package/src/layout/Layout.tsx +122 -0
- package/src/layout/MainContent.tsx +43 -0
- package/src/layout/MobileDrawer.tsx +103 -0
- package/src/layout/NavigationTree.tsx +284 -0
- package/src/layout/SideBar.tsx +80 -0
- package/src/layout/TopBar.tsx +142 -0
- package/src/locales/arabic/adminLocalsAr.json +356 -0
- package/src/locales/arabic/common.json +34 -0
- package/src/locales/arabic/index.ts +7 -0
- package/src/locales/english/adminLocalsEn.json +356 -0
- package/src/locales/english/common.json +33 -0
- package/src/locales/english/index.ts +6 -0
- package/src/locales/english/index.tsx +0 -0
- package/src/locales/i18n.ts +15 -0
- package/src/locales/index.ts +9 -0
- package/src/navigationItems/Administration/adminNavigationItems.tsx +182 -0
- package/src/navigationItems/Administration/index.tsx +71 -0
- package/src/navigationItems/common/CommonNavigationItems.tsx +12 -0
- package/src/navigationItems/common/index.tsx +7 -0
- package/src/navigationItems/index.tsx +34 -0
- package/src/redux/features/administration/AdministrationStoresMetaData.ts +72 -0
- package/src/redux/features/business/BusinessStoresMetaData.ts +3 -0
- package/src/redux/features/business/CommonStoreSlice.ts +37 -0
- package/src/redux/features/common/AppInfoSlice.ts +30 -0
- package/src/redux/features/common/AppLayoutSlice.ts +37 -0
- package/src/redux/features/common/LoadingMaskSlice.ts +30 -0
- package/src/redux/features/common/UserSessionSlice.ts +62 -0
- package/src/redux/store.ts +10 -10
- package/src/routes/administration/adminRoutes.tsx +259 -0
- package/src/routes/administration/index.ts +4 -0
- package/src/routes/index.ts +11 -0
- package/src/routes/types/index.ts +5 -0
- package/src/theme/DarkThemeOptions.ts +30 -0
- package/src/theme/LightThemeOptions.ts +34 -0
- package/src/util/AppUtils.ts +18 -0
- package/src/util/constants.ts +2 -0
- package/tsconfig.json +2 -2
- package/src/redux/CounterSlice.ts +0 -17
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import List from "@mui/material/List";
|
|
3
|
+
import Card from "@mui/material/Card";
|
|
4
|
+
import CardHeader from "@mui/material/CardHeader";
|
|
5
|
+
import ListItem from "@mui/material/ListItem";
|
|
6
|
+
import ListItemText from "@mui/material/ListItemText";
|
|
7
|
+
import ListItemIcon from "@mui/material/ListItemIcon";
|
|
8
|
+
import Checkbox from "@mui/material/Checkbox";
|
|
9
|
+
import Button from "@mui/material/Button";
|
|
10
|
+
import Divider from "@mui/material/Divider";
|
|
11
|
+
import { Box, Grid2 } from "@mui/material";
|
|
12
|
+
import TemplateTextField from "./DataEntryTemplates/TemplateDataForm/FormFields/TemplateTextField";
|
|
13
|
+
|
|
14
|
+
function not(a, b) {
|
|
15
|
+
return a.filter((value) => b.indexOf(value) === -1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function intersection(a, b) {
|
|
19
|
+
return a.filter((value) => b.indexOf(value) !== -1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function union(a, b) {
|
|
23
|
+
return [...a, ...not(b, a)];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type TransferListProps = {
|
|
27
|
+
valueField: string;
|
|
28
|
+
displayField: string;
|
|
29
|
+
options: Array<any>;
|
|
30
|
+
selectedOptions: Array<any>;
|
|
31
|
+
setSelection: any;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const TransferList: React.FC<TransferListProps> = ({
|
|
35
|
+
valueField = "id",
|
|
36
|
+
displayField = "name",
|
|
37
|
+
options = [],
|
|
38
|
+
selectedOptions = [],
|
|
39
|
+
setSelection,
|
|
40
|
+
}) => {
|
|
41
|
+
const [checked, setChecked] = React.useState([]);
|
|
42
|
+
const [left, setLeft] = React.useState(options);
|
|
43
|
+
const [right, setRight] = React.useState(selectedOptions);
|
|
44
|
+
|
|
45
|
+
const [leftFilterValue, setLeftFilterValue] = React.useState<string>("");
|
|
46
|
+
const [rightFilterValue, setRightFilterValue] = React.useState<string>("");
|
|
47
|
+
|
|
48
|
+
const leftChecked = intersection(checked, left);
|
|
49
|
+
const rightChecked = intersection(checked, right);
|
|
50
|
+
|
|
51
|
+
const handleToggle = (value) => () => {
|
|
52
|
+
const currentIndex = checked.indexOf(value);
|
|
53
|
+
const newChecked = [...checked];
|
|
54
|
+
|
|
55
|
+
if (currentIndex === -1) {
|
|
56
|
+
newChecked.push(value);
|
|
57
|
+
} else {
|
|
58
|
+
newChecked.splice(currentIndex, 1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setChecked(newChecked);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const numberOfChecked = (items) => intersection(checked, items).length;
|
|
65
|
+
|
|
66
|
+
const handleToggleAll = (items) => () => {
|
|
67
|
+
if (numberOfChecked(items) === items.length) {
|
|
68
|
+
setChecked(not(checked, items));
|
|
69
|
+
} else {
|
|
70
|
+
setChecked(union(checked, items));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleCheckedRight = () => {
|
|
75
|
+
setRight((oldState) => {
|
|
76
|
+
let newState = right.concat(leftChecked);
|
|
77
|
+
setSelection(newState);
|
|
78
|
+
return newState;
|
|
79
|
+
});
|
|
80
|
+
setLeft(not(left, leftChecked));
|
|
81
|
+
setChecked(not(checked, leftChecked));
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const handleCheckedLeft = () => {
|
|
85
|
+
setLeft(left.concat(rightChecked));
|
|
86
|
+
setRight((oldState) => {
|
|
87
|
+
let newState = not(right, rightChecked);
|
|
88
|
+
setSelection(newState);
|
|
89
|
+
return newState;
|
|
90
|
+
});
|
|
91
|
+
setChecked(not(checked, rightChecked));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const customList = (
|
|
95
|
+
title: string,
|
|
96
|
+
unfilteredItems: Array<any>,
|
|
97
|
+
side: "left" | "right"
|
|
98
|
+
) => {
|
|
99
|
+
const items = unfilteredItems.filter((option: any) => {
|
|
100
|
+
if (option[displayField]) {
|
|
101
|
+
const value: string = option[displayField];
|
|
102
|
+
if (
|
|
103
|
+
side === "left" &&
|
|
104
|
+
value
|
|
105
|
+
.toLocaleLowerCase()
|
|
106
|
+
.includes(leftFilterValue.toLocaleLowerCase())
|
|
107
|
+
) {
|
|
108
|
+
return true;
|
|
109
|
+
} else if (
|
|
110
|
+
side === "right" &&
|
|
111
|
+
value
|
|
112
|
+
.toLocaleLowerCase()
|
|
113
|
+
.includes(rightFilterValue.toLocaleLowerCase())
|
|
114
|
+
) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
});
|
|
120
|
+
return (
|
|
121
|
+
<Card sx={{ height: "100%" }}>
|
|
122
|
+
<CardHeader
|
|
123
|
+
sx={{ px: 2, py: 1 }}
|
|
124
|
+
avatar={
|
|
125
|
+
<Checkbox
|
|
126
|
+
onClick={handleToggleAll(items)}
|
|
127
|
+
checked={
|
|
128
|
+
numberOfChecked(items) === items.length && items.length !== 0
|
|
129
|
+
}
|
|
130
|
+
indeterminate={
|
|
131
|
+
numberOfChecked(items) !== items.length &&
|
|
132
|
+
numberOfChecked(items) !== 0
|
|
133
|
+
}
|
|
134
|
+
disabled={items.length === 0}
|
|
135
|
+
inputProps={{
|
|
136
|
+
"aria-label": "all items selected",
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
}
|
|
140
|
+
title={title}
|
|
141
|
+
subheader={`${numberOfChecked(unfilteredItems)} / ${
|
|
142
|
+
unfilteredItems.length
|
|
143
|
+
} Selected`}
|
|
144
|
+
/>
|
|
145
|
+
<Box sx={{ width: "100%", padding: 1 }}>
|
|
146
|
+
<TemplateTextField
|
|
147
|
+
fullWidth
|
|
148
|
+
label="search"
|
|
149
|
+
value={side === "left" ? leftFilterValue : rightFilterValue}
|
|
150
|
+
onChange={(event) => {
|
|
151
|
+
if (side === "left") {
|
|
152
|
+
setLeftFilterValue(event.target.value);
|
|
153
|
+
} else {
|
|
154
|
+
setRightFilterValue(event.target.value);
|
|
155
|
+
}
|
|
156
|
+
}}
|
|
157
|
+
/>
|
|
158
|
+
</Box>
|
|
159
|
+
<Divider />
|
|
160
|
+
<List
|
|
161
|
+
sx={{
|
|
162
|
+
width: "100%",
|
|
163
|
+
height: "100%",
|
|
164
|
+
bgcolor: "secondary",
|
|
165
|
+
overflow: "auto",
|
|
166
|
+
}}
|
|
167
|
+
dense
|
|
168
|
+
component="div"
|
|
169
|
+
role="list"
|
|
170
|
+
>
|
|
171
|
+
{items.map((value) => {
|
|
172
|
+
const labelId = `transfer-list-all-item-${value[valueField]}-label`;
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<ListItem
|
|
176
|
+
key={value[valueField]}
|
|
177
|
+
role="listitem"
|
|
178
|
+
component="button"
|
|
179
|
+
onClick={handleToggle(value)}
|
|
180
|
+
>
|
|
181
|
+
<ListItemIcon>
|
|
182
|
+
<Checkbox
|
|
183
|
+
checked={checked.indexOf(value) !== -1}
|
|
184
|
+
tabIndex={-1}
|
|
185
|
+
disableRipple
|
|
186
|
+
inputProps={{
|
|
187
|
+
"aria-labelledby": labelId,
|
|
188
|
+
}}
|
|
189
|
+
/>
|
|
190
|
+
</ListItemIcon>
|
|
191
|
+
<ListItemText
|
|
192
|
+
id={value[valueField]}
|
|
193
|
+
primary={value[displayField]}
|
|
194
|
+
/>
|
|
195
|
+
</ListItem>
|
|
196
|
+
);
|
|
197
|
+
})}
|
|
198
|
+
</List>
|
|
199
|
+
</Card>
|
|
200
|
+
);
|
|
201
|
+
};
|
|
202
|
+
return (
|
|
203
|
+
<Grid2
|
|
204
|
+
container
|
|
205
|
+
spacing={2}
|
|
206
|
+
sx={{
|
|
207
|
+
flexGrow: 1,
|
|
208
|
+
overflow: "auto",
|
|
209
|
+
margin: 1,
|
|
210
|
+
display: "flex",
|
|
211
|
+
width: "100%",
|
|
212
|
+
}}
|
|
213
|
+
justifyContent="center"
|
|
214
|
+
alignItems="center"
|
|
215
|
+
>
|
|
216
|
+
<Grid2 sx={{ height: "100%", flex: 1 }}>
|
|
217
|
+
{customList("Available Items", left, "left")}
|
|
218
|
+
</Grid2>
|
|
219
|
+
<Grid2>
|
|
220
|
+
<Grid2 container direction="column" alignItems="center">
|
|
221
|
+
<Button
|
|
222
|
+
sx={{ my: 0.5 }}
|
|
223
|
+
variant="outlined"
|
|
224
|
+
size="small"
|
|
225
|
+
onClick={handleCheckedRight}
|
|
226
|
+
disabled={leftChecked.length === 0}
|
|
227
|
+
aria-label="move selected right"
|
|
228
|
+
>
|
|
229
|
+
>
|
|
230
|
+
</Button>
|
|
231
|
+
<Button
|
|
232
|
+
sx={{ my: 0.5 }}
|
|
233
|
+
variant="outlined"
|
|
234
|
+
size="small"
|
|
235
|
+
onClick={handleCheckedLeft}
|
|
236
|
+
disabled={rightChecked.length === 0}
|
|
237
|
+
aria-label="move selected left"
|
|
238
|
+
>
|
|
239
|
+
<
|
|
240
|
+
</Button>
|
|
241
|
+
</Grid2>
|
|
242
|
+
</Grid2>
|
|
243
|
+
<Grid2 sx={{ height: "100%", flex: 1 }}>
|
|
244
|
+
{customList("Currently Selected", right, "right")}
|
|
245
|
+
</Grid2>
|
|
246
|
+
</Grid2>
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export default TransferList;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogActions,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogContentText,
|
|
7
|
+
DialogTitle,
|
|
8
|
+
} from "@mui/material";
|
|
9
|
+
import { useTranslation } from "react-i18next";
|
|
10
|
+
|
|
11
|
+
interface ConfirmationWindowProps {
|
|
12
|
+
open: boolean;
|
|
13
|
+
setOpen: Function;
|
|
14
|
+
title: string;
|
|
15
|
+
body: string;
|
|
16
|
+
onConfirmationCallBk: Function;
|
|
17
|
+
}
|
|
18
|
+
const ConfirmationWindow: React.FC<ConfirmationWindowProps> = (props) => {
|
|
19
|
+
const handleClose = () => {
|
|
20
|
+
props.setOpen(false);
|
|
21
|
+
};
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
return (
|
|
24
|
+
<Dialog open={props.open}>
|
|
25
|
+
<DialogTitle>{props.title}</DialogTitle>
|
|
26
|
+
<DialogContent>
|
|
27
|
+
<DialogContentText>{props.body}</DialogContentText>
|
|
28
|
+
</DialogContent>
|
|
29
|
+
<DialogActions>
|
|
30
|
+
<Button
|
|
31
|
+
variant="contained"
|
|
32
|
+
color="primary"
|
|
33
|
+
onClick={() => {
|
|
34
|
+
handleClose();
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{t("NO_LABEL")}
|
|
38
|
+
</Button>
|
|
39
|
+
<Button
|
|
40
|
+
variant="contained"
|
|
41
|
+
color="error"
|
|
42
|
+
onClick={() => {
|
|
43
|
+
props.onConfirmationCallBk();
|
|
44
|
+
handleClose();
|
|
45
|
+
}}
|
|
46
|
+
autoFocus
|
|
47
|
+
>
|
|
48
|
+
{t("YES_LABEL")}
|
|
49
|
+
</Button>
|
|
50
|
+
</DialogActions>
|
|
51
|
+
</Dialog>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default ConfirmationWindow;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import Grid from "@mui/material/Grid2";
|
|
2
|
+
import TemplatePieChart from "./charts/TemplatePieChart";
|
|
3
|
+
import TemplateBarChart from "./charts/TemplateBarChart";
|
|
4
|
+
import TemplateLineChart from "./charts/TemplateLineChart";
|
|
5
|
+
import TemplateGauge from "./charts/TemplateGauge";
|
|
6
|
+
import TemplateDataCard from "./charts/TemplateDataCard";
|
|
7
|
+
import TemplateLineProgress from "./charts/TemplateLineProgress";
|
|
8
|
+
import { Typography } from "@mui/material";
|
|
9
|
+
|
|
10
|
+
interface WidgetContainerProps {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
widgetType: "Line" | "Bar" | "Pie" | "Card" | "Gauge" | "Progress";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface WidgetProps {
|
|
16
|
+
widgetTitle?: string;
|
|
17
|
+
widgetType: "Line" | "Bar" | "Pie" | "Card" | "Gauge" | "Progress";
|
|
18
|
+
data: any;
|
|
19
|
+
valueField: string; //x-axis field in case of line/bar chart
|
|
20
|
+
labelField: string; //y-axis field in case of line/bar chart, it can also be a comma separated string for multiple series
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SingleRecordWidgetProps {
|
|
24
|
+
widgetTitle?: string;
|
|
25
|
+
record: object;
|
|
26
|
+
valueField: string;
|
|
27
|
+
labelField: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface DashboardProps {
|
|
31
|
+
dashboardTitle: string;
|
|
32
|
+
dashboardWidgets: Array<WidgetProps>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
36
|
+
children,
|
|
37
|
+
widgetType,
|
|
38
|
+
}) => {
|
|
39
|
+
return (
|
|
40
|
+
<Grid
|
|
41
|
+
size={{ xs: 12, sm: 6, md: 4 }}
|
|
42
|
+
sx={{
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
justifyContent: "center",
|
|
45
|
+
padding: 1,
|
|
46
|
+
display: "flex",
|
|
47
|
+
flexDirection: widgetType != "Card" ? "column" : undefined,
|
|
48
|
+
height: 300,
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</Grid>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const TemplateDashboard: React.FC<DashboardProps> = (props) => {
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<Typography sx={{ fontSize: 20, fontWeight: "bold" }}>
|
|
60
|
+
{props.dashboardTitle}
|
|
61
|
+
</Typography>
|
|
62
|
+
<Grid
|
|
63
|
+
container
|
|
64
|
+
sx={{
|
|
65
|
+
flexGrow: 1,
|
|
66
|
+
width: "100%",
|
|
67
|
+
overflowY: "auto",
|
|
68
|
+
padding: 2,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{props.dashboardWidgets.map((widgetProps: any, index: any) => {
|
|
72
|
+
if (
|
|
73
|
+
widgetProps.widgetType === "Card" ||
|
|
74
|
+
widgetProps.widgetType === "Gauge" ||
|
|
75
|
+
widgetProps.widgetType === "Progress"
|
|
76
|
+
) {
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
{widgetProps.data.map((record: any, index: any) => {
|
|
80
|
+
const singleRecordWidgetProps: SingleRecordWidgetProps = {
|
|
81
|
+
widgetTitle: widgetProps.widgetTitle,
|
|
82
|
+
record,
|
|
83
|
+
labelField: widgetProps.labelField,
|
|
84
|
+
valueField: widgetProps.valueField,
|
|
85
|
+
};
|
|
86
|
+
return (
|
|
87
|
+
<WidgetContainer
|
|
88
|
+
key={index}
|
|
89
|
+
widgetType={widgetProps.widgetType}
|
|
90
|
+
>
|
|
91
|
+
{widgetProps.widgetType === "Card" ? (
|
|
92
|
+
<TemplateDataCard {...singleRecordWidgetProps} />
|
|
93
|
+
) : null}
|
|
94
|
+
{widgetProps.widgetType === "Gauge" ? (
|
|
95
|
+
<TemplateGauge {...singleRecordWidgetProps} />
|
|
96
|
+
) : null}
|
|
97
|
+
{widgetProps.widgetType === "Progress" ? (
|
|
98
|
+
<TemplateLineProgress {...singleRecordWidgetProps} />
|
|
99
|
+
) : null}
|
|
100
|
+
</WidgetContainer>
|
|
101
|
+
);
|
|
102
|
+
})}
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
} else {
|
|
106
|
+
return (
|
|
107
|
+
<WidgetContainer key={index} widgetType={widgetProps.widgetType}>
|
|
108
|
+
{widgetProps.widgetType === "Pie" ? (
|
|
109
|
+
<TemplatePieChart {...widgetProps} />
|
|
110
|
+
) : null}
|
|
111
|
+
{widgetProps.widgetType === "Line" ? (
|
|
112
|
+
<TemplateLineChart {...widgetProps} />
|
|
113
|
+
) : null}
|
|
114
|
+
{widgetProps.widgetType === "Bar" ? (
|
|
115
|
+
<TemplateBarChart {...widgetProps} />
|
|
116
|
+
) : null}
|
|
117
|
+
</WidgetContainer>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
})}
|
|
121
|
+
</Grid>
|
|
122
|
+
</>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default TemplateDashboard;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BarChart } from "@mui/x-charts";
|
|
2
|
+
import { WidgetProps } from "../TemplateDashboard";
|
|
3
|
+
|
|
4
|
+
const TemplateBarChart: React.FC<WidgetProps> = (props) => {
|
|
5
|
+
return (
|
|
6
|
+
<BarChart
|
|
7
|
+
dataset={props.data}
|
|
8
|
+
xAxis={[{ dataKey: props.valueField, scaleType: "band" }]}
|
|
9
|
+
series={props.labelField?.split(",").map((labelField) => {
|
|
10
|
+
return { dataKey: labelField, label: labelField };
|
|
11
|
+
})}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default TemplateBarChart;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Box, Paper, Typography } from "@mui/material";
|
|
2
|
+
import { SingleRecordWidgetProps } from "../TemplateDashboard";
|
|
3
|
+
|
|
4
|
+
const TemplateDataCard: React.FC<SingleRecordWidgetProps> = (props: any) => {
|
|
5
|
+
return (
|
|
6
|
+
<Paper
|
|
7
|
+
sx={{
|
|
8
|
+
display: "flex",
|
|
9
|
+
flexDirection: "column",
|
|
10
|
+
height: 150,
|
|
11
|
+
padding: 1,
|
|
12
|
+
flexGrow: 1,
|
|
13
|
+
justifyContent: "center",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
}}
|
|
16
|
+
>
|
|
17
|
+
<Box
|
|
18
|
+
sx={{
|
|
19
|
+
display: "flex",
|
|
20
|
+
width: "100%",
|
|
21
|
+
justifyContent: "space-evenly",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<Typography sx={{ fontSize: 16, fontWeight: "bold" }}>
|
|
26
|
+
{props.widgetTitle}
|
|
27
|
+
</Typography>
|
|
28
|
+
</Box>
|
|
29
|
+
<Box
|
|
30
|
+
sx={{
|
|
31
|
+
flex: 1,
|
|
32
|
+
display: "flex",
|
|
33
|
+
width: "100%",
|
|
34
|
+
justifyContent: "space-evenly",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{/* <div>left</div> */}
|
|
39
|
+
<div>{`${props.record[props.labelField]} : ${
|
|
40
|
+
props.record[props.valueField]
|
|
41
|
+
}`}</div>
|
|
42
|
+
{/* <div>right</div> */}
|
|
43
|
+
</Box>
|
|
44
|
+
<Box
|
|
45
|
+
sx={{
|
|
46
|
+
display: "flex",
|
|
47
|
+
width: "100%",
|
|
48
|
+
justifyContent: "space-evenly",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
{/* <div>left</div>
|
|
53
|
+
<div>center</div>
|
|
54
|
+
<div>right</div> */}
|
|
55
|
+
</Box>
|
|
56
|
+
</Paper>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default TemplateDataCard;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Gauge } from "@mui/x-charts";
|
|
2
|
+
import { SingleRecordWidgetProps } from "../TemplateDashboard";
|
|
3
|
+
import { Typography } from "@mui/material";
|
|
4
|
+
|
|
5
|
+
const TemplateGauge: React.FC<SingleRecordWidgetProps> = (props: any) => {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<Typography sx={{ fontSize: 16, fontWeight: "bold" }}>
|
|
9
|
+
{props.widgetTitle} - {props.record[props.labelField]}
|
|
10
|
+
</Typography>
|
|
11
|
+
<Gauge width={200} height={200} value={props.record[props.valueField]} />
|
|
12
|
+
</>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default TemplateGauge;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LineChart } from "@mui/x-charts";
|
|
2
|
+
import { WidgetProps } from "../TemplateDashboard";
|
|
3
|
+
|
|
4
|
+
const TemplateLineChart: React.FC<WidgetProps> = (props) => {
|
|
5
|
+
return (
|
|
6
|
+
<LineChart
|
|
7
|
+
dataset={props.data}
|
|
8
|
+
xAxis={[{ dataKey: props.valueField, scaleType: "band" }]}
|
|
9
|
+
series={props.labelField?.split(",").map((labelField) => {
|
|
10
|
+
return { dataKey: labelField, label: labelField };
|
|
11
|
+
})}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default TemplateLineChart;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import LinearProgress, {
|
|
3
|
+
LinearProgressProps,
|
|
4
|
+
} from "@mui/material/LinearProgress";
|
|
5
|
+
import Typography from "@mui/material/Typography";
|
|
6
|
+
import Box from "@mui/material/Box";
|
|
7
|
+
import { SingleRecordWidgetProps } from "../TemplateDashboard";
|
|
8
|
+
|
|
9
|
+
function LinearProgressWithLabel(
|
|
10
|
+
props: LinearProgressProps & { value: number }
|
|
11
|
+
) {
|
|
12
|
+
return (
|
|
13
|
+
<Box sx={{ display: "flex", alignItems: "center" }}>
|
|
14
|
+
<Box sx={{ width: "100%", mr: 1 }}>
|
|
15
|
+
<LinearProgress variant="determinate" {...props} />
|
|
16
|
+
</Box>
|
|
17
|
+
<Box sx={{ minWidth: 35 }}>
|
|
18
|
+
<Typography
|
|
19
|
+
variant="body2"
|
|
20
|
+
sx={{ color: "text.secondary" }}
|
|
21
|
+
>{`${Math.round(props.value)}%`}</Typography>
|
|
22
|
+
</Box>
|
|
23
|
+
</Box>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const TemplateLineProgress: React.FC<SingleRecordWidgetProps> = (
|
|
28
|
+
props: any
|
|
29
|
+
) => {
|
|
30
|
+
return (
|
|
31
|
+
<Box sx={{ width: "100%" }}>
|
|
32
|
+
<Typography sx={{ fontSize: 16, fontWeight: "bold" }}>
|
|
33
|
+
{props.widgetTitle} - {props.record[props.labelField]}
|
|
34
|
+
</Typography>
|
|
35
|
+
<LinearProgressWithLabel value={props.record[props.valueField]} />
|
|
36
|
+
</Box>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default TemplateLineProgress;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PieChart } from "@mui/x-charts/PieChart";
|
|
2
|
+
import { WidgetProps } from "../TemplateDashboard";
|
|
3
|
+
|
|
4
|
+
const TemplatePieChart: React.FC<WidgetProps> = (props) => {
|
|
5
|
+
// construct data object
|
|
6
|
+
const chartData = props.data.map((record: any, index: any) => {
|
|
7
|
+
return {
|
|
8
|
+
id: index,
|
|
9
|
+
value: record[props.valueField],
|
|
10
|
+
label: record[props.labelField] + "",
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
console.log("chartData", chartData);
|
|
14
|
+
return (
|
|
15
|
+
<PieChart
|
|
16
|
+
series={[
|
|
17
|
+
{
|
|
18
|
+
data: chartData,
|
|
19
|
+
},
|
|
20
|
+
]}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default TemplatePieChart;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogActions,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogContentText,
|
|
7
|
+
DialogTitle,
|
|
8
|
+
} from "@mui/material";
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { useTranslation } from "react-i18next";
|
|
11
|
+
|
|
12
|
+
interface ConfirmationWindowProps {
|
|
13
|
+
title: string;
|
|
14
|
+
body: string;
|
|
15
|
+
onConfirmationCallBk: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const useConfirmationWindow = (props: ConfirmationWindowProps) => {
|
|
19
|
+
const [open, setOpen] = useState<boolean>(false);
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const ConfirmationWindow: React.FC = () => {
|
|
22
|
+
return (
|
|
23
|
+
<Dialog open={open}>
|
|
24
|
+
<DialogTitle>{props.title}</DialogTitle>
|
|
25
|
+
<DialogContent>
|
|
26
|
+
<DialogContentText>{props.body}</DialogContentText>
|
|
27
|
+
</DialogContent>
|
|
28
|
+
<DialogActions>
|
|
29
|
+
<Button
|
|
30
|
+
variant="contained"
|
|
31
|
+
color="primary"
|
|
32
|
+
onClick={() => {
|
|
33
|
+
setOpen(false);
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
{t("NO_LABEL")}
|
|
37
|
+
</Button>
|
|
38
|
+
<Button
|
|
39
|
+
variant="contained"
|
|
40
|
+
color="error"
|
|
41
|
+
onClick={() => {
|
|
42
|
+
props.onConfirmationCallBk();
|
|
43
|
+
setOpen(false);
|
|
44
|
+
}}
|
|
45
|
+
autoFocus
|
|
46
|
+
>
|
|
47
|
+
{t("YES_LABEL")}
|
|
48
|
+
</Button>
|
|
49
|
+
</DialogActions>
|
|
50
|
+
</Dialog>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
return { ConfirmationWindow, open, setOpen };
|
|
54
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export const useIsMobile = (breakpoint = 768) => {
|
|
4
|
+
const [isMobile, setIsMobile] = useState(window.innerWidth < breakpoint);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handleResize = () => setIsMobile(window.innerWidth < breakpoint);
|
|
8
|
+
window.addEventListener("resize", handleResize);
|
|
9
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
10
|
+
}, [breakpoint]);
|
|
11
|
+
|
|
12
|
+
return isMobile;
|
|
13
|
+
};
|