@adaptabletools/adaptable-plugin-ipushpull-cjs 20.0.0-canary.6 → 20.0.0-canary.7
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/package.json +1 -1
- package/src/Module/PushPullModule.js +46 -46
package/package.json
CHANGED
|
@@ -106,58 +106,55 @@ class PushPullModule extends AdaptableModuleBase_1.AdaptableModuleBase {
|
|
|
106
106
|
return this.ippService;
|
|
107
107
|
}
|
|
108
108
|
sendNewLiveData() {
|
|
109
|
-
//
|
|
110
|
-
if (this.isSendingData
|
|
109
|
+
// We wait for the last sendNewLiveData to finish
|
|
110
|
+
if (this.isSendingData === true) {
|
|
111
111
|
this.throttledRecomputeAndSendLiveDataEvent();
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
const currentLiveIPushPullReport = this.getIPPApi().getCurrentLiveIPushPullReport();
|
|
115
115
|
if (currentLiveIPushPullReport) {
|
|
116
116
|
this.isSendingData = true;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
else {
|
|
132
|
-
reject('no data in the report');
|
|
133
|
-
}
|
|
134
|
-
});
|
|
117
|
+
this.api.exportApi
|
|
118
|
+
.getReportData(currentLiveIPushPullReport.ReportName, 'JSON')
|
|
119
|
+
.then((exportResultData) => {
|
|
120
|
+
if (exportResultData?.type !== 'json' || !exportResultData.data) {
|
|
121
|
+
throw new Error('No data in the report');
|
|
122
|
+
}
|
|
123
|
+
const reportDataAsArray = this.api.exportApi.internalApi.convertReportDataToArray(exportResultData.data);
|
|
124
|
+
const currentData = JSON.stringify(reportDataAsArray);
|
|
125
|
+
if (currentData === this.lastData) {
|
|
126
|
+
this.adaptable.logger.warn(EQUAL_DATA_ERR);
|
|
127
|
+
this.isSendingData = false;
|
|
128
|
+
throw new Error(EQUAL_DATA_ERR); // Using throw to exit the promise chain
|
|
129
|
+
}
|
|
130
|
+
return { reportDataAsArray, currentData };
|
|
135
131
|
})
|
|
136
|
-
.then((
|
|
137
|
-
return this.getIPPService()
|
|
132
|
+
.then(({ reportDataAsArray, currentData }) => {
|
|
133
|
+
return this.getIPPService()
|
|
134
|
+
.pushData(currentLiveIPushPullReport.Page, reportDataAsArray)
|
|
135
|
+
.then(() => currentData); // Pass currentData to the next then
|
|
138
136
|
})
|
|
139
|
-
.then(() => {
|
|
137
|
+
.then((currentData) => {
|
|
140
138
|
this.lastData = currentData;
|
|
139
|
+
this.adaptable.logger.success('All live report data sent');
|
|
140
|
+
this.isSendingData = false;
|
|
141
141
|
return this.api.exportApi.internalApi.publishLiveLiveDataChangedEvent('ipushpull', 'LiveDataUpdated', currentLiveIPushPullReport);
|
|
142
142
|
})
|
|
143
143
|
.catch((reason) => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
// Skip logging for expected cases
|
|
145
|
+
if (reason?.message !== EQUAL_DATA_ERR) {
|
|
146
|
+
this.isSendingData = false;
|
|
147
|
+
this.adaptable.logger.warn('Failed to send data to ipushpull for [' +
|
|
148
|
+
currentLiveIPushPullReport.ReportName +
|
|
149
|
+
']', reason);
|
|
150
|
+
this.stopLiveData();
|
|
151
|
+
let errorMessage = 'Export Failed';
|
|
152
|
+
if (reason) {
|
|
153
|
+
errorMessage += ': ' + reason;
|
|
154
|
+
}
|
|
155
|
+
errorMessage += '. This live export has been cancelled.';
|
|
156
|
+
this.api.alertApi.showAlertError('ipushpull Export Error', errorMessage);
|
|
149
157
|
}
|
|
150
|
-
errorMessage += '. This live export has been cancelled.';
|
|
151
|
-
this.api.alertApi.showAlertError('ipushpull Export Error', errorMessage);
|
|
152
|
-
});
|
|
153
|
-
Promise.resolve()
|
|
154
|
-
.then(() => {
|
|
155
|
-
this.adaptable.logger.success('All live report data sent');
|
|
156
|
-
this.isSendingData = false;
|
|
157
|
-
})
|
|
158
|
-
.catch(() => {
|
|
159
|
-
this.adaptable.logger.warn('Failed to send data');
|
|
160
|
-
this.isSendingData = false;
|
|
161
158
|
});
|
|
162
159
|
}
|
|
163
160
|
}
|
|
@@ -165,13 +162,16 @@ class PushPullModule extends AdaptableModuleBase_1.AdaptableModuleBase {
|
|
|
165
162
|
this.getIPPService()
|
|
166
163
|
.loadPage(iPushPullReport.Folder, iPushPullReport.Page)
|
|
167
164
|
.then(() => {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
return this.api.exportApi.getReportData(iPushPullReport.ReportName, 'JSON');
|
|
166
|
+
})
|
|
167
|
+
.then((exportResultData) => {
|
|
168
|
+
if (exportResultData?.type === 'json' && exportResultData?.data) {
|
|
169
|
+
const reportDataAsArray = this.api.exportApi.internalApi.convertReportDataToArray(exportResultData.data);
|
|
170
|
+
return this.getIPPService().pushData(iPushPullReport.Page, reportDataAsArray);
|
|
174
171
|
}
|
|
172
|
+
})
|
|
173
|
+
.catch((error) => {
|
|
174
|
+
this.adaptable.logger.warn(`Failed to send snapshot for report [${iPushPullReport.ReportName}]`, error);
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
startLiveData(iPushPullReport) {
|