SDKs & Sample Apps
...
SDKs
Console SDK

Vue.JS Integration with Console UI

25min

Overview

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.

Step 1: Installation

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.

Step 2: Integration of the SDK

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:

JS


Step 3: Providing Controls

Developers can provide injectable controls for headers, sidebars, or navigation bars by binding them to OS1Provider according to business requirements.

JS


📘NOTE

It's important to note that a maximum of 3 injectable controls are allowed, each assigned a unique ID.

Step 4: Adding the Toast Component

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:

JS


Step 5: Adding the Modal 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:

JS


Step 6: Using a Variable

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.

JS


📘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.

JS


Step 7: Configuring Headers

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

  1. By default, all of these headers are set to true. To exclude them from the request, provide the value as false against these headers.
  2. The access token is verified and, if expired, regenerated each time an API request is initiated.
  3. The x-coreos-userinfo header includes the userId, and the x-coreos-auth header contains the id_token.
  4. 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.
JS


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.

JS


Step 8: Generating Access Token

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.

JS


Configuration for Injectable Controls offered

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.

How to configure different Injectable Controls in the Console UI

Here, configurations for different injectable controls are provided. Up to 3 injectable controls can be used.

Textbox

Configuration for adding a "textbox" in Console UI, emitting OnChange and OnBlur events.

JS


NOTE

  • Here, “attributesis 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.

TextBoxButton

Configuration for adding a "TextBoxButton", allowing customization of button appearance:

JS


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, “attributesis 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.

SearchBox

Configuration for adding a "SearchBox" with a lens icon:

JS


Note

  • LensIcon is an optional attribute, if it is set to true then lensIcon will display itself in injectable control.
  • Here, “attributesis 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.

AutoComplete

Configuration for adding an "AutoComplete" control with dynamic options:

JS


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.
JS

  • 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.

DropDown

Configuration for adding a "DropDown" control with options, including initial values.

JS


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.
JS

  • 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.