wcz-layout 5.2.1 → 5.2.2
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/src/components/Layout.js +1 -1
- package/dist/src/components/Layout.js.map +1 -1
- package/dist/src/components/layout/leftDrawer/LeftDrawerItem.js.map +1 -1
- package/dist/src/models/KeycloakExtendedConfig.js.map +1 -1
- package/dist/src/models/LeftDrawerItem.js.map +1 -1
- package/dist/src/models/SnackbarModel.js.map +1 -1
- package/dist/src/models/User.js.map +1 -1
- package/dist/src/utils/Fetches.js.map +1 -1
- package/dist/src/utils/Helpers.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/Layout.tsx +2 -2
- package/src/models/KeycloakExtendedConfig.ts +11 -11
- package/src/models/LeftDrawerItem.ts +6 -6
- package/src/models/SnackbarModel.ts +5 -5
- package/src/models/User.ts +12 -12
- package/src/utils/Fetches.ts +91 -91
- package/src/utils/Helpers.ts +8 -8
- package/dist/package.json +0 -49
package/package.json
CHANGED
|
@@ -96,7 +96,7 @@ export default function Layout(props: LayoutProps) {
|
|
|
96
96
|
|
|
97
97
|
return (
|
|
98
98
|
<ThemeProvider theme={theme}>
|
|
99
|
-
<Box sx={{ display: 'flex', position:
|
|
99
|
+
<Box sx={{ display: 'flex', position: 'sticky' }}>
|
|
100
100
|
<CssBaseline />
|
|
101
101
|
<AppBar position="fixed" open={leftDrawerOpen}>
|
|
102
102
|
<Toolbar>
|
|
@@ -114,7 +114,7 @@ export default function Layout(props: LayoutProps) {
|
|
|
114
114
|
|
|
115
115
|
<LeftDrawer appVersion={appVersion} items={leftDrawerItems} drawerOpen={leftDrawerOpen} setDrawerOpen={setLeftDrawerOpen} />
|
|
116
116
|
|
|
117
|
-
<Box component="main" sx={{
|
|
117
|
+
<Box component="main" sx={{ flex: 1, overflow: "auto" }}>
|
|
118
118
|
<DrawerHeader />
|
|
119
119
|
{authorized ? children : <CenteredBox label={t("Layout.Unauthorized")!} />}
|
|
120
120
|
</Box>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export default interface KeycloakExtendedConfig {
|
|
2
|
-
autoLogin?: boolean,
|
|
3
|
-
confidential?: Confidential,
|
|
4
|
-
realm: string,
|
|
5
|
-
"auth-server-url": string,
|
|
6
|
-
idpHint?: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface Confidential {
|
|
10
|
-
client: string,
|
|
11
|
-
secret: string
|
|
1
|
+
export default interface KeycloakExtendedConfig {
|
|
2
|
+
autoLogin?: boolean,
|
|
3
|
+
confidential?: Confidential,
|
|
4
|
+
realm: string,
|
|
5
|
+
"auth-server-url": string,
|
|
6
|
+
idpHint?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Confidential {
|
|
10
|
+
client: string,
|
|
11
|
+
secret: string
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export interface LeftDrawerItem {
|
|
2
|
-
title: string,
|
|
3
|
-
path: string,
|
|
4
|
-
icon: React.ReactNode,
|
|
5
|
-
hidden?: boolean
|
|
6
|
-
}
|
|
1
|
+
export interface LeftDrawerItem {
|
|
2
|
+
title: string,
|
|
3
|
+
path: string,
|
|
4
|
+
icon: React.ReactNode,
|
|
5
|
+
hidden?: boolean
|
|
6
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AlertColor } from "@mui/material";
|
|
2
|
-
|
|
3
|
-
export default interface SnackbarModel {
|
|
4
|
-
message: string,
|
|
5
|
-
severity?: AlertColor
|
|
1
|
+
import { AlertColor } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
export default interface SnackbarModel {
|
|
4
|
+
message: string,
|
|
5
|
+
severity?: AlertColor
|
|
6
6
|
}
|
package/src/models/User.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { KeycloakPromise } from "keycloak-js";
|
|
2
|
-
|
|
3
|
-
export interface User {
|
|
4
|
-
id: string,
|
|
5
|
-
name: string,
|
|
6
|
-
department: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface ExtendedUser extends User {
|
|
10
|
-
loggedIn: boolean,
|
|
11
|
-
login: () => KeycloakPromise<void, void>,
|
|
12
|
-
logout: () => KeycloakPromise<void, void>
|
|
1
|
+
import { KeycloakPromise } from "keycloak-js";
|
|
2
|
+
|
|
3
|
+
export interface User {
|
|
4
|
+
id: string,
|
|
5
|
+
name: string,
|
|
6
|
+
department: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ExtendedUser extends User {
|
|
10
|
+
loggedIn: boolean,
|
|
11
|
+
login: () => KeycloakPromise<void, void>,
|
|
12
|
+
logout: () => KeycloakPromise<void, void>
|
|
13
13
|
}
|
package/src/utils/Fetches.ts
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import { getToken } from "./UserService";
|
|
2
|
-
|
|
3
|
-
export const fetchGet = async (url: string, signal: AbortSignal | undefined): Promise<any> => {
|
|
4
|
-
const initReq: RequestInit = await getRequestInit("GET", null, signal);
|
|
5
|
-
|
|
6
|
-
const response: Response = await fetch(url, initReq);
|
|
7
|
-
if (!response.ok)
|
|
8
|
-
throw await getQueryErrorMessage(response);
|
|
9
|
-
|
|
10
|
-
return response.json();
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const fetchFileGet = async (url: string, signal: AbortSignal | undefined): Promise<Blob> => {
|
|
14
|
-
const initReq: RequestInit = await getRequestInit("GET", null, signal);
|
|
15
|
-
|
|
16
|
-
const response: Response = await fetch(url, initReq);
|
|
17
|
-
if (!response.ok)
|
|
18
|
-
throw await getQueryErrorMessage(response);
|
|
19
|
-
|
|
20
|
-
return response.blob();
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const fetchPost = async (url: string, data: unknown): Promise<any> => {
|
|
24
|
-
const initReq: RequestInit = await getRequestInit("POST", data);
|
|
25
|
-
|
|
26
|
-
const response: Response = await fetch(url, initReq);
|
|
27
|
-
if (!response.ok)
|
|
28
|
-
throw await getQueryErrorMessage(response);
|
|
29
|
-
|
|
30
|
-
return response.json();
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const fetchPut = async (url: string, data: unknown): Promise<Response> => {
|
|
34
|
-
const initReq: RequestInit = await getRequestInit("PUT", data);
|
|
35
|
-
|
|
36
|
-
const response: Response = await fetch(url, initReq);
|
|
37
|
-
if (!response.ok)
|
|
38
|
-
throw await getQueryErrorMessage(response);
|
|
39
|
-
|
|
40
|
-
return response;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const fetchDelete = async (url: string): Promise<Response> => {
|
|
44
|
-
const initReq: RequestInit = await getRequestInit("DELETE");
|
|
45
|
-
|
|
46
|
-
const response: Response = await fetch(url, initReq);
|
|
47
|
-
if (!response.ok)
|
|
48
|
-
throw await getQueryErrorMessage(response);
|
|
49
|
-
|
|
50
|
-
return response;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const getRequestInit = async (method: string, data?: unknown, signal?: AbortSignal): Promise<RequestInit> => {
|
|
54
|
-
const request: RequestInit = {
|
|
55
|
-
method: method,
|
|
56
|
-
signal: signal,
|
|
57
|
-
credentials: 'include'
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
if (data) {
|
|
61
|
-
if (data instanceof FormData)
|
|
62
|
-
request.body = data;
|
|
63
|
-
else
|
|
64
|
-
request.body = JSON.stringify(data);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (data instanceof FormData)
|
|
68
|
-
request.headers = {
|
|
69
|
-
'Authorization': `Bearer ${await getToken()}`
|
|
70
|
-
};
|
|
71
|
-
else {
|
|
72
|
-
request.headers = {
|
|
73
|
-
'Content-Type': 'application/json',
|
|
74
|
-
'Authorization': `Bearer ${await getToken()}`
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return request;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const getQueryErrorMessage = async (response: Response): Promise<string> => {
|
|
82
|
-
let message: string = `Error connecting to server`;
|
|
83
|
-
|
|
84
|
-
const detailMessage: string | undefined = await response.json()
|
|
85
|
-
.then(data => data.message ?? data.title)
|
|
86
|
-
.catch(() => (message));
|
|
87
|
-
|
|
88
|
-
if (detailMessage)
|
|
89
|
-
message = detailMessage;
|
|
90
|
-
|
|
91
|
-
return message;
|
|
1
|
+
import { getToken } from "./UserService";
|
|
2
|
+
|
|
3
|
+
export const fetchGet = async (url: string, signal: AbortSignal | undefined): Promise<any> => {
|
|
4
|
+
const initReq: RequestInit = await getRequestInit("GET", null, signal);
|
|
5
|
+
|
|
6
|
+
const response: Response = await fetch(url, initReq);
|
|
7
|
+
if (!response.ok)
|
|
8
|
+
throw await getQueryErrorMessage(response);
|
|
9
|
+
|
|
10
|
+
return response.json();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const fetchFileGet = async (url: string, signal: AbortSignal | undefined): Promise<Blob> => {
|
|
14
|
+
const initReq: RequestInit = await getRequestInit("GET", null, signal);
|
|
15
|
+
|
|
16
|
+
const response: Response = await fetch(url, initReq);
|
|
17
|
+
if (!response.ok)
|
|
18
|
+
throw await getQueryErrorMessage(response);
|
|
19
|
+
|
|
20
|
+
return response.blob();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const fetchPost = async (url: string, data: unknown): Promise<any> => {
|
|
24
|
+
const initReq: RequestInit = await getRequestInit("POST", data);
|
|
25
|
+
|
|
26
|
+
const response: Response = await fetch(url, initReq);
|
|
27
|
+
if (!response.ok)
|
|
28
|
+
throw await getQueryErrorMessage(response);
|
|
29
|
+
|
|
30
|
+
return response.json();
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const fetchPut = async (url: string, data: unknown): Promise<Response> => {
|
|
34
|
+
const initReq: RequestInit = await getRequestInit("PUT", data);
|
|
35
|
+
|
|
36
|
+
const response: Response = await fetch(url, initReq);
|
|
37
|
+
if (!response.ok)
|
|
38
|
+
throw await getQueryErrorMessage(response);
|
|
39
|
+
|
|
40
|
+
return response;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const fetchDelete = async (url: string): Promise<Response> => {
|
|
44
|
+
const initReq: RequestInit = await getRequestInit("DELETE");
|
|
45
|
+
|
|
46
|
+
const response: Response = await fetch(url, initReq);
|
|
47
|
+
if (!response.ok)
|
|
48
|
+
throw await getQueryErrorMessage(response);
|
|
49
|
+
|
|
50
|
+
return response;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getRequestInit = async (method: string, data?: unknown, signal?: AbortSignal): Promise<RequestInit> => {
|
|
54
|
+
const request: RequestInit = {
|
|
55
|
+
method: method,
|
|
56
|
+
signal: signal,
|
|
57
|
+
credentials: 'include'
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
if (data) {
|
|
61
|
+
if (data instanceof FormData)
|
|
62
|
+
request.body = data;
|
|
63
|
+
else
|
|
64
|
+
request.body = JSON.stringify(data);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (data instanceof FormData)
|
|
68
|
+
request.headers = {
|
|
69
|
+
'Authorization': `Bearer ${await getToken()}`
|
|
70
|
+
};
|
|
71
|
+
else {
|
|
72
|
+
request.headers = {
|
|
73
|
+
'Content-Type': 'application/json',
|
|
74
|
+
'Authorization': `Bearer ${await getToken()}`
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return request;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const getQueryErrorMessage = async (response: Response): Promise<string> => {
|
|
82
|
+
let message: string = `Error connecting to server`;
|
|
83
|
+
|
|
84
|
+
const detailMessage: string | undefined = await response.json()
|
|
85
|
+
.then(data => data.message ?? data.title)
|
|
86
|
+
.catch(() => (message));
|
|
87
|
+
|
|
88
|
+
if (detailMessage)
|
|
89
|
+
message = detailMessage;
|
|
90
|
+
|
|
91
|
+
return message;
|
|
92
92
|
};
|
package/src/utils/Helpers.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Guid } from "guid-ts";
|
|
2
|
-
|
|
3
|
-
export const isAndroid: boolean = /(android)/i.test(navigator.userAgent);
|
|
4
|
-
export const isMobile: boolean = /(android|iphone)/i.test(navigator.userAgent);
|
|
5
|
-
|
|
6
|
-
export const isDevelopment: boolean = window.location.href.includes(".dev") || window.location.href.includes("localhost");
|
|
7
|
-
|
|
8
|
-
export const newGuid = (): string => Guid.newGuid().toString();
|
|
1
|
+
import { Guid } from "guid-ts";
|
|
2
|
+
|
|
3
|
+
export const isAndroid: boolean = /(android)/i.test(navigator.userAgent);
|
|
4
|
+
export const isMobile: boolean = /(android|iphone)/i.test(navigator.userAgent);
|
|
5
|
+
|
|
6
|
+
export const isDevelopment: boolean = window.location.href.includes(".dev") || window.location.href.includes("localhost");
|
|
7
|
+
|
|
8
|
+
export const newGuid = (): string => Guid.newGuid().toString();
|
package/dist/package.json
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "wcz-layout",
|
|
3
|
-
"license": "MIT",
|
|
4
|
-
"author": "Dalibor Homola",
|
|
5
|
-
"version": "0.1.8",
|
|
6
|
-
"main": "dist/src/index.js",
|
|
7
|
-
"module": "dist/src/index.js",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": "./dist/src/index.js"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"npm-install": "npm install",
|
|
13
|
-
"npm-update": "npm update",
|
|
14
|
-
"analyze": "cem analyze --litelement",
|
|
15
|
-
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
16
|
-
"build": "tsc && npm run analyze -- --exclude dist",
|
|
17
|
-
"prepublish": "tsc && npm run analyze -- --exclude dist",
|
|
18
|
-
"publish": "npm publish"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"guid-ts": "^1.1.2",
|
|
22
|
-
"i18next": "^22.0.6",
|
|
23
|
-
"i18next-browser-languagedetector": "^7.0.1",
|
|
24
|
-
"i18next-http-backend": "^2.0.1",
|
|
25
|
-
"keycloak-js": "^19.0.2",
|
|
26
|
-
"react-i18next": "^12.0.0"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@custom-elements-manifest/analyzer": "^0.4.17",
|
|
30
|
-
"@web/dev-server": "^0.1.28",
|
|
31
|
-
"concurrently": "^5.3.0",
|
|
32
|
-
"lit": "^2.0.2",
|
|
33
|
-
"react": "18.2.0",
|
|
34
|
-
"react-dom": "18.2.0",
|
|
35
|
-
"tslib": "^2.3.1",
|
|
36
|
-
"typescript": "^4.8.4"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"@emotion/react": "11.x",
|
|
40
|
-
"@emotion/styled": "11.x",
|
|
41
|
-
"@mui/icons-material": "5.x",
|
|
42
|
-
"@mui/material": "5.x",
|
|
43
|
-
"@tanstack/react-query": "4.x",
|
|
44
|
-
"moment": "2.x",
|
|
45
|
-
"react-router-dom": "6.x"
|
|
46
|
-
},
|
|
47
|
-
"customElements": "custom-elements.json",
|
|
48
|
-
"keycloak": {}
|
|
49
|
-
}
|