Data Analysis and Building Reports > Plugins > Connecting Plugin to Dashboard
To enhance capabilities of building a dashboard one can connect a plugin.
To connect a plugin to a dashboard:
In the web application and in the designer of business applications:
Add the plugin files <plugin name>.js and <plugin name>.css to the folder with installed web application or designer of business applications:
The path to the folder with installed web application:
If plugin description is added in the config.json configuration file:
In Linux OS: /opt/foresight/fp10.x-webserver/r.
In Windows OS: C:\Program Files (x86)\Foresight\Analytics Platform 10.x Web Application\r.
If plugin description is added in the PP.xml configuration file:
In Linux OS: /opt/foresight/fp10.x-webserver.
In Windows OS: C:\Program Files (x86)\Foresight\Analytics Platform 10.x Web Application.
The path to the folder with installed designer of business applications:
If the designer of business applications back end is installed automatically on Apache2 or manually on ASP.NET:
In Linux OS: /opt/foresight/fp10.x-dba.
In Windows OS: C:\Program Files (x86)\Foresight\DBA_10.x. The DBA_10.x folder is created manually and may differ.
If the designer of business applications back end is installed manually on Apache2, Java or automatically on ASP.NET:
In Linux OS: /opt/foresight/dba/10.x.
In Windows OS: C:\Program Files (x86)\Foresight\Designer of Business Application 10.x Web Server.
TIP. To facilitate the use of plugins, create the custom_plugins folder, which will store plugins.
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.
"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"
}
]
},
{
...
}
]
<plugins>
<plugin type="PP.Ui.Dashboard.MyLabel" path="../custom_plugins/MyLabel.js" css="../custom_plugins/MyLabel.css" loaded="false" name="MyLabel"/>
<plugin ... />
</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.
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.
In the desktop application register a plugin in services. After executing the operation the plugin will be registered in common resources and can be inserted to a dashboard.
To insert the connected plugin, execute one of the operations in the dashboard:
Execute the command corresponding to plugin name in the drop-down menu of the Plugins button on the Home or Insert ribbon tab.
Execute the command corresponding to plugin name in the drop-down menu of the New Block > Plugins item in the dashboard's context menu.
After executing the operations the plugin will be inserted to the dashboard as a single object.
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:
For the desktop application:
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;
For the web application:
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: