@asaleh37/ui-base 25.9.3 → 25.9.5
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/public/bg.jpg +0 -0
- package/src/components/administration/admin/PersonGrid.tsx +4 -4
- package/src/components/common/AzureLogin.tsx +172 -20
- package/src/components/common/Login.tsx +48 -29
- package/src/main.tsx +2 -2
- package/src/redux/features/administration/AdministrationStoresMetaData.ts +5 -0
package/package.json
CHANGED
package/public/bg.jpg
ADDED
|
Binary file
|
|
@@ -23,7 +23,7 @@ const PersonGrid: React.FC = () => {
|
|
|
23
23
|
);
|
|
24
24
|
const [data, setData] = useState([]);
|
|
25
25
|
const apiActions = useApiActions({
|
|
26
|
-
|
|
26
|
+
commonStoreKey: "persons",
|
|
27
27
|
deleteById: "api/v1/admin/person",
|
|
28
28
|
save: "api/v1/admin/person",
|
|
29
29
|
findById: "api/v1/admin/person",
|
|
@@ -276,10 +276,10 @@ const PersonGrid: React.FC = () => {
|
|
|
276
276
|
data={data}
|
|
277
277
|
setData={setData}
|
|
278
278
|
editMode={{
|
|
279
|
-
editMode: "modal",
|
|
279
|
+
editMode: "modal",
|
|
280
280
|
specs: {
|
|
281
281
|
modalIcon: "user",
|
|
282
|
-
modalTitle: "Person Profile",
|
|
282
|
+
modalTitle: "Person Profile",
|
|
283
283
|
modalWidth: 300,
|
|
284
284
|
},
|
|
285
285
|
}}
|
|
@@ -320,7 +320,7 @@ const PersonGrid: React.FC = () => {
|
|
|
320
320
|
]}
|
|
321
321
|
girdIcon="users"
|
|
322
322
|
editAction={{
|
|
323
|
-
isEnabled: true,
|
|
323
|
+
isEnabled: true,
|
|
324
324
|
authority: "PERSON_EDIT",
|
|
325
325
|
preActionValidation: (data) => {
|
|
326
326
|
if (
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { PublicClientApplication } from "@azure/msal-browser";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Button,
|
|
5
|
+
CircularProgress,
|
|
6
|
+
createTheme,
|
|
7
|
+
Paper,
|
|
8
|
+
Typography,
|
|
9
|
+
} from "@mui/material";
|
|
3
10
|
import { useDispatch, useSelector } from "react-redux";
|
|
4
11
|
import { AppInfo } from "../../redux/features/common/AppInfoSlice";
|
|
5
12
|
import { useAxios } from "../../hooks";
|
|
6
13
|
import { UserSessionActions } from "../../redux/features/common/UserSessionSlice";
|
|
7
|
-
import { useEffect } from "react";
|
|
14
|
+
import { useEffect, useState } from "react";
|
|
8
15
|
|
|
16
|
+
import { ThemeProvider } from "@emotion/react";
|
|
17
|
+
import {
|
|
18
|
+
DARK_THEME_INITIAL_MAIN_COLOR,
|
|
19
|
+
DARK_THEME_INITIAL_SECANDARY_COLOR,
|
|
20
|
+
LIGHT_THEME_INITIAL_MAIN_COLOR,
|
|
21
|
+
LIGHT_THEME_INITIAL_SECANDARY_COLOR,
|
|
22
|
+
} from "../../util";
|
|
23
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
9
24
|
interface AzureLoginProps {
|
|
10
25
|
msalInstance: PublicClientApplication;
|
|
11
26
|
}
|
|
@@ -13,16 +28,17 @@ interface AzureLoginProps {
|
|
|
13
28
|
const AzureLogin: React.FC<AzureLoginProps> = ({ msalInstance }) => {
|
|
14
29
|
const appInfo: AppInfo = useSelector((state: any) => state.AppInfo.value);
|
|
15
30
|
const userSession = useSelector((state: any) => state.UserSession.value);
|
|
31
|
+
const [isLoginInProcess, setIsLoginInProcess] = useState(false);
|
|
16
32
|
const { handleGetRequest } = useAxios();
|
|
17
33
|
const dispatch = useDispatch();
|
|
18
34
|
const checkUserSession = async () => {
|
|
19
|
-
if (
|
|
20
|
-
if (
|
|
21
|
-
const token = localStorage.getItem("TOKEN");
|
|
35
|
+
if (localStorage.getItem("TOKEN")) {
|
|
36
|
+
if (appInfo?.apiBaseUrl) {
|
|
22
37
|
handleGetRequest({
|
|
23
38
|
endPointURI: "api/auth/userInfo",
|
|
24
39
|
showMask: true,
|
|
25
40
|
successCallBkFn: (response) => {
|
|
41
|
+
setIsLoginInProcess(false);
|
|
26
42
|
if (response != null && response.data != null) {
|
|
27
43
|
const UserSession = {
|
|
28
44
|
...response.data,
|
|
@@ -34,36 +50,172 @@ const AzureLogin: React.FC<AzureLoginProps> = ({ msalInstance }) => {
|
|
|
34
50
|
localStorage.removeItem("TOKEN");
|
|
35
51
|
}
|
|
36
52
|
},
|
|
53
|
+
failureCallBkFn: () => {
|
|
54
|
+
setIsLoginInProcess(false);
|
|
55
|
+
},
|
|
37
56
|
});
|
|
38
57
|
}
|
|
58
|
+
} else {
|
|
59
|
+
dispatch(UserSessionActions.setUnAuthenticated());
|
|
60
|
+
setIsLoginInProcess(false);
|
|
39
61
|
}
|
|
40
62
|
};
|
|
41
63
|
const handleLogin = async () => {
|
|
64
|
+
setIsLoginInProcess(true);
|
|
42
65
|
const response = await msalInstance.acquireTokenPopup({
|
|
43
66
|
scopes: appInfo?.azureConfiguration?.scopes,
|
|
44
67
|
});
|
|
45
68
|
if (response?.accessToken) {
|
|
46
69
|
localStorage.setItem("TOKEN", response.accessToken);
|
|
47
70
|
checkUserSession();
|
|
71
|
+
} else {
|
|
72
|
+
setIsLoginInProcess(false);
|
|
48
73
|
}
|
|
49
74
|
};
|
|
50
|
-
const
|
|
51
|
-
const response = await handleGetRequest({
|
|
52
|
-
endPointURI: "api/auth/userInfo",
|
|
53
|
-
showMask: true,
|
|
54
|
-
successCallBkFn: (response) => {
|
|
55
|
-
console.log(response);
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
};
|
|
75
|
+
const UserSessionState = useSelector((state: any) => state.UserSession.value);
|
|
59
76
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
checkUserSession();
|
|
79
|
+
}, [appInfo]);
|
|
80
|
+
|
|
81
|
+
const loginTheme = createTheme({
|
|
82
|
+
components: {
|
|
83
|
+
MuiCssBaseline: {
|
|
84
|
+
styleOverrides: `
|
|
85
|
+
/* Custom Scrollbar */
|
|
86
|
+
* {
|
|
87
|
+
scrollbar-width: thin;
|
|
88
|
+
scrollbar-color: ${
|
|
89
|
+
appInfo.appTheme?.dark?.primaryColor ||
|
|
90
|
+
DARK_THEME_INITIAL_MAIN_COLOR
|
|
91
|
+
} #121212;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Webkit Browsers */
|
|
95
|
+
*::-webkit-scrollbar {
|
|
96
|
+
width: 12px;
|
|
97
|
+
height: 10px;
|
|
98
|
+
}
|
|
99
|
+
`,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
palette: {
|
|
103
|
+
mode: appInfo?.loginScreenStyle?.themeMode || "dark",
|
|
104
|
+
primary: {
|
|
105
|
+
main:
|
|
106
|
+
appInfo?.loginScreenStyle?.themeMode === "light"
|
|
107
|
+
? appInfo.appTheme?.light?.primaryColor ||
|
|
108
|
+
LIGHT_THEME_INITIAL_MAIN_COLOR
|
|
109
|
+
: appInfo.appTheme?.dark?.primaryColor ||
|
|
110
|
+
DARK_THEME_INITIAL_MAIN_COLOR,
|
|
111
|
+
},
|
|
112
|
+
secondary: {
|
|
113
|
+
main:
|
|
114
|
+
appInfo?.loginScreenStyle?.themeMode === "light"
|
|
115
|
+
? appInfo.appTheme?.light?.secondaryColor ||
|
|
116
|
+
LIGHT_THEME_INITIAL_SECANDARY_COLOR
|
|
117
|
+
: appInfo.appTheme?.dark?.secondaryColor ||
|
|
118
|
+
DARK_THEME_INITIAL_SECANDARY_COLOR,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
});
|
|
63
122
|
return (
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
123
|
+
<ThemeProvider theme={loginTheme}>
|
|
124
|
+
{UserSessionState.isAuthenticated == false ? (
|
|
125
|
+
<Box
|
|
126
|
+
sx={{
|
|
127
|
+
// position: "relative",
|
|
128
|
+
display: "flex",
|
|
129
|
+
alignItems: "center",
|
|
130
|
+
justifyContent: "center",
|
|
131
|
+
minHeight: "100vh",
|
|
132
|
+
width: "100%",
|
|
133
|
+
backgroundImage: "url('/bg.jpg')",
|
|
134
|
+
backgroundRepeat: "no-repeat",
|
|
135
|
+
backgroundSize: "cover",
|
|
136
|
+
backgroundPosition: "center",
|
|
137
|
+
"&::before": {
|
|
138
|
+
content: '""',
|
|
139
|
+
position: "absolute",
|
|
140
|
+
top: 0,
|
|
141
|
+
left: 0,
|
|
142
|
+
right: 0,
|
|
143
|
+
bottom: 0,
|
|
144
|
+
backgroundColor: "rgba(0, 0, 0, 0.4)", // 👈 controls opacity
|
|
145
|
+
zIndex: 0,
|
|
146
|
+
},
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
<Paper
|
|
150
|
+
sx={{
|
|
151
|
+
display: "flex",
|
|
152
|
+
width: "fit-content",
|
|
153
|
+
padding: 2,
|
|
154
|
+
height: "fit-content",
|
|
155
|
+
borderRadius: 5,
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
justifyContent: "center",
|
|
158
|
+
textAlign: "center",
|
|
159
|
+
zIndex: 1,
|
|
160
|
+
p: 4,
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
<Box
|
|
164
|
+
sx={{
|
|
165
|
+
display: "flex",
|
|
166
|
+
flexDirection: "column",
|
|
167
|
+
alignItems: "center",
|
|
168
|
+
justifyContent: "center",
|
|
169
|
+
}}
|
|
170
|
+
>
|
|
171
|
+
<img src={appInfo?.appLogo} width={150} height={150} />
|
|
172
|
+
<Typography sx={{ m: 1 }} variant="h4" color="textSecondary">
|
|
173
|
+
{appInfo?.appName}
|
|
174
|
+
</Typography>
|
|
175
|
+
<Typography
|
|
176
|
+
sx={{
|
|
177
|
+
paddingRight: 1,
|
|
178
|
+
width: "100%",
|
|
179
|
+
textAlign: "right",
|
|
180
|
+
fontSize: 10,
|
|
181
|
+
}}
|
|
182
|
+
variant="caption"
|
|
183
|
+
color="textSecondary"
|
|
184
|
+
>
|
|
185
|
+
V.{appInfo.appVersion}
|
|
186
|
+
</Typography>
|
|
187
|
+
<Button
|
|
188
|
+
loading={isLoginInProcess}
|
|
189
|
+
onClick={handleLogin}
|
|
190
|
+
variant="contained"
|
|
191
|
+
color="primary"
|
|
192
|
+
sx={{ m: 1 }}
|
|
193
|
+
startIcon={
|
|
194
|
+
<FontAwesomeIcon
|
|
195
|
+
icon={{ iconName: "microsoft", prefix: "fab" }}
|
|
196
|
+
/>
|
|
197
|
+
}
|
|
198
|
+
>
|
|
199
|
+
login
|
|
200
|
+
</Button>
|
|
201
|
+
</Box>
|
|
202
|
+
</Paper>
|
|
203
|
+
</Box>
|
|
204
|
+
) : (
|
|
205
|
+
<Paper
|
|
206
|
+
sx={{
|
|
207
|
+
width: "100%",
|
|
208
|
+
height: "100vh",
|
|
209
|
+
display: "flex",
|
|
210
|
+
alignItems: "center",
|
|
211
|
+
justifyContent: "center",
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
<CircularProgress sx={{ marginRight: 1 }} />
|
|
215
|
+
<div>You will be redirected shortly ... please wait</div>
|
|
216
|
+
</Paper>
|
|
217
|
+
)}
|
|
218
|
+
</ThemeProvider>
|
|
67
219
|
);
|
|
68
220
|
};
|
|
69
221
|
|
|
@@ -140,39 +140,50 @@ const Login: React.FC = () => {
|
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
useEffect(() => {
|
|
143
|
-
console.log("checking usersession on reload", userSession);
|
|
144
|
-
console.log("checking usersession app info", appInfo);
|
|
145
143
|
checkUserSession();
|
|
146
144
|
}, [appInfo, userSession.isAuthenticated]);
|
|
147
145
|
|
|
148
146
|
return (
|
|
149
147
|
<ThemeProvider theme={loginTheme}>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
minHeight: "100vh", // full page height
|
|
153
|
-
width: "100%",
|
|
154
|
-
display: "flex",
|
|
155
|
-
alignItems: "center",
|
|
156
|
-
justifyContent: "center",
|
|
157
|
-
background: appInfo?.loginScreenStyle?.backgroundColor,
|
|
158
|
-
backgroundImage: `url('/${appInfo?.loginScreenStyle?.backgroundImageNameInPublicFolder}')`,
|
|
159
|
-
backgroundRepeat: "no-repeat",
|
|
160
|
-
backgroundSize: "cover", // 🔥 makes it responsive
|
|
161
|
-
backgroundPosition: "center", // keeps it centered
|
|
162
|
-
}}
|
|
163
|
-
>
|
|
164
|
-
<Paper
|
|
148
|
+
{UserSessionState.isAuthenticated == false ? (
|
|
149
|
+
<Box
|
|
165
150
|
sx={{
|
|
151
|
+
// position: "relative",
|
|
166
152
|
display: "flex",
|
|
167
|
-
width: "fit-content",
|
|
168
|
-
padding: 2,
|
|
169
|
-
height: "fit-content",
|
|
170
|
-
borderRadius: 5,
|
|
171
153
|
alignItems: "center",
|
|
172
154
|
justifyContent: "center",
|
|
155
|
+
minHeight: "100vh",
|
|
156
|
+
width: "100%",
|
|
157
|
+
backgroundImage: "url('/bg.jpg')",
|
|
158
|
+
backgroundRepeat: "no-repeat",
|
|
159
|
+
backgroundSize: "cover",
|
|
160
|
+
backgroundPosition: "center",
|
|
161
|
+
"&::before": {
|
|
162
|
+
content: '""',
|
|
163
|
+
position: "absolute",
|
|
164
|
+
top: 0,
|
|
165
|
+
left: 0,
|
|
166
|
+
right: 0,
|
|
167
|
+
bottom: 0,
|
|
168
|
+
backgroundColor: "rgba(0, 0, 0, 0.4)", // 👈 controls opacity
|
|
169
|
+
zIndex: 0,
|
|
170
|
+
},
|
|
173
171
|
}}
|
|
174
172
|
>
|
|
175
|
-
|
|
173
|
+
<Paper
|
|
174
|
+
sx={{
|
|
175
|
+
display: "flex",
|
|
176
|
+
width: "fit-content",
|
|
177
|
+
padding: 2,
|
|
178
|
+
height: "fit-content",
|
|
179
|
+
borderRadius: 5,
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
justifyContent: "center",
|
|
182
|
+
textAlign: "center",
|
|
183
|
+
zIndex: 1,
|
|
184
|
+
p: 4,
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
176
187
|
<Box
|
|
177
188
|
sx={{
|
|
178
189
|
display: "flex",
|
|
@@ -234,14 +245,22 @@ const Login: React.FC = () => {
|
|
|
234
245
|
login
|
|
235
246
|
</Button>
|
|
236
247
|
</Box>
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
</Paper>
|
|
249
|
+
</Box>
|
|
250
|
+
) : (
|
|
251
|
+
<Paper
|
|
252
|
+
sx={{
|
|
253
|
+
width: "100%",
|
|
254
|
+
height: "100vh",
|
|
255
|
+
display: "flex",
|
|
256
|
+
alignItems: "center",
|
|
257
|
+
justifyContent: "center",
|
|
258
|
+
}}
|
|
259
|
+
>
|
|
260
|
+
<CircularProgress sx={{ marginRight: 1 }} />
|
|
261
|
+
<div>You will be redirected shortly ... please wait</div>
|
|
243
262
|
</Paper>
|
|
244
|
-
|
|
263
|
+
)}
|
|
245
264
|
</ThemeProvider>
|
|
246
265
|
);
|
|
247
266
|
};
|
package/src/main.tsx
CHANGED
|
@@ -8,11 +8,11 @@ createRoot(document.getElementById("root")!).render(
|
|
|
8
8
|
appLogo={"/logo.png"}
|
|
9
9
|
appName="UI Base Library"
|
|
10
10
|
loginScreenStyle={{
|
|
11
|
-
themeMode: "
|
|
11
|
+
themeMode: "dark",
|
|
12
12
|
backgroundImageNameInPublicFolder: "bg.jpg",
|
|
13
13
|
}}
|
|
14
14
|
appVersion="0.0"
|
|
15
|
-
authenticationMethod="
|
|
15
|
+
authenticationMethod="AZURE"
|
|
16
16
|
azureConfiguration={{
|
|
17
17
|
frontEndClientId: "c3bbbdbd-f392-4459-b3dd-2351cb07f924",
|
|
18
18
|
tenantId: "9f136fef-4529-475f-98e6-d271eb04eb00",
|