@sumaris-net/ngx-components 1.16.0 → 1.16.3
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/bundles/sumaris-net.ngx-components.umd.js +42 -28
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/admin/services/person.service.js +2 -2
- package/esm2015/src/app/core/services/model/entity.model.js +4 -1
- package/esm2015/src/app/shared/services/job.utils.js +32 -22
- package/fesm2015/sumaris-net.ngx-components.js +35 -22
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/admin/services/person.service.d.ts +1 -1
- package/src/app/core/services/model/entity.model.d.ts +1 -0
- package/src/app/shared/services/job.utils.d.ts +1 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -10935,6 +10935,9 @@
|
|
|
10935
10935
|
EntityUtils.isLocalId = function (id) {
|
|
10936
10936
|
return isNotNil(id) && +id < 0;
|
|
10937
10937
|
};
|
|
10938
|
+
EntityUtils.isRemoteId = function (id) {
|
|
10939
|
+
return isNotNil(id) && +id >= 0;
|
|
10940
|
+
};
|
|
10938
10941
|
return EntityUtils;
|
|
10939
10942
|
}());
|
|
10940
10943
|
|
|
@@ -20305,53 +20308,59 @@
|
|
|
20305
20308
|
.then(function () {
|
|
20306
20309
|
if (opts === null || opts === void 0 ? void 0 : opts.maxProgression)
|
|
20307
20310
|
progression.next(opts.maxProgression);
|
|
20308
|
-
|
|
20309
|
-
opts.progression.complete();
|
|
20311
|
+
progression.complete();
|
|
20310
20312
|
})
|
|
20311
20313
|
.catch(function (err) { return progression.error(err); });
|
|
20312
20314
|
return progression;
|
|
20313
20315
|
};
|
|
20314
20316
|
JobUtils.fetchAllPages = function (loadPageFn, opts) {
|
|
20315
|
-
var _a;
|
|
20316
20317
|
return __awaiter(this, void 0, void 0, function () {
|
|
20317
|
-
var maxProgression, total, pageCount, progressionStep, currentPageDataCount, fetchSize, offset, data, res
|
|
20318
|
-
return __generator(this, function (
|
|
20319
|
-
switch (
|
|
20318
|
+
var maxProgression, progression, total, pageCount, progressionStep, currentPageDataCount, fetchSize, offset, data, res;
|
|
20319
|
+
return __generator(this, function (_a) {
|
|
20320
|
+
switch (_a.label) {
|
|
20320
20321
|
case 0:
|
|
20321
|
-
maxProgression = opts
|
|
20322
|
-
|
|
20322
|
+
maxProgression = toNumber(opts === null || opts === void 0 ? void 0 : opts.maxProgression, 100);
|
|
20323
|
+
progression = opts === null || opts === void 0 ? void 0 : opts.progression;
|
|
20324
|
+
fetchSize = toNumber(opts === null || opts === void 0 ? void 0 : opts.fetchSize, 1000);
|
|
20325
|
+
if (fetchSize <= 0)
|
|
20326
|
+
throw new Error('Unable to fetch pages: invalid fetchSize: ' + fetchSize);
|
|
20323
20327
|
offset = 0;
|
|
20324
20328
|
data = [];
|
|
20325
|
-
|
|
20329
|
+
_a.label = 1;
|
|
20326
20330
|
case 1:
|
|
20327
20331
|
if (opts && opts.logPrefix)
|
|
20328
20332
|
console.debug(opts.logPrefix + " Fetching page #" + offset / fetchSize + "...");
|
|
20329
20333
|
return [4 /*yield*/, loadPageFn(offset, fetchSize)];
|
|
20330
20334
|
case 2:
|
|
20331
|
-
res =
|
|
20335
|
+
res = _a.sent();
|
|
20336
|
+
// Concat to previous result
|
|
20332
20337
|
data = data.concat(res.data);
|
|
20338
|
+
// Compute variables, for next loop
|
|
20333
20339
|
currentPageDataCount = res.data && res.data.length || 0;
|
|
20334
20340
|
offset += currentPageDataCount;
|
|
20335
|
-
// Set total count (only
|
|
20341
|
+
// Set total count (only once)
|
|
20336
20342
|
if (isNil(total) && isNotNil(res.total)) {
|
|
20337
20343
|
total = res.total;
|
|
20338
20344
|
// Compute the number of page
|
|
20339
20345
|
pageCount = Math.round(res.total / fetchSize + 0.5); // Round to HALF_UP integer
|
|
20340
|
-
|
|
20341
|
-
|
|
20342
|
-
|
|
20343
|
-
|
|
20346
|
+
// Compute step, by dividing maxProgression by number of page
|
|
20347
|
+
if (progression) {
|
|
20348
|
+
progressionStep = maxProgression / pageCount;
|
|
20349
|
+
// DEBUG
|
|
20350
|
+
if (opts && opts.logPrefix)
|
|
20351
|
+
console.debug(opts.logPrefix + " {pageCount: " + pageCount + ", progression: " + progression.value + ", pageProgressionStep: " + progressionStep + "}");
|
|
20352
|
+
}
|
|
20344
20353
|
}
|
|
20345
20354
|
// Increment progression on each iteration (if possible)
|
|
20346
|
-
if (
|
|
20347
|
-
|
|
20355
|
+
if (isNotNil(progressionStep)) {
|
|
20356
|
+
progression.next(progression.value + progressionStep);
|
|
20348
20357
|
}
|
|
20349
|
-
if (opts
|
|
20358
|
+
if (opts === null || opts === void 0 ? void 0 : opts.onPageLoaded)
|
|
20350
20359
|
opts.onPageLoaded(res);
|
|
20351
|
-
|
|
20360
|
+
_a.label = 3;
|
|
20352
20361
|
case 3:
|
|
20353
20362
|
if (currentPageDataCount > 0 && ((isNil(total) && currentPageDataCount === fetchSize) || (isNotNil(total) && (offset < total)))) return [3 /*break*/, 1];
|
|
20354
|
-
|
|
20363
|
+
_a.label = 4;
|
|
20355
20364
|
case 4:
|
|
20356
20365
|
// Complete progression to reach progressionStep value (because of round)
|
|
20357
20366
|
if (isNotNil(progressionStep)) {
|
|
@@ -20361,14 +20370,19 @@
|
|
|
20361
20370
|
total = data.length;
|
|
20362
20371
|
pageCount = Math.round(data.length / fetchSize + 0.5);
|
|
20363
20372
|
}
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
|
|
20367
|
-
|
|
20373
|
+
// Compute final increment, using the real page count
|
|
20374
|
+
progressionStep = Math.max(0, maxProgression - (progressionStep * pageCount));
|
|
20375
|
+
}
|
|
20376
|
+
// Or increment once (e.g. when total is not known, in received LoadResult)
|
|
20377
|
+
else if (progression) {
|
|
20378
|
+
progressionStep = maxProgression;
|
|
20368
20379
|
}
|
|
20369
|
-
//
|
|
20370
|
-
|
|
20371
|
-
|
|
20380
|
+
// DEBUG
|
|
20381
|
+
if (opts && opts.logPrefix)
|
|
20382
|
+
console.debug(opts.logPrefix + " All pages fetched - {progression: " + progression.value + ", lastProgressionStep: " + progressionStep);
|
|
20383
|
+
// Final increment
|
|
20384
|
+
if (progression && progressionStep > 0) {
|
|
20385
|
+
progression.next(progression.value + progressionStep);
|
|
20372
20386
|
}
|
|
20373
20387
|
return [2 /*return*/, {
|
|
20374
20388
|
data: data,
|
|
@@ -29483,7 +29497,7 @@
|
|
|
29483
29497
|
fetchPolicy: 'network-only',
|
|
29484
29498
|
withTotal: (offset === 0),
|
|
29485
29499
|
toEntity: false
|
|
29486
|
-
}); },
|
|
29500
|
+
}); }, { progression: opts === null || opts === void 0 ? void 0 : opts.progression, maxProgression: maxProgression * 0.9 })];
|
|
29487
29501
|
case 1:
|
|
29488
29502
|
res = _a.sent();
|
|
29489
29503
|
// Save result locally
|