@genesislcap/grid-pro 15.97.0 → 15.98.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 +1492 -14
- package/dist/dts/datasource/cube.block-loads.d.ts +29 -0
- package/dist/dts/datasource/cube.block-loads.d.ts.map +1 -0
- package/dist/dts/datasource/cube.client.d.ts +50 -0
- package/dist/dts/datasource/cube.client.d.ts.map +1 -0
- package/dist/dts/datasource/cube.request.d.ts +99 -0
- package/dist/dts/datasource/cube.request.d.ts.map +1 -0
- package/dist/dts/datasource/cube.source.d.ts +43 -0
- package/dist/dts/datasource/cube.source.d.ts.map +1 -0
- package/dist/dts/datasource/infinite.datasource.d.ts +39 -3
- package/dist/dts/datasource/infinite.datasource.d.ts.map +1 -1
- package/dist/dts/datasource/infinite.resource-cube.d.ts +22 -0
- package/dist/dts/datasource/infinite.resource-cube.d.ts.map +1 -0
- package/dist/dts/datasource/server-side.datasource.d.ts +49 -1
- package/dist/dts/datasource/server-side.datasource.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.resource-cube.d.ts +21 -0
- package/dist/dts/datasource/server-side.resource-cube.d.ts.map +1 -0
- package/dist/dts/grid-pro-genesis-datasource/datasource-events.types.d.ts +2 -1
- package/dist/dts/grid-pro-genesis-datasource/datasource-events.types.d.ts.map +1 -1
- package/dist/esm/datasource/cube.block-loads.js +48 -0
- package/dist/esm/datasource/cube.client.js +144 -0
- package/dist/esm/datasource/cube.request.js +165 -0
- package/dist/esm/datasource/cube.source.js +73 -0
- package/dist/esm/datasource/infinite.datasource.js +157 -24
- package/dist/esm/datasource/infinite.resource-cube.js +56 -0
- package/dist/esm/datasource/server-side.datasource.js +197 -23
- package/dist/esm/datasource/server-side.resource-cube.js +58 -0
- package/dist/grid-pro.api.json +510 -3
- package/dist/grid-pro.d.ts +139 -3
- package/package.json +12 -12
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CubeBlockLoads } from './cube.block-loads';
|
|
2
|
+
import { cubeRowCount } from './cube.request';
|
|
3
|
+
const ROW_COUNT_UNKNOWN = -1;
|
|
4
|
+
export class CubeInfiniteDatasource {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
this.detached = false;
|
|
8
|
+
this.loads = new CubeBlockLoads(options);
|
|
9
|
+
}
|
|
10
|
+
getRows(params) {
|
|
11
|
+
if (this.detached) {
|
|
12
|
+
params.failCallback();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const { startRow, endRow, sortModel, filterModel } = params;
|
|
16
|
+
const isWanted = this.loads.begin(JSON.stringify({ sortModel, filterModel }));
|
|
17
|
+
this.options.fetchRows({ startRow, endRow, sortModel, filterModel }).then((envelope) => {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
|
+
// Failed rather than dropped: AG Grid frees a request slot only on success or fail.
|
|
20
|
+
if (!isWanted()) {
|
|
21
|
+
params.failCallback();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const rows = (_a = envelope.rows) !== null && _a !== void 0 ? _a : [];
|
|
25
|
+
params.successCallback(rows, (_b = cubeRowCount(envelope, startRow)) !== null && _b !== void 0 ? _b : ROW_COUNT_UNKNOWN);
|
|
26
|
+
this.loads.deliver(startRow, rows);
|
|
27
|
+
if (startRow !== 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (rows.length) {
|
|
31
|
+
(_d = (_c = this.options).onDataAvailable) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
(_f = (_e = this.options).onNoDataAvailable) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
35
|
+
}
|
|
36
|
+
}, (error) => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
params.failCallback();
|
|
39
|
+
if (isWanted()) {
|
|
40
|
+
(_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
invalidatePendingLoads() {
|
|
45
|
+
this.loads.invalidate();
|
|
46
|
+
}
|
|
47
|
+
/** AG Grid calls this on a datasource it then keeps using, so replies in flight stay valid. */
|
|
48
|
+
destroy() {
|
|
49
|
+
this.loads.forgetRows();
|
|
50
|
+
}
|
|
51
|
+
/** The host is replacing this instance; AG Grid keeps asking it for blocks until the swap. */
|
|
52
|
+
detach() {
|
|
53
|
+
this.detached = true;
|
|
54
|
+
this.loads.invalidate();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
|
2
|
-
import { Datasource, MessageType, normaliseCriteria, toFieldMetadata, } from '@genesislcap/foundation-comms';
|
|
2
|
+
import { Datasource, Http, MessageType, normaliseCriteria, toFieldMetadata, } from '@genesislcap/foundation-comms';
|
|
3
3
|
import { LifecycleMixin } from '@genesislcap/foundation-utils';
|
|
4
4
|
import { attr, customElement, DOM, observable } from '@microsoft/fast-element';
|
|
5
|
+
import { debounceTime, skip } from 'rxjs/operators';
|
|
5
6
|
import { gridProGenesisDatasourceEventNames } from '../grid-pro-genesis-datasource';
|
|
6
7
|
import { datasourceEventNames, } from '../grid-pro-genesis-datasource/datasource-events.types';
|
|
7
8
|
import { logger } from '../utils';
|
|
8
9
|
import { GridProBaseDatasource } from './base.datasource';
|
|
10
|
+
import { cubeFilterParams, describeCubeError, toCubeColumnDefs } from './cube.client';
|
|
11
|
+
import { CUBE_CHILD_COUNT, CUBE_ROW_REF, toCubeRowId } from './cube.request';
|
|
12
|
+
import { CubeSource } from './cube.source';
|
|
9
13
|
import { filterDataserverResult } from './dataserver-result.filter';
|
|
10
14
|
import { getFilterByFieldType, getServerSideFilterParamsByFieldType, } from './server-side.grid-definitions';
|
|
15
|
+
import { CubeServerSideDatasource } from './server-side.resource-cube';
|
|
11
16
|
import { DataserverServerSideDatasource } from './server-side.resource-dataserver';
|
|
12
17
|
import { ReqRepServerSideDatasource } from './server-side.resource-reqrep';
|
|
13
18
|
import { getIndexLeadingFields } from './sort-index.utils';
|
|
14
19
|
const criteriaDelimiter = ';';
|
|
15
20
|
const withoutColumnDefs = null;
|
|
21
|
+
/** How long a burst of `setFilter()` calls is collapsed for, matching the infinite model. */
|
|
22
|
+
const FILTER_DEBOUNCE_MS = 600;
|
|
16
23
|
/**
|
|
17
24
|
* A Genesis Datasource element, for server-side | SSRM-compatible data fetching and used exclusively by the GridPro element.
|
|
18
25
|
* @remarks Only supports Server-Side Row Model. Requires `@ag-grid-enterprise/server-side-row-model` setup and valid AG Grid Enterprise license.
|
|
@@ -21,6 +28,16 @@ const withoutColumnDefs = null;
|
|
|
21
28
|
* `criteriaOnlyRequest`. A req/rep resource without it reports a `resource-type` error and no
|
|
22
29
|
* datasource is attached to the grid.
|
|
23
30
|
*
|
|
31
|
+
* **Genesis Spring data cubes**: with `cube-url` set, `resource-name` names a cube resource read
|
|
32
|
+
* over HTTP from that URL: its `query` endpoint, or the named `cube-operation`. Filtering, sorting
|
|
33
|
+
* and paging run on the cube, and on the `query` endpoint row grouping and value aggregation do
|
|
34
|
+
* too; `criteria` restricts every request. The Genesis stream attributes (`live-updates`, polling,
|
|
35
|
+
* `is-snapshot`, `order-by`, `request`) do not apply. Row grouping also requires the AG Grid
|
|
36
|
+
* Enterprise `RowGroupingModule`, and is not offered on date and datetime columns: a request that
|
|
37
|
+
* groups by one is refused and reported as a datasource error. Rows that carry no id - a resource
|
|
38
|
+
* that is not `addressable`, or a named operation whose rows have no `ROW_REF`, with no `row-id`
|
|
39
|
+
* set - get AG Grid's own row ids and raise no `datasource-data-changed`.
|
|
40
|
+
*
|
|
24
41
|
* **Custom Sort Indicators**: This datasource automatically applies custom sort indicators that are always visible (instead of only on hover).
|
|
25
42
|
* Sortable columns will show a subtle sort icon even when not sorted, and active sort indicators will be more prominent.
|
|
26
43
|
* The custom styling uses AG Grid's native icon font for consistency with the grid theme.
|
|
@@ -56,7 +73,13 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
56
73
|
*/
|
|
57
74
|
this.liveUpdates = false;
|
|
58
75
|
this.request = {};
|
|
76
|
+
this.cube = new CubeSource(this);
|
|
77
|
+
this.initialised = false;
|
|
59
78
|
this.onDatasourceReady = (_event) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
if (this.isCube) {
|
|
80
|
+
yield this.onCubeReady();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
60
83
|
const initOK = yield this.initializeDatasource(this.datasourceOptions(), true, false);
|
|
61
84
|
if (!initOK) {
|
|
62
85
|
logger.debug(`Genesis Datasource init failed for ${this.resourceName}`);
|
|
@@ -150,6 +173,20 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
150
173
|
* @internal
|
|
151
174
|
*/
|
|
152
175
|
this.hasCapturedFirstPollResult = false;
|
|
176
|
+
/** A group row is identified by its group value: only some cubes give group rows a `ROW_REF`. */
|
|
177
|
+
this.cubeRowId = ({ data, level, parentKeys }) => {
|
|
178
|
+
var _a;
|
|
179
|
+
if (!data)
|
|
180
|
+
return null;
|
|
181
|
+
const groupField = (_a = this.cubeSsrmDatasource) === null || _a === void 0 ? void 0 : _a.groupFieldAt(level);
|
|
182
|
+
return toCubeRowId(parentKeys, data[groupField !== null && groupField !== void 0 ? groupField : this.rowId]);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
get rowId() {
|
|
186
|
+
return this.isCube ? this.rowIdAttr || CUBE_ROW_REF : super.rowId;
|
|
187
|
+
}
|
|
188
|
+
get isCube() {
|
|
189
|
+
return Boolean(this.cubeUrl);
|
|
153
190
|
}
|
|
154
191
|
resourceNameChanged(oldValue, newValue) {
|
|
155
192
|
if (!oldValue || oldValue === newValue)
|
|
@@ -158,8 +195,18 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
158
195
|
yield this.restart();
|
|
159
196
|
}));
|
|
160
197
|
}
|
|
198
|
+
cubeUrlChanged(oldValue, newValue) {
|
|
199
|
+
this.restartOnCubeSourceChange(oldValue, newValue);
|
|
200
|
+
}
|
|
201
|
+
cubeOperationChanged(oldValue, newValue) {
|
|
202
|
+
this.restartOnCubeSourceChange(oldValue, newValue);
|
|
203
|
+
}
|
|
161
204
|
criteriaChanged(oldCriteria, newCriteria) {
|
|
162
205
|
const criteriaIsNotDuplicate = oldCriteria !== normaliseCriteria(newCriteria, criteriaDelimiter);
|
|
206
|
+
if (this.cubeSsrmDatasource && criteriaIsNotDuplicate) {
|
|
207
|
+
DOM.queueUpdate(() => this.reloadResourceData());
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
163
210
|
if (this.ssrmDatasource && criteriaIsNotDuplicate) {
|
|
164
211
|
DOM.queueUpdate(() => __awaiter(this, void 0, void 0, function* () {
|
|
165
212
|
yield this.ssrmDatasource.refreshDatasource({
|
|
@@ -175,7 +222,8 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
175
222
|
if (!shouldRunConnect)
|
|
176
223
|
return;
|
|
177
224
|
this.init();
|
|
178
|
-
this.
|
|
225
|
+
this.syncConnectionSubscription();
|
|
226
|
+
this.subscribeToFilterChanges();
|
|
179
227
|
});
|
|
180
228
|
}
|
|
181
229
|
disconnectedCallback() {
|
|
@@ -184,10 +232,39 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
184
232
|
DOM.queueUpdate(() => __awaiter(this, void 0, void 0, function* () {
|
|
185
233
|
if (!shouldRunDisconnect)
|
|
186
234
|
return;
|
|
235
|
+
this.initialised = false;
|
|
187
236
|
yield this.destroy();
|
|
188
237
|
this.unsubscribeFromConnection();
|
|
238
|
+
this.unsubscribeFromFilterChanges();
|
|
189
239
|
}));
|
|
190
240
|
}
|
|
241
|
+
/** Cube reads go over HTTP, so a socket drop says nothing about them. */
|
|
242
|
+
syncConnectionSubscription() {
|
|
243
|
+
if (this.isCube) {
|
|
244
|
+
this.unsubscribeFromConnection();
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.subscribeToConnection();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Re-reads an attached cube once a burst of `setFilter()` / `removeFilter()` calls settles.
|
|
252
|
+
* @remarks Genesis resources are left as they were: their criteria is fixed when the stream or
|
|
253
|
+
* request is created.
|
|
254
|
+
*/
|
|
255
|
+
subscribeToFilterChanges() {
|
|
256
|
+
this.unsubscribeFromFilterChanges();
|
|
257
|
+
// `update` replays its current value on subscribe, which init() is already reading.
|
|
258
|
+
this.filterSub = this.update.pipe(skip(1), debounceTime(FILTER_DEBOUNCE_MS)).subscribe(() => {
|
|
259
|
+
if (this.cubeSsrmDatasource)
|
|
260
|
+
this.purgeCubeRows();
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
unsubscribeFromFilterChanges() {
|
|
264
|
+
var _a;
|
|
265
|
+
(_a = this.filterSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
266
|
+
this.filterSub = undefined;
|
|
267
|
+
}
|
|
191
268
|
deepClone() {
|
|
192
269
|
const copy = super.deepClone();
|
|
193
270
|
copy.deferredGridOptions = structuredClone(this.deferredGridOptions);
|
|
@@ -202,6 +279,10 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
202
279
|
reloadResourceData(params) {
|
|
203
280
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
281
|
var _a, _b, _c;
|
|
282
|
+
if (this.isCube) {
|
|
283
|
+
yield this.reloadCubeData();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
205
286
|
this.datasource.destroy();
|
|
206
287
|
// A block request still in flight was read for the cache being dropped here; its reply must
|
|
207
288
|
// not be reported as rows the grid holds.
|
|
@@ -276,25 +357,12 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
276
357
|
}
|
|
277
358
|
init() {
|
|
278
359
|
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
return String(params.data[this.rowId]);
|
|
285
|
-
}, getRowStyle(params) {
|
|
286
|
-
var _a, _b;
|
|
287
|
-
if ((_b = (_a = params.data) === null || _a === void 0 ? void 0 : _a.ROW_REF) === null || _b === void 0 ? void 0 : _b.includes('_deleted')) {
|
|
288
|
-
return { color: 'grey' };
|
|
289
|
-
}
|
|
290
|
-
}, cacheBlockSize: this.maxRows, defaultColDef: {
|
|
291
|
-
filter: true,
|
|
292
|
-
resizable: true,
|
|
293
|
-
sortable: false,
|
|
294
|
-
unSortIcon: true,
|
|
295
|
-
}, rowBuffer: 0, rowModelType: 'serverSide', suppressServerSideInfiniteScroll: false, suppressMultiSort: true, onFilterChanged: (params) => { }, onSortChanged: (params) => { } }, this.deferredGridOptions);
|
|
360
|
+
this.initialised = true;
|
|
361
|
+
const options = this.isCube ? yield this.cubeGridOptions() : this.genesisGridOptions();
|
|
362
|
+
if (!options)
|
|
363
|
+
return;
|
|
296
364
|
this.$emit(datasourceEventNames.initialize, {
|
|
297
|
-
options
|
|
365
|
+
options,
|
|
298
366
|
keepColDefsOnClearRowData: this.keepColDefsOnClearRowData,
|
|
299
367
|
});
|
|
300
368
|
// TODO: refactor this to prevent rendering datasource component until grid is ready
|
|
@@ -307,20 +375,41 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
307
375
|
}
|
|
308
376
|
});
|
|
309
377
|
}
|
|
378
|
+
genesisGridOptions() {
|
|
379
|
+
return Object.assign({ getRowId: (params) => {
|
|
380
|
+
if (!params.data) {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
return String(params.data[this.rowId]);
|
|
384
|
+
}, getRowStyle(params) {
|
|
385
|
+
var _a, _b;
|
|
386
|
+
if ((_b = (_a = params.data) === null || _a === void 0 ? void 0 : _a.ROW_REF) === null || _b === void 0 ? void 0 : _b.includes('_deleted')) {
|
|
387
|
+
return { color: 'grey' };
|
|
388
|
+
}
|
|
389
|
+
}, cacheBlockSize: this.maxRows, defaultColDef: {
|
|
390
|
+
filter: true,
|
|
391
|
+
resizable: true,
|
|
392
|
+
sortable: false,
|
|
393
|
+
unSortIcon: true,
|
|
394
|
+
}, rowBuffer: 0, rowModelType: 'serverSide', suppressServerSideInfiniteScroll: false, suppressMultiSort: true, onFilterChanged: (params) => { }, onSortChanged: (params) => { } }, this.deferredGridOptions);
|
|
395
|
+
}
|
|
310
396
|
clearReadyListener() {
|
|
311
397
|
this.removeEventListener(datasourceEventNames.ready, this.onDatasourceReady);
|
|
312
398
|
}
|
|
313
399
|
destroy() {
|
|
314
400
|
return __awaiter(this, void 0, void 0, function* () {
|
|
315
|
-
var _a, _b;
|
|
401
|
+
var _a, _b, _c;
|
|
402
|
+
this.cube.reset();
|
|
403
|
+
(_a = this.cubeSsrmDatasource) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
404
|
+
this.cubeSsrmDatasource = undefined;
|
|
316
405
|
this.clearReadyListener();
|
|
317
406
|
this.datasource.destroy();
|
|
318
|
-
(
|
|
407
|
+
(_b = this.liveUpdatesStream) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
319
408
|
this.liveUpdatesStream = undefined;
|
|
320
409
|
this.clearRowData();
|
|
321
410
|
if (this.ssrmDatasource) {
|
|
322
411
|
yield this.ssrmDatasource.destroy();
|
|
323
|
-
(
|
|
412
|
+
(_c = this.pollingDatasource) === null || _c === void 0 ? void 0 : _c.destroy();
|
|
324
413
|
this.ssrmDatasource = undefined;
|
|
325
414
|
}
|
|
326
415
|
// Remove custom sort indicator styling
|
|
@@ -668,13 +757,98 @@ let GridProServerSideDatasource = class GridProServerSideDatasource extends Life
|
|
|
668
757
|
loadMore() {
|
|
669
758
|
throw new Error('loadMore() method is not supported for server-side datasource');
|
|
670
759
|
}
|
|
760
|
+
restartOnCubeSourceChange(oldValue, newValue) {
|
|
761
|
+
if (!this.initialised || oldValue === newValue)
|
|
762
|
+
return;
|
|
763
|
+
DOM.queueUpdate(() => {
|
|
764
|
+
this.syncConnectionSubscription();
|
|
765
|
+
return this.restart();
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
cubeGridOptions() {
|
|
769
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
770
|
+
const settings = yield this.cube.readGridSettings();
|
|
771
|
+
if (!settings)
|
|
772
|
+
return undefined;
|
|
773
|
+
return Object.assign(Object.assign(Object.assign({}, (settings.rowsCarryId ? { getRowId: this.cubeRowId } : {})), { getChildCount: (data) => data === null || data === void 0 ? void 0 : data[CUBE_CHILD_COUNT], cacheBlockSize: settings.cacheBlockSize, defaultColDef: {
|
|
774
|
+
filter: true,
|
|
775
|
+
resizable: true,
|
|
776
|
+
sortable: true,
|
|
777
|
+
}, rowBuffer: 0, rowModelType: 'serverSide' }), this.deferredGridOptions);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
onCubeReady() {
|
|
781
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
782
|
+
let schema;
|
|
783
|
+
try {
|
|
784
|
+
schema = yield this.cube.readSchema(this.buildCriteria());
|
|
785
|
+
}
|
|
786
|
+
catch (error) {
|
|
787
|
+
this.handleErrors(describeCubeError(error), 'resource-validation');
|
|
788
|
+
this.refuseServerSideDatasource();
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
if (!schema)
|
|
792
|
+
return;
|
|
793
|
+
const { client, fieldMetadata, fieldTypes, rowsCarryId } = schema;
|
|
794
|
+
this.$emit(gridProGenesisDatasourceEventNames.dataInit);
|
|
795
|
+
this.clearErrors();
|
|
796
|
+
const colDefs = this.generateColumnDefsFromMetadata(fieldMetadata, cubeFilterParams, getFilterByFieldType);
|
|
797
|
+
this.$emit(datasourceEventNames.schemaUpdated, {
|
|
798
|
+
schema: toCubeColumnDefs(colDefs, fieldMetadata, this.cubeOperation),
|
|
799
|
+
metadata: fieldMetadata,
|
|
800
|
+
});
|
|
801
|
+
this.cubeSsrmDatasource = new CubeServerSideDatasource({
|
|
802
|
+
rowId: rowsCarryId ? this.rowId : undefined,
|
|
803
|
+
fetchRows: (request) => client.fetchRows(request, { baseCriteria: this.buildCriteria(), fieldTypes }),
|
|
804
|
+
onRowsDelivered: (rows) => this.reportDeliveredRows(rows),
|
|
805
|
+
onRowsWithdrawn: (rowIds) => this.reportWithdrawnRows(rowIds),
|
|
806
|
+
onRowCacheReset: () => this.clearRowData(withoutColumnDefs),
|
|
807
|
+
onNoDataAvailable: () => this.$emit(datasourceEventNames.noDataAvailable),
|
|
808
|
+
onDataAvailable: () => this.$emit(datasourceEventNames.loadingFinished),
|
|
809
|
+
onError: (error) => this.handleErrors(describeCubeError(error), 'stream'),
|
|
810
|
+
});
|
|
811
|
+
this.$emit(datasourceEventNames.setServerSideDatasource, {
|
|
812
|
+
datasource: this.cubeSsrmDatasource,
|
|
813
|
+
});
|
|
814
|
+
this.$emit(datasourceEventNames.filtersRestored);
|
|
815
|
+
this.applyServerSideSortIndicatorStyling();
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
reloadCubeData() {
|
|
819
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
820
|
+
if (!this.cubeSsrmDatasource) {
|
|
821
|
+
yield this.restart();
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
this.purgeCubeRows();
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
purgeCubeRows() {
|
|
828
|
+
this.cubeSsrmDatasource.invalidatePendingLoads();
|
|
829
|
+
this.clearRowData(withoutColumnDefs);
|
|
830
|
+
this.clearErrors();
|
|
831
|
+
this.$emit(datasourceEventNames.loadingStarted);
|
|
832
|
+
this.$emit(datasourceEventNames.refreshServerSide, {
|
|
833
|
+
purge: true,
|
|
834
|
+
});
|
|
835
|
+
}
|
|
671
836
|
};
|
|
672
837
|
__decorate([
|
|
673
838
|
Datasource
|
|
674
839
|
], GridProServerSideDatasource.prototype, "pollingDatasource", void 0);
|
|
840
|
+
__decorate([
|
|
841
|
+
Http
|
|
842
|
+
], GridProServerSideDatasource.prototype, "http", void 0);
|
|
675
843
|
__decorate([
|
|
676
844
|
attr({ mode: 'boolean', attribute: 'live-updates' })
|
|
677
845
|
], GridProServerSideDatasource.prototype, "liveUpdates", void 0);
|
|
846
|
+
__decorate([
|
|
847
|
+
attr({ attribute: 'cube-url' })
|
|
848
|
+
], GridProServerSideDatasource.prototype, "cubeUrl", void 0);
|
|
849
|
+
__decorate([
|
|
850
|
+
attr({ attribute: 'cube-operation' })
|
|
851
|
+
], GridProServerSideDatasource.prototype, "cubeOperation", void 0);
|
|
678
852
|
__decorate([
|
|
679
853
|
observable
|
|
680
854
|
], GridProServerSideDatasource.prototype, "request", void 0);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CubeBlockLoads } from './cube.block-loads';
|
|
2
|
+
import { toLoadSuccess } from './cube.request';
|
|
3
|
+
const GROUPED = 'grouped';
|
|
4
|
+
/**
|
|
5
|
+
* Only flat rows are reported, and AG Grid re-reads all of them when their sort or filter
|
|
6
|
+
* changes. Under row grouping it keeps the levels a sort does not reorder, so nothing is keyed.
|
|
7
|
+
*/
|
|
8
|
+
const flatRowsCacheKey = ({ rowGroupCols, sortModel, filterModel }) => (rowGroupCols === null || rowGroupCols === void 0 ? void 0 : rowGroupCols.length) ? GROUPED : JSON.stringify({ sortModel, filterModel });
|
|
9
|
+
export class CubeServerSideDatasource {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.rowGroupFields = [];
|
|
13
|
+
this.loads = new CubeBlockLoads(options);
|
|
14
|
+
}
|
|
15
|
+
getRows(params) {
|
|
16
|
+
var _a;
|
|
17
|
+
const { request } = params;
|
|
18
|
+
this.rowGroupFields = ((_a = request.rowGroupCols) !== null && _a !== void 0 ? _a : []).map(({ field }) => field);
|
|
19
|
+
const isWanted = this.loads.begin(flatRowsCacheKey(request));
|
|
20
|
+
this.options.fetchRows(request).then((envelope) => {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
22
|
+
if (!isWanted()) {
|
|
23
|
+
params.fail();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const result = toLoadSuccess(envelope, request.startRow);
|
|
27
|
+
params.success(result);
|
|
28
|
+
const isTopLevel = !((_a = request.groupKeys) === null || _a === void 0 ? void 0 : _a.length);
|
|
29
|
+
if (isTopLevel && !((_b = request.rowGroupCols) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
30
|
+
this.loads.deliver(request.startRow, result.rowData);
|
|
31
|
+
}
|
|
32
|
+
if (isTopLevel && request.startRow === 0) {
|
|
33
|
+
if (result.rowData.length) {
|
|
34
|
+
(_d = (_c = this.options).onDataAvailable) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
(_f = (_e = this.options).onNoDataAvailable) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}, (error) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
params.fail();
|
|
43
|
+
if (isWanted()) {
|
|
44
|
+
(_b = (_a = this.options).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
invalidatePendingLoads() {
|
|
49
|
+
this.loads.invalidate();
|
|
50
|
+
}
|
|
51
|
+
destroy() {
|
|
52
|
+
this.loads.invalidate();
|
|
53
|
+
}
|
|
54
|
+
/** The column the latest request groups the rows at `level` by; none when they are leaves. */
|
|
55
|
+
groupFieldAt(level) {
|
|
56
|
+
return this.rowGroupFields[level];
|
|
57
|
+
}
|
|
58
|
+
}
|