@os1-platform/console-ui-react 0.8.4 → 0.9.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.
@@ -85,12 +85,12 @@ var HeaderAndSideBar = function (props) {
85
85
  var _b = (0, react_1.useState)(true), load = _b[0], setLoad = _b[1];
86
86
  (0, react_1.useEffect)(function () {
87
87
  if (!props.isLoading) {
88
- var console_1 = console_ui_js_1.ConsoleUiInit.getInstance(props.clientId, props.loginRedirectPath, props.logoutRedirectPath, props.authurl, props.orgShortName, props.devTenantId, props.appId, props.userManager);
88
+ var console_1 = console_ui_js_1.ConsoleUiInit.getInstance(props.clientId, props.loginRedirectPath, props.logoutRedirectPath, props.authurl, props.orgShortName, props.devTenantId, props.appId, props.userManager, props.interTabCommunicationRequired);
89
89
  setConsoleInstance(console_1);
90
90
  console_1.getSubscription();
91
91
  }
92
92
  }, [props.isLoading]);
93
- document === null || document === void 0 ? void 0 : document.addEventListener("OS1-SubscriptionRequestCompleted", function (e) {
93
+ document === null || document === void 0 ? void 0 : document.addEventListener('OS1-SubscriptionRequestCompleted', function (e) {
94
94
  setLoad(false);
95
95
  });
96
96
  (0, react_1.useEffect)(function () {
@@ -131,10 +131,11 @@ var HeaderAndSideBar = function (props) {
131
131
  return ((0, jsx_runtime_1.jsx)(exports.ConsoleUIContext.Provider, __assign({ value: consoleInstance }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ id: "headerAndSidebar" }, { children: props.children })) })));
132
132
  };
133
133
  var OS1Provider = function (props) {
134
- var _a = (0, react_1.useState)(''), authUrl = _a[0], setAuthUrl = _a[1];
135
- var _b = (0, react_1.useState)(''), orgShortName = _b[0], setOrgShortName = _b[1];
134
+ var _a;
135
+ var _b = (0, react_1.useState)(''), authUrl = _b[0], setAuthUrl = _b[1];
136
+ var _c = (0, react_1.useState)(''), orgShortName = _c[0], setOrgShortName = _c[1];
136
137
  // const [tenantDns, setTenantDns] = useState('');
137
- var _c = (0, react_1.useState)(false), isMountedRef = _c[0], setisMountedRef = _c[1];
138
+ var _d = (0, react_1.useState)(false), isMountedRef = _d[0], setisMountedRef = _d[1];
138
139
  var authHelper = new console_ui_js_1.AuthHelper();
139
140
  var authUrls;
140
141
  (0, react_1.useEffect)(function () {
@@ -154,16 +155,18 @@ var OS1Provider = function (props) {
154
155
  });
155
156
  })();
156
157
  }, []);
157
- return (isMountedRef ?
158
- (0, jsx_runtime_1.jsx)(OS1Provider2, { clientId: props.clientId, loginRedirectPath: props.loginRedirectPath, logoutRedirectPath: props.logoutRedirectPath, devTenantId: props.devTenantId, appId: props.appId, controls: props.controls, authUrl: authUrl, authHelper: authHelper, orgShortName: orgShortName, props: props }) : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}));
158
+ return isMountedRef ? ((0, jsx_runtime_1.jsx)(OS1Provider2, __assign({ clientId: props.clientId, loginRedirectPath: props.loginRedirectPath, logoutRedirectPath: props.logoutRedirectPath, devTenantId: props.devTenantId, appId: props.appId, controls: props.controls, authUrl: authUrl, authHelper: authHelper, orgShortName: orgShortName, interTabCommunicationRequired: (_a = props === null || props === void 0 ? void 0 : props.interTabCommunicationRequired) !== null && _a !== void 0 ? _a : false }, props))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}));
159
159
  };
160
160
  exports.OS1Provider = OS1Provider;
161
161
  var OS1Provider2 = function (props) {
162
+ var _a;
162
163
  //console.log(props);
163
- var userManager = (0, react_1.useMemo)(function () { return new console_ui_js_1.AAA(props.clientId, props.loginRedirectPath, props.logoutRedirectPath, props.devTenantId, props.authUrl); }, []);
164
+ var userManager = (0, react_1.useMemo)(function () {
165
+ return new console_ui_js_1.AAA(props.clientId, props.loginRedirectPath, props.logoutRedirectPath, props.devTenantId, props.authUrl);
166
+ }, []);
164
167
  var value = '';
165
168
  //console.log('userManager', userManager);
166
- var _a = (0, react_1.useState)(true), isLoading = _a[0], setIsLoading = _a[1];
169
+ var _b = (0, react_1.useState)(true), isLoading = _b[0], setIsLoading = _b[1];
167
170
  var isMountedRef = (0, react_1.useRef)(false);
168
171
  var authHelper = props.authHelper;
169
172
  (0, react_1.useEffect)(function () {
@@ -227,7 +230,7 @@ var OS1Provider2 = function (props) {
227
230
  isMountedRef.current = false;
228
231
  };
229
232
  }, [window.location, userManager]);
230
- return ((0, jsx_runtime_1.jsx)(exports.AuthContext.Provider, __assign({ value: value }, { children: (0, jsx_runtime_1.jsx)(HeaderAndSideBar, __assign({ userManager: userManager, isLoading: isLoading, loader: props.loader, devTenantId: props.devTenantId, controls: props.controls, appId: props.appId, authUrl: props.authUrl, orgShortName: props.orgShortName }, { children: props.props.children })) })));
233
+ return ((0, jsx_runtime_1.jsx)(exports.AuthContext.Provider, __assign({ value: value }, { children: (0, jsx_runtime_1.jsx)(HeaderAndSideBar, __assign({ userManager: userManager, isLoading: isLoading, loader: props.loader, devTenantId: props.devTenantId, controls: props.controls, appId: props.appId, authUrl: props.authUrl, orgShortName: props.orgShortName, interTabCommunicationRequired: (_a = props === null || props === void 0 ? void 0 : props.interTabCommunicationRequired) !== null && _a !== void 0 ? _a : false }, { children: props.children })) })));
231
234
  };
232
235
  // export { Toast, Modal };
233
236
  var OS1Toast = function (props) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/aaa/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA0L;AAmOxL,8FAnO2B,6BAAa,OAmO3B;AACb,oGApO0D,mCAAmB,OAoO1D;AACnB,gHArO+E,+CAA+B,OAqO/E;AAC/B,wGAtO4H,uCAAuB,OAsO5H;AArOzB,6CAAoE;AAIvD,QAAA,WAAW,GAAG,eAAK,CAAC,aAAa,CAAkB,SAAS,CAAC,CAAC;AAC9D,QAAA,gBAAgB,GAAG,eAAK,CAAC,aAAa,CAAM,SAAS,CAAC,CAAC;AAEpE,IA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AC,KAAiB;IAEjC,IAAA,iBAAS,EAAC;QACR,IAAM,aAAa,GAAG,IAAI,6BAAa,EAAE,CAAA;QACzC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAChE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,gCAAK,EAAE,EAAE,KAAK,CAAC,SAAS,GAAQ,CAAC;AAC1C,CAAC,CAAC;AAMA,4BAAQ","sourcesContent":["import { AAA, ConsoleUiInit, OS1HttpClient, OS1Components, functionBoundOption, functionBoundAutoCompleteOption, AuthHelper, OS1DropDownDefaultValue} from '@os1-platform/console-ui-js';\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { ModalProps } from '../components/modal/interface';\nimport { ToastProps } from '../components/toast/interface';\n\nexport const AuthContext = React.createContext<any | undefined>(undefined);\nexport const ConsoleUIContext = React.createContext<any>(undefined);\n\nconst HeaderAndSideBar = (props: any) => {\n const [consoleInstance, setConsoleInstance] = useState<any>(null);\n const [load, setLoad] = useState<boolean>(true);\n\n useEffect(() => {\n if (!props.isLoading) {\n const console = ConsoleUiInit.getInstance(\n props.clientId,\n props.loginRedirectPath,\n props.logoutRedirectPath,\n props.authurl,\n props.orgShortName,\n props.devTenantId,\n props.appId,\n props.userManager\n );\n\n setConsoleInstance(console);\n console.getSubscription()\n }\n }, [props.isLoading]);\n\ndocument?.addEventListener(\"OS1-SubscriptionRequestCompleted\", (e: Event) => {\n setLoad(false)\n } )\n\n useEffect(()=>{\n consoleInstance?.renderHeaderAndSidebar('headerAndSidebar', props.controls);\n }, [load])\n\n if (props.isLoading || load) {\n if (props.loader) {\n return props.loader;\n } else {\n const keyframes = `\n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n }\n }\n `;\n const styleSheets = Array.from(document.styleSheets).filter(\n (styleSheet) =>\n !styleSheet.href || styleSheet.href.startsWith(window.location.origin)\n );\n for (let style of styleSheets) {\n if (style instanceof CSSStyleSheet && style.cssRules) {\n style.insertRule(keyframes, style.cssRules.length);\n }\n }\n const loaderStyle = () => ({\n marginTop: '50vh',\n marginLeft: '50vw',\n border: '12px solid #F3F3F3',\n borderRadius: '50%',\n borderTop: '12px solid grey',\n width: '40px',\n height: '40px',\n animationName: 'spin',\n animationDuration: '2s',\n animationTimingFunction: 'linear',\n animationIterationCount: 'infinite',\n });\n return <div style={loaderStyle()}></div>;\n }\n }\n //console.log(consoleInstance, props);\n return (\n <ConsoleUIContext.Provider value={consoleInstance}>\n <div id=\"headerAndSidebar\">{props.children}</div>\n </ConsoleUIContext.Provider>\n );\n};\n\nconst OS1Provider = (props: any) => {\n const [authUrl, setAuthUrl] = useState('');\n const [orgShortName, setOrgShortName] = useState('');\n // const [tenantDns, setTenantDns] = useState('');\n let [isMountedRef, setisMountedRef] = useState<boolean>(false);\n \n const authHelper = new AuthHelper();\n let authUrls:{tenantUrl: string, orgName:string };\n useEffect(() => {\n (async function () {\n authUrls = await authHelper.getKeyCloakAuthority(\n window.location.hostname,\n props.devTenantId\n );\n setAuthUrl(authUrls.tenantUrl);\n setOrgShortName(authUrls.orgName)\n setisMountedRef(true)\n })();\n }, []);\n\n return (\n isMountedRef?\n <OS1Provider2\n clientId={props.clientId}\n loginRedirectPath={props.loginRedirectPath}\n logoutRedirectPath={props.logoutRedirectPath}\n devTenantId={props.devTenantId}\n appId={props.appId}\n controls={props.controls}\n authUrl={authUrl}\n authHelper = {authHelper}\n orgShortName= {orgShortName}\n props={...props}\n />:<></>\n );\n};\nconst OS1Provider2 = (props: any) => {\n //console.log(props);\n const userManager = useMemo(()=>new AAA(\n props.clientId,\n props.loginRedirectPath,\n props.logoutRedirectPath,\n props.devTenantId,\n props.authUrl\n ),[])\n const value = '';\n //console.log('userManager', userManager);\n const [isLoading, setIsLoading] = useState(true);\n let isMountedRef = useRef<boolean>(false);\n const { authHelper } = props;\n\n useEffect(() => {\n // Store current isMounted since this could change while awaiting async operations below\n isMountedRef.current = true;\n (async () => {\n let user = undefined;\n try {\n user = await userManager!.getUserInfo();\n } catch (error: any) {\n\n }\n /**\n * Check if the user is returning back from OIDC and throws error.\n */\n if (authHelper.hasErrorInUrl(window.location)){\n \n await userManager.logout();\n return\n }\n /**\n * Check if the user is returning back from OIDC.\n */\n if (authHelper.hasCodeInUrl(window.location)) {\n try{\n await userManager?.logincallback();\n }catch (error: any) {\n window.console.log('Error: ', error);\n await userManager.logout()\n }\n authHelper.cleanBrowserUrl();\n setIsLoading(false);\n return;\n }\n\n if (!(await userManager?.isAuthenticated())) {\n userManager?.login();\n } else if (isMountedRef.current) {\n setIsLoading(false);\n }\n })();\n\n return () => {\n isMountedRef.current = false;\n };\n }, [window.location, userManager]);\n\n\n return (\n <AuthContext.Provider value={value}>\n <HeaderAndSideBar\n userManager={userManager}\n isLoading={isLoading}\n loader={props.loader}\n devTenantId={props.devTenantId}\n controls={props.controls}\n appId={props.appId}\n authUrl={props.authUrl}\n orgShortName= {props.orgShortName}\n >\n {props.props.children}\n </HeaderAndSideBar>\n </AuthContext.Provider>\n );\n};\n\n// export { Toast, Modal };\n\nconst OS1Toast = (props: ToastProps) => {\n\n useEffect(() => {\n const os1Components = new OS1Components()\n os1Components.renderToast(props.elementId, props.toastConfig);\n }, []);\n\n return <div id={props.elementId}></div>;\n};\n\nconst OS1Modal = (props: ModalProps) => {\n\n useEffect(() => {\n const os1Components = new OS1Components()\n os1Components.renderModal(props.elementId, props.modalConfig);\n }, []);\n\n return <div id={props.elementId}></div>;\n};\n\n\nexport {\n OS1Provider,\n OS1Toast,\n OS1Modal,\n OS1HttpClient,\n functionBoundOption,\n functionBoundAutoCompleteOption,\n OS1DropDownDefaultValue\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/aaa/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AK,aAAL,KAAK,uBAAL,KAAK,CAAE,6BAA6B,mCAAI,KAAK,gBAG9C,KAAK,CAAC,QAAQ,IACE,IACE,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,2BAA2B;AAE3B,IAAM,QAAQ,GAAG,UAAC,KAAiB;IACjC,IAAA,iBAAS,EAAC;QACR,IAAM,aAAa,GAAG,IAAI,6BAAa,EAAE,CAAC;QAC1C,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAChE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,gCAAK,EAAE,EAAE,KAAK,CAAC,SAAS,GAAQ,CAAC;AAC1C,CAAC,CAAC;AAaA,4BAAQ;AAXV,IAAM,QAAQ,GAAG,UAAC,KAAiB;IACjC,IAAA,iBAAS,EAAC;QACR,IAAM,aAAa,GAAG,IAAI,6BAAa,EAAE,CAAC;QAC1C,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAChE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,gCAAK,EAAE,EAAE,KAAK,CAAC,SAAS,GAAQ,CAAC;AAC1C,CAAC,CAAC;AAKA,4BAAQ","sourcesContent":["import {\n AAA,\n ConsoleUiInit,\n OS1HttpClient,\n OS1Components,\n functionBoundOption,\n functionBoundAutoCompleteOption,\n AuthHelper,\n OS1DropDownDefaultValue,\n} from '@os1-platform/console-ui-js';\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { ModalProps } from '../components/modal/interface';\nimport { ToastProps } from '../components/toast/interface';\n\nexport const AuthContext = React.createContext<any | undefined>(undefined);\nexport const ConsoleUIContext = React.createContext<any>(undefined);\n\nconst HeaderAndSideBar = (props: any) => {\n const [consoleInstance, setConsoleInstance] = useState<any>(null);\n const [load, setLoad] = useState<boolean>(true);\n\n useEffect(() => {\n if (!props.isLoading) {\n const console = ConsoleUiInit.getInstance(\n props.clientId,\n props.loginRedirectPath,\n props.logoutRedirectPath,\n props.authurl,\n props.orgShortName,\n props.devTenantId,\n props.appId,\n props.userManager,\n props.interTabCommunicationRequired\n );\n\n setConsoleInstance(console);\n console.getSubscription();\n }\n }, [props.isLoading]);\n\n document?.addEventListener('OS1-SubscriptionRequestCompleted', (e: Event) => {\n setLoad(false);\n });\n\n useEffect(() => {\n consoleInstance?.renderHeaderAndSidebar('headerAndSidebar', props.controls);\n }, [load]);\n\n if (props.isLoading || load) {\n if (props.loader) {\n return props.loader;\n } else {\n const keyframes = `\n @-webkit-keyframes spin {\n 0% {\n -webkit-transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n }\n }\n `;\n const styleSheets = Array.from(document.styleSheets).filter(\n (styleSheet) =>\n !styleSheet.href || styleSheet.href.startsWith(window.location.origin)\n );\n for (let style of styleSheets) {\n if (style instanceof CSSStyleSheet && style.cssRules) {\n style.insertRule(keyframes, style.cssRules.length);\n }\n }\n const loaderStyle = () => ({\n marginTop: '50vh',\n marginLeft: '50vw',\n border: '12px solid #F3F3F3',\n borderRadius: '50%',\n borderTop: '12px solid grey',\n width: '40px',\n height: '40px',\n animationName: 'spin',\n animationDuration: '2s',\n animationTimingFunction: 'linear',\n animationIterationCount: 'infinite',\n });\n return <div style={loaderStyle()}></div>;\n }\n }\n //console.log(consoleInstance, props);\n return (\n <ConsoleUIContext.Provider value={consoleInstance}>\n <div id=\"headerAndSidebar\">{props.children}</div>\n </ConsoleUIContext.Provider>\n );\n};\n\nconst OS1Provider = (props: any) => {\n const [authUrl, setAuthUrl] = useState('');\n const [orgShortName, setOrgShortName] = useState('');\n // const [tenantDns, setTenantDns] = useState('');\n let [isMountedRef, setisMountedRef] = useState<boolean>(false);\n\n const authHelper = new AuthHelper();\n let authUrls: { tenantUrl: string; orgName: string };\n useEffect(() => {\n (async function () {\n authUrls = await authHelper.getKeyCloakAuthority(\n window.location.hostname,\n props.devTenantId\n );\n setAuthUrl(authUrls.tenantUrl);\n setOrgShortName(authUrls.orgName);\n setisMountedRef(true);\n })();\n }, []);\n\n return isMountedRef ? (\n <OS1Provider2\n clientId={props.clientId}\n loginRedirectPath={props.loginRedirectPath}\n logoutRedirectPath={props.logoutRedirectPath}\n devTenantId={props.devTenantId}\n appId={props.appId}\n controls={props.controls}\n authUrl={authUrl}\n authHelper={authHelper}\n orgShortName={orgShortName}\n interTabCommunicationRequired={\n props?.interTabCommunicationRequired ?? false\n }\n {...props}\n />\n ) : (\n <></>\n );\n};\nconst OS1Provider2 = (props: any) => {\n //console.log(props);\n const userManager = useMemo(\n () =>\n new AAA(\n props.clientId,\n props.loginRedirectPath,\n props.logoutRedirectPath,\n props.devTenantId,\n props.authUrl\n ),\n []\n );\n const value = '';\n //console.log('userManager', userManager);\n const [isLoading, setIsLoading] = useState(true);\n let isMountedRef = useRef<boolean>(false);\n const { authHelper } = props;\n\n useEffect(() => {\n // Store current isMounted since this could change while awaiting async operations below\n isMountedRef.current = true;\n (async () => {\n let user = undefined;\n try {\n user = await userManager!.getUserInfo();\n } catch (error: any) {}\n /**\n * Check if the user is returning back from OIDC and throws error.\n */\n if (authHelper.hasErrorInUrl(window.location)) {\n await userManager.logout();\n return;\n }\n /**\n * Check if the user is returning back from OIDC.\n */\n if (authHelper.hasCodeInUrl(window.location)) {\n try {\n await userManager?.logincallback();\n } catch (error: any) {\n window.console.log('Error: ', error);\n await userManager.logout();\n }\n authHelper.cleanBrowserUrl();\n setIsLoading(false);\n return;\n }\n\n if (!(await userManager?.isAuthenticated())) {\n userManager?.login();\n } else if (isMountedRef.current) {\n setIsLoading(false);\n }\n })();\n\n return () => {\n isMountedRef.current = false;\n };\n }, [window.location, userManager]);\n\n return (\n <AuthContext.Provider value={value}>\n <HeaderAndSideBar\n userManager={userManager}\n isLoading={isLoading}\n loader={props.loader}\n devTenantId={props.devTenantId}\n controls={props.controls}\n appId={props.appId}\n authUrl={props.authUrl}\n orgShortName={props.orgShortName}\n interTabCommunicationRequired={\n props?.interTabCommunicationRequired ?? false\n }\n >\n {props.children}\n </HeaderAndSideBar>\n </AuthContext.Provider>\n );\n};\n\n// export { Toast, Modal };\n\nconst OS1Toast = (props: ToastProps) => {\n useEffect(() => {\n const os1Components = new OS1Components();\n os1Components.renderToast(props.elementId, props.toastConfig);\n }, []);\n\n return <div id={props.elementId}></div>;\n};\n\nconst OS1Modal = (props: ModalProps) => {\n useEffect(() => {\n const os1Components = new OS1Components();\n os1Components.renderModal(props.elementId, props.modalConfig);\n }, []);\n\n return <div id={props.elementId}></div>;\n};\n\nexport {\n OS1Provider,\n OS1Toast,\n OS1Modal,\n OS1HttpClient,\n functionBoundOption,\n functionBoundAutoCompleteOption,\n OS1DropDownDefaultValue,\n};\n"]}
@@ -7,4 +7,4 @@ export declare const ConsoleUIContext: React.Context<any>;
7
7
  declare const OS1Provider: (props: any) => JSX.Element;
8
8
  declare const OS1Toast: (props: ToastProps) => JSX.Element;
9
9
  declare const OS1Modal: (props: ModalProps) => JSX.Element;
10
- export { OS1Provider, OS1Toast, OS1Modal, OS1HttpClient, functionBoundOption, functionBoundAutoCompleteOption, OS1DropDownDefaultValue };
10
+ export { OS1Provider, OS1Toast, OS1Modal, OS1HttpClient, functionBoundOption, functionBoundAutoCompleteOption, OS1DropDownDefaultValue, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@os1-platform/console-ui-react",
3
- "version": "0.8.4",
3
+ "version": "0.9.0",
4
4
  "description": "React wrapper for console-ui library",
5
5
  "main": "dist/commonjs/aaa/index.js",
6
6
  "types": "dist/commonjs/types/aaa/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@fullhuman/postcss-purgecss": "^5.0.0",
30
- "@os1-platform/console-ui-js": "0.8.4",
30
+ "@os1-platform/console-ui-js": "0.9.0",
31
31
  "@react-native-community/eslint-config": "^2.0.0",
32
32
  "@types/react": "^17.0.37",
33
33
  "axios": "^0.21.4",
package/readme.md CHANGED
@@ -76,7 +76,7 @@
76
76
  <OS1Toast elementId={"toastElement"} toastConfig={toastConfig} />
77
77
  ```
78
78
 
79
- NOTE: Each toast element that is to be rendered on the page should be given a unique elementId.
79
+ NOTE: Each toast element that is to be rendered on the page should be given a unique elementId.
80
80
 
81
81
  6. Use the Modal function to render a modal component in your webpage.
82
82
  For example:
@@ -96,13 +96,10 @@
96
96
  },
97
97
  ],
98
98
  };
99
- <OS1Modal
100
- elementId={'modalElement'}
101
- modalConfig={modalConfig}
102
- />;
99
+ <OS1Modal elementId={'modalElement'} modalConfig={modalConfig} />;
103
100
  ```
104
101
 
105
- Note:- Listen to event when button is clicked, `event.details` will contain the modal element Id.
102
+ Note:- Listen to event when button is clicked, `event.details` will contain the modal element Id.
106
103
 
107
104
  7. Use state variable of `ConsoleUIContext` context to listen to events emitted by injectable controls. This instance is usually passed as a prop to apps.
108
105
  For example:
@@ -124,13 +121,16 @@
124
121
 
125
122
  ```javascript
126
123
  import { OS1HttpClient } from '@os1-platform/console-ui-react';
127
- if (consoleInstane) {
128
- var client = new OS1HttpClient(consoleInstane.authInitializer, `https://abc.domain.com`); // Base url is set in OS1HttpClient class.
129
- }
124
+ if (consoleInstane) {
125
+ var client = new OS1HttpClient(
126
+ consoleInstane.authInitializer,
127
+ `https://abc.domain.com`
128
+ ); // Base url is set in OS1HttpClient class.
129
+ }
130
130
  ```
131
131
 
132
132
  9. Use REST api methods, on the instance created for OS1HttpClient.
133
- Following headers are automatically configured to requests originating from the `NetworkClient` adding Access token(`x-coreos-access`) or Tenant id(`x-coreos-tid`) or User info(`x-coreos-userinfo`) or Auth token(`x-coreos-auth`) headers to the actual request.
133
+ Following headers are automatically configured to requests originating from the `NetworkClient` adding Access token(`x-coreos-access`) or Tenant id(`x-coreos-tid`) or User info(`x-coreos-userinfo`) or Auth token(`x-coreos-auth`) headers to the actual request.
134
134
 
135
135
  - `withAccess`
136
136
  - `withTid`
@@ -146,38 +146,47 @@
146
146
  5. If you want to use `X-Coreos-Request-Id`, that is generated by library and also need to send request headers, then send requestId parameter as `undefined`.
147
147
 
148
148
  ```javascript
149
-
150
149
  const handleClick = () => {
151
- //here consoleInstance is the state variable of ConsoleUIContext;
152
- if (consoleInstance) {
153
- const client = new OS1HttpClient(consoleInstance.authInitializer, `https://abc.domain.com`); //consoleInstance.authInitializer is an instance of AAA class that we get from ConsoleUi Context
154
- const reqHeaders: any = {
155
- withAccess: false,
156
- withTid: false,
157
- withUserInfo: false,
158
- withAuth: false,
159
- };
160
- client.get(`/users`).then(response => {
161
- console.log("api response", response.data)
162
- }).catch(function (err) {
163
- console.error('error', err);
164
- });
165
-
166
- // this example covers case when requestId is generated from console and requestHeaders are passed
167
- client.post(`/todos`,{ "todo": "study" }, undefined, reqHeaders).then(response => {
168
- console.log("api response", response.data)
169
- }).catch(function (err) {
170
- console.error('error', err);
171
- });
150
+ //here consoleInstance is the state variable of ConsoleUIContext;
151
+ if (consoleInstance) {
152
+ const client = new OS1HttpClient(
153
+ consoleInstance.authInitializer,
154
+ `https://abc.domain.com`
155
+ ); //consoleInstance.authInitializer is an instance of AAA class that we get from ConsoleUi Context
156
+ const reqHeaders: any = {
157
+ withAccess: false,
158
+ withTid: false,
159
+ withUserInfo: false,
160
+ withAuth: false,
172
161
  };
162
+ client
163
+ .get(`/users`)
164
+ .then((response) => {
165
+ console.log('api response', response.data);
166
+ })
167
+ .catch(function (err) {
168
+ console.error('error', err);
169
+ });
170
+
171
+ // this example covers case when requestId is generated from console and requestHeaders are passed
172
+ client
173
+ .post(`/todos`, { todo: 'study' }, undefined, reqHeaders)
174
+ .then((response) => {
175
+ console.log('api response', response.data);
176
+ })
177
+ .catch(function (err) {
178
+ console.error('error', err);
179
+ });
180
+ }
173
181
  };
174
182
  ```
175
183
 
176
184
  10. Click on Need Help button in case you want to query about any application or want to use product guide.
177
- - Click on `Raise a Ticket` button and Use Contact Us page, if you want to query about any application.
178
- - We provide text area to describe the issue in details.
179
- - We provide option to upload screenshots if any, that may help to understand the issue.
180
- - We will get the query along with your details and we can contact you.`
185
+
186
+ - Click on `Raise a Ticket` button and Use Contact Us page, if you want to query about any application.
187
+ - We provide text area to describe the issue in details.
188
+ - We provide option to upload screenshots if any, that may help to understand the issue.
189
+ - We will get the query along with your details and we can contact you.`
181
190
  - Click on `Product Guide` button to learn about the product.
182
191
 
183
192
  11. Option to change the timezone of the application. At initital load, time zone will be tenant specific but user can change the time zone according to his choice and it will be stored in his browser's local Storage.
@@ -194,13 +203,14 @@
194
203
  }
195
204
  ```
196
205
 
197
- 13. We have provided that defines how user navigates on Routing of tabs. Users can choose, how they want to navigate apps i.e. they want to open the app on new tab or the current tab. This is done by going into user preference in profile dropdown and select the choice in Set App Redirect Behaviour. For the first time, it will ask how, we want to redirect our apps.
206
+ 13. We have provided that defines how user navigates on Routing of tabs. Users can choose, how they want to navigate apps i.e. they want to open the app on new tab or the current tab. This is done by going into user preference in profile dropdown and select the choice in Set App Redirect Behaviour. For the first time, it will ask how, we want to redirect our apps.
198
207
 
199
208
  14. When user clicks on subroutes, then event naming `changeRoutes` is emitted, which contains the details of subMenu apps and their parent app details like appId, appUrl and appName.
200
209
 
201
210
  15. If nothing is selected then, when user clicks on app for the first time, it asks how we want to redirect the app.
202
211
 
203
212
  16. To get Access Token, use `getAuthenticationTokens` method, for userInfo, use `getUser`, and check whether user is authenticated use `isAuthenticated()`. User have to use context of consoleUi and call authInitializer method of it. `getTenantConfigurations` method, to get all the organization based tenant data.
213
+
204
214
  ```Javascript
205
215
  if (consoleInstance) {
206
216
  const accessToken = await consoleInstance.authInitializer.getAuthenticationTokens();
@@ -210,27 +220,49 @@
210
220
  }
211
221
  ```
212
222
 
213
-
214
223
  17. Link to acceess [example app](https://github.com/OS1-logistics/vehicle-reference-app/tree/console-v2-integration)
215
224
 
216
-
217
225
  18. #### Integration guidelines for Rest Api Calls Using console UI Axios Client:-
218
- - Console has already exposed the `OS1HttpClient` class that accepts all HTTP methods.
219
- - Wherever the user wants to send a callback url in their api call, they have to mention it like a placeholder naming `{{SSE_CALLBACK}}`. Console will look for this placeholder and replace it with a callback url.
226
+
227
+ - Console has already exposed the `OS1HttpClient` class that accepts all HTTP methods.
228
+ - Wherever the user wants to send a callback url in their api call, they have to mention it like a placeholder naming `{{SSE_CALLBACK}}`. Console will look for this placeholder and replace it with a callback url.
220
229
  - Internally this function will establish the sse connection and obtain the callback url from the server. Application developers just need to provide the parameter in api request where the callback url needs to be set.
221
230
 
222
- - Console will make an api call by intercepting the request. Once callback is received from the server, the callback data is sent to the UI as a custom event named: `SSECallBackEvent`
231
+ - **Having intertab communication:** The SSE console will make one connection per browser per user agent. If it is not enabled, it will make a new connection for each tab. All events will initially be sent to the master tab, which is the tab that has established the SSE connection. After that, the events will be shared with other tabs.
232
+ - **Broadcasting to different users:** Each tab can subscribe to the topic(s). Any message broadcasted to topic(s) will be delivered to their subscribers.
233
+
234
+ ##### Enabling inter-tab communication:-
235
+
236
+ To enable inter-tab communication, set the interTabCommunicationRequired flag to true, while initializing the console UI. if not set, it defaults to false.
223
237
 
224
238
  ```javascript
225
- // here consoleInstance is an instance that is being created for consoleUI Context while initialization of console UI
226
- document.addEventListener(`${consoleInstance.events().SSECallBackEvent}`, (eventData) => {
227
- // This event Data can be used further as per the usage of app
228
- })
239
+ <OS1Provider
240
+ clientId={process.env.REACT_APP_CLIENT_ID}
241
+ loginRedirectPath={'/redirectPath'}
242
+ logoutRedirectPath={'/logoutPath'}
243
+ appId={process.env.REACT_APP_INITIAL_APP_ID}
244
+ controls={controls}
245
+ interTabCommunicationRequired={true} // here it is set as true
246
+ >
247
+ <Initiate setConsole={handleConsoleInstanceChange} />
248
+ </OS1Provider>
249
+ ```
250
+
251
+ - Console will make an api call by intercepting the request. Once callback is received from the server, the callback data is sent to the UI as a custom event named: `SSECallBackEvent`
229
252
 
253
+ ```javascript
254
+ // here consoleInstance is an instance that is being created for consoleUI Context while initialization of console UI
255
+ document.addEventListener(
256
+ `${consoleInstance.events().SSECallBackEvent}`,
257
+ (eventData) => {
258
+ // This event Data can be used further as per the usage of app
259
+ }
260
+ );
230
261
  ```
262
+
231
263
  - Users can set the callback url in their url path, query, payload or in headers.
232
- - If any internal error is there while making a connection, It will be thrown back as an error and an api call will be made with null as callback url.
233
- - Retriable errors like re-establishing connection will not be thrown as those will be retried internally. Only fatal errors along with api errors are thrown in following format:-
264
+ - If any internal error is there while making a connection, It will be thrown back as an error and an api call will be made with null as callback url.
265
+ - Retriable errors like re-establishing connection will not be thrown as those will be retried internally. Only fatal errors along with api errors are thrown in following format:-
234
266
 
235
267
  ```javascript
236
268
  "error": {
@@ -243,108 +275,115 @@
243
275
  Example to implement this mentioned below.
244
276
 
245
277
  - Users can pass the placeholder for callback url as a parameter, body or header in an api and from there a message can be sent.
246
- ```javascript
247
- const dto = getDtoFromDisplay(data);
248
- dto['callback'] = "{{SSE_CALLBACK}}"
249
- // here client is the context of consoleUI that is set at the time of initialization.
250
- const axiosClient = new OS1HttpClient(client.authInitializer, `${process.env.REACT_APP_BASE_URL}`);
251
-
252
- try {
253
- await axiosClient.post(
254
- '/vehicles',
255
- Dto, // payload for api
256
- 'createVehicles',
257
- { withAuth: false }, // request headers for not sending token headers, this optional parameter
258
- {
259
- headers: { // custom headers passed, this is optional parameter
260
- 'Callback': "{{SSE_CALLBACK}}",
261
- 'Content-Type': 'application/json',
262
- }
263
- });
264
- return;
265
- } catch (error) {
266
- console.error('error', error);
267
- }
268
278
 
279
+ ```javascript
280
+ const dto = getDtoFromDisplay(data);
281
+ dto['callback'] = '{{SSE_CALLBACK}}';
282
+ // here client is the context of consoleUI that is set at the time of initialization.
283
+ const axiosClient = new OS1HttpClient(
284
+ client.authInitializer,
285
+ `${process.env.REACT_APP_BASE_URL}`
286
+ );
287
+
288
+ try {
289
+ await axiosClient.post(
290
+ '/vehicles',
291
+ Dto, // payload for api
292
+ 'createVehicles',
293
+ { withAuth: false }, // request headers for not sending token headers, this optional parameter
294
+ {
295
+ headers: {
296
+ // custom headers passed, this is optional parameter
297
+ 'Callback': '{{SSE_CALLBACK}}',
298
+ 'Content-Type': 'application/json',
299
+ },
300
+ }
301
+ );
302
+ return;
303
+ } catch (error) {
304
+ console.error('error', error);
305
+ }
269
306
  ```
307
+
270
308
  - Here, in the above mentioned example `{{SSE_CALLBACK}}`, is passed in payload as well as in custom headers. Console Will replace this variable from the callback url and make an api call.
271
309
  - When msg is received on the client side, an event naming SSECallBackEvent is emitted and the user can listen to this event using document.addEventListener.
272
310
 
273
- ``` Javascript
311
+ ```Javascript
274
312
  // here consoleInstance is an instance that is being created for consoleUI Context while initialization of console UI
275
313
  document.addEventListener(`${consoleInstance.events().SSECallBackEvent}`, (eventData) => {
276
314
  // This event Data can be used further as per the usage of app
277
- })
278
- // For better performance use removeEventListener to clean up this event listener.
315
+ })
316
+ // For better performance use removeEventListener to clean up this event listener.
279
317
 
280
318
  ```
281
319
 
282
320
  #### Approach for rest and graphql api both-
321
+
283
322
  - Console has exposed OS1HttpClient to make api calls. To use Server Side Events in apps, users need to instantiate the OS1HttpClient class. Even if they make their api calls with any other way instead of console axios client.
284
- ```Javascript
285
- const cl = new OS1HttpClient(props.console.authInitializer, 'https://abc.sandbox.getos1.com');
286
- // here, the first parameter is the console UI context and the second parameter is the domain url for which api call is to be made
287
- ```
288
- - In `OS1HttpCLien`t, we have exposed the `getEventBrokerUrl` function to make Server side connection(example is added below). This function returns the callback url that has been established after successful connection establishment. When the callback url is already present, it will just increase the timer for the sliding window so that connection will persist longer for that particular url.
289
- - A callback url returned from the function, can be set in a state, to be used in the api call.
290
- - For optimized behavior, can use UseEffect hook to optimize the update of state. When the api needs to be triggered, users can check whether the callback url that is present in their state is different from the callback url received from the callback function. If it's different, then just update the state and return, else just call the api with the callback url that is stored in state.
291
- - Another approach is, users can maintain their global state or context, and store the callback url in it. Then whenever they need to make an api call just pass that context or state in their api. But they need to make sure that the getEventBrokerUrl function is called before an api call as it will always guarantee that the callback url is still active.
292
- Example:-
293
- ```Javascript
294
- const [ callBackUrl, setCallBackUrl] = useState(null)
295
- useEffect(()=>{
296
- callEvent()
297
- }, [callBackUrl])
298
-
299
- if (props.console) { //consoleInstance that is set at console Initialization
300
- var cl = new OS1HttpClient(props.console.authInitializer,
301
- 'https://os1devs.sandbox.getos1.com');
302
- }
303
- //This function is called whenever user want to make an api call
304
- const handleHandshake = async () => {
305
- const callbackResponse = await cl.getEventBrokerUrl()
306
- if (callBackUrl && callbackResponse.callback === callBackUrl){
307
- callEvent()
308
- } else {
309
- setCallBackUrl(callbackResponse.callback)
310
- }
311
- }
312
323
 
324
+ ```Javascript
325
+ const cl = new OS1HttpClient(props.console.authInitializer, 'https://abc.sandbox.getos1.com');
326
+ // here, the first parameter is the console UI context and the second parameter is the domain url for which api call is to be made
327
+ ```
328
+
329
+ - In `OS1HttpCLien`t, we have exposed the `getEventBrokerUrl` function to make Server side connection(example is added below). This function returns the callback url that has been established after successful connection establishment. When the callback url is already present, it will just increase the timer for the sliding window so that connection will persist longer for that particular url.
330
+ - A callback url returned from the function, can be set in a state, to be used in the api call. - For optimized behavior, can use UseEffect hook to optimize the update of state. When the api needs to be triggered, users can check whether the callback url that is present in their state is different from the callback url received from the callback function. If it's different, then just update the state and return, else just call the api with the callback url that is stored in state. - Another approach is, users can maintain their global state or context, and store the callback url in it. Then whenever they need to make an api call just pass that context or state in their api. But they need to make sure that the getEventBrokerUrl function is called before an api call as it will always guarantee that the callback url is still active.
331
+ Example:-
313
332
 
314
- //Sample function to make an api call with generated callback url
315
- function callEvent(){
316
- if (props.console) {
317
- cl.post(`/core/api/v1/aaa/apps`,{
318
- properties: {"availability":true,"fuelType":"CNG","operatorId":"op-1" },
319
- callBackUrl} // payload passed
320
- )
321
- .then(response => {
322
- console.log("api response", response.data)
323
- })
324
- .catch(function (err) {
325
- console.error('error in api call', err);
326
- });
327
- }
333
+ ```Javascript
334
+ const [ callBackUrl, setCallBackUrl] = useState(null)
335
+ useEffect(()=>{
336
+ callEvent()
337
+ }, [callBackUrl])
338
+
339
+ if (props.console) { //consoleInstance that is set at console Initialization
340
+ var cl = new OS1HttpClient(props.console.authInitializer,
341
+ 'https://os1devs.sandbox.getos1.com');
342
+ }
343
+ //This function is called whenever user want to make an api call
344
+ const handleHandshake = async () => {
345
+ const callbackResponse = await cl.getEventBrokerUrl()
346
+ if (callBackUrl && callbackResponse.callback === callBackUrl){
347
+ callEvent()
348
+ } else {
349
+ setCallBackUrl(callbackResponse.callback)
350
+ }
328
351
  }
329
- ```
330
-
331
- Here, in the above example:-
332
- - When the user calls handleHandshake function, then a call to establish connection is made and a callback url is received.
333
- - This callback url is being set to a state and can be used in an api call as a path, query, header or as a body.
334
- - After an api call is made and a message can be sent to that callback url from the backend application and UI application can listen to those messages via `SSECallBackEvent` that is exposed:
352
+
353
+
354
+ //Sample function to make an api call with generated callback url
355
+ function callEvent(){
356
+ if (props.console) {
357
+ cl.post(`/core/api/v1/aaa/apps`,{
358
+ properties: {"availability":true,"fuelType":"CNG","operatorId":"op-1" },
359
+ callBackUrl} // payload passed
360
+ )
361
+ .then(response => {
362
+ console.log("api response", response.data)
363
+ })
364
+ .catch(function (err) {
365
+ console.error('error in api call', err);
366
+ });
367
+ }
368
+ }
369
+ ```
370
+
371
+ Here, in the above example:- - When the user calls handleHandshake function, then a call to establish connection is made and a callback url is received. - This callback url is being set to a state and can be used in an api call as a path, query, header or as a body. - After an api call is made and a message can be sent to that callback url from the backend application and UI application can listen to those messages via `SSECallBackEvent` that is exposed:
335
372
 
336
373
  ```Javascript
337
374
  // here consoleInstance is an instance that is being created for consoleUI Context while initialization of console UI
338
-
375
+
339
376
  document.addEventListener(`${consoleInstance.events().SSECallBackEvent}`, (eventData) => {
340
377
  // This event Data can be used further as per the usage of app
341
- })
378
+ })
342
379
  // For better performance use removeEventListener to clean up this event listener.
343
380
 
344
381
  ```
345
382
 
346
383
  ### SSE Callback Event Payload:-
347
- - Event payload that will come from `SSECallBackEvent` will look like this:-
384
+
385
+ - Event payload that will come from `SSECallBackEvent` will look like this:-
386
+
348
387
  ```Javascript
349
388
  {
350
389
  "payload": {
@@ -365,46 +404,158 @@ var cl = new OS1HttpClient(props.console.authInitializer,
365
404
  "agentTimestamp": 1699251799605,
366
405
  "consoleTimestamp": 1699251800245
367
406
  }
368
- }
407
+ }
369
408
  ```
370
409
 
371
410
  - Here, in the above mentioned example. Object will come under the detail property of the event.
372
- - The object contains a payload property that contains `data, consoleTimestamp, agentTimeStamp, BrokerTimeStamp, eventId and X-COREOS-REQUEST-ID`.
373
- - The data property contains the response that has been received by callback url.
411
+ - The object contains a payload property that contains `data, consoleTimestamp, agentTimeStamp, BrokerTimeStamp, eventId and X-COREOS-REQUEST-ID`.
412
+ - The data property contains the response that has been received by callback url.
413
+
414
+ ##### BroadCasting event to users
415
+
416
+ - This guide details the integration of Server-Side Events (SSE) using the OS1HttpClient class provided by the Console, allowing for real-time communication from server to client in your application. There are two ways to implement Server Side Events (SSE) broadcasting feature in your application:
417
+ - ##### Prerequisites before using broadcasting feature:-
374
418
 
419
+ - To use broadcasting features, developers must set the interTabCommunicationRequired flag to true for their app. They need to subscribe to topic(s) they want to listen to the broadcast messages.The maximum number of topics that can be broadcast at a time is five. There should be no commas in topic names.
375
420
 
421
+ - #### Subscribing a Topic:
422
+
423
+ - Developers can subscribe to topics by calling the `subscribeBroadcastTopic` function and passing the desired topic name. It is essential to note that each app has a limit of 10 topics and a maximum of 10 subscribers per topic. To make the most out of these limits, topics should be specific and tailored to the events they represent. This would enable targeted events within the limits while ensuring precision. Therefore, specific topic names that reflect granular contexts should stay within the subscriber limits.
424
+
425
+ ```javascript
426
+ await cl.subscribeBroadCastTopic([
427
+ 'dispatch:e3956ddf-e7a2-4a9e-914a-ddace6a9d701',
428
+ 'facility:326e7698-c039-416a-a697-768e9bbb451c:dispatches',
429
+ ]);
430
+ ```
431
+
432
+ - #### Using the {{SSE_BroadCast}} Placeholder
433
+ This is the simplest option if using the Console’s Axios client.
434
+ - **Step 1:** Setting the Broadcast URL Parameter
435
+ When making an API call, specify the attribute where the broadcast url is expected on the backend and its value needs to be set by using the placeholder `{{SSE_BROADCAST(topicNames)}}`. The Console will automatically detect and replace this placeholder with the actual broadcast URL. Developers can pass the callback attribute in the request URL, headers, or the request body.
436
+ The example below adds `{{SSE_BROADCAST(topicNames)}}` to the header for the createVehicles request.
437
+ ```javascript
438
+ try {
439
+ await axiosClient.post(
440
+ '/vehicles',
441
+ dto, // The payload for the API call
442
+ 'createVehicles', // The operation or function being called
443
+ { withAuth: false }, // Options, set to false if authentication is not required
444
+ {
445
+ headers: {
446
+ 'Callback':
447
+ '{{SSE_BROADCAST(dispatch:e3956ddf-e7a2-4a9e-914a-ddace6a9d701, facility:326e7698-c039-416a-a697-768e9bbb451c:dispatches)}}', // Updated automatically by the Axios Client
448
+ 'Content-Type': 'application/json', // Set the content type of the request
449
+ },
450
+ }
451
+ );
452
+ } catch (error) {
453
+ console.error('error', error);
454
+ }
455
+ ```
456
+
457
+ ### Calling the broadCastEvents
458
+
459
+ - When you are ready to make an API call, ensure that the brodacastEvents function is invoked to broadcast events. This function will accept the topicNames on which it needs to broadcast and payload which needs to be passed. See the example code below:
460
+
461
+ ```javascript
462
+ const broadcast = await cl.broadCastEvents(
463
+ ['dispatch:e3956ddf-e7a2-4a9e-914a-ddace6a9d701'],
464
+ payload
465
+ );
466
+ ```
467
+
468
+ #### Broadcast Event payload
469
+
470
+ ```javascript
471
+ {
472
+ "data": {
473
+ "businessCommand": "participantsboatsEntityCreate",
474
+ "callbackMeta": {},
475
+ "commandName": "ParticipantCreationSuccessEvent",
476
+ "data": {
477
+ "appId": "participants",
478
+ "createdAt": "1707463018469",
479
+ "createdBy": {
480
+ "id": "1",
481
+ "name": "vehicle-consoleUi"
482
+ },
483
+ "entityName": "boats",
484
+ "isActive": true,
485
+ "name": "sjdsadghafja",
486
+ "owner": "tenants:436a9b2c-5f79-5b51-92ba-2da25050dd36",
487
+ "properties": {
488
+ "availability": true,
489
+ "failurereason": "",
490
+ "fuelType": "CNG",
491
+ "inprogress": false,
492
+ "isfail": false,
493
+ "mode": "sdhavdhha",
494
+ "operatorId": "hdad",
495
+ "processingstage": "isActive",
496
+ "servicecode": "",
497
+ "system": false
498
+ },
499
+ "state": {
500
+ "current": "onboarding:onboarding",
501
+ "transitions": [
502
+ "active:active"
503
+ ]
504
+ },
505
+ "uniqueCode": "bjhgfajdf",
506
+ "updatedAt": "1707463018469",
507
+ "updatedBy": {
508
+ "id": "1",
509
+ "name": "vehicle-consoleUi"
510
+ },
511
+ "id": "boats:c6cf6d0c-7024-5925-90d9-a803b59df46f"
512
+ },
513
+ "requestId": "d133e887-e52b-47dc-80ca-9f4228708cab",
514
+ "tenantId": "developsln1"
515
+ },
516
+ "eventId": "e5462690-e8b1-49e6-a082-82bad87ee70d",
517
+ "X-COREOS-REQUEST-ID": "",
518
+ "brokerTimestamp": 1707463018742,
519
+ "agentTimestamp": 1707463018747,
520
+ "topics": [
521
+ "TenantId:app:0641372d-802aaeb4:Test17"
522
+ ],
523
+ "type": "broadcast", // by this we are distinguishing between broadcast and callback
524
+ "consoleTimestamp": 1707463018796
525
+ }
526
+
527
+ ```
376
528
 
377
529
  ## Configuration for Injectable Controls offered by the Library
378
530
 
379
- #### Common parameters, that will be passed in all injectable controls:-
380
- - **type:-** This field shows the type of injectable controls that is being used. Available types are TextBox, TextBoxButton, AutoComplete, DropDown, SearchBox
381
- - **width:-** This field shows the maximum percentage of width that can be passed.
382
- - **placeholder:-** This field displays the placeholder text, that is passed in injectable control.
531
+ #### Common parameters, that will be passed in all injectable controls:-
532
+
533
+ - **type:-** This field shows the type of injectable controls that is being used. Available types are TextBox, TextBoxButton, AutoComplete, DropDown, SearchBox
534
+ - **width:-** This field shows the maximum percentage of width that can be passed.
535
+ - **placeholder:-** This field displays the placeholder text, that is passed in injectable control.
383
536
  - **id:-** This is unique id that is given to injectable controls that uniquely identifies that particular component.
384
537
  - **float:-** This is optional component, by default every component is left floated.
385
538
 
386
-
387
539
  ##### TextBox:-
388
540
 
389
541
  - To use textbox in console ui, we provide following configuration:-
390
542
 
391
543
  ```javascript
392
544
  {
393
- type: "TextBox",
394
- width: 100,
545
+ type: "TextBox",
546
+ width: 100,
395
547
  placeholder: "Search Package",
396
- float: "left",
397
- id: "TextBox1"
548
+ float: "left",
549
+ id: "TextBox1"
398
550
  attributes: {
399
551
  maxlength: “50”;
400
- }
552
+ }
401
553
  }
402
554
  ```
403
555
 
404
- - **Note:-**
405
- - Here, attributes is an optional attributes parameter that contains object which defines if any attribute needs to be set to injectable controls.
406
- - OnChange and OnBlur event is emitted by this injectable control.
407
-
556
+ - **Note:-**
557
+ - Here, attributes is an optional attributes parameter that contains object which defines if any attribute needs to be set to injectable controls.
558
+ - OnChange and OnBlur event is emitted by this injectable control.
408
559
 
409
560
  ##### TextBoxButton:-
410
561
 
@@ -412,23 +563,24 @@ var cl = new OS1HttpClient(props.console.authInitializer,
412
563
 
413
564
  ```javascript
414
565
  {
415
- type: "TextBoxButton",
416
- width: 100,
417
- placeholder: "Search Package",
418
- float: "left",
566
+ type: "TextBoxButton",
567
+ width: 100,
568
+ placeholder: "Search Package",
569
+ float: "left",
419
570
  id: "TextBoxButton1"
420
571
  attributes: {
421
572
  maxlength: “50”;
422
- }
423
- button: true,
424
- buttonText: “Search”,
573
+ }
574
+ button: true,
575
+ buttonText: “Search”,
425
576
  buttonColor: “red”
426
577
  }
427
578
  ```
428
- - **Note:-**
429
- - Here button by default set to false, but if we set it to true, then we have to pass buttonText and buttonColor, which specifies the outlook of a button
430
- - Here, attributes is an optional attributes parameter that contains object which defines if any attribute needs to be set to injectable controls.
431
- - OnChange is emitted when we change text in input box and OnClick is emitted when user clicks on button.
579
+
580
+ - **Note:-**
581
+ - Here button by default set to false, but if we set it to true, then we have to pass buttonText and buttonColor, which specifies the outlook of a button
582
+ - Here, attributes is an optional attributes parameter that contains object which defines if any attribute needs to be set to injectable controls.
583
+ - OnChange is emitted when we change text in input box and OnClick is emitted when user clicks on button.
432
584
 
433
585
  ##### Search Box:-
434
586
 
@@ -436,20 +588,20 @@ var cl = new OS1HttpClient(props.console.authInitializer,
436
588
 
437
589
  ```javascript
438
590
  {
439
- type: "SearchBox",
440
- width: 100,
591
+ type: "SearchBox",
592
+ width: 100,
441
593
  placeholder: "Search Package",
442
- float: "right",
594
+ float: "right",
443
595
  id: "SearchBox1"
444
- attributes: { maxlength: “50”; }
445
- lensIcon: true
596
+ attributes: { maxlength: “50”; }
597
+ lensIcon: true
446
598
  }
447
599
  ```
448
600
 
449
- - **Note:-**
450
- - Here lensIcon is optional, if it is set to true then lensIcon will be shown in injectable control.
451
- - Here, attributes is an optional attributes parameter that contains object which defines if any attribute needs to be set to injectable controls.
452
- - OnChange, onBlur, onFocus is emitted on input box.
601
+ - **Note:-**
602
+ - Here lensIcon is optional, if it is set to true then lensIcon will be shown in injectable control.
603
+ - Here, attributes is an optional attributes parameter that contains object which defines if any attribute needs to be set to injectable controls.
604
+ - OnChange, onBlur, onFocus is emitted on input box.
453
605
 
454
606
  ##### AutoComplete:-
455
607
 
@@ -457,27 +609,29 @@ var cl = new OS1HttpClient(props.console.authInitializer,
457
609
 
458
610
  ```javascript
459
611
  {
460
- type: "AutoComplete",
461
- width: 100,
462
- placeholder: "Search Package",
612
+ type: "AutoComplete",
613
+ width: 100,
614
+ placeholder: "Search Package",
463
615
  float: "right",
464
- id: "AutcoComplete1"
616
+ id: "AutcoComplete1"
465
617
  functionBoundOption: autoComplete(), // This field can be a function which return array of Objects or normal array of objects in the form of [{ value: string, text: string }],
466
618
  }
467
619
  ```
468
- - **Note:-**
469
- - In this `functionBoundOption` is passed when options are static and they can be passed in the form of [{ value: string, text: string }], User can declare this as value of this field or can pass the function that returns the value in above mentioned format.
470
- - For setting options dynamically, user can set `hasAsyncFunctionBoundOption`, then they can call `functionBoundAutoCompleteOption` from `@os1-platform/console-ui-react` and pass array of objects and id of autocomplete as parameters to that function.
471
-
472
- ``` javascript
473
- import {functionBoundAutoCompleteOption} from '@os1-platform/console-ui-react';
474
-
475
- if (consoleInstance){
476
- functionBoundAutoCompleteOption(autoCompleteValues,"AutoComplete1" ) // here firstParament is a variable that contains the array of objects that needs to be present in dropdown. Second parameter contains the id of dropdown on which we want to load the values
477
- }
478
- ```
479
- - OnChange, onBlur, OnClick, OnScroll is emitted on this injectable controls
480
620
 
621
+ - **Note:-**
622
+
623
+ - In this `functionBoundOption` is passed when options are static and they can be passed in the form of [{ value: string, text: string }], User can declare this as value of this field or can pass the function that returns the value in above mentioned format.
624
+ - For setting options dynamically, user can set `hasAsyncFunctionBoundOption`, then they can call `functionBoundAutoCompleteOption` from `@os1-platform/console-ui-react` and pass array of objects and id of autocomplete as parameters to that function.
625
+
626
+ ```javascript
627
+ import { functionBoundAutoCompleteOption } from '@os1-platform/console-ui-react';
628
+
629
+ if (consoleInstance) {
630
+ functionBoundAutoCompleteOption(autoCompleteValues, 'AutoComplete1'); // here firstParament is a variable that contains the array of objects that needs to be present in dropdown. Second parameter contains the id of dropdown on which we want to load the values
631
+ }
632
+ ```
633
+
634
+ - OnChange, onBlur, OnClick, OnScroll is emitted on this injectable controls
481
635
 
482
636
  ##### DropDown:-
483
637
 
@@ -494,19 +648,28 @@ var cl = new OS1HttpClient(props.console.authInitializer,
494
648
  throttleTime: 300 // this is an optional parameter which enables to set throttletime for on scroll Event. By default it is 500 ms.
495
649
  }
496
650
  ```
497
- - **Note:-**
498
- - In this `functionBoundOption` is passed when options are static and they can be passed in the form of [{ value: string, text: string }], User can declare this as value of this field or can pass the function that returns the value in above mentioned format.
499
- - For setting options dynamically, user can set `hasAsyncFunctionBoundOption`, then they can call `functionBoundOption` from `@os1-platform/console-ui-react` and pass array of objects and id of dropdown as parameters to that function.
500
- - For setting initial Value to dropdown, `OS1DropDownDefaultValue` from `@os1-platform/console-ui-react` needs to be passed with value and id of dropdown. It can only be passed when instance of console UI is available or console UI has been loaded.
501
- ``` javascript
502
- import {functionBoundOption, OS1DropDownDefaultValue} from '@os1-platform/console-ui-react';
503
-
504
- if (consoleInstance){
505
- functionBoundOption(dropDownValues,"Dropdown1" ) // here firstParament is a variable that contains the array of objects that needs to be present in dropdown. Second parameter contains the id of dropdown on which we want to load the values
506
- OS1DropDownDefaultValue('initialValue', "DropDown1"); // Here first parameter contains the value that needs to passed as initialValue, second Parameter is the id of the dropdown on which Id, needs to be set.
507
- }
508
- ```
509
- - OnChange, onScroll, OnClick, OnSearch, OnBlur is emitted on this injectable controls
651
+
652
+ - **Note:-**
653
+
654
+ - In this `functionBoundOption` is passed when options are static and they can be passed in the form of [{ value: string, text: string }], User can declare this as value of this field or can pass the function that returns the value in above mentioned format.
655
+ - For setting options dynamically, user can set `hasAsyncFunctionBoundOption`, then they can call `functionBoundOption` from `@os1-platform/console-ui-react` and pass array of objects and id of dropdown as parameters to that function.
656
+ - For setting initial Value to dropdown, `OS1DropDownDefaultValue` from `@os1-platform/console-ui-react` needs to be passed with value and id of dropdown. It can only be passed when instance of console UI is available or console UI has been loaded.
657
+
658
+ ```javascript
659
+ import {
660
+ functionBoundOption,
661
+ OS1DropDownDefaultValue,
662
+ } from '@os1-platform/console-ui-react';
663
+
664
+ if (consoleInstance) {
665
+ functionBoundOption(dropDownValues, 'Dropdown1'); // here firstParament is a variable that contains the array of objects that needs to be present in dropdown. Second parameter contains the id of dropdown on which we want to load the values
666
+ OS1DropDownDefaultValue('initialValue', 'DropDown1'); // Here first parameter contains the value that needs to passed as initialValue, second Parameter is the id of the dropdown on which Id, needs to be set.
667
+ }
668
+ ```
669
+
670
+ - OnChange, onScroll, OnClick, OnSearch, OnBlur is emitted on this injectable controls
671
+
510
672
  ## Configuration required in Next.js projects.
511
- - In Next.js, we need to have some library that supports global CSS.
512
- - One of these library is `next-global-css`, we require to import `withGlobalCss` from it and wrap our configuration within it. [Link to configure next-global-css](https://www.npmjs.com/package/next-global-css)
673
+
674
+ - In Next.js, we need to have some library that supports global CSS.
675
+ - One of these library is `next-global-css`, we require to import `withGlobalCss` from it and wrap our configuration within it. [Link to configure next-global-css](https://www.npmjs.com/package/next-global-css)