@genesislcap/grid-pro 14.201.0 → 14.202.1-alpha-34c59e8.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/README.md +117 -111
- package/dist/custom-elements.json +2742 -840
- package/dist/dts/datasource/base.datasource.d.ts +22 -6
- 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 -0
- package/dist/dts/datasource/server-side.datasource.d.ts +27 -83
- package/dist/dts/datasource/server-side.datasource.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.grid-definitions.d.ts.map +1 -1
- package/dist/dts/datasource/server-side.resource-base.d.ts +55 -0
- package/dist/dts/datasource/server-side.resource-base.d.ts.map +1 -0
- package/dist/dts/datasource/server-side.resource-dataserver.d.ts +20 -0
- package/dist/dts/datasource/server-side.resource-dataserver.d.ts.map +1 -0
- package/dist/dts/datasource/server-side.resource-reqrep.d.ts +17 -0
- package/dist/dts/datasource/server-side.resource-reqrep.d.ts.map +1 -0
- package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts +13 -13
- package/dist/dts/grid-pro-genesis-datasource/grid-pro-genesis-datasource.d.ts.map +1 -1
- package/dist/dts/grid-pro.d.ts +16 -2
- package/dist/dts/grid-pro.d.ts.map +1 -1
- package/dist/esm/datasource/base.datasource.js +79 -9
- package/dist/esm/datasource/base.types.js +1 -0
- package/dist/esm/datasource/client-side.grid-definitions.js +1 -1
- package/dist/esm/datasource/server-side.datasource.js +220 -396
- package/dist/esm/datasource/server-side.grid-definitions.js +42 -7
- package/dist/esm/datasource/server-side.resource-base.js +285 -0
- package/dist/esm/datasource/server-side.resource-dataserver.js +132 -0
- package/dist/esm/datasource/server-side.resource-reqrep.js +131 -0
- package/dist/esm/grid-pro-genesis-datasource/grid-pro-genesis-datasource.js +55 -61
- package/dist/esm/grid-pro.js +7 -4
- package/dist/grid-pro.api.json +21 -142
- package/dist/grid-pro.d.ts +77 -112
- package/docs/api/grid-pro.gridpro.addeventlistener.md +2 -2
- package/docs/api/grid-pro.gridpro.md +1 -1
- package/docs/api/grid-pro.gridprogenesisdatasource.deinit.md +5 -0
- package/docs/api/{grid-pro.gridprogenesisdatasource.auth.md → grid-pro.gridprogenesisdatasource.destroy.md} +9 -3
- package/docs/api/grid-pro.gridprogenesisdatasource.handleerrors.md +2 -2
- package/docs/api/grid-pro.gridprogenesisdatasource.md +2 -6
- package/docs/api/grid-pro.gridprogenesisdatasource.reset.md +1 -1
- package/docs/api-report.md +19 -68
- package/package.json +13 -13
- package/docs/api/grid-pro.gridprogenesisdatasource.datasource.md +0 -11
- package/docs/api/grid-pro.gridprogenesisdatasource.disablepolling.md +0 -11
- package/docs/api/grid-pro.gridprogenesisdatasource.pollinginterval.md +0 -11
- package/docs/api/grid-pro.gridprogenesisdatasource.request.md +0 -11
|
@@ -13,7 +13,7 @@ export function getServerSideFilterParamsByFieldType(type) {
|
|
|
13
13
|
buttons: ['reset', 'apply'],
|
|
14
14
|
closeOnApply: true,
|
|
15
15
|
closeOnClear: true,
|
|
16
|
-
|
|
16
|
+
maxNumConditions: 1,
|
|
17
17
|
filterOptions: [
|
|
18
18
|
'contains',
|
|
19
19
|
{
|
|
@@ -61,9 +61,22 @@ export function getServerSideFilterParamsByFieldType(type) {
|
|
|
61
61
|
buttons: ['reset', 'apply'],
|
|
62
62
|
closeOnApply: true,
|
|
63
63
|
closeOnClear: true,
|
|
64
|
-
|
|
64
|
+
maxNumConditions: 1,
|
|
65
65
|
browserDatePicker: true,
|
|
66
|
-
filterOptions: [
|
|
66
|
+
filterOptions: [
|
|
67
|
+
'equals',
|
|
68
|
+
'lessThan',
|
|
69
|
+
'greaterThan',
|
|
70
|
+
'inRange',
|
|
71
|
+
{
|
|
72
|
+
displayKey: 'isToday',
|
|
73
|
+
displayName: 'Is today',
|
|
74
|
+
numberOfInputs: 0,
|
|
75
|
+
predicate: () => true,
|
|
76
|
+
},
|
|
77
|
+
'blank',
|
|
78
|
+
'notBlank',
|
|
79
|
+
],
|
|
67
80
|
};
|
|
68
81
|
}
|
|
69
82
|
case FieldTypeEnum.NUMBER: {
|
|
@@ -71,8 +84,18 @@ export function getServerSideFilterParamsByFieldType(type) {
|
|
|
71
84
|
buttons: ['reset', 'apply'],
|
|
72
85
|
closeOnApply: true,
|
|
73
86
|
closeOnClear: true,
|
|
74
|
-
|
|
75
|
-
filterOptions: [
|
|
87
|
+
maxNumConditions: 1,
|
|
88
|
+
filterOptions: [
|
|
89
|
+
'equals',
|
|
90
|
+
'notEqual',
|
|
91
|
+
'greaterThan',
|
|
92
|
+
'greaterThanOrEqual',
|
|
93
|
+
'lessThan',
|
|
94
|
+
'lessThanOrEqual',
|
|
95
|
+
'inRange',
|
|
96
|
+
'blank',
|
|
97
|
+
'notBlank',
|
|
98
|
+
],
|
|
76
99
|
};
|
|
77
100
|
}
|
|
78
101
|
default: {
|
|
@@ -80,8 +103,20 @@ export function getServerSideFilterParamsByFieldType(type) {
|
|
|
80
103
|
buttons: ['reset', 'apply'],
|
|
81
104
|
closeOnApply: true,
|
|
82
105
|
closeOnClear: true,
|
|
83
|
-
|
|
84
|
-
filterOptions: [
|
|
106
|
+
maxNumConditions: 1,
|
|
107
|
+
filterOptions: [
|
|
108
|
+
'contains',
|
|
109
|
+
'equals',
|
|
110
|
+
'notEqual',
|
|
111
|
+
{
|
|
112
|
+
displayKey: 'wordStartsWith',
|
|
113
|
+
displayName: 'Word starts with',
|
|
114
|
+
numberOfInputs: 1,
|
|
115
|
+
predicate: () => true,
|
|
116
|
+
},
|
|
117
|
+
'blank',
|
|
118
|
+
'notBlank',
|
|
119
|
+
],
|
|
85
120
|
};
|
|
86
121
|
}
|
|
87
122
|
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { __awaiter, __decorate } from "tslib";
|
|
2
|
+
import { Auth, Connect, logger, } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { UUID } from '@genesislcap/foundation-utils';
|
|
4
|
+
import { getAvailableIndexes, getAvailableIndexFields } from '../utils';
|
|
5
|
+
export class BaseServerSideDatasource {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.rowData = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* The number of rows in the grid. THIS DO NOT CONSIDER CRITERIA_MATCH scenarios.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
this.serverRowsCount = 0;
|
|
13
|
+
/**
|
|
14
|
+
* The number of rows in the grid. THIS IS A LOCAL COUNT CONSIDERING CONSIDER CRITERIA_MATCH scenarios.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
this.clientRowsCount = 0;
|
|
18
|
+
this.moreRows = false;
|
|
19
|
+
this.calculatedRowsCount = 0;
|
|
20
|
+
this.currentSequenceId = null;
|
|
21
|
+
this.reloadResourceDataFunc = options.reloadResourceDataFunc;
|
|
22
|
+
this.resourceName = options.resourceName;
|
|
23
|
+
this.resourceParams = options.resourceParams;
|
|
24
|
+
this.originalCriteriaMatch = options.resourceParams.CRITERIA_MATCH;
|
|
25
|
+
this.resourceIndexes = options.resourceIndexes;
|
|
26
|
+
this.resourceColDefs = options.resourceColDefs;
|
|
27
|
+
this.maxRows = options.maxRows;
|
|
28
|
+
this.maxView = options.maxView;
|
|
29
|
+
this.rowId = options.rowId;
|
|
30
|
+
this.pagination = options.pagination;
|
|
31
|
+
this.zeroBasedViewNumber = options.zeroBasedViewNumber;
|
|
32
|
+
}
|
|
33
|
+
getRows(params) {
|
|
34
|
+
throw new Error('Method not implemented.');
|
|
35
|
+
}
|
|
36
|
+
setupFilteringAndSorting(params) {
|
|
37
|
+
var _a;
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const filterModelBeingApplied = params.request.filterModel;
|
|
40
|
+
const filtersAreBeingApplied = Object.keys(filterModelBeingApplied).length > 0;
|
|
41
|
+
const filtersAreGettingCleaned = Object.keys(filterModelBeingApplied).length === 0;
|
|
42
|
+
const filterModelBeingAppliedDiffersFromCurrent = JSON.stringify(filterModelBeingApplied) !== JSON.stringify(this.currentFilterModel);
|
|
43
|
+
if (filterModelBeingAppliedDiffersFromCurrent || filtersAreBeingApplied) {
|
|
44
|
+
if (filtersAreGettingCleaned && this.currentFilterModel) {
|
|
45
|
+
this.currentFilterModel = null;
|
|
46
|
+
this.resourceParams.CRITERIA_MATCH = this.originalCriteriaMatch;
|
|
47
|
+
yield this.refreshDatasource(params);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
else if (filterModelBeingAppliedDiffersFromCurrent && filtersAreBeingApplied) {
|
|
51
|
+
this.currentFilterModel = filterModelBeingApplied;
|
|
52
|
+
this.resourceParams.CRITERIA_MATCH = this.buildCriteriaMatchFromFilters();
|
|
53
|
+
yield this.refreshDatasource(params);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const toBeAppliedSortModel = params.request.sortModel;
|
|
58
|
+
if (((_a = this.currentSortModel) === null || _a === void 0 ? void 0 : _a.length) !== toBeAppliedSortModel.length ||
|
|
59
|
+
toBeAppliedSortModel.length > 0) {
|
|
60
|
+
if (toBeAppliedSortModel.length === 0 && this.currentSortModel) {
|
|
61
|
+
this.calculatedRowsCount = 0;
|
|
62
|
+
this.currentSortModel = null;
|
|
63
|
+
this.resourceParams.ORDER_BY = null;
|
|
64
|
+
this.resourceParams.REVERSE = null;
|
|
65
|
+
yield this.refreshDatasource(params);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
else if (toBeAppliedSortModel.length > 0) {
|
|
69
|
+
this.currentSortModel = toBeAppliedSortModel;
|
|
70
|
+
const coldIdBeingSorted = toBeAppliedSortModel[0].colId; // Not allowing multiple sorts by user
|
|
71
|
+
const sortTypeBeingApplied = toBeAppliedSortModel[0].sort;
|
|
72
|
+
const orderByAndToBeSortedColIds = this.getOrderByAndToBeSortedColIds(this.resourceIndexes, coldIdBeingSorted);
|
|
73
|
+
if (!orderByAndToBeSortedColIds) {
|
|
74
|
+
this.calculatedRowsCount = 0;
|
|
75
|
+
const availableIndexes = getAvailableIndexes(this.resourceIndexes);
|
|
76
|
+
const availableIndexFields = getAvailableIndexFields(this.resourceIndexes);
|
|
77
|
+
logger.warn('The FIELD/column (${coldIdBeingSorted}) being sorted is not part of an INDEX, required for the [orderBy] operation. See https://learn.genesis.global/docs/database/data-types/index-entities/');
|
|
78
|
+
logger.debug('Available indexes:', availableIndexes);
|
|
79
|
+
logger.debug('Columns that can be sorted with the available indexes:', availableIndexFields);
|
|
80
|
+
params.fail();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
else if (JSON.stringify(toBeAppliedSortModel) !== JSON.stringify(this.currentSortModel)) {
|
|
84
|
+
this.resourceParams.ORDER_BY = orderByAndToBeSortedColIds.orderBy;
|
|
85
|
+
this.resourceParams.REVERSE = sortTypeBeingApplied === 'desc' ? true : false;
|
|
86
|
+
yield this.refreshDatasource(params);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
destroy() {
|
|
94
|
+
this.rowData = new Map();
|
|
95
|
+
this.clientRowsCount = 0;
|
|
96
|
+
this.calculatedRowsCount = 0;
|
|
97
|
+
this.serverRowsCount = 0;
|
|
98
|
+
this.currentSequenceId = 0;
|
|
99
|
+
this.moreRows = false;
|
|
100
|
+
this.sourceRef = undefined;
|
|
101
|
+
this.lastSuccessRowData = undefined;
|
|
102
|
+
}
|
|
103
|
+
refreshDatasource(params) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
yield this.destroy();
|
|
106
|
+
yield this.reloadResourceDataFunc({
|
|
107
|
+
criteria: this.resourceParams.CRITERIA_MATCH,
|
|
108
|
+
orderBy: this.resourceParams.ORDER_BY,
|
|
109
|
+
reverse: this.resourceParams.REVERSE,
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
getOrderByAndToBeSortedColIds(map, searchValue) {
|
|
114
|
+
for (const [key, value] of map.entries()) {
|
|
115
|
+
const searchIndex = value.findIndex((x) => x === searchValue);
|
|
116
|
+
if (searchIndex !== -1) {
|
|
117
|
+
const copy = [...value];
|
|
118
|
+
const toBeSorted = copy.splice(searchIndex, 1);
|
|
119
|
+
return { orderBy: key, toBeSorted };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
buildCriteriaMatchFromFilters() {
|
|
124
|
+
this.resourceParams.CRITERIA_MATCH = this.originalCriteriaMatch;
|
|
125
|
+
if (this.resourceParams.CRITERIA_MATCH &&
|
|
126
|
+
typeof this.resourceParams.CRITERIA_MATCH === 'string') {
|
|
127
|
+
this.resourceParams.CRITERIA_MATCH = this.resourceParams.CRITERIA_MATCH.split(';');
|
|
128
|
+
}
|
|
129
|
+
if (!this.resourceParams.CRITERIA_MATCH) {
|
|
130
|
+
this.resourceParams.CRITERIA_MATCH = [];
|
|
131
|
+
}
|
|
132
|
+
const criteria = this.resourceParams.CRITERIA_MATCH.concat(this.criteriaFromFilters());
|
|
133
|
+
return criteria.join(' && ');
|
|
134
|
+
}
|
|
135
|
+
criteriaFromFilters() {
|
|
136
|
+
const filters = [];
|
|
137
|
+
this.getFiltersByType('text').forEach((k) => {
|
|
138
|
+
if (!this.currentFilterModel[k].filter &&
|
|
139
|
+
(this.currentFilterModel[k].type === 'false' || this.currentFilterModel[k].type === 'true')) {
|
|
140
|
+
filters.push(`${k} == ${this.currentFilterModel[k].type}`);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
switch (this.currentFilterModel[k].type) {
|
|
144
|
+
case 'blank':
|
|
145
|
+
filters.push(`${k} == ''`);
|
|
146
|
+
break;
|
|
147
|
+
case 'contains':
|
|
148
|
+
filters.push(`Expr.containsIgnoreCase(${k}, '${this.currentFilterModel[k].filter}')`);
|
|
149
|
+
break;
|
|
150
|
+
case 'equals':
|
|
151
|
+
filters.push(`${k} == '${this.currentFilterModel[k].filter}'`);
|
|
152
|
+
break;
|
|
153
|
+
case 'notBlank':
|
|
154
|
+
filters.push(`${k} != ''`);
|
|
155
|
+
break;
|
|
156
|
+
case 'notEqual':
|
|
157
|
+
filters.push(`${k} != '${this.currentFilterModel[k].filter}'`);
|
|
158
|
+
break;
|
|
159
|
+
case 'wordStartsWith':
|
|
160
|
+
filters.push(`Expr.containsWordsStartingWithIgnoreCase(${k}, '${this.currentFilterModel[k].filter}')`);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
this.getFiltersByType('number').forEach((k) => {
|
|
166
|
+
const value = this.currentFilterModel[k].filter;
|
|
167
|
+
const valueTwo = this.currentFilterModel[k].filterTo;
|
|
168
|
+
switch (this.currentFilterModel[k].type) {
|
|
169
|
+
case 'equals':
|
|
170
|
+
!isNaN(value) && filters.push(`${k} == ${value}`);
|
|
171
|
+
break;
|
|
172
|
+
case 'notEqual':
|
|
173
|
+
!isNaN(value) && filters.push(`${k} != ${value}`);
|
|
174
|
+
break;
|
|
175
|
+
case 'greaterThan':
|
|
176
|
+
!isNaN(value) && filters.push(`${k} > ${value}`);
|
|
177
|
+
break;
|
|
178
|
+
case 'greaterThanOrEqual':
|
|
179
|
+
!isNaN(value) && filters.push(`${k} >= ${value}`);
|
|
180
|
+
break;
|
|
181
|
+
case 'lessThan':
|
|
182
|
+
!isNaN(value) && filters.push(`${k} < ${value}`);
|
|
183
|
+
break;
|
|
184
|
+
case 'lessThanOrEqual':
|
|
185
|
+
!isNaN(value) && filters.push(`${k} <= ${value}`);
|
|
186
|
+
break;
|
|
187
|
+
case 'inRange':
|
|
188
|
+
!isNaN(value) &&
|
|
189
|
+
!isNaN(valueTwo) &&
|
|
190
|
+
filters.push(`${k} >= ${value} && ${k} <= ${valueTwo}`);
|
|
191
|
+
break;
|
|
192
|
+
case 'blank':
|
|
193
|
+
filters.push(`${k} == 0`);
|
|
194
|
+
break;
|
|
195
|
+
case 'notBlank':
|
|
196
|
+
filters.push(`${k} != 0`);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
this.getFiltersByType('date').forEach((k) => {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
const dateFrom = (_a = this.currentFilterModel[k].dateFrom) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '').replace('T', '-').split(' ')[0];
|
|
203
|
+
const dateTo = (_b = this.currentFilterModel[k].dateTo) === null || _b === void 0 ? void 0 : _b.replace(/-/g, '').replace('T', '-').split(' ')[0];
|
|
204
|
+
switch (this.currentFilterModel[k].type) {
|
|
205
|
+
case 'equals':
|
|
206
|
+
filters.push(`Expr.dateIsEqual(${k}, '${dateFrom}')`);
|
|
207
|
+
break;
|
|
208
|
+
case 'lessThan':
|
|
209
|
+
filters.push(`Expr.dateIsBefore(${k}, '${dateFrom}')`);
|
|
210
|
+
break;
|
|
211
|
+
case 'greaterThan':
|
|
212
|
+
filters.push(`Expr.dateIsAfter(${k}, '${dateFrom}')`);
|
|
213
|
+
break;
|
|
214
|
+
case 'inRange':
|
|
215
|
+
filters.push(`Expr.dateIsAfter(${k}, '${dateFrom}') && Expr.dateIsBefore(${k}, '${dateTo}')`);
|
|
216
|
+
break;
|
|
217
|
+
case 'isToday':
|
|
218
|
+
const now = new Date();
|
|
219
|
+
const year = now.getFullYear();
|
|
220
|
+
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
|
221
|
+
const day = now.getDate().toString().padStart(2, '0');
|
|
222
|
+
const todayStr = `${year}-${month}-${day} 00:00:00`;
|
|
223
|
+
filters.push(`Expr.dateIsEqual(${k}, '${todayStr}')`);
|
|
224
|
+
break;
|
|
225
|
+
case 'blank':
|
|
226
|
+
filters.push(`${k} == null`);
|
|
227
|
+
break;
|
|
228
|
+
case 'notBlank':
|
|
229
|
+
filters.push(`${k} != null`);
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return filters;
|
|
234
|
+
}
|
|
235
|
+
getFiltersByType(filterType) {
|
|
236
|
+
return Object.keys(this.currentFilterModel)
|
|
237
|
+
.filter((k) => this.resourceColDefs.findIndex((o) => o.NAME === k) !== -1)
|
|
238
|
+
.filter((k) => this.currentFilterModel[k].filterType === filterType);
|
|
239
|
+
}
|
|
240
|
+
getPageNumber(start, recordsPerPage, totalRecords, zeroBasedViewNumber = true) {
|
|
241
|
+
if (start > totalRecords) {
|
|
242
|
+
start = Math.floor((totalRecords - 1) / recordsPerPage) * recordsPerPage + 1;
|
|
243
|
+
}
|
|
244
|
+
const currentPageIndex = Math.ceil(start / recordsPerPage);
|
|
245
|
+
return zeroBasedViewNumber ? currentPageIndex : currentPageIndex + 1;
|
|
246
|
+
}
|
|
247
|
+
getCorrectRowCount(params) {
|
|
248
|
+
const currentLastRowNumber = params.request.endRow;
|
|
249
|
+
this.calculatedRowsCount = this.clientRowsCount || currentLastRowNumber;
|
|
250
|
+
const defaultCount = Math.min(this.serverRowsCount, this.maxView);
|
|
251
|
+
let rowCount;
|
|
252
|
+
if (this.pagination) {
|
|
253
|
+
rowCount = !this.resourceParams.CRITERIA_MATCH
|
|
254
|
+
? Math.min(this.serverRowsCount, this.maxView)
|
|
255
|
+
: undefined;
|
|
256
|
+
if (this.resourceParams.CRITERIA_MATCH) {
|
|
257
|
+
rowCount = defaultCount;
|
|
258
|
+
}
|
|
259
|
+
return rowCount;
|
|
260
|
+
}
|
|
261
|
+
if (currentLastRowNumber === this.serverRowsCount) {
|
|
262
|
+
rowCount = this.serverRowsCount;
|
|
263
|
+
}
|
|
264
|
+
else if (currentLastRowNumber > this.maxView ||
|
|
265
|
+
currentLastRowNumber > this.calculatedRowsCount) {
|
|
266
|
+
rowCount = Math.min(defaultCount, this.calculatedRowsCount);
|
|
267
|
+
}
|
|
268
|
+
else if (!this.moreRows && this.serverRowsCount > this.calculatedRowsCount) {
|
|
269
|
+
rowCount = this.calculatedRowsCount;
|
|
270
|
+
}
|
|
271
|
+
return rowCount;
|
|
272
|
+
}
|
|
273
|
+
get isNotFirstViewNumber() {
|
|
274
|
+
return this.zeroBasedViewNumber ? this.currentSequenceId > 0 : this.currentSequenceId > 1;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
__decorate([
|
|
278
|
+
Auth
|
|
279
|
+
], BaseServerSideDatasource.prototype, "auth", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
Connect
|
|
282
|
+
], BaseServerSideDatasource.prototype, "connect", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
UUID
|
|
285
|
+
], BaseServerSideDatasource.prototype, "uuid", void 0);
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { logger, MessageType, dataServerResultFilter, } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { DOM } from '@microsoft/fast-element';
|
|
4
|
+
import { BaseServerSideDatasource } from './server-side.resource-base';
|
|
5
|
+
/**
|
|
6
|
+
* The DATASERVER IServerSideDatasource implementation, used for SSRM (Server-Side Row Model) in the grid.
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export class DataserverServerSideDatasource extends BaseServerSideDatasource {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.createDataserverStreamFunc = options.createDataserverStreamFunc;
|
|
13
|
+
}
|
|
14
|
+
refreshDatasource(params) {
|
|
15
|
+
const _super = Object.create(null, {
|
|
16
|
+
refreshDatasource: { get: () => super.refreshDatasource }
|
|
17
|
+
});
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
this.dataserverStreamSubscription.unsubscribe();
|
|
20
|
+
this.dataserverStreamSubscription = undefined;
|
|
21
|
+
yield _super.refreshDatasource.call(this, params);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
getRows(params) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
yield this.setupFilteringAndSorting(params);
|
|
27
|
+
if (this.pagination && !this.isNewPageSize && this.currentSequenceId > 0) {
|
|
28
|
+
params.success(this.lastSuccessRowData);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!this.dataserverStream) {
|
|
32
|
+
this.dataserverStream = yield this.createDataserverStreamFunc(this.resourceParams);
|
|
33
|
+
}
|
|
34
|
+
if (this.currentSequenceId >= 1 &&
|
|
35
|
+
(this.moreRows ||
|
|
36
|
+
params.request.startRow >= Number(this.maxRows) ||
|
|
37
|
+
params.request.startRow === 0)) {
|
|
38
|
+
if (this.pagination) {
|
|
39
|
+
this.resourceParams.VIEW_NUMBER = this.getPageNumber(params.request.startRow, this.maxRows, this.maxView, this.zeroBasedViewNumber);
|
|
40
|
+
// if (this.resourceParams.VIEW_NUMBER === 1) {
|
|
41
|
+
// await this.refreshDatasource(params);
|
|
42
|
+
// return;
|
|
43
|
+
// }
|
|
44
|
+
}
|
|
45
|
+
this.connect.getMoreRows(this.sourceRef, this.resourceParams.VIEW_NUMBER);
|
|
46
|
+
}
|
|
47
|
+
let applyResult = true;
|
|
48
|
+
this.dataserverStreamSubscription = this.dataserverStream.subscribe((dataserverResult) => {
|
|
49
|
+
if (applyResult) {
|
|
50
|
+
DOM.queueUpdate(() => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (this.resourceParams.CRITERIA_MATCH) {
|
|
52
|
+
const updatedInfo = yield this.connect.snapshot(this.resourceName, {
|
|
53
|
+
MAX_ROWS: this.maxView,
|
|
54
|
+
MAX_VIEW: this.maxView,
|
|
55
|
+
CRITERIA_MATCH: this.resourceParams.CRITERIA_MATCH,
|
|
56
|
+
});
|
|
57
|
+
if (!updatedInfo.ROW && !updatedInfo.ROWS_COUNT) {
|
|
58
|
+
logger.warn('No data returned when criteria is applied.');
|
|
59
|
+
this.serverRowsCount = 0;
|
|
60
|
+
this.clientRowsCount = 0;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.serverRowsCount = this.resourceParams.CRITERIA_MATCH
|
|
64
|
+
? updatedInfo.ROW.length
|
|
65
|
+
: updatedInfo.ROWS_COUNT;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this.applyServerSideData(params, dataserverResult);
|
|
69
|
+
applyResult = false;
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
applyServerSideData(params, result) {
|
|
76
|
+
var _a;
|
|
77
|
+
const messageType = result.MESSAGE_TYPE;
|
|
78
|
+
if (messageType &&
|
|
79
|
+
(messageType === MessageType.LOGOFF_ACK || messageType === MessageType.MSG_NACK)) {
|
|
80
|
+
params.fail();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.moreRows = result.MORE_ROWS;
|
|
84
|
+
if (result.ROW) {
|
|
85
|
+
const nextMessage = dataServerResultFilter(result);
|
|
86
|
+
this.handleCurrentStreamLoad(nextMessage);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.rowData = new Map();
|
|
90
|
+
const successRowData = { rowData: [] };
|
|
91
|
+
successRowData.rowCount = 0;
|
|
92
|
+
params.success(successRowData);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.currentSequenceId = result.SEQUENCE_ID;
|
|
96
|
+
if (this.currentSequenceId === 1) {
|
|
97
|
+
this.sourceRef = result.SOURCE_REF;
|
|
98
|
+
if (this.serverRowsCount === 0) {
|
|
99
|
+
this.serverRowsCount = (_a = result.ROWS_COUNT) !== null && _a !== void 0 ? _a : this.rowData.size;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const successRowData = {
|
|
103
|
+
rowData: Array.from(this.rowData.values()),
|
|
104
|
+
};
|
|
105
|
+
successRowData.rowCount = this.getCorrectRowCount(params);
|
|
106
|
+
this.lastSuccessRowData = successRowData;
|
|
107
|
+
params.success(successRowData);
|
|
108
|
+
}
|
|
109
|
+
destroy() {
|
|
110
|
+
const _super = Object.create(null, {
|
|
111
|
+
destroy: { get: () => super.destroy }
|
|
112
|
+
});
|
|
113
|
+
var _a;
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
this.dataserverStream = undefined;
|
|
116
|
+
(_a = this.dataserverStreamSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
117
|
+
this.dataserverStreamSubscription = undefined;
|
|
118
|
+
yield _super.destroy.call(this);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
handleCurrentStreamLoad(result) {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
if (!result)
|
|
124
|
+
return;
|
|
125
|
+
const rows = new Map();
|
|
126
|
+
(_a = result.inserts) === null || _a === void 0 ? void 0 : _a.forEach((insertData) => {
|
|
127
|
+
rows.set(insertData[this.rowId], insertData);
|
|
128
|
+
});
|
|
129
|
+
this.clientRowsCount += (_b = result.inserts.length) !== null && _b !== void 0 ? _b : 0;
|
|
130
|
+
this.rowData = rows;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { MessageType, } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { logger } from '../utils';
|
|
4
|
+
import { BaseServerSideDatasource } from './server-side.resource-base';
|
|
5
|
+
/**
|
|
6
|
+
* The REQUEST_SERVER IServerSideDatasource implementation, used for SSRM (Server-Side Row Model) in the grid.
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export class ReqRepServerSideDatasource extends BaseServerSideDatasource {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
var _a;
|
|
12
|
+
super(options);
|
|
13
|
+
this.createReqRepRequestFunc = options.createReqRepRequestFunc;
|
|
14
|
+
if (!((_a = options.resourceParams) === null || _a === void 0 ? void 0 : _a.VIEW_NUMBER)) {
|
|
15
|
+
this.resourceParams.VIEW_NUMBER = this.zeroBasedViewNumber ? 0 : 1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
getRows(params) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
yield this.setupFilteringAndSorting(params);
|
|
21
|
+
if (this.pagination && !this.isNewPageSize && this.currentSequenceId > 0) {
|
|
22
|
+
params.success(this.lastSuccessRowData);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (this.currentSequenceId !== null && this.currentSequenceId >= 0 && this.moreRows) {
|
|
26
|
+
if (this.pagination) {
|
|
27
|
+
this.resourceParams.VIEW_NUMBER = this.getPageNumber(params.request.startRow, this.maxRows, this.maxView);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.resourceParams.VIEW_NUMBER += 1;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const requestParams = {
|
|
34
|
+
DETAILS: {
|
|
35
|
+
CRITERIA_MATCH: this.resourceParams.CRITERIA_MATCH,
|
|
36
|
+
MAX_ROWS: this.resourceParams.MAX_ROWS,
|
|
37
|
+
VIEW_NUMBER: this.resourceParams.VIEW_NUMBER,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const requestResult = yield this.createReqRepRequestFunc(requestParams);
|
|
41
|
+
// TODO: massive limitation on the GSF. It should return -1 if it's already the last view (but it doesn't, next will have 0 rows then the NEXT_VIEW=-1).
|
|
42
|
+
let isLastView = false;
|
|
43
|
+
if (requestResult.NEXT_VIEW !== -1) {
|
|
44
|
+
const preCheckRequestParams = Object.assign(Object.assign({}, requestParams), { DETAILS: Object.assign(Object.assign({}, requestParams.DETAILS), { VIEW_NUMBER: requestResult.NEXT_VIEW }) });
|
|
45
|
+
const moreRowsPreCheck = yield this.createReqRepRequestFunc(preCheckRequestParams);
|
|
46
|
+
isLastView = moreRowsPreCheck.NEXT_VIEW === -1;
|
|
47
|
+
}
|
|
48
|
+
let applyResult = true;
|
|
49
|
+
if (applyResult) {
|
|
50
|
+
this.applyServerSideData(params, requestResult, isLastView);
|
|
51
|
+
applyResult = false;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
applyServerSideData(params, result, isLastView) {
|
|
56
|
+
var _a;
|
|
57
|
+
const messageType = result.MESSAGE_TYPE;
|
|
58
|
+
if (messageType &&
|
|
59
|
+
(messageType === MessageType.LOGOFF_ACK || messageType === MessageType.MSG_NACK)) {
|
|
60
|
+
params.fail();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.moreRows =
|
|
64
|
+
!isLastView && result.NEXT_VIEW !== -1 && result.NEXT_VIEW > this.resourceParams.VIEW_NUMBER;
|
|
65
|
+
if (result.REPLY) {
|
|
66
|
+
this.handleCurrentStreamLoad(result.REPLY);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.rowData = new Map();
|
|
70
|
+
const successRowData = { rowData: [] };
|
|
71
|
+
successRowData.rowCount = 0;
|
|
72
|
+
params.success(successRowData);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this.currentSequenceId = this.resourceParams.VIEW_NUMBER; // result.NEXT_VIEW > 0 ? result.NEXT_VIEW - 1 : 0;
|
|
76
|
+
this.sourceRef = result.SOURCE_REF;
|
|
77
|
+
this.serverRowsCount += (_a = result.ROWS_COUNT) !== null && _a !== void 0 ? _a : this.rowData.size;
|
|
78
|
+
const successRowData = {
|
|
79
|
+
rowData: Array.from(this.rowData.values()),
|
|
80
|
+
};
|
|
81
|
+
successRowData.rowCount = this.getCorrectRowCount(params);
|
|
82
|
+
this.lastSuccessRowData = successRowData;
|
|
83
|
+
params.success(successRowData);
|
|
84
|
+
}
|
|
85
|
+
getCorrectRowCount(params) {
|
|
86
|
+
const lastRow = this.moreRows ? -1 : params.request.startRow + this.serverRowsCount;
|
|
87
|
+
const currentLastRowNumber = params.request.endRow;
|
|
88
|
+
this.calculatedRowsCount = this.serverRowsCount || currentLastRowNumber;
|
|
89
|
+
const defaultCount = Math.min(lastRow, this.maxView);
|
|
90
|
+
let rowCount;
|
|
91
|
+
if (this.pagination) {
|
|
92
|
+
rowCount = !this.resourceParams.CRITERIA_MATCH ? Math.min(lastRow, this.maxView) : undefined;
|
|
93
|
+
if (this.resourceParams.CRITERIA_MATCH) {
|
|
94
|
+
rowCount = defaultCount;
|
|
95
|
+
}
|
|
96
|
+
if (!this.moreRows && lastRow > this.calculatedRowsCount) {
|
|
97
|
+
rowCount = this.calculatedRowsCount;
|
|
98
|
+
}
|
|
99
|
+
return rowCount;
|
|
100
|
+
}
|
|
101
|
+
if (currentLastRowNumber === lastRow) {
|
|
102
|
+
rowCount = lastRow;
|
|
103
|
+
}
|
|
104
|
+
else if (currentLastRowNumber > this.maxView ||
|
|
105
|
+
currentLastRowNumber > this.calculatedRowsCount) {
|
|
106
|
+
rowCount = Math.min(defaultCount, this.calculatedRowsCount);
|
|
107
|
+
}
|
|
108
|
+
else if (!this.moreRows && lastRow > this.calculatedRowsCount) {
|
|
109
|
+
rowCount = this.calculatedRowsCount;
|
|
110
|
+
}
|
|
111
|
+
return rowCount;
|
|
112
|
+
}
|
|
113
|
+
handleCurrentStreamLoad(reply) {
|
|
114
|
+
if (!reply || reply.length == 0)
|
|
115
|
+
return;
|
|
116
|
+
const rows = new Map();
|
|
117
|
+
reply.forEach((insertData) => {
|
|
118
|
+
const insertDataRowId = insertData[this.rowId];
|
|
119
|
+
if (insertDataRowId) {
|
|
120
|
+
rows.set(insertDataRowId, insertData);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const noRowIdMessage = `The specified rowId (${this.rowId}) is not present in the data. Since this is a snapshot (isSnapshot=true), an auto-generated UUID will be used. For custom identifiers, use the 'row-id' attribute.`;
|
|
124
|
+
logger.error(noRowIdMessage);
|
|
125
|
+
const tempId = this.uuid.createId();
|
|
126
|
+
insertData[this.rowId] = tempId;
|
|
127
|
+
rows.set(tempId, insertData);
|
|
128
|
+
});
|
|
129
|
+
this.rowData = rows;
|
|
130
|
+
}
|
|
131
|
+
}
|