@os1-platform/console-ui-react 0.7.3 → 0.8.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/commonjs/aaa/index.js +1 -1
- package/dist/commonjs/aaa/index.js.map +1 -1
- package/package.json +2 -2
- package/readme.md +161 -0
|
@@ -153,7 +153,7 @@ var OS1Provider = function (props) {
|
|
|
153
153
|
exports.OS1Provider = OS1Provider;
|
|
154
154
|
var OS1Provider2 = function (props) {
|
|
155
155
|
//console.log(props);
|
|
156
|
-
var userManager = new console_ui_js_1.AAA(props.clientId, props.loginRedirectPath, props.logoutRedirectPath, props.devTenantId, props.authUrl);
|
|
156
|
+
var userManager = (0, react_1.useMemo)(function () { return new console_ui_js_1.AAA(props.clientId, props.loginRedirectPath, props.logoutRedirectPath, props.devTenantId, props.authUrl); }, []);
|
|
157
157
|
var value = '';
|
|
158
158
|
//console.log('userManager', userManager);
|
|
159
159
|
var _a = (0, react_1.useState)(true), isLoading = _a[0], setIsLoading = _a[1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/aaa/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA0L;AAwNxL,8FAxN2B,6BAAa,OAwN3B;AACb,oGAzN0D,mCAAmB,OAyN1D;AACnB,gHA1N+E,+CAA+B,OA0N/E;AAC/B,wGA3N4H,uCAAuB,OA2N5H;AA1NzB,6CAA2D;AAI9C,QAAA,WAAW,GAAG,eAAK,CAAC,aAAa,CAAkB,SAAS,CAAC,CAAC;AAC9D,QAAA,gBAAgB,GAAG,eAAK,CAAC,aAAa,CAAM,SAAS,CAAC,CAAC;AAEpE,IAAM,gBAAgB,GAAG,UAAC,KAAU;IAC5B,IAAA,KAAwC,IAAA,gBAAQ,EAAM,IAAI,CAAC,EAA1D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EAAE,SAAS,EACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,YAAY,EAAG,KAAK,CAAC,YAAY,gBAEhC,KAAK,CAAC,KAAK,CAAC,QAAQ,IACJ,IACE,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,2BAA2B;AAE3B,IAAM,QAAQ,GAAG,UAAC,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;AAeA,4BAAQ;AAbV,IAAM,QAAQ,GAAG,UAAC,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, 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\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.renderHeaderAndSidebar('headerAndSidebar', props.controls);\n }\n }, [props.isLoading]);\n\n if (props.isLoading) {\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 = 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 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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA0L;AAwNxL,8FAxN2B,6BAAa,OAwN3B;AACb,oGAzN0D,mCAAmB,OAyN1D;AACnB,gHA1N+E,+CAA+B,OA0N/E;AAC/B,wGA3N4H,uCAAuB,OA2N5H;AA1NzB,6CAAoE;AAIvD,QAAA,WAAW,GAAG,eAAK,CAAC,aAAa,CAAkB,SAAS,CAAC,CAAC;AAC9D,QAAA,gBAAgB,GAAG,eAAK,CAAC,aAAa,CAAM,SAAS,CAAC,CAAC;AAEpE,IAAM,gBAAgB,GAAG,UAAC,KAAU;IAC5B,IAAA,KAAwC,IAAA,gBAAQ,EAAM,IAAI,CAAC,EAA1D,eAAe,QAAA,EAAE,kBAAkB,QAAuB,CAAC;IAElE,IAAA,iBAAS,EAAC;QACR,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;YACpB,IAAM,SAAO,GAAG,6BAAa,CAAC,WAAW,CACvC,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,iBAAiB,EACvB,KAAK,CAAC,kBAAkB,EACxB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC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AY,gBAEhC,KAAK,CAAC,KAAK,CAAC,QAAQ,IACJ,IACE,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,2BAA2B;AAE3B,IAAM,QAAQ,GAAG,UAAC,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;AAeA,4BAAQ;AAbV,IAAM,QAAQ,GAAG,UAAC,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\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.renderHeaderAndSidebar('headerAndSidebar', props.controls);\n }\n }, [props.isLoading]);\n\n if (props.isLoading) {\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 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 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os1-platform/console-ui-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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": "
|
|
30
|
+
"@os1-platform/console-ui-js": "0.8.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
|
@@ -213,6 +213,167 @@
|
|
|
213
213
|
|
|
214
214
|
17. Link to acceess [example app](https://github.com/OS1-logistics/vehicle-reference-app/tree/console-v2-integration)
|
|
215
215
|
|
|
216
|
+
|
|
217
|
+
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.
|
|
220
|
+
- 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
|
+
|
|
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`
|
|
223
|
+
|
|
224
|
+
```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
|
+
})
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
- 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:-
|
|
234
|
+
|
|
235
|
+
```javascript
|
|
236
|
+
"error": {
|
|
237
|
+
"code": "200101",
|
|
238
|
+
"description": "There is a problem in SSE connection from server end"
|
|
239
|
+
},
|
|
240
|
+
"status": 503
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Example to implement this mentioned below.
|
|
244
|
+
|
|
245
|
+
- 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
|
+
|
|
269
|
+
```
|
|
270
|
+
- 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
|
+
- 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
|
+
|
|
273
|
+
``` Javascript
|
|
274
|
+
// here consoleInstance is an instance that is being created for consoleUI Context while initialization of console UI
|
|
275
|
+
document.addEventListener(`${consoleInstance.events().SSECallBackEvent}`, (eventData) => {
|
|
276
|
+
// 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.
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
#### Approach for rest and graphql api both-
|
|
283
|
+
- 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
|
+
|
|
313
|
+
|
|
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
|
+
}
|
|
328
|
+
}
|
|
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:
|
|
335
|
+
|
|
336
|
+
```Javascript
|
|
337
|
+
// here consoleInstance is an instance that is being created for consoleUI Context while initialization of console UI
|
|
338
|
+
|
|
339
|
+
document.addEventListener(`${consoleInstance.events().SSECallBackEvent}`, (eventData) => {
|
|
340
|
+
// This event Data can be used further as per the usage of app
|
|
341
|
+
})
|
|
342
|
+
// For better performance use removeEventListener to clean up this event listener.
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### SSE Callback Event Payload:-
|
|
347
|
+
- Event payload that will come from `SSECallBackEvent` will look like this:-
|
|
348
|
+
```Javascript
|
|
349
|
+
{
|
|
350
|
+
"payload": {
|
|
351
|
+
"data": {
|
|
352
|
+
"name": "Mini Truck 3",
|
|
353
|
+
"owner": "tenants:cfecb885-e060-514a-b4f7-0094cf6f48e2",
|
|
354
|
+
"properties": {
|
|
355
|
+
"availability": true,
|
|
356
|
+
"fuelType": "CNG",
|
|
357
|
+
"mode": "truck",
|
|
358
|
+
"operatorId": "op-2342"
|
|
359
|
+
},
|
|
360
|
+
"uniqueCode": "2b8d45f6-7c6c-11ee-b962-0242ac120002"
|
|
361
|
+
},
|
|
362
|
+
"eventId": "ebd31aad-7712-441e-b376-b59cf1e23d06",
|
|
363
|
+
"X-COREOS-REQUEST-ID": "f52d1676-002a-4968-abcc-c3a651537670",
|
|
364
|
+
"brokerTimestamp": 1699251799599,
|
|
365
|
+
"agentTimestamp": 1699251799605,
|
|
366
|
+
"consoleTimestamp": 1699251800245
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
- 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.
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
216
377
|
## Configuration for Injectable Controls offered by the Library
|
|
217
378
|
|
|
218
379
|
#### Common parameters, that will be passed in all injectable controls:-
|