@adaptabletools/adaptable-plugin-ipushpull-cjs 17.0.0-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # AdapTable ipushpull Plugin Read Me
2
+
3
+ The ipushpull plugin connects AdapTable with [ipushpull](https://www.ipushpull.com) the market-leading collaborative software.
4
+
5
+ It allows user to send Reports - either System Reports shipped by AdapTable or those created via the AdapTable Export function - to ipushpull and from their to Symphony and other destinations.
6
+
7
+ ## Version 7
8
+ Version 7 of AdapTable made significant changes to how ipushpull is set up, primarily by using this dedicated plugin.
9
+
10
+ As a consequence, the ipushpull section from Predefined Config was removed and no ipushpull information is provided by users that way.
11
+
12
+ Similarly all ipushpull state is now transient and **not persisted** when the application ends.
13
+
14
+ Instead we now use the `ipushpullPluginOptions` object in a similar way to other plugins.
15
+
16
+ The actual ipushpull functionality is unchanged, and the information required to be supplied by the user is identical but it now done through Options and not Predefined Config - isolating it in this way enables us to add more ipushpull-related functionality in a much quicker and safer way, isolated from the rest of the application.
17
+
18
+ ## ipushpull Options
19
+
20
+ The ipushpull plugin contains an `ipushpullPluginOptions` object which allows users to set up their instance.
21
+
22
+ It contains credential details, useful properties (e.g. `throttleTime`, `autoLogin` etc.) and the ipupshpull config object.
23
+
24
+ ## ipushpull Api
25
+
26
+ The `ipushpullApi` is available for full runtime programmatic access to ipushpull objects and methods.
27
+
28
+ > Note: because ipushpull is a plugin, you can get hold of this object through the `getPluginApi` method of pluginsApi.
29
+
30
+ ## ipushpull Setup Example
31
+
32
+ ```ts
33
+
34
+ // set up AdaptableOptions
35
+ const adaptableOptions: AdaptableOptions = {
36
+ ******
37
+ plugins: [
38
+ ipp({
39
+ username: process.env.IPUSHPULL_USERNAME,
40
+ password: process.env.IPUSHPULL_PASSWORD,
41
+ throttleTime: 5000,
42
+ includeSystemReports: true,
43
+ ippConfig: {
44
+ api_secret: process.env.IPUSHPULL_API_KEY,
45
+ api_key: process.env.IPUSHPULL_API_KEY,
46
+ api_url: 'https://www.ipushpull.com/api/1.0',
47
+ ws_url: 'https://www.ipushpull.com',
48
+ web_url: 'https://www.ipushpull.com',
49
+ docs_url: 'https://docs.ipushpull.com',
50
+ storage_prefix: 'ipp_local',
51
+ transport: 'polling',
52
+ hsts: false, // strict cors policy
53
+ },
54
+ }),
55
+ ],
56
+ ******
57
+ };
58
+
59
+ // Instantitate AdapTable and get the main Api object
60
+ adaptableApi = await Adaptable.init(adaptableOptions);
61
+
62
+ // use the plugins api to get the IPushPullApi object
63
+ const ipushpullApi: IPushPullApi = adaptableApi.pluginsApi.getPluginApi(
64
+ 'ipushpull'
65
+ );
66
+
67
+ ```
68
+
69
+ ## ipushpull Toolbar
70
+
71
+ The ipushpull plugin includes a dedicated ipushpull Toolbar - the main way to interact with ipushpull inside AdapTable.
72
+
73
+ At start-up this simply displays a login button that, when clicked, opens a login screen asking for username and password.
74
+
75
+ > There is a `AutoLogin` property option which will automatically log the user in to ipushpull (if the correct credentials have been provided in ipushpull Plugin Options).
76
+
77
+ Once the user is successfully logged in, the Toolbar will contain a number of elements (primarily dropdowns and buttons). These include:
78
+
79
+ ### Dropdowns
80
+
81
+ 1. **Reports Dropdown** - this shows all the Reports that have been created via the Export function.
82
+ > This dropdown will also include any System Reports that AdapTable ships by default (e.g. Selected Cells); however these can be removed by setting `IncludeSystemReports` to false
83
+
84
+ 2. **Folders Dropdown** - lists all the folders (aka 'Domains') to which the user has access in ipushpull
85
+
86
+ 3. **Pages Dropdown** - lists all the ipushpull pages in the currently selected Folder (in the Folders Dropdown).
87
+
88
+ ### Buttons
89
+
90
+ 1. **Send Snapshot** - this will run the current report and send the data to the currently selected ipushpull page. This is a **one-off** action.
91
+
92
+ 2. **Run Live Report** - this will run the current report and send the data to the currently selected ipushpull page. It will also send live updates so as the data in the grid ticks and the report updaes, ipushpull will be updated in real time.
93
+ > The button displays a 'Play' icon; however, when a Live Report is running this changes to a 'Pause' icon.
94
+
95
+ 3. **New ipushpull Page** - alllows the user to create a new ipushpull page in the folder of his choice.
96
+
97
+ 4. **Create Schedule** - enables an ipushpull report to be sent at a schedule of the user's choice
98
+ >This leverages AdapTable Scheduling which enables actions to be performed either at a one off date and time or to be repeated daily at a scheduled time.
99
+
100
+ 5. **Logout Button** - logs the User out of ipushpull (and displays the login button).
101
+
102
+
103
+ ## Help
104
+
105
+ Developers can learn how to access AdapTable programmatically at [AdapTable Documentation](https://docs.adaptabletools.com).
106
+
107
+ ## More Information
108
+
109
+ General information about Adaptable Tools is available at our [Website](http://www.adaptabletools.com)
110
+
111
+ ## Support
112
+
113
+ For all support enquiries please email [`support@adaptabletools.com`](mailto:support@adaptabletools.com) or [raise a Support Ticket](https://adaptabletools.zendesk.com/hc/en-us/requests/new).
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@adaptabletools/adaptable-plugin-ipushpull-cjs",
3
+ "version": "17.0.0-canary.1",
4
+ "description": "",
5
+ "homepage": "http://www.adaptabletools.com/",
6
+ "author": {
7
+ "name": "Jonny Wolfson",
8
+ "email": "jonny.wolfson@adaptabletools.com"
9
+ },
10
+ "main": "src/index.js",
11
+ "typings": "src/index.d.ts",
12
+ "dependencies": {
13
+ "ipushpull-js": "^2.25.0",
14
+ "lodash": "^4.17.15",
15
+ "prop-types": "^15.6.2",
16
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
17
+ "react-redux": "7.2.8",
18
+ "rebass": "^3.2.2",
19
+ "redux": "4.0.5",
20
+ "styled-components": "^4.4.1",
21
+ "tslib": "^2.3.0",
22
+ "@adaptabletools/adaptable-cjs": "17.0.0-canary.1"
23
+ },
24
+ "peerDependencies": {}
25
+ }
@@ -0,0 +1,47 @@
1
+ import { ApiBase } from '@adaptabletools/adaptable/src/Api/Implementation/ApiBase';
2
+ import { IPushPullDomain, IPushPullReport, IPushPullSchedule } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
3
+ import { IPushPullApi } from '@adaptabletools/adaptable/src/Api/IPushPullApi';
4
+ import { IPushPullPluginOptions } from '@adaptabletools/adaptable/src/AdaptableOptions/IPushPullPluginOptions';
5
+ import { IAdaptable } from '@adaptabletools/adaptable/src/AdaptableInterfaces/IAdaptable';
6
+ export declare class IPushPullApiImpl extends ApiBase implements IPushPullApi {
7
+ private ippInstance;
8
+ private ippService;
9
+ private options;
10
+ constructor(adaptable: IAdaptable, options: IPushPullPluginOptions);
11
+ getCurrentIPushPullUsername(): string | undefined;
12
+ getCurrentIPushPullPassword(): string | undefined;
13
+ getIPushPullUsername(): string | undefined;
14
+ getIPushPullPassword(): string | undefined;
15
+ getAutoLogin(): boolean;
16
+ getCurrentLiveIPushPullReport(): IPushPullReport | undefined;
17
+ setIPushPullInstance(ippInstance: any): void;
18
+ getIPushPullInstance(): any;
19
+ sendSnapshot(iPushPullReport: IPushPullReport): void;
20
+ startLiveData(iPushPullReport: IPushPullReport): void;
21
+ stopLiveData(): void;
22
+ isIPushPullReportLive(iPushPullReport: IPushPullReport): boolean;
23
+ isIPushPullAvailable(): boolean;
24
+ isIPushPullRunning(): boolean | undefined;
25
+ getIPushPullDomains(): IPushPullDomain[];
26
+ getPagesForIPushPullDomain(folderName: string): string[];
27
+ setIPushPullLoginErrorMessage(loginErrorMessage: string): void;
28
+ getFolderIdForName(folderName: string): number;
29
+ addNewIPushPullPage(folderName: string, pageName: string): void;
30
+ getIPushPullThrottleTime(): number | undefined;
31
+ setIPushPullThrottleTime(throttleTime: number): void;
32
+ setIPushPullDomains(iPushPullDomains: IPushPullDomain[]): void;
33
+ clearIPushPullDomains(): void;
34
+ getIPushPullSchedules(): IPushPullSchedule[];
35
+ showIPushPullPopup(): void;
36
+ setIPushPullAvailableOn(): void;
37
+ setIPushPullAvailableOff(): void;
38
+ setIPushPullRunningOn(): void;
39
+ setIPushPullRunningOff(): void;
40
+ isIPushPullLiveDataRunning(): boolean;
41
+ private getIPPService;
42
+ loginToIPushPull(userName: string, password: string): Promise<void>;
43
+ retrieveIPushPullDomainsFromIPushPull(): Promise<void>;
44
+ logoutFromIPushPull(): void;
45
+ includeSystemReports(): boolean;
46
+ clearIPushPullInternalState(): void;
47
+ }
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPushPullApiImpl = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ApiBase_1 = require("@adaptabletools/adaptable-cjs/src/Api/Implementation/ApiBase");
6
+ const ModuleConstants = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/ModuleConstants"));
7
+ const IPushPullRedux = tslib_1.__importStar(require("./Redux/ActionReducers/IPushPullRedux"));
8
+ const ArrayExtensions_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/ArrayExtensions"));
9
+ const Helper_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/Utilities/Helpers/Helper"));
10
+ class IPushPullApiImpl extends ApiBase_1.ApiBase {
11
+ constructor(adaptable, options) {
12
+ super(adaptable);
13
+ this.ippService = null;
14
+ this.options = options;
15
+ }
16
+ getCurrentIPushPullUsername() {
17
+ return this.getAdaptableState().System.CurrentIPushpullUsername;
18
+ }
19
+ getCurrentIPushPullPassword() {
20
+ return this.getAdaptableState().System.CurrentIPushpullPassword;
21
+ }
22
+ getIPushPullUsername() {
23
+ return this.options.username;
24
+ }
25
+ getIPushPullPassword() {
26
+ return this.options.password;
27
+ }
28
+ getAutoLogin() {
29
+ var _a;
30
+ return (_a = this.options.autoLogin) !== null && _a !== void 0 ? _a : false;
31
+ }
32
+ getCurrentLiveIPushPullReport() {
33
+ return this.getAdaptableState().System.CurrentLiveIPushPullReport;
34
+ }
35
+ setIPushPullInstance(ippInstance) {
36
+ this.ippInstance = ippInstance;
37
+ }
38
+ getIPushPullInstance() {
39
+ return this.ippInstance;
40
+ }
41
+ sendSnapshot(iPushPullReport) {
42
+ if (this.checkItemExists(iPushPullReport, iPushPullReport.ReportName, 'IPushPull Report')) {
43
+ this.dispatchAction(IPushPullRedux.IPushPullSendSnapshot(iPushPullReport));
44
+ this.adaptable.ReportService.PublishLiveLiveDataChangedEvent('ipushpull', 'SnapshotSent');
45
+ }
46
+ }
47
+ startLiveData(iPushPullReport) {
48
+ if (this.checkItemExists(iPushPullReport, iPushPullReport.ReportName, 'IPushPull Report')) {
49
+ this.dispatchAction(IPushPullRedux.IPushPullLiveReportSet(iPushPullReport));
50
+ this.adaptable.ReportService.PublishLiveLiveDataChangedEvent('ipushpull', 'LiveDataStarted', iPushPullReport);
51
+ }
52
+ }
53
+ stopLiveData() {
54
+ let currentLiveReport = this.getCurrentLiveIPushPullReport();
55
+ if (!currentLiveReport) {
56
+ return;
57
+ }
58
+ this.getIPPService().unloadPage(currentLiveReport.Page);
59
+ // clear the live report
60
+ this.dispatchAction(IPushPullRedux.IPushPullLiveReportClear());
61
+ // fire the Live Report event for Export Stopped
62
+ this.adaptable.ReportService.PublishLiveLiveDataChangedEvent('ipushpull', 'LiveDataStopped', currentLiveReport);
63
+ }
64
+ isIPushPullReportLive(iPushPullReport) {
65
+ if (!iPushPullReport) {
66
+ return false;
67
+ }
68
+ const CurrentLiveIPushPullReport = this.getCurrentLiveIPushPullReport();
69
+ return CurrentLiveIPushPullReport != null && CurrentLiveIPushPullReport == iPushPullReport;
70
+ }
71
+ isIPushPullAvailable() {
72
+ return true;
73
+ }
74
+ isIPushPullRunning() {
75
+ return this.getAdaptableState().System.IsIPushPullRunning;
76
+ }
77
+ getIPushPullDomains() {
78
+ return this.getAdaptableState().System.IPushPullDomainsPages || [];
79
+ }
80
+ getPagesForIPushPullDomain(folderName) {
81
+ let returnArray = [];
82
+ let iPushPullDomains = this.getIPushPullDomains();
83
+ if (ArrayExtensions_1.default.IsNotNullOrEmpty(iPushPullDomains)) {
84
+ let iPushPullDomain = iPushPullDomains.find((f) => f.Name == folderName);
85
+ if (iPushPullDomain) {
86
+ returnArray = iPushPullDomain.Pages;
87
+ }
88
+ }
89
+ return returnArray;
90
+ }
91
+ setIPushPullLoginErrorMessage(loginErrorMessage) {
92
+ this.dispatchAction(IPushPullRedux.IPushPullSetLoginErrorMessage(loginErrorMessage));
93
+ }
94
+ getFolderIdForName(folderName) {
95
+ let iPushPullDomains = this.getIPushPullDomains();
96
+ return iPushPullDomains.find((i) => i.Name == folderName).FolderId;
97
+ }
98
+ addNewIPushPullPage(folderName, pageName) {
99
+ let folderId = this.getFolderIdForName(folderName);
100
+ this.getIPPService().addNewPage(folderId, pageName);
101
+ }
102
+ getIPushPullThrottleTime() {
103
+ return this.options.throttleTime;
104
+ }
105
+ setIPushPullThrottleTime(throttleTime) {
106
+ this.dispatchAction(IPushPullRedux.IPushPullSetThrottleTime(throttleTime));
107
+ }
108
+ setIPushPullDomains(iPushPullDomains) {
109
+ this.dispatchAction(IPushPullRedux.IPushPullSetDomainsPages(iPushPullDomains));
110
+ }
111
+ clearIPushPullDomains() {
112
+ this.dispatchAction(IPushPullRedux.IPushPullClearDomainsPages());
113
+ }
114
+ getIPushPullSchedules() {
115
+ return this.getAdaptableState().Schedule.IPushPullSchedules || [];
116
+ }
117
+ showIPushPullPopup() {
118
+ this.showModulePopup(ModuleConstants.IPushPullModuleId);
119
+ }
120
+ setIPushPullAvailableOn() {
121
+ this.dispatchAction(IPushPullRedux.SetIPushPullAvailableOn());
122
+ }
123
+ setIPushPullAvailableOff() {
124
+ this.dispatchAction(IPushPullRedux.SetIPushPullAvailableOff());
125
+ }
126
+ setIPushPullRunningOn() {
127
+ this.dispatchAction(IPushPullRedux.SetIPushPullRunningOn());
128
+ this.adaptable.ReportService.PublishLiveLiveDataChangedEvent('ipushpull', 'Connected');
129
+ }
130
+ setIPushPullRunningOff() {
131
+ this.dispatchAction(IPushPullRedux.SetIPushPullRunningOff());
132
+ this.adaptable.ReportService.PublishLiveLiveDataChangedEvent('ipushpull', 'Disconnected');
133
+ }
134
+ isIPushPullLiveDataRunning() {
135
+ return Helper_1.default.objectExists(this.getCurrentLiveIPushPullReport());
136
+ }
137
+ getIPPService() {
138
+ if (!this.ippService) {
139
+ this.ippService = this.adaptable.getPluginProperty('ipushpull', 'service') || null;
140
+ }
141
+ return this.ippService;
142
+ }
143
+ async loginToIPushPull(userName, password) {
144
+ await this.getIPPService().login(userName, password);
145
+ const domainpages = await this.getIPPService().getDomainPages();
146
+ this.setIPushPullDomains(domainpages);
147
+ this.setIPushPullRunningOn();
148
+ this.getAdaptableApi().internalApi.hidePopupScreen();
149
+ this.setIPushPullLoginErrorMessage('');
150
+ this.dispatchAction(IPushPullRedux.IPushPullSetLoginDetails(userName, password));
151
+ }
152
+ async retrieveIPushPullDomainsFromIPushPull() {
153
+ this.clearIPushPullDomains();
154
+ const domainpages = await this.getIPPService().getDomainPages();
155
+ this.setIPushPullDomains(domainpages);
156
+ }
157
+ logoutFromIPushPull() {
158
+ this.clearIPushPullInternalState();
159
+ this.dispatchAction(IPushPullRedux.IPushPullLogout());
160
+ this.getAdaptableApi().internalApi.hidePopupScreen();
161
+ }
162
+ includeSystemReports() {
163
+ return this.options.includeSystemReports || false;
164
+ }
165
+ clearIPushPullInternalState() {
166
+ this.setIPushPullDomains([]);
167
+ this.setIPushPullRunningOff();
168
+ this.setIPushPullLoginErrorMessage('');
169
+ this.dispatchAction(IPushPullRedux.IPushPullLiveReportClear());
170
+ }
171
+ }
172
+ exports.IPushPullApiImpl = IPushPullApiImpl;
@@ -0,0 +1,7 @@
1
+ import { IPushPullReport } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
2
+ import { IModule } from '@adaptabletools/adaptable/src/Strategy/Interface/IModule';
3
+ export interface IPushPullModule extends IModule {
4
+ sendSnapshot(report: IPushPullReport): void;
5
+ startLiveData(report: IPushPullReport): void;
6
+ stopLiveData(): void;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { AdaptableModuleBase } from '@adaptabletools/adaptable/src/Strategy/AdaptableModuleBase';
2
+ import { IPushPullModule } from './Interface/IPushPullModule';
3
+ import { IPushPullReport } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
4
+ import { IPushPullApi } from '@adaptabletools/adaptable/src/Api/IPushPullApi';
5
+ import { AccessLevel, AdaptableApi } from '@adaptabletools/adaptable/types';
6
+ export declare class PushPullModule extends AdaptableModuleBase implements IPushPullModule {
7
+ private isSendingData;
8
+ private ippService;
9
+ private adaptable;
10
+ private throttledRecomputeAndSendLiveDataEvent;
11
+ private lastData;
12
+ constructor(api: AdaptableApi);
13
+ protected getViewAccessLevel(): AccessLevel;
14
+ setModuleEntitlement(): void;
15
+ getIPPApi(): IPushPullApi;
16
+ private getCurrentReport;
17
+ private getIPPService;
18
+ private sendNewLiveData;
19
+ sendSnapshot(iPushPullReport: IPushPullReport): void;
20
+ startLiveData(iPushPullReport: IPushPullReport): void;
21
+ stopLiveData(): void;
22
+ private getThrottleTimeFromState;
23
+ }
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PushPullModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const AdaptableModuleBase_1 = require("@adaptabletools/adaptable-cjs/src/Strategy/AdaptableModuleBase");
6
+ const ModuleConstants = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/ModuleConstants"));
7
+ const throttle_1 = tslib_1.__importDefault(require("lodash/throttle"));
8
+ const GeneralConstants_1 = require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/GeneralConstants");
9
+ const EQUAL_DATA_ERR = 'equal data, so not sending';
10
+ class PushPullModule extends AdaptableModuleBase_1.AdaptableModuleBase {
11
+ constructor(api) {
12
+ super(ModuleConstants.IPushPullModuleId, 'ipushpull', 'download', null, 'Send data from AdapTable to ipushpull', api);
13
+ this.isSendingData = false;
14
+ this.ippService = null;
15
+ this.adaptable = api.internalApi.getAdaptableInstance();
16
+ this.api.eventApi.on('AdaptableReady', () => {
17
+ setTimeout(() => {
18
+ this.throttledRecomputeAndSendLiveDataEvent = (0, throttle_1.default)(() => this.sendNewLiveData(), this.getThrottleTimeFromState());
19
+ }, 1000);
20
+ });
21
+ // if a piece of data has updated then update any live reports except cell or row selected where the data change is relevant
22
+ // currently we DONT send deltas - we simply send everything to ipushpull every time a relevant change happens
23
+ this.api.internalApi
24
+ .getDataService()
25
+ .on('CellDataChanged', (cellDataChangedInfo) => {
26
+ const api = this.getIPPApi();
27
+ const exportApi = this.api.exportApi;
28
+ if (api.isIPushPullLiveDataRunning()) {
29
+ let currentLiveIPushPullReport = api.getCurrentLiveIPushPullReport();
30
+ if (currentLiveIPushPullReport &&
31
+ currentLiveIPushPullReport.ReportName !== GeneralConstants_1.SELECTED_CELLS_REPORT &&
32
+ currentLiveIPushPullReport.ReportName !== GeneralConstants_1.SELECTED_ROWS_REPORT &&
33
+ exportApi.internalApi.isDataChangeInReport(cellDataChangedInfo, this.getCurrentReport())) {
34
+ this.throttledRecomputeAndSendLiveDataEvent();
35
+ }
36
+ }
37
+ });
38
+ // if the grid has refreshed then update all live reports
39
+ this.adaptable._on('GridRefreshed', () => {
40
+ if (this.getIPPApi().isIPushPullLiveDataRunning()) {
41
+ this.throttledRecomputeAndSendLiveDataEvent();
42
+ }
43
+ });
44
+ // if the grid filters have changed then update any live reports except cell or row selected
45
+ this.adaptable._on('AdapTableFiltersApplied', () => {
46
+ // Rerun all reports except selected cells / rows when filter changes
47
+ if (this.getIPPApi().isIPushPullLiveDataRunning()) {
48
+ let currentLiveIPushPullReport = this.getIPPApi().getCurrentLiveIPushPullReport();
49
+ if (currentLiveIPushPullReport &&
50
+ currentLiveIPushPullReport.ReportName !== GeneralConstants_1.SELECTED_CELLS_REPORT &&
51
+ currentLiveIPushPullReport.ReportName !== GeneralConstants_1.SELECTED_ROWS_REPORT) {
52
+ this.throttledRecomputeAndSendLiveDataEvent();
53
+ }
54
+ }
55
+ });
56
+ // if grid selection has changed and the ipushpull Live report is 'Selected Cells' or 'Selected Rows' then send updated data
57
+ this.api.eventApi.on('SelectionChanged', () => {
58
+ if (this.getIPPApi().isIPushPullLiveDataRunning()) {
59
+ let currentLiveIPushPullReport = this.getIPPApi().getCurrentLiveIPushPullReport();
60
+ if (currentLiveIPushPullReport &&
61
+ (currentLiveIPushPullReport.ReportName === GeneralConstants_1.SELECTED_CELLS_REPORT ||
62
+ currentLiveIPushPullReport.ReportName === GeneralConstants_1.SELECTED_ROWS_REPORT)) {
63
+ this.throttledRecomputeAndSendLiveDataEvent();
64
+ }
65
+ }
66
+ });
67
+ }
68
+ getViewAccessLevel() {
69
+ return 'Full';
70
+ }
71
+ setModuleEntitlement() {
72
+ // TODO
73
+ if (!this.api.pluginsApi.getipushpullPluginApi().isIPushPullAvailable()) {
74
+ this.AccessLevel = 'Hidden';
75
+ }
76
+ else {
77
+ this.AccessLevel = this.api.internalApi
78
+ .getEntitlementService()
79
+ .getEntitlementAccessLevelForModule(this.moduleInfo.ModuleName);
80
+ }
81
+ }
82
+ getIPPApi() {
83
+ return this.api.pluginsApi.getipushpullPluginApi();
84
+ }
85
+ getCurrentReport() {
86
+ const api = this.getIPPApi();
87
+ const exportApi = this.api.exportApi;
88
+ if (api.isIPushPullLiveDataRunning()) {
89
+ let currentLiveIPushPullReport = api.getCurrentLiveIPushPullReport();
90
+ return currentLiveIPushPullReport
91
+ ? exportApi.getReportByName(currentLiveIPushPullReport.ReportName)
92
+ : null;
93
+ }
94
+ return null;
95
+ }
96
+ getIPPService() {
97
+ if (!this.ippService) {
98
+ this.ippService = this.adaptable.getPluginProperty('ipushpull', 'service') || null;
99
+ }
100
+ return this.ippService;
101
+ }
102
+ sendNewLiveData() {
103
+ //we wait for the last sendNewLiveData to finish
104
+ if (this.isSendingData == true) {
105
+ this.throttledRecomputeAndSendLiveDataEvent();
106
+ return;
107
+ }
108
+ let currentLiveIPushPullReport = this.getIPPApi().getCurrentLiveIPushPullReport();
109
+ if (currentLiveIPushPullReport) {
110
+ this.isSendingData = true;
111
+ let report = this.api.exportApi.getReportByName(currentLiveIPushPullReport.ReportName);
112
+ let reportAsArray = this.adaptable.ReportService.getReportDataAsArray(report);
113
+ const currentData = JSON.stringify(reportAsArray);
114
+ if (currentData === this.lastData) {
115
+ this.adaptable.logger.warn(EQUAL_DATA_ERR);
116
+ this.isSendingData = false;
117
+ return;
118
+ }
119
+ Promise.resolve()
120
+ .then(() => {
121
+ return new Promise((resolve, reject) => {
122
+ if (reportAsArray) {
123
+ resolve(reportAsArray);
124
+ }
125
+ else {
126
+ reject('no data in the report');
127
+ }
128
+ });
129
+ })
130
+ .then((reportAsArray) => {
131
+ return this.getIPPService().pushData(currentLiveIPushPullReport.Page, reportAsArray);
132
+ })
133
+ .then(() => {
134
+ this.lastData = currentData;
135
+ return this.adaptable.ReportService.PublishLiveLiveDataChangedEvent('ipushpull', 'LiveDataUpdated', currentLiveIPushPullReport);
136
+ })
137
+ .catch((reason) => {
138
+ this.adaptable.logger.warn('Failed to send data to ipushpull for [' + currentLiveIPushPullReport.ReportName + ']', reason);
139
+ this.stopLiveData();
140
+ let errorMessage = 'Export Failed';
141
+ if (reason) {
142
+ errorMessage += ': ' + reason;
143
+ }
144
+ errorMessage += '. This live export has been cancelled.';
145
+ this.api.alertApi.showAlertError('ipushpull Export Error', errorMessage);
146
+ });
147
+ Promise.resolve()
148
+ .then(() => {
149
+ this.adaptable.logger.success('All live report data sent');
150
+ this.isSendingData = false;
151
+ })
152
+ .catch(() => {
153
+ this.adaptable.logger.warn('Failed to send data');
154
+ this.isSendingData = false;
155
+ });
156
+ }
157
+ }
158
+ sendSnapshot(iPushPullReport) {
159
+ this.getIPPService()
160
+ .loadPage(iPushPullReport.Folder, iPushPullReport.Page)
161
+ .then(() => {
162
+ let report = this.api.exportApi.getReportByName(iPushPullReport.ReportName);
163
+ if (report) {
164
+ let reportAsArray = this.adaptable.ReportService.getReportDataAsArray(report);
165
+ if (reportAsArray) {
166
+ this.getIPPService().pushData(iPushPullReport.Page, reportAsArray);
167
+ }
168
+ }
169
+ });
170
+ }
171
+ startLiveData(iPushPullReport) {
172
+ this.getIPPService()
173
+ .loadPage(iPushPullReport.Folder, iPushPullReport.Page)
174
+ .then(() => {
175
+ this.getIPPApi().startLiveData(iPushPullReport);
176
+ });
177
+ }
178
+ stopLiveData() {
179
+ this.lastData = '';
180
+ this.getIPPApi().stopLiveData();
181
+ }
182
+ getThrottleTimeFromState() {
183
+ let iPushPullThrottleTime;
184
+ if (this.getIPPApi().isIPushPullRunning()) {
185
+ iPushPullThrottleTime = this.getIPPApi().getIPushPullThrottleTime();
186
+ }
187
+ return iPushPullThrottleTime ? iPushPullThrottleTime : GeneralConstants_1.DEFAULT_LIVE_REPORT_THROTTLE_TIME;
188
+ }
189
+ }
190
+ exports.PushPullModule = PushPullModule;
@@ -0,0 +1,85 @@
1
+ import * as Redux from 'redux';
2
+ import { IPushPullReport } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
3
+ import { IPushPullDomain } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
4
+ import { IPushPullState } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
5
+ export interface IPushPullSetThrottleTimeAction extends Redux.Action {
6
+ throttleTime: number;
7
+ }
8
+ export interface IPushPullSendSnapshotAction extends Redux.Action {
9
+ iPushPullReport: IPushPullReport;
10
+ }
11
+ export interface IPushPullStartLiveDataAction extends Redux.Action {
12
+ iPushPullReport: IPushPullReport;
13
+ }
14
+ export interface IPushPullStopLiveDataAction extends Redux.Action {
15
+ }
16
+ export interface IPushPullLoginAction extends Redux.Action {
17
+ username: string;
18
+ password: string;
19
+ }
20
+ export interface IPushPullLogoutAction extends Redux.Action {
21
+ }
22
+ export interface IPushPullSetLoginDetailsAction extends Redux.Action {
23
+ username: string;
24
+ password: string;
25
+ }
26
+ export interface IPushPullSetLoginErrorMessageAction extends Redux.Action {
27
+ errorMessage: string;
28
+ }
29
+ export interface IPushPullAddPageAction extends Redux.Action {
30
+ folder: string;
31
+ page: string;
32
+ }
33
+ export interface SetIPushPullAvailableOnAction extends Redux.Action {
34
+ }
35
+ export interface SetIPushPullAvailableOffAction extends Redux.Action {
36
+ }
37
+ export interface SetIPushPullRunningOnAction extends Redux.Action {
38
+ }
39
+ export interface SetIPushPullRunningOffAction extends Redux.Action {
40
+ }
41
+ export interface IPushPullDomainsPagesSetAction extends Redux.Action {
42
+ IPushPullDomainsPages: IPushPullDomain[];
43
+ }
44
+ export interface IPushPullDomainsPagesClearAction extends Redux.Action {
45
+ }
46
+ export interface IPushPullLiveReportSetAction extends Redux.Action {
47
+ iPushPullReport: IPushPullReport;
48
+ }
49
+ export interface IPushPullLiveReportClearAction extends Redux.Action {
50
+ }
51
+ export interface IPushPullSetCurrentReportNameAction extends Redux.Action {
52
+ reportName: string;
53
+ }
54
+ export interface IPushPullSetCurrentFolderAction extends Redux.Action {
55
+ folder: string;
56
+ }
57
+ export interface IPushPullSetCurrentPageAction extends Redux.Action {
58
+ page: string;
59
+ }
60
+ export interface IPushPullSetCurrentAvailablePagesAction extends Redux.Action {
61
+ availablePages: string[];
62
+ }
63
+ export declare const IPushPullSetThrottleTime: (throttleTime: number) => IPushPullSetThrottleTimeAction;
64
+ export declare const IPushPullSendSnapshot: (iPushPullReport: IPushPullReport) => IPushPullSendSnapshotAction;
65
+ export declare const IPushPullStartLiveData: (iPushPullReport: IPushPullReport) => IPushPullStartLiveDataAction;
66
+ export declare const IPushPullStopLiveData: () => IPushPullStopLiveDataAction;
67
+ export declare const IPushPullLogin: (username: string, password: string) => IPushPullLoginAction;
68
+ export declare const IPushPullLogout: () => IPushPullLogoutAction;
69
+ export declare const IPushPullSetLoginDetails: (username: string, password: string) => IPushPullSetLoginDetailsAction;
70
+ export declare const IPushPullSetLoginErrorMessage: (errorMessage: string) => IPushPullSetLoginErrorMessageAction;
71
+ export declare const IPushPullAddPage: (folder: string, page: string) => IPushPullAddPageAction;
72
+ export declare const SetIPushPullAvailableOn: () => SetIPushPullAvailableOnAction;
73
+ export declare const SetIPushPullAvailableOff: () => SetIPushPullAvailableOffAction;
74
+ export declare const SetIPushPullRunningOn: () => SetIPushPullRunningOnAction;
75
+ export declare const SetIPushPullRunningOff: () => SetIPushPullRunningOffAction;
76
+ export declare const IPushPullSetDomainsPages: (IPushPullDomainsPages: IPushPullDomain[]) => IPushPullDomainsPagesSetAction;
77
+ export declare const IPushPullClearDomainsPages: () => IPushPullDomainsPagesClearAction;
78
+ export declare const IPushPullLiveReportSet: (iPushPullReport: IPushPullReport) => IPushPullLiveReportSetAction;
79
+ export declare const IPushPullLiveReportClear: () => IPushPullLiveReportClearAction;
80
+ export declare const IPushPullSetCurrentReportName: (reportName: string) => IPushPullSetCurrentReportNameAction;
81
+ export declare const IPushPullSetCurrentFolder: (folder: string) => IPushPullSetCurrentFolderAction;
82
+ export declare const IPushPullSetCurrentPage: (page: string) => IPushPullSetCurrentPageAction;
83
+ export declare const IPushPullSetCurrentAvailablePages: (availablePages: string[]) => IPushPullSetCurrentAvailablePagesAction;
84
+ export declare const iPushPullInitialState: IPushPullState;
85
+ export declare const IPushPullReducer: Redux.Reducer<IPushPullState>;