wcz-test 2.4.0 → 2.6.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 +16 -88
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.ts +0 -345
package/dist/index.js
CHANGED
|
@@ -1121,6 +1121,9 @@ var RouterError = ({ error }) => {
|
|
|
1121
1121
|
] }) });
|
|
1122
1122
|
};
|
|
1123
1123
|
|
|
1124
|
+
// src/index.ts
|
|
1125
|
+
import { PageContainer, PageHeader } from "@toolpad/core/PageContainer";
|
|
1126
|
+
|
|
1124
1127
|
// src/providers/LayoutProvider.tsx
|
|
1125
1128
|
import { LinearProgress, useMediaQuery } from "@mui/material";
|
|
1126
1129
|
|
|
@@ -1153,9 +1156,7 @@ import { useThemeProps } from "@mui/material/styles";
|
|
|
1153
1156
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1154
1157
|
var _excluded = ["localeText"];
|
|
1155
1158
|
var MuiPickersAdapterContext = /* @__PURE__ */ React4.createContext(null);
|
|
1156
|
-
if (process.env.NODE_ENV !== "production")
|
|
1157
|
-
MuiPickersAdapterContext.displayName = "MuiPickersAdapterContext";
|
|
1158
|
-
}
|
|
1159
|
+
if (process.env.NODE_ENV !== "production") MuiPickersAdapterContext.displayName = "MuiPickersAdapterContext";
|
|
1159
1160
|
var LocalizationProvider = function LocalizationProvider2(inProps) {
|
|
1160
1161
|
const {
|
|
1161
1162
|
localeText: inLocaleText
|
|
@@ -1221,6 +1222,7 @@ var LocalizationProvider = function LocalizationProvider2(inProps) {
|
|
|
1221
1222
|
children
|
|
1222
1223
|
});
|
|
1223
1224
|
};
|
|
1225
|
+
if (process.env.NODE_ENV !== "production") LocalizationProvider.displayName = "LocalizationProvider";
|
|
1224
1226
|
process.env.NODE_ENV !== "production" ? LocalizationProvider.propTypes = {
|
|
1225
1227
|
// ----------------------------- Warning --------------------------------
|
|
1226
1228
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -1887,8 +1889,8 @@ var ToolbarAccount = () => {
|
|
|
1887
1889
|
setAnchorEl(null);
|
|
1888
1890
|
setTimeout(() => setTab("settings"), 300);
|
|
1889
1891
|
};
|
|
1890
|
-
const
|
|
1891
|
-
const
|
|
1892
|
+
const login = () => user.login();
|
|
1893
|
+
const logout = () => user.logout();
|
|
1892
1894
|
const changeTab = (newTab) => () => setTab(newTab);
|
|
1893
1895
|
const settings = /* @__PURE__ */ jsxs6(List, { component: "nav", subheader: /* @__PURE__ */ jsx11(ListSubheader, { sx: { backgroundColor: "transparent" }, children: t("Layout.Settings") }), children: [
|
|
1894
1896
|
/* @__PURE__ */ jsxs6(ListItemButton, { onClick: changeTab("theme"), sx: { py: 0.3 }, children: [
|
|
@@ -1937,11 +1939,11 @@ var ToolbarAccount = () => {
|
|
|
1937
1939
|
/* @__PURE__ */ jsx11("br", {}),
|
|
1938
1940
|
/* @__PURE__ */ jsx11("span", { children: user.department })
|
|
1939
1941
|
] }) }) }),
|
|
1940
|
-
/* @__PURE__ */ jsxs6(ListItemButton, { onClick:
|
|
1942
|
+
/* @__PURE__ */ jsxs6(ListItemButton, { onClick: logout, children: [
|
|
1941
1943
|
/* @__PURE__ */ jsx11(ListItemIcon, { children: /* @__PURE__ */ jsx11(Logout, { color: "error" }) }),
|
|
1942
1944
|
/* @__PURE__ */ jsx11(ListItemText, { primary: t("Layout.Logout") })
|
|
1943
1945
|
] })
|
|
1944
|
-
] }) : /* @__PURE__ */ jsxs6(ListItemButton, { onClick:
|
|
1946
|
+
] }) : /* @__PURE__ */ jsxs6(ListItemButton, { onClick: login, children: [
|
|
1945
1947
|
/* @__PURE__ */ jsx11(ListItemIcon, { children: /* @__PURE__ */ jsx11(Login, { color: "success" }) }),
|
|
1946
1948
|
/* @__PURE__ */ jsx11(ListItemText, { primary: t("Layout.LogIn") })
|
|
1947
1949
|
] }) }),
|
|
@@ -1963,83 +1965,6 @@ import { useTranslation as useTranslation4 } from "react-i18next";
|
|
|
1963
1965
|
// src/utils/ClientUtils.ts
|
|
1964
1966
|
import { useQueryClient } from "@tanstack/react-query";
|
|
1965
1967
|
import axios from "axios";
|
|
1966
|
-
|
|
1967
|
-
// src/services/UserService.ts
|
|
1968
|
-
import Keycloak from "keycloak-js";
|
|
1969
|
-
var keycloakConfig = {
|
|
1970
|
-
url: import.meta.env.VITE_KEYCLOAK_URL,
|
|
1971
|
-
realm: import.meta.env.VITE_KEYCLOAK_REALM,
|
|
1972
|
-
clientId: import.meta.env.VITE_KEYCLOAK_CLIENT_ID,
|
|
1973
|
-
idpHint: import.meta.env.VITE_KEYCLOAK_IDP_HINT,
|
|
1974
|
-
confidentialClientId: import.meta.env.VITE_KEYCLOAK_CONFIDENTIAL_CLIENT_ID,
|
|
1975
|
-
confidentialClientSecret: import.meta.env.VITE_KEYCLOAK_CONFIDENTIAL_CLIENT_SECRET
|
|
1976
|
-
};
|
|
1977
|
-
var _kc = new Keycloak({
|
|
1978
|
-
url: keycloakConfig.url,
|
|
1979
|
-
realm: keycloakConfig.realm,
|
|
1980
|
-
clientId: keycloakConfig.clientId
|
|
1981
|
-
});
|
|
1982
|
-
var initKeycloak = async () => {
|
|
1983
|
-
if (typeof window === "undefined") return;
|
|
1984
|
-
const authenticated = await _kc.init({ onLoad: "check-sso" });
|
|
1985
|
-
if (authenticated) {
|
|
1986
|
-
return await loadUserInfo();
|
|
1987
|
-
} else {
|
|
1988
|
-
await _kc.login({ idpHint: keycloakConfig.idpHint });
|
|
1989
|
-
return await loadUserInfo();
|
|
1990
|
-
}
|
|
1991
|
-
};
|
|
1992
|
-
var login = _kc.login;
|
|
1993
|
-
var logout = _kc.logout;
|
|
1994
|
-
var getToken = () => {
|
|
1995
|
-
if (_kc.token) {
|
|
1996
|
-
return _kc.token;
|
|
1997
|
-
} else {
|
|
1998
|
-
return getConfidentialToken();
|
|
1999
|
-
}
|
|
2000
|
-
};
|
|
2001
|
-
var getConfidentialToken = async () => {
|
|
2002
|
-
const { confidentialClientId, confidentialClientSecret, url, realm } = keycloakConfig;
|
|
2003
|
-
if (!confidentialClientId || !confidentialClientSecret)
|
|
2004
|
-
throw new Error("Confidential client id or secret is missing");
|
|
2005
|
-
const credentials = btoa(`${confidentialClientId}:${confidentialClientSecret}`);
|
|
2006
|
-
const urlencoded = new URLSearchParams({ grant_type: "client_credentials" });
|
|
2007
|
-
const response = await fetch(`${url}/realms/${realm}/protocol/openid-connect/token`, {
|
|
2008
|
-
method: "POST",
|
|
2009
|
-
headers: {
|
|
2010
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
2011
|
-
"Authorization": `Basic ${credentials}`
|
|
2012
|
-
},
|
|
2013
|
-
body: urlencoded
|
|
2014
|
-
});
|
|
2015
|
-
if (!response.ok)
|
|
2016
|
-
throw new Error("Failed to obtain confidential token");
|
|
2017
|
-
const data = await response.json();
|
|
2018
|
-
return data.access_token;
|
|
2019
|
-
};
|
|
2020
|
-
var updateToken = () => _kc.updateToken(30).catch(login);
|
|
2021
|
-
var hasRole = (roles) => roles.some((role) => _kc.hasRealmRole(role) || _kc.hasResourceRole(role));
|
|
2022
|
-
var loadUserInfo = async () => {
|
|
2023
|
-
const user2 = await _kc.loadUserInfo();
|
|
2024
|
-
return {
|
|
2025
|
-
name: user2.name,
|
|
2026
|
-
employeeId: user2.employeeId?.toUpperCase() ?? "",
|
|
2027
|
-
department: user2.department ?? "",
|
|
2028
|
-
email: user2.email,
|
|
2029
|
-
company: user2.company,
|
|
2030
|
-
category: user2.category
|
|
2031
|
-
};
|
|
2032
|
-
};
|
|
2033
|
-
var UserService = {
|
|
2034
|
-
initKeycloak,
|
|
2035
|
-
login,
|
|
2036
|
-
logout,
|
|
2037
|
-
getToken,
|
|
2038
|
-
updateToken,
|
|
2039
|
-
hasRole
|
|
2040
|
-
};
|
|
2041
|
-
|
|
2042
|
-
// src/utils/ClientUtils.ts
|
|
2043
1968
|
var Platform = class {
|
|
2044
1969
|
static isAndroid = /android/i.test(navigator.userAgent);
|
|
2045
1970
|
static isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
@@ -2072,9 +1997,6 @@ var rootRouteHead = ({ title, themeColor }) => () => ({
|
|
|
2072
1997
|
});
|
|
2073
1998
|
var wczApiClient = axios.create();
|
|
2074
1999
|
wczApiClient.interceptors.request.use(async (config) => {
|
|
2075
|
-
await UserService.updateToken();
|
|
2076
|
-
const token = await UserService.getToken();
|
|
2077
|
-
config.headers.Authorization = `Bearer ${token}`;
|
|
2078
2000
|
return config;
|
|
2079
2001
|
});
|
|
2080
2002
|
var WISTRON_PRIMARY_COLOR = "#00506E";
|
|
@@ -2223,7 +2145,11 @@ var LayoutProvider = (props) => {
|
|
|
2223
2145
|
const appTitle = rootRouterState.meta?.find((meta) => meta?.title)?.title;
|
|
2224
2146
|
if (!appTitle)
|
|
2225
2147
|
throw new Error("Title is not defined in the RootRoute head.");
|
|
2226
|
-
return /* @__PURE__ */ jsx13(LocalizationProvider, { dateAdapter: AdapterDayjs, adapterLocale: i18n2.resolvedLanguage, children: /* @__PURE__ */ jsx13(TanstackRouterAppProvider, { navigation, theme,
|
|
2148
|
+
return /* @__PURE__ */ jsx13(LocalizationProvider, { dateAdapter: AdapterDayjs, adapterLocale: i18n2.resolvedLanguage, children: /* @__PURE__ */ jsx13(TanstackRouterAppProvider, { navigation, theme, localeText: {
|
|
2149
|
+
confirm: t("Layout.Confirm"),
|
|
2150
|
+
cancel: t("Layout.Cancel"),
|
|
2151
|
+
alert: t("Layout.Alert")
|
|
2152
|
+
}, children: /* @__PURE__ */ jsx13(NotificationsProvider, { slotProps: { snackbar: { anchorOrigin: { vertical: isLargeScreen ? "top" : "bottom", horizontal: "center" } } }, children: /* @__PURE__ */ jsx13(LayoutContext.Provider, { value: { appTitle }, children: /* @__PURE__ */ jsxs7(
|
|
2227
2153
|
DashboardLayout,
|
|
2228
2154
|
{
|
|
2229
2155
|
defaultSidebarCollapsed: true,
|
|
@@ -2711,6 +2637,8 @@ export {
|
|
|
2711
2637
|
ChipInputCell,
|
|
2712
2638
|
EditableColumnHeader,
|
|
2713
2639
|
LayoutProvider,
|
|
2640
|
+
PageContainer,
|
|
2641
|
+
PageHeader,
|
|
2714
2642
|
Platform,
|
|
2715
2643
|
RouterButton,
|
|
2716
2644
|
RouterError,
|