To create and add a new widget to Atoti UI, follow these steps:Documentation Index
Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
Use this file to discover all available pages before exploring further.
- Create a new widget file. The widget file holds the code to describe the widget.
- Use pluginWidget to make the new widget available to the UI
- Register the new widget to make it visible for users on the dashboard.
Widget file
You need to create a widget file that contains the widget component. In this example, you can name itCustomWidget.tsx.
CustomWidget is a function component that accepts WidgetPluginProps and simply returns a div containing “Hello World!”.
Plugin widget file
The widget plugin is an object containing all the information needed to register a new widget in Atoti. Here you can create a second file in the same location and call itpluginWidgetCustomWidget.ts.
This gives a final name of pluginWidgetCustomWidget.
pluginWidgetCustomWidget contains several properties:
- The component is the thing that actually gets displayed. In this case it is
CustomWidget. - The key is added to each widget to register the widget. This detail can be used to allow users to visualise the widget.
- The initialState describes the look of the widget when it is first added to a dashboard.
- icon
- translations
Register a new widget type
To use this widget in your application:- Open up
plugins.tsx. - Add
pluginWidgetCustomWidgetinto thewidgetPluginsarray.
The widgetPlugins array is eventually passed to the plugin registry. This
is how Atoti UI knows what plugins it has.
Connect a widget to the server
Depending on your needs, you may want to adduseQueryResult to the widget. This hook allows the user to run a query from the dashboard and see the retrieved data displayed in the widget.
If useQueryResult is not added to the widget, the widget does not retrieve and display data from the server.