Show contents 

Data Analysis and Building Reports > Plugins > Connecting Plugin to Dashboard

Connecting Plugin to Dashboard

To enhance capabilities of building a dashboard one can connect a plugin.

To connect a plugin to a dashboard:

The path to the folder with installed web application:

The path to the folder with installed designer of business applications:

TIP. To facilitate the use of plugins, create the custom_plugins folder, which will store plugins.

    1. Add plugin description in the config.json/PP.xml configuration file for the web application or config.json/DBA.config.json for the designer of business applications.

In the config.json file of the web application/designer of business applications use the plugins field to describe plugin:
"plugins": [
    {
        "name": "Test", //plugin name
        "path": "./custom_plugins/Test.js", //relative path to JS file of plugin
        "css": "./custom_plugins/Test.css", //relative path to CSS file with plugin styles
        "id": "PP.Ui.Dashboard.Test", //plugin identifier corresponding to object instance type
        "params": [ //plugin opening parameters
          {
            "name": "APIKey",
            "value": "AIzaSyCT36DH2CuXQ8GHtNSZASvoxQtbidhuWCU"
          }
        ]
    },
    {
        ...
    }
]
To describe the plugin in the PP.xml file, use the <plugins> section:
<plugins>
    <plugin type="PP.Ui.Dashboard.MyLabel" path="../custom_plugins/MyLabel.js" css="../custom_plugins/MyLabel.css" loaded="false" name="MyLabel"/>
    <plugin ... />
</plugins>
To describe the plugin in the DBA.config.json file, use the plugins:
"plugins": [
    {
        "Type": "PP.Ui.Dashboard.MyLabel", //plugin identifier corresponding to object instance type
        "Path": "../custom_plugins/MyLabel.js", //relative path to JS file of plugin
        "Css": "../custom_plugins/MyLabel.css", //relative path to CSS file with plugin styles
        "Name": "MyLabel", //plugin name
        "Loaded": false //plugin loading method
    },
    {
        ...
    }
]

IMPORTANT. The following identifiers are reserved for the preset plugins: PP.Ui.Dashboard.Sankey - Sankey Chart; PP.Ui.Dashboard.Gantt - Gantt Chart; PP.Ui.Dashboard.Indicator - Indicator. Make sure that the PP.xml and DBA.config.json configuration files contain the type attribute that has the identifier that is different from the reserved ones.

In the config.json configuration file of the web application/designer of business applications plugin settings are combined, if the id attribute of the plugin matches with identifiers of preconfigured plugins.

    1. Restart the web server.

Along with the specified method, the web application allows for connecting a plugin in the repository.

Connect plugin via repository using the PP.xml file

After executing the operations, the plugin is autonomously registered on opening a dashboard in the web application. The plugin can be inserted to a dashboard.

When developing the web application by means of DHTML components connect a plugin in the repository using the KapBox constructor or the Kap.regPluginBlock method used as an independent plugin connection method.

To insert the connected plugin, execute one of the operations in the dashboard:

After executing the operations the plugin will be inserted to the dashboard as a single object.

Registering Plugin in Services

A plugin can be registered in the development environment in the Fore programming language using the ISharedPluginsContainer.Plugins property.

To register a plugin in services, add links to the Metabase and Fore system assemblies and execute the unit:

Sub UserProc;
Var
    mb: IMetabase;
    plugins: ISharedPlugins;
    cont: ISharedPluginsContainer;
    adhoc_plugs: ISharedAdhocPlugins;
    plugin: ISharedAdhocPlugin;
Begin
    // Get object for working with the current repository
    mb := MetabaseClass.Active;
    // Get object for working with plugins container
    cont := mb.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedPluginsContainer;
    // Get object for working with plugins
    plugins := cont.Plugins;
    // Get collection of plugins of the Dashboards tool
    adhoc_plugs := plugins.AdhocPlugins;
    // Create a new plugin
    plugin := plugins.AdhocPlugins.Add;
    // Set identifier and name of plugin
    plugin.Id := "ID"// Instead of "ID" specify unique identifier of plugin in upper case that matches with identifier in plugin JS script structure
    plugin.Name := "name"// Instead of "name" specify plugin name that will be displayed in dashboard
    // Set visualizer form and master form
    plugin.ViewForm := mb.ItemById("ViewForm_Id"); // Instead of "ViewForm_Id" specify visualizer form identifier
    plugin.MasterForm := mb.ItemById("MasterForm_Id"); // Instead of "MasterForm_Id" specify master form identifier
    // Save the created plugin
    (cont As IMetabaseObject).Save;
End Sub UserProc;

Sub UserProc;
Var
    mb: IMetabase;
    plugins: ISharedPlugins;
    cont: ISharedPluginsContainer;
    adhoc_plugs: ISharedAdhocPlugins;
    plugin: ISharedAdhocPlugin;
Begin
    // Get object for working with the current repository
    mb := MetabaseClass.Active;
    // Get object for working with plugins container
    cont := mb.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedPluginsContainer;
    // Get object for working with plugins
    plugins := cont.Plugins;
    // Get collection of plugins of the Dashboards tool
    adhoc_plugs := plugins.AdhocPlugins;
    // Create a new plugin
    plugin := plugins.AdhocPlugins.Add;
    // Set identifier and name of plugin
    plugin.Id := "ID"// Instead of "ID" specify unique identifier of plugin in upper case that matches with identifier in plugin JS script structure
    plugin.Name := "name"// Instead "name" specify plugin name that will be displayed in dashboard
    // Set relative path to JS script
    plugin.WebUrl := "url"// Instead of "url" specify relative path to JS script from root folder of the web application
    // Save the created plugin
    (cont As IMetabaseObject).Save;
End Sub UserProc;

After executing the unit the plugin will be registered in services and can be inserted to a dashboard.

See also:

Plugins | Creating a Plugin