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