Vue.JS Integration with Console UI
The Console UI SDK helps developers integrate Console UI components into their applications, such as authentication, headers, sidebars, and modals. These components make it easier for users to navigate and access content.
This guide outlines the integration of the Console UI SDK with your application using the Vue.js library. To begin, developers should install the “console-ui-vue” package in their projects. This package includes all the essential components and utilities for seamless integration.
📘Note
Console UI is built using Vue.JS 3, and hence it is not compatible with earlier versions.
To install the package, navigate to your project directory in your terminal and run the following command:
npm install
npm install @os1-platform/console-ui-vue
This command adds the Console UI SDK to your project's dependencies, enabling developers to import and utilize it within their application.
📘 Update Console Version
You can also run the npm install @os1-platform/console-ui-vue command to update Console to the latest version.
Start the integration process by importing the OS1Provider component from the library. This component acts as a context provider, granting child components access to Console UI features.
See the Vue.JS example of how to integrate the SDK below:
Developers can provide injectable controls for headers, sidebars, or navigation bars by binding them to OS1Provider according to business requirements.
📘NOTE
It's important to note that a maximum of 3 injectable controls are allowed, each assigned a unique ID.
Learn more about How to configure different injectable controls.
Render the Toast component on your webpage using the Toast function. Each configured Toast component must have a unique element ID.
Shown below is an example of configuring a Toast component:
Use the modal function to configure modal components on your webpage. Listen for a button click event; the event.details will contain the modal element ID.
See the example below for configuring a modal component:
Use a variable containing the emitted event value from the Console UI. This variable can be combined with the current instance to listen for events emitted by injectable controls.
📘NOTE
Currently exposed events for injectableIDs are OnChangeEvent, OnBlurEvent, OnScrollEvent, OnClickEvent, OnFocusEvent, and OnSearchEvent.
Use the OS1HttpClient class to create its instance and then use that instance to call the API. Incorporate the authInitializer property from ConsoleUiContext as a constructor parameter.
Utilize the REST API method on the instance created for the OS1HttpClient.
This automatically configures headers for requests originating from NetworkClient, adding an access token, tenant ID, user info, or auth token headers to the actual request.
- withAccess
- withTid
- withUserInfo
- withAuth
Note
- By default, all of these headers are set to true. To exclude them from the request, provide the value as false against these headers.
- The access token is verified and, if expired, regenerated each time an API request is initiated.
- The x-coreos-userinfo header includes the userId, and the x-coreos-auth header contains the id_token.
- If the developer wants to use X-Coreos-Request-Id, they can pass the requestId parameter as undefined. This header is generated by the library and requires sending request headers.
Using the Help Button
Click on the “Need Help” button to query about any application or to use the product guide.
- Click on the “Raise a Ticket” button and use the “Contact Us” page, to query about any application.
- The text area is available to describe the issue in detail.
- Additionally, upload screenshots if any, as it may help to understand the issue.
- Once the query along with the details is received the support team will contact the developer.
- Click on the “Product Guide” button to learn about the product.
Changing Time Zone
Developers can change the application's timezone by using the function provided by Console UI. The convertTime function converts time, while currentTimeZone retrieves the current timezone. When the timezone is updated, the UpdateTimeZoneEvent is emitted.
convertTime function is exposed to the developers, it converts the time of the developer’s application in their desired format, and currentTimeZone function gives the developer the current timezone that is stored in the browser. When TimeZone is updated it emits an UpdateTimeZoneEvent event.
To generate an Access Token, developers can use the getAuthenticationTokens method. For user info, the getUser method can be used. Authentication status can be checked using isAuthenticated(), calling the authInitializer method from the console UI context.
Certain standard parameters are passed to all injectable controls:
- type: Specifies the type of injectable control (e.g., TextBox, TextBoxButton, AutoComplete, DropDown, SearchBox).
- width: Defines the maximum percentage width.
- placeholder: Displays placeholder text.
- id: A unique identifier for the control.
- float: An optional parameter indicating the component type.
Here, configurations for different injectable controls are provided. Up to 3 injectable controls can be used.
Configuration for adding a "textbox" in Console UI, emitting OnChange and OnBlur events.
NOTE
- Here, “attributes” is an optional parameter that holds an object defining whether any attributes should be assigned to injectable controls.
- OnChange and OnBlur events are emitted by this injectable control.
Configuration for adding a "TextBoxButton", allowing customization of button appearance:
Note
- The default value of the button is false. Developers can change the value to true for adding a TextBoxButton and can provide buttonText and buttonColor, to specify the outlook of a button.
- Here, “attributes” is an optional parameter that holds an object defining whether any attributes should be assigned to injectable controls.
- OnChange is emitted when the developer changes the text in the input box and OnClick is emitted when the user clicks on the button.
Configuration for adding a "SearchBox" with a lens icon:
Note
- LensIcon is an optional attribute, if it is set to true then lensIcon will display itself in injectable control.
- Here, “attributes” is an optional parameter that holds an object defining whether any attributes should be assigned to injectable controls.
- OnChange, onBlur, and onFocus are the events that are emitted on the input box, developers can use these events as per their app requirements.
Configuration for adding an "AutoComplete" control with dynamic options:
Note
- The functionBoundOption is passed when options are static and they can be passed in the form of [{ value: string, text: string }]. The developer can declare this as the value of this field or can pass the function that returns the value in the above-mentioned format.
- For setting options dynamically, the developer can set the hasAsyncFunctionBoundOption. Then, call functionBoundAutoCompleteOption from @os1-platform/console-ui-react and pass an array of objects and ID of autocomplete as parameters to that function.
- OnChange, onBlur, OnClick, and onScroll are the events that are emitted on the input box. Developers can use these events as per their app requirements.
Configuration for adding a "DropDown" control with options, including initial values.
Note
- The functionBoundOption is passed when options are static and can be passed in the form of [{ value: string, text: string }]. Developers can declare the string & text as the values of this field or can pass the function that returns the value in above mentioned format.
- To establish dynamic options, developers can configure the hasAsyncFunctionBoundOption parameter. Post that, they can call the functionBoundOption from @os1-platform/console-ui-react, passing an array of objects and the dropdown's ID as parameters to the function.
- To set the initial value of a dropdown, use OS1DropDownDefaultValue from @os1-platform/console-ui-react by providing the dropdown's value and ID. This can be passed only when an instance of Console UI is accessible or once Console UI has been loaded.
- OnChange, onScroll, OnClick, and onSearchEvent are the events that are emitted on the input box, developers can use these events as per their app requirements.