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 plugins folder, which will store plugins.

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

To describe the plugin in the PP.xml file, use the <plugins> section:
<plugins>
    <plugin type="PP.Ui.Dashboard.MyLabel" path="../plugins/MyLabel.js" css="../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": "../plugins/MyLabel.js", //relative path to plugin JS file
        "Css": "../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 "type" attribute has the identifier that is different from the reserved ones.

    1. Restart the web server.

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

Connect a plugin in the repository

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 to work with the current repository
    mb := MetabaseClass.Active;
    
// Get object to work with plugin container
    cont := mb.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedPluginsContainer;
    
// Get object to work 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 plugin identifier and name
    plugin.Id := 
"ID"// Specify unique plugin identifier in upper case instead of "ID", identifier should match with identifier in plugin JS script structure
    plugin.Name := "name"// Specify plugin name that be displayed in dashboard instead of "name"
    // Set visualizer form and master form
    plugin.ViewForm := mb.ItemById("ViewForm_Id"); // Specify visualizer form identifier instead of "ViewForm_Id"
    plugin.MasterForm := mb.ItemById("MasterForm_Id"); // Specify master form identifier instead of "MasterForm_Id"
    // Save 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 plugin 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 plugin name and identifier
    plugin.Id := 
"ID"// Instead of "ID" specify unique plugin identifier in the upper case that matches with the identifier in plugin JS script structure
    plugin.Name := "name"// Instead of "name" specify plugin name that will be displayed in dashboard
    // Set relative path of JS script
    plugin.WebUrl := "url"// Instead of "url" specify relative path of JS script from web application root folder
    // Save 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