@genesislcap/grid-pro 14.292.0 → 14.293.0
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/dist/custom-elements.json +651 -95
- package/dist/dts/datasource/base.datasource.d.ts +42 -11
- package/dist/dts/datasource/base.datasource.d.ts.map +1 -1
- package/dist/dts/datasource/base.types.d.ts +22 -0
- package/dist/dts/datasource/base.types.d.ts.map +1 -1
- package/dist/dts/datasource/error-handler.dialog.d.ts +3 -0
- package/dist/dts/datasource/error-handler.dialog.d.ts.map +1 -0
- package/dist/dts/datasource/server-side.datasource.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.resource-base.d.ts +1 -0
- package/dist/dts/datasource/server-side.resource-base.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.resource-dataserver.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.resource-reqrep.d.ts.map +1 -1
- package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts +0 -3
- package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts.map +1 -1
- package/dist/dts/grid-pro.d.ts +9 -4
- package/dist/dts/grid-pro.d.ts.map +1 -1
- package/dist/dts/grid-pro.styles.d.ts.map +1 -1
- package/dist/dts/grid-pro.template.d.ts +1 -1
- package/dist/dts/grid-pro.template.d.ts.map +1 -1
- package/dist/esm/datasource/base.datasource.js +162 -1
- package/dist/esm/datasource/base.types.js +8 -1
- package/dist/esm/datasource/error-handler.dialog.js +116 -0
- package/dist/esm/datasource/server-side.datasource.js +15 -4
- package/dist/esm/datasource/server-side.resource-base.js +1 -0
- package/dist/esm/datasource/server-side.resource-dataserver.js +7 -0
- package/dist/esm/datasource/server-side.resource-reqrep.js +7 -0
- package/dist/esm/grid-pro-genesis-datasource/grid-pro-genesis-datasource.js +14 -48
- package/dist/esm/grid-pro.js +20 -3
- package/dist/esm/grid-pro.styles.js +2 -22
- package/dist/esm/grid-pro.template.js +3 -33
- package/dist/grid-pro.api.json +307 -79
- package/dist/grid-pro.d.ts +60 -18
- package/docs/api/grid-pro.genesisgriddatasourceelement.clearerrors.md +17 -0
- package/docs/api/grid-pro.genesisgriddatasourceelement.handleerrors.md +25 -0
- package/docs/api/grid-pro.genesisgriddatasourceelement.md +3 -0
- package/docs/api/grid-pro.genesisgriddatasourceelement.restartonreconnection.md +18 -0
- package/docs/api/grid-pro.gridprobasedatasource.connectionsub.md +11 -0
- package/docs/api/grid-pro.gridprobasedatasource.isdisconnected.md +17 -0
- package/docs/api/grid-pro.gridprobasedatasource.md +5 -0
- package/docs/api/grid-pro.gridprobasedatasource.setdisconnected.md +24 -0
- package/docs/api/grid-pro.gridprobasedatasource.subscribetoconnection.md +15 -0
- package/docs/api/grid-pro.gridprobasedatasource.unsubscribefromconnection.md +15 -0
- package/docs/api/grid-pro.gridprogenesisdatasource.md +0 -2
- package/docs/api/grid-pro.gridprotemplate.md +1 -1
- package/docs/api-report.md +15 -4
- package/package.json +13 -13
- package/docs/api/grid-pro.gridprogenesisdatasource.handleerrors.md +0 -22
- package/docs/api/grid-pro.gridprogenesisdatasource.restartonreconnection.md +0 -11
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { css, html, when, repeat } from '@microsoft/fast-element';
|
|
2
|
+
const extractMessage = (detail) => {
|
|
3
|
+
if (!detail)
|
|
4
|
+
return '';
|
|
5
|
+
if (typeof detail === 'string')
|
|
6
|
+
return detail;
|
|
7
|
+
if (Array.isArray(detail)) {
|
|
8
|
+
return detail.map(extractMessage).join(', ');
|
|
9
|
+
}
|
|
10
|
+
if (typeof detail === 'object') {
|
|
11
|
+
if ('message' in detail && typeof detail.message === 'string')
|
|
12
|
+
return detail.message;
|
|
13
|
+
if ('TEXT' in detail && typeof detail.TEXT === 'string')
|
|
14
|
+
return detail.TEXT;
|
|
15
|
+
return JSON.stringify(detail);
|
|
16
|
+
}
|
|
17
|
+
return String(detail);
|
|
18
|
+
};
|
|
19
|
+
export const errorHandlerDialogStyles = css `
|
|
20
|
+
.overlay {
|
|
21
|
+
position: absolute;
|
|
22
|
+
inset: 0;
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
background-color: var(--datasource-error-background-color, var(--neutral-layer-4));
|
|
26
|
+
opacity: var(--datasource-error-background-opacity, 0.5);
|
|
27
|
+
z-index: 1000;
|
|
28
|
+
pointer-events: auto;
|
|
29
|
+
border-radius: 2px;
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
}
|
|
34
|
+
.dialog-container {
|
|
35
|
+
position: absolute;
|
|
36
|
+
left: 50%;
|
|
37
|
+
top: 50%;
|
|
38
|
+
transform: translate(-50%, -50%);
|
|
39
|
+
z-index: 1001;
|
|
40
|
+
max-width: 90vw;
|
|
41
|
+
max-height: 90vh;
|
|
42
|
+
width: 100%;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
opacity: 1 !important;
|
|
48
|
+
filter: none !important;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
}
|
|
51
|
+
.grid-datasource-error-dialog {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
margin: 0 auto;
|
|
57
|
+
max-width: 400px;
|
|
58
|
+
width: 100%;
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
background: var(--dialog-background, #2d2533);
|
|
61
|
+
box-shadow: 0 4px 32px 0 rgba(0, 0, 0, 0.45);
|
|
62
|
+
overflow: visible;
|
|
63
|
+
min-height: 120px;
|
|
64
|
+
}
|
|
65
|
+
.error-details {
|
|
66
|
+
max-height: 120px;
|
|
67
|
+
overflow: auto;
|
|
68
|
+
width: 100%;
|
|
69
|
+
margin-top: 8px;
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
export function getErrorHandlerDialogTemplate(prefix, gridErrorItems) {
|
|
73
|
+
const dialogTag = `${prefix}-dialog`;
|
|
74
|
+
const buttonTag = `${prefix}-button`;
|
|
75
|
+
return html `
|
|
76
|
+
${when(() => gridErrorItems && gridErrorItems.length > 0, html `
|
|
77
|
+
<div class="overlay"></div>
|
|
78
|
+
<div class="dialog-container">
|
|
79
|
+
<${dialogTag}
|
|
80
|
+
class="grid-datasource-error-dialog"
|
|
81
|
+
type="error"
|
|
82
|
+
show-close-icon="false"
|
|
83
|
+
open
|
|
84
|
+
>
|
|
85
|
+
<h2 slot="top" class="title">Datasource Error</h2>
|
|
86
|
+
<div>
|
|
87
|
+
<p>
|
|
88
|
+
The Datasource is currently unavailable due to an error.
|
|
89
|
+
</p>
|
|
90
|
+
<p>
|
|
91
|
+
This may be due to a network issue, server maintenance or a Datasource configuration error.
|
|
92
|
+
</p>
|
|
93
|
+
<details class="error-details">
|
|
94
|
+
<summary>Show error details</summary>
|
|
95
|
+
${repeat(() => gridErrorItems, html `
|
|
96
|
+
<p>
|
|
97
|
+
<strong>Error:</strong>
|
|
98
|
+
${(x) => extractMessage(x.detail) || 'Unknown error occurred'}
|
|
99
|
+
</p>
|
|
100
|
+
`)}
|
|
101
|
+
</details>
|
|
102
|
+
</div>
|
|
103
|
+
<div slot="bottom">
|
|
104
|
+
<${buttonTag} appearance="lightweight" @click=${(x) => {
|
|
105
|
+
var _a;
|
|
106
|
+
x.hideDatasourceError();
|
|
107
|
+
(_a = x.gridProDatasource) === null || _a === void 0 ? void 0 : _a.restart();
|
|
108
|
+
}}>
|
|
109
|
+
Reload
|
|
110
|
+
</${buttonTag}>
|
|
111
|
+
</div>
|
|
112
|
+
</${dialogTag}>
|
|
113
|
+
</div>
|
|
114
|
+
`)}
|
|
115
|
+
`;
|
|
116
|
+
}
|
|
@@ -106,6 +106,7 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
106
106
|
if (!shouldRunConnect)
|
|
107
107
|
return;
|
|
108
108
|
this.init();
|
|
109
|
+
this.subscribeToConnection();
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
disconnectedCallback() {
|
|
@@ -115,6 +116,7 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
115
116
|
if (!shouldRunDisconnect)
|
|
116
117
|
return;
|
|
117
118
|
yield this.destroy();
|
|
119
|
+
this.unsubscribeFromConnection();
|
|
118
120
|
}));
|
|
119
121
|
}
|
|
120
122
|
deepClone() {
|
|
@@ -137,10 +139,11 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
137
139
|
// Cache the current filter model before clearing data to preserve column filters
|
|
138
140
|
yield ((_b = this.agGrid) === null || _b === void 0 ? void 0 : _b.cacheFilterConfig());
|
|
139
141
|
this.clearRowData(withoutColumnDefs);
|
|
142
|
+
this.setDisconnected(false);
|
|
140
143
|
(_c = this.agGrid.gridApi) === null || _c === void 0 ? void 0 : _c.refreshServerSide({ purge: true });
|
|
141
144
|
if (params) {
|
|
142
145
|
const options = Object.assign(Object.assign({}, this.datasourceOptions()), params);
|
|
143
|
-
const initOK = yield this.
|
|
146
|
+
const initOK = yield this.initializeDatasource(options, true, false);
|
|
144
147
|
if (!initOK) {
|
|
145
148
|
(_d = this.agGrid.gridApi) === null || _d === void 0 ? void 0 : _d.setServerSideDatasource(null);
|
|
146
149
|
logger.error('Genesis Datasource re-init failed on filtering/sorting.');
|
|
@@ -215,13 +218,15 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
215
218
|
this.agGrid.gridOptions = gridOptions;
|
|
216
219
|
this.agGrid['initGrid']();
|
|
217
220
|
this.agGrid.addEventListener(Events.EVENT_GRID_READY, () => __awaiter(this, void 0, void 0, function* () {
|
|
218
|
-
const initOK = yield this.
|
|
221
|
+
const initOK = yield this.initializeDatasource(this.datasourceOptions(), true, false);
|
|
219
222
|
if (!initOK) {
|
|
220
223
|
logger.debug(`Genesis Datasource init failed for ${this.resourceName}`);
|
|
221
224
|
this.clearRowData();
|
|
225
|
+
this.setDisconnected(true);
|
|
222
226
|
return;
|
|
223
227
|
}
|
|
224
228
|
this.$emit(gridProGenesisDatasourceEventNames.dataInit);
|
|
229
|
+
this.setDisconnected(false);
|
|
225
230
|
this.indexes = this.getResourceIndexes(this.datasource.availableIndexes);
|
|
226
231
|
const fieldMetadata = toFieldMetadata(this.datasource.originalFieldDef);
|
|
227
232
|
const agColumnDefs = yield this.getAgColumnDefs(fieldMetadata);
|
|
@@ -230,6 +235,7 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
230
235
|
this.ssrmDatasource = new ReqRepServerSideDatasource({
|
|
231
236
|
createReqRepRequestFunc: this.createReqRepRequest.bind(this),
|
|
232
237
|
reloadResourceDataFunc: this.reloadResourceData.bind(this),
|
|
238
|
+
errorHandlerFunc: this.handleErrors.bind(this),
|
|
233
239
|
resourceName: this.resourceName,
|
|
234
240
|
resourceParams: this.params,
|
|
235
241
|
resourceIndexes: this.indexes,
|
|
@@ -245,6 +251,7 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
245
251
|
this.ssrmDatasource = new DataserverServerSideDatasource({
|
|
246
252
|
createDataserverStreamFunc: this.createDataserverStream.bind(this),
|
|
247
253
|
reloadResourceDataFunc: this.reloadResourceData.bind(this),
|
|
254
|
+
errorHandlerFunc: this.handleErrors.bind(this),
|
|
248
255
|
resourceName: this.resourceName,
|
|
249
256
|
resourceParams: this.params,
|
|
250
257
|
resourceIndexes: this.indexes,
|
|
@@ -264,7 +271,7 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
264
271
|
}), { once: true });
|
|
265
272
|
return;
|
|
266
273
|
}
|
|
267
|
-
|
|
274
|
+
this.handleErrors('Application not connected or invalid resource name, datasource will not work.', 'unknown');
|
|
268
275
|
});
|
|
269
276
|
}
|
|
270
277
|
onPaginationChanged(event) {
|
|
@@ -379,7 +386,11 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
379
386
|
}
|
|
380
387
|
}
|
|
381
388
|
});
|
|
382
|
-
const onError = (error) =>
|
|
389
|
+
const onError = (error) => {
|
|
390
|
+
var _a;
|
|
391
|
+
logger.error(error);
|
|
392
|
+
this.handleErrors(((_a = error.receivedMessage) === null || _a === void 0 ? void 0 : _a.ERROR) || error.message, 'stream');
|
|
393
|
+
};
|
|
383
394
|
this.liveUpdatesStream = this.connect
|
|
384
395
|
.stream(this.resourceName, () => { }, onError, existingParams !== null && existingParams !== void 0 ? existingParams : this.params)
|
|
385
396
|
.subscribe((message) => streamOnMessage(message));
|
|
@@ -25,6 +25,7 @@ export class BaseServerSideDatasource {
|
|
|
25
25
|
this.calculatedRowsCount = 0;
|
|
26
26
|
this.currentSequenceId = null;
|
|
27
27
|
this.reloadResourceDataFunc = options.reloadResourceDataFunc;
|
|
28
|
+
this.errorHandlerFunc = options.errorHandlerFunc;
|
|
28
29
|
this.resourceName = options.resourceName;
|
|
29
30
|
this.resourceParams = options.resourceParams;
|
|
30
31
|
this.originalCriteriaMatch = options.resourceParams.CRITERIA_MATCH;
|
|
@@ -79,6 +79,13 @@ export class DataserverServerSideDatasource extends BaseServerSideDatasource {
|
|
|
79
79
|
const messageType = result.MESSAGE_TYPE;
|
|
80
80
|
if (messageType &&
|
|
81
81
|
(messageType === MessageType.LOGOFF_ACK || messageType === MessageType.MSG_NACK)) {
|
|
82
|
+
// Trigger error dialog for connection/authentication errors
|
|
83
|
+
if (this.errorHandlerFunc) {
|
|
84
|
+
const errorMessage = messageType === MessageType.LOGOFF_ACK
|
|
85
|
+
? `Connection lost to ${this.resourceName}`
|
|
86
|
+
: `Authentication failed for ${this.resourceName}`;
|
|
87
|
+
this.errorHandlerFunc(errorMessage, 'connection');
|
|
88
|
+
}
|
|
82
89
|
params.fail();
|
|
83
90
|
return;
|
|
84
91
|
}
|
|
@@ -58,6 +58,13 @@ export class ReqRepServerSideDatasource extends BaseServerSideDatasource {
|
|
|
58
58
|
const messageType = result.MESSAGE_TYPE;
|
|
59
59
|
if (messageType &&
|
|
60
60
|
(messageType === MessageType.LOGOFF_ACK || messageType === MessageType.MSG_NACK)) {
|
|
61
|
+
// Trigger error dialog for connection/authentication errors
|
|
62
|
+
if (this.errorHandlerFunc) {
|
|
63
|
+
const errorMessage = messageType === MessageType.LOGOFF_ACK
|
|
64
|
+
? `Connection lost to ${this.resourceName}`
|
|
65
|
+
: `Authentication failed for ${this.resourceName}`;
|
|
66
|
+
this.errorHandlerFunc(errorMessage, 'connection');
|
|
67
|
+
}
|
|
61
68
|
params.fail();
|
|
62
69
|
return;
|
|
63
70
|
}
|
|
@@ -24,7 +24,6 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
24
24
|
this.applyAsyncFuncName = 'applyTransactionAsync';
|
|
25
25
|
// Cache for rowData array to avoid repeated Array.from() calls
|
|
26
26
|
this.cachedRowArray = [];
|
|
27
|
-
this.restartOnReconnection = true;
|
|
28
27
|
this.keepColDefsOnClearRowData = false;
|
|
29
28
|
this.requiresFullRowDataAndColDefs = true;
|
|
30
29
|
this._lastMoreRows = false;
|
|
@@ -57,18 +56,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
57
56
|
if (!shouldRunConnect)
|
|
58
57
|
return;
|
|
59
58
|
this.init();
|
|
60
|
-
|
|
61
|
-
this.connectionSub = this.connect.isConnected$.subscribe((isConnected) => {
|
|
62
|
-
var _a;
|
|
63
|
-
if (isConnected && ((_a = this.agGrid) === null || _a === void 0 ? void 0 : _a.attributes['ds-disconnected'])) {
|
|
64
|
-
this.agGrid.removeAttribute('ds-disconnected');
|
|
65
|
-
if (this.restartOnReconnection) {
|
|
66
|
-
this.reloadResourceData();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (!isConnected) {
|
|
70
|
-
this.agGrid.setAttribute('ds-disconnected', 'ds-disconnected');
|
|
71
|
-
}
|
|
59
|
+
this.subscribeToConnection();
|
|
72
60
|
});
|
|
73
61
|
}
|
|
74
62
|
disconnectedCallback() {
|
|
@@ -78,6 +66,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
78
66
|
if (!shouldRunDisconnect)
|
|
79
67
|
return;
|
|
80
68
|
this.destroy();
|
|
69
|
+
this.unsubscribeFromConnection();
|
|
81
70
|
});
|
|
82
71
|
}
|
|
83
72
|
deepClone() {
|
|
@@ -142,7 +131,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
142
131
|
});
|
|
143
132
|
return;
|
|
144
133
|
}
|
|
145
|
-
this.handleErrors('Application not connected or invalid resource name, datasource will not work.
|
|
134
|
+
this.handleErrors('Application not connected or invalid resource name, datasource will not work.', 'unknown');
|
|
146
135
|
});
|
|
147
136
|
}
|
|
148
137
|
/**
|
|
@@ -164,6 +153,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
164
153
|
this.connectionSub.unsubscribe();
|
|
165
154
|
this.connectionSub = undefined;
|
|
166
155
|
}
|
|
156
|
+
this._sourceRef = undefined;
|
|
167
157
|
this.clearRowData();
|
|
168
158
|
this._lastMoreRows = false;
|
|
169
159
|
this._isMoreRowsResult = false;
|
|
@@ -173,7 +163,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
173
163
|
this.criteriaFromFilters = new Map();
|
|
174
164
|
(_a = this.update) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
175
165
|
this.update = new BehaviorSubject(new Map());
|
|
176
|
-
this.
|
|
166
|
+
this.setDisconnected(false);
|
|
177
167
|
// TODO: There may need to be a full destroy path. Datasources need some love!
|
|
178
168
|
this.datasource.destroy();
|
|
179
169
|
}
|
|
@@ -301,7 +291,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
301
291
|
yield ((_a = this.agGrid) === null || _a === void 0 ? void 0 : _a.cacheFilterConfig());
|
|
302
292
|
this.clearRowData(withoutColumnDefs);
|
|
303
293
|
(_c = (_b = this.agGrid) === null || _b === void 0 ? void 0 : _b.gridApi) === null || _c === void 0 ? void 0 : _c.showLoadingOverlay();
|
|
304
|
-
this.
|
|
294
|
+
this.setDisconnected(false);
|
|
305
295
|
yield this.loadResourceData(withoutFullInit);
|
|
306
296
|
});
|
|
307
297
|
}
|
|
@@ -317,7 +307,8 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
317
307
|
return __awaiter(this, void 0, void 0, function* () {
|
|
318
308
|
const requiresMetadataFetch = withFullInit || !this.datasource.initialized;
|
|
319
309
|
try {
|
|
320
|
-
|
|
310
|
+
// Use the base datasource error handling
|
|
311
|
+
const initOK = yield this.initializeDatasource(this.datasourceOptions(), requiresMetadataFetch, false);
|
|
321
312
|
if (!initOK) {
|
|
322
313
|
logger.debug(`Genesis Datasource init failed for ${this.resourceName}`);
|
|
323
314
|
this.clearRowData();
|
|
@@ -337,7 +328,8 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
337
328
|
this.dataSub = this.datasource.stream
|
|
338
329
|
.pipe(catchError((err) => {
|
|
339
330
|
var _a;
|
|
340
|
-
|
|
331
|
+
// Use base error handling for stream errors
|
|
332
|
+
this.handleErrors(((_a = err === null || err === void 0 ? void 0 : err.receivedMessage) === null || _a === void 0 ? void 0 : _a.ERROR) || (err === null || err === void 0 ? void 0 : err.message) || err, 'stream');
|
|
341
333
|
return EMPTY;
|
|
342
334
|
}))
|
|
343
335
|
.subscribe((result) => {
|
|
@@ -346,11 +338,11 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
346
338
|
const hasRowsCountInResult = 'ROWS_COUNT' in result;
|
|
347
339
|
this._isMoreRowsResult = hasMoreRowsInResult && !hasRowsCountInResult;
|
|
348
340
|
if (result === null || result === void 0 ? void 0 : result.ERROR) {
|
|
349
|
-
this.handleErrors(result.ERROR);
|
|
341
|
+
this.handleErrors(result.ERROR, 'criteria');
|
|
350
342
|
}
|
|
351
343
|
const messageType = result.MESSAGE_TYPE;
|
|
352
344
|
if (messageType && messageType === MessageType.LOGOFF_ACK) {
|
|
353
|
-
this.handleErrors(`Genesis datasource for ${this.resourceName} disconnected
|
|
345
|
+
this.handleErrors(`Genesis datasource for ${this.resourceName} disconnected.`, 'connection');
|
|
354
346
|
this.dataSubWasLoggedOff = true;
|
|
355
347
|
return;
|
|
356
348
|
}
|
|
@@ -381,7 +373,8 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
381
373
|
message = error.receivedMessage.ERROR;
|
|
382
374
|
}
|
|
383
375
|
logger.error(message);
|
|
384
|
-
|
|
376
|
+
// Use base error handling for general errors
|
|
377
|
+
this.handleErrors(message, 'unknown');
|
|
385
378
|
}
|
|
386
379
|
});
|
|
387
380
|
}
|
|
@@ -396,30 +389,6 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
396
389
|
}
|
|
397
390
|
return result.inserts;
|
|
398
391
|
}
|
|
399
|
-
handleErrors(errors) {
|
|
400
|
-
let message;
|
|
401
|
-
if (Array.isArray(errors)) {
|
|
402
|
-
const stringArray = errors.map((item) => {
|
|
403
|
-
if (typeof item === 'string') {
|
|
404
|
-
return item;
|
|
405
|
-
}
|
|
406
|
-
else if (typeof item === 'object' && item !== null && 'TEXT' in item) {
|
|
407
|
-
return item.TEXT;
|
|
408
|
-
}
|
|
409
|
-
else {
|
|
410
|
-
throw new Error('Array contains invalid elements');
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
message = stringArray.join(', ');
|
|
414
|
-
}
|
|
415
|
-
if (this.agGrid) {
|
|
416
|
-
this.agGrid.setAttribute('ds-disconnected', 'ds-disconnected');
|
|
417
|
-
}
|
|
418
|
-
if (message) {
|
|
419
|
-
logger.error(message);
|
|
420
|
-
this.$emit(gridProGenesisDatasourceEventNames.error, { message });
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
392
|
handleStreamResult(result) {
|
|
424
393
|
if (!result)
|
|
425
394
|
return;
|
|
@@ -574,9 +543,6 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
|
|
|
574
543
|
this.connect.getMoreRows(this._sourceRef);
|
|
575
544
|
}
|
|
576
545
|
};
|
|
577
|
-
__decorate([
|
|
578
|
-
attr({ mode: 'boolean', attribute: 'restart-on-reconnection' })
|
|
579
|
-
], GridProGenesisDatasource.prototype, "restartOnReconnection", void 0);
|
|
580
546
|
__decorate([
|
|
581
547
|
attr({ mode: 'boolean', attribute: 'keep-col-defs-on-clear-row-data' })
|
|
582
548
|
], GridProGenesisDatasource.prototype, "keepColDefsOnClearRowData", void 0);
|
package/dist/esm/grid-pro.js
CHANGED
|
@@ -14,6 +14,7 @@ import { DateEditor, MultiselectEditor, NumberEditor, SelectEditor, StringEditor
|
|
|
14
14
|
import { ActionRenderer, ActionsMenuRenderer, BooleanRenderer, EditableRenderer, StatusPillRenderer, SelectRenderer, } from './cell-renderers';
|
|
15
15
|
import { GridProColumn } from './column';
|
|
16
16
|
import { GridProClientSideDatasource, GridProServerSideDatasource } from './datasource';
|
|
17
|
+
import { baseDatasourceEventNames } from './datasource/base.types';
|
|
17
18
|
import { agThemeFontFaceMap, defaultAgGridFontFace } from './external';
|
|
18
19
|
import { GridProGenesisDatasource, gridProGenesisDatasourceEventNames, } from './grid-pro-genesis-datasource';
|
|
19
20
|
import { DEBOUNCED_RESIZE_TIME, gridProErrorNames, gridProEventNames, } from './grid-pro.definitions';
|
|
@@ -162,9 +163,14 @@ export class GridPro extends LifecycleMixin(FoundationElement) {
|
|
|
162
163
|
return map;
|
|
163
164
|
}, {});
|
|
164
165
|
const hideDataSourceError = this.hideDatasourceError.bind(this);
|
|
165
|
-
this.rootEventsListeners.push({ key: gridProGenesisDatasourceEventNames.dataInit, action: hideDataSourceError }, { key: gridProEventNames.datasourceErrorClose, action: hideDataSourceError },
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
this.rootEventsListeners.push({ key: gridProGenesisDatasourceEventNames.dataInit, action: hideDataSourceError }, { key: gridProEventNames.datasourceErrorClose, action: hideDataSourceError },
|
|
167
|
+
// Base datasource error handling for resource validation and initialization errors
|
|
168
|
+
{
|
|
169
|
+
key: baseDatasourceEventNames.error,
|
|
170
|
+
action: this.handleBaseDatasourceError.bind(this),
|
|
171
|
+
}, {
|
|
172
|
+
key: baseDatasourceEventNames.connected,
|
|
173
|
+
action: hideDataSourceError,
|
|
168
174
|
});
|
|
169
175
|
}
|
|
170
176
|
/**
|
|
@@ -194,6 +200,17 @@ export class GridPro extends LifecycleMixin(FoundationElement) {
|
|
|
194
200
|
handleError(type, event) {
|
|
195
201
|
this.gridErrorItems = [...this.gridErrorItems, { detail: event.detail, type }];
|
|
196
202
|
}
|
|
203
|
+
handleBaseDatasourceError(event) {
|
|
204
|
+
// Map base datasource errors to grid-pro error format
|
|
205
|
+
const gridProError = {
|
|
206
|
+
detail: { message: event.detail.message },
|
|
207
|
+
type: gridProErrorNames.datasource,
|
|
208
|
+
};
|
|
209
|
+
this.gridErrorItems = [
|
|
210
|
+
...this.gridErrorItems,
|
|
211
|
+
{ detail: gridProError.detail, type: gridProError.type },
|
|
212
|
+
];
|
|
213
|
+
}
|
|
197
214
|
hideDatasourceError() {
|
|
198
215
|
this.gridErrorItems = this.gridErrorItems.filter((item) => item.type !== gridProErrorNames.datasource);
|
|
199
216
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { css } from '@microsoft/fast-element';
|
|
2
|
+
import { errorHandlerDialogStyles } from './datasource/error-handler.dialog';
|
|
2
3
|
import { agExternalStockStyles } from './external';
|
|
3
4
|
/**
|
|
4
5
|
* The Grid Pro styles.
|
|
@@ -7,6 +8,7 @@ import { agExternalStockStyles } from './external';
|
|
|
7
8
|
*/
|
|
8
9
|
export const foundationGridProStyles = css `
|
|
9
10
|
${agExternalStockStyles}
|
|
11
|
+
${errorHandlerDialogStyles}
|
|
10
12
|
:host {
|
|
11
13
|
--datasource-error-background-color: var(--neutral-layer-4);
|
|
12
14
|
--datasource-error-background-opacity: 0.5;
|
|
@@ -43,28 +45,6 @@ export const foundationGridProStyles = css `
|
|
|
43
45
|
display: none;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
.grid-datasource-error-dialog::part(dialog) {
|
|
47
|
-
position: absolute;
|
|
48
|
-
z-index: 2;
|
|
49
|
-
max-width: var(--datasource-error-dialog-max-width);
|
|
50
|
-
|
|
51
|
-
--dialog-min-width: var(--datasource-error-dialog-min-width);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.grid-datasource-error-dialog::before {
|
|
55
|
-
content: '';
|
|
56
|
-
position: absolute;
|
|
57
|
-
top: 50%;
|
|
58
|
-
transform: translateY(-50%);
|
|
59
|
-
left: 0;
|
|
60
|
-
height: 100%;
|
|
61
|
-
width: 100%;
|
|
62
|
-
border-radius: 2px;
|
|
63
|
-
background-color: var(--datasource-error-background-color);
|
|
64
|
-
opacity: var(--datasource-error-background-opacity);
|
|
65
|
-
z-index: 1;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
48
|
.error {
|
|
69
49
|
border-color: var(--error-color) !important;
|
|
70
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { html, ref } from '@microsoft/fast-element';
|
|
2
|
-
import {
|
|
2
|
+
import { getErrorHandlerDialogTemplate } from './datasource/error-handler.dialog';
|
|
3
3
|
/**
|
|
4
4
|
* Get a Design System prefixed The Grid Pro template.
|
|
5
5
|
* @param prefix - The design system prefix to use. Defaults to 'foundation'.
|
|
@@ -12,43 +12,13 @@ export const getGridProTemplate = (prefix = 'foundation') => html `
|
|
|
12
12
|
<slot name="grid" ${ref('gridSlot')}></slot>
|
|
13
13
|
<slot></slot>
|
|
14
14
|
</span>
|
|
15
|
-
|
|
16
|
-
name="grid-datasource-error"
|
|
17
|
-
part="grid-datasource-error"
|
|
18
|
-
class="${(x) => (x.gridErrorItems.filter(({ type }) => type === gridProErrorNames.datasource).length > 0 ? '' : 'hidden')}"
|
|
19
|
-
>
|
|
20
|
-
<${prefix}-dialog
|
|
21
|
-
class="grid-datasource-error-dialog"
|
|
22
|
-
type="error"
|
|
23
|
-
show-close-icon="false"
|
|
24
|
-
open
|
|
25
|
-
>
|
|
26
|
-
<h2 slot="top" class="title">Component unavailable</h2>
|
|
27
|
-
<p>
|
|
28
|
-
Please refresh to reconnect.
|
|
29
|
-
It is recommended that you save your data before refreshing.
|
|
30
|
-
Data is not current and may be incomplete.
|
|
31
|
-
</p>
|
|
32
|
-
<div slot="bottom">
|
|
33
|
-
<${prefix}-button
|
|
34
|
-
appearance="lightweight"
|
|
35
|
-
@click=${(x) => {
|
|
36
|
-
var _a;
|
|
37
|
-
x.hideDatasourceError();
|
|
38
|
-
(_a = x.gridProDatasource) === null || _a === void 0 ? void 0 : _a.restart();
|
|
39
|
-
}}
|
|
40
|
-
>
|
|
41
|
-
Refresh
|
|
42
|
-
</${prefix}-button>
|
|
43
|
-
</div>
|
|
44
|
-
</${prefix}-dialog>
|
|
45
|
-
</slot>
|
|
15
|
+
${(x) => getErrorHandlerDialogTemplate(prefix, x.gridErrorItems.filter(({ type }) => type === 'datasource'))}
|
|
46
16
|
</template>
|
|
47
17
|
`;
|
|
48
18
|
/**
|
|
49
19
|
*
|
|
50
20
|
* @public
|
|
51
21
|
* @remarks
|
|
52
|
-
* HTML Element:
|
|
22
|
+
* HTML Element: <foundation-grid-pro>
|
|
53
23
|
*/
|
|
54
24
|
export const gridProTemplate = getGridProTemplate();
|