OpenFin Plugin

The OpenFin Plugin provides extra functionality for users when AdapTable is running in the OpenFin container.

Setup

To set up the plugin and access the OpenFin Api object, follow these steps:

  1. Import the plugin:

    import openfin from '@adaptabletools/adaptable-plugin-openfin';
  2. Import the OpenFin Api:

    import { OpenFinApi } from '@adaptabletools/adaptable/types';
  1. Create the OpenFinPluginOptions as appropriate:

    const openfinPluginOptions: OpenFinPluginOptions = {
    notificationTimeout: false,
    showApplicationIconInNotifications: true,
    }
  2. Specify the Plugin in Adaptable Options passing in the Options set up in previous step:

    const adaptableOptions: AdaptableOptions = {
    adaptableId: 'openfindemo',
    plugins: [
    openfin(openfinPluginOptions),
    ]
    // ... other options
    }
    note

    In this example we have set the throttleTime property in OpenFinPlugin Options

  3. Access the Open Fin Api via the main Adaptable Api object and use as needed:

    const openfinApi: OpenFinApi = adaptableApi.pluginsApi.getPluginApi(
    'openfin'
    );

OpenFin Toolbar

The OpenFin Plugin makes a dedicated Dashboard Toolbar called 'OpenFin' available.

important

This makes it possible to run Live Reports in Excel

The Toolbar can be referenced in Dashboard Predefined Config as follows:

const demoConfig: PredefinedConfig = {
Dashboard: {
Tabs: [
{
Name: 'Dashboard Toolbars',
Toolbars: ['Layout', 'OpenFin', 'Export'],
},
],
},
};

Live Reports

One feature available when AdapTable is running in the OpenFin Plugin is Live Export via Excel.

This enables grid data to be sent from AdapTable to Excel with 2 way updates:

note

Any Reports created in the Export function will appear in the Toolbar

  • Excel will automatically update in line with cell edits and ticking data changes in AdapTable
  • Any date edits made directly in Excel will be automatically reflected in AdapTable
tip

Live Reports can, like all Reports, be set to run on a Schedule.

To make this functionality available, specify the following in the app.json file:

"services": [
{ "name": "excel",
"manifestUrl": "http://openfin.github.io/excel-api-example/provider/app.json"
}
]

Validating Excel Changes

The Cell Validation Function in AdapTable enables custom Validation Rules to be provided which are checked after each Data Change.

When running Live Reports these validation rules can be extended to edits made in Excel also by setting the onValidationFailureInExcel property in OpenFinPluginOptions.

This property can take one of 3 values:

  • override: automatically updates Excel with the previous value (i.e. before the edit was made)

  • show-notification: displays an Open Notification explaining that the edit in Excel broke validation

  • show-undo-notification: displays an Open Notification containing a button; when clicked AdapTable will override the edit in Excel with the previous value

OpenFin Notifications

AdapTable can enable OpenFin Notifications to display if required.

When using the OpenFin Plugin an extra option is displayed in the Alert UI, which allows the Alert to be shown as an Open Notification in the systray.

tip

This can be configured at design-time through the ShowInOpenFin property in Alert Properties

Managing Notifications

There are 4 properties (2 of them JavaScript functions) in OpenFinPluginOptions which help to manage how OpenFin notifications will look and work.

  • notificationTimeout - when OpenFin notifications will expire after being displayed

  • showAppIconInNotifications - displays App Icon (supplied in User Interface Options) in the notification

  • onNotificationAction - function invoked when a button in an OpenFin notification is clicked

  • onShowNotification - function which custom updates an OpenFin notification before it is displayed

Using Notifications Example

The example below taken from the OpenFin Demo App illustrates:

  • 2 buttons being added to the Notification when it renders: "jump-to-cell" and "increase-limit"
  • if action is "increase-limit" the Adaptable Alert Definition is updated via the Alert Api
  • if action is "jump-to-cell" the jumpToCell and highlightCell methods of Grid Api are invoked
const openfinPluginOptions: OpenFinPluginOptions = {
notificationTimeout: false,
showAppIconInNotifications: true,
onShowNotification: (notification) => {
notification.buttons = [
{
title: "Show Me",
type: "button",
cta: true,
onClick: {
task: "jump-to-cell",
},
},
{
title: "Increase Limit",
type: "button",
onClick: {
task: "increase-limit",
},
},
];
},
onNotificationAction: (event) => {
if (event.result.task === "jump-to-cell") {
const alert = event.notification.alert as AdaptableAlert;
adaptableApiRef.current.gridApi.jumpToCell(
alert.DataChangedInfo?.primaryKeyValue,
alert.DataChangedInfo?.columnId || ""
);
adaptableApiRef.current.gridApi.highlightCell({
columnId: alert.DataChangedInfo?.columnId || "",
primaryKeyValue: alert.DataChangedInfo?.primaryKeyValue,
timeout: 2500,
highlightType: alert.AlertDefinition.MessageType,
});
}
if (event.result.task === "increase-limit") {
const alert: AdaptableAlert = event.notification.alert as AdaptableAlert;
if (alert) {
let alertDefinition: AlertDefinition = alert.AlertDefinition;
if (alertDefinition) {
let predicate = alertDefinition.Predicate;
if (predicate) {
let inputs: any[] | undefined = predicate.Inputs;
if (inputs && inputs.length > 0) {
let firstInput = inputs[0];
let newValue = firstInput + 1000;
let newPredicate: AdaptablePredicate = {
PredicateId: "GreaterThan",
Inputs: [newValue],
};
alertDefinition.Predicate = newPredicate;
adaptableApiRef.current.alertApi.editAlert(alertDefinition);
}
}
}
}
}
},
};

Further Information