@sumaris-net/ngx-components 1.15.14 → 1.16.2
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 +38 -32
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +3 -0
- package/esm2015/src/app/admin/services/person.service.js +5 -9
- package/esm2015/src/app/core/services/model/entity.model.js +4 -1
- package/esm2015/src/app/shared/services/job.utils.js +28 -21
- package/fesm2015/sumaris-net.ngx-components.js +33 -26
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/admin/services/person.service.d.ts +2 -1
- package/src/app/core/services/model/entity.model.d.ts +1 -0
- package/src/app/shared/services/job.utils.d.ts +4 -2
- 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
|
|
|
@@ -20301,51 +20304,57 @@
|
|
|
20301
20304
|
};
|
|
20302
20305
|
JobUtils.run = function (runnable, opts) {
|
|
20303
20306
|
var progression = new rxjs.BehaviorSubject(0);
|
|
20304
|
-
runnable(
|
|
20307
|
+
runnable(Object.assign(Object.assign({}, opts), { progression: progression }))
|
|
20305
20308
|
.then(function () {
|
|
20306
|
-
if (opts
|
|
20309
|
+
if (opts === null || opts === void 0 ? void 0 : opts.maxProgression)
|
|
20307
20310
|
progression.next(opts.maxProgression);
|
|
20308
|
-
progression
|
|
20311
|
+
if (opts === null || opts === void 0 ? void 0 : opts.progression)
|
|
20312
|
+
opts.progression.complete();
|
|
20309
20313
|
})
|
|
20310
20314
|
.catch(function (err) { return progression.error(err); });
|
|
20311
20315
|
return progression;
|
|
20312
20316
|
};
|
|
20313
|
-
JobUtils.fetchAllPages = function (loadPageFn,
|
|
20317
|
+
JobUtils.fetchAllPages = function (loadPageFn, opts) {
|
|
20318
|
+
var _a;
|
|
20314
20319
|
return __awaiter(this, void 0, void 0, function () {
|
|
20315
|
-
var maxProgression, total,
|
|
20316
|
-
return __generator(this, function (
|
|
20317
|
-
switch (
|
|
20320
|
+
var maxProgression, total, pageCount, progressionStep, currentPageDataCount, fetchSize, offset, data, res, actualProgression, lastProgressionStep;
|
|
20321
|
+
return __generator(this, function (_b) {
|
|
20322
|
+
switch (_b.label) {
|
|
20318
20323
|
case 0:
|
|
20319
20324
|
maxProgression = opts && opts.maxProgression || undefined;
|
|
20320
20325
|
fetchSize = opts && opts.fetchSize || 1000;
|
|
20321
20326
|
offset = 0;
|
|
20322
20327
|
data = [];
|
|
20323
|
-
|
|
20328
|
+
_b.label = 1;
|
|
20324
20329
|
case 1:
|
|
20325
20330
|
if (opts && opts.logPrefix)
|
|
20326
20331
|
console.debug(opts.logPrefix + " Fetching page #" + offset / fetchSize + "...");
|
|
20327
20332
|
return [4 /*yield*/, loadPageFn(offset, fetchSize)];
|
|
20328
20333
|
case 2:
|
|
20329
|
-
res =
|
|
20334
|
+
res = _b.sent();
|
|
20330
20335
|
data = data.concat(res.data);
|
|
20331
|
-
|
|
20332
|
-
offset +=
|
|
20336
|
+
currentPageDataCount = res.data && res.data.length || 0;
|
|
20337
|
+
offset += currentPageDataCount;
|
|
20333
20338
|
// Set total count (only if not already set)
|
|
20334
20339
|
if (isNil(total) && isNotNil(res.total)) {
|
|
20335
20340
|
total = res.total;
|
|
20336
|
-
|
|
20337
|
-
|
|
20341
|
+
// Compute the number of page
|
|
20342
|
+
pageCount = Math.round(res.total / fetchSize + 0.5); // Round to HALF_UP integer
|
|
20343
|
+
actualProgression = Math.max(0, toNumber(opts && ((_a = opts.progression) === null || _a === void 0 ? void 0 : _a.value), 0));
|
|
20344
|
+
progressionStep = maxProgression
|
|
20345
|
+
? (maxProgression - actualProgression) / pageCount
|
|
20346
|
+
: undefined /*if 0 reset to undefined*/;
|
|
20338
20347
|
}
|
|
20339
20348
|
// Increment progression on each iteration (if possible)
|
|
20340
|
-
if (isNotNil(progressionStep)) {
|
|
20341
|
-
progression.next(progression.
|
|
20349
|
+
if (opts && opts.progression && isNotNil(progressionStep)) {
|
|
20350
|
+
opts.progression.next(opts.progression.value + progressionStep);
|
|
20342
20351
|
}
|
|
20343
20352
|
if (opts && opts.onPageLoaded)
|
|
20344
20353
|
opts.onPageLoaded(res);
|
|
20345
|
-
|
|
20354
|
+
_b.label = 3;
|
|
20346
20355
|
case 3:
|
|
20347
|
-
if (
|
|
20348
|
-
|
|
20356
|
+
if (currentPageDataCount > 0 && ((isNil(total) && currentPageDataCount === fetchSize) || (isNotNil(total) && (offset < total)))) return [3 /*break*/, 1];
|
|
20357
|
+
_b.label = 4;
|
|
20349
20358
|
case 4:
|
|
20350
20359
|
// Complete progression to reach progressionStep value (because of round)
|
|
20351
20360
|
if (isNotNil(progressionStep)) {
|
|
@@ -20353,16 +20362,16 @@
|
|
|
20353
20362
|
if (isNotNil(total) && data.length < total) {
|
|
20354
20363
|
console.warn("A function loadAll() returned a bad total (less than all page's data)! Expected " + total + " but fetch " + data.length);
|
|
20355
20364
|
total = data.length;
|
|
20356
|
-
|
|
20365
|
+
pageCount = Math.round(data.length / fetchSize + 0.5);
|
|
20357
20366
|
}
|
|
20358
|
-
lastProgressionStep = opts.maxProgression - (progressionStep *
|
|
20359
|
-
if (lastProgressionStep > 0) {
|
|
20360
|
-
progression.next(progression.
|
|
20367
|
+
lastProgressionStep = opts.maxProgression - (progressionStep * pageCount);
|
|
20368
|
+
if (opts && opts.progression && lastProgressionStep > 0) {
|
|
20369
|
+
opts.progression.next(opts.progression.value + lastProgressionStep);
|
|
20361
20370
|
}
|
|
20362
20371
|
}
|
|
20363
20372
|
// Or increment once
|
|
20364
|
-
else if (opts.maxProgression) {
|
|
20365
|
-
progression.next(
|
|
20373
|
+
else if (opts && opts.progression && opts.maxProgression) {
|
|
20374
|
+
opts.progression.next(opts.maxProgression);
|
|
20366
20375
|
}
|
|
20367
20376
|
return [2 /*return*/, {
|
|
20368
20377
|
data: data,
|
|
@@ -29459,28 +29468,25 @@
|
|
|
29459
29468
|
});
|
|
29460
29469
|
});
|
|
29461
29470
|
};
|
|
29462
|
-
PersonService.prototype.executeImport = function (
|
|
29471
|
+
PersonService.prototype.executeImport = function (filter, opts) {
|
|
29463
29472
|
var _super = Object.create(null, {
|
|
29464
29473
|
loadAll: { get: function () { return _super_1.prototype.loadAll; } }
|
|
29465
29474
|
});
|
|
29466
29475
|
return __awaiter(this, void 0, void 0, function () {
|
|
29467
|
-
var maxProgression,
|
|
29476
|
+
var maxProgression, res;
|
|
29468
29477
|
var _this = this;
|
|
29469
29478
|
return __generator(this, function (_a) {
|
|
29470
29479
|
switch (_a.label) {
|
|
29471
29480
|
case 0:
|
|
29472
29481
|
maxProgression = opts && opts.maxProgression || 100;
|
|
29473
|
-
filter = {
|
|
29474
|
-
statusIds: [StatusIds.ENABLE, StatusIds.TEMPORARY],
|
|
29475
|
-
userProfiles: ['SUPERVISOR', 'USER', 'GUEST']
|
|
29476
|
-
};
|
|
29482
|
+
filter = Object.assign(Object.assign({}, filter), { statusIds: [StatusIds.ENABLE, StatusIds.TEMPORARY], userProfiles: ['SUPERVISOR', 'USER', 'GUEST'] });
|
|
29477
29483
|
console.info('[person-service] Importing persons...');
|
|
29478
29484
|
return [4 /*yield*/, JobUtils.fetchAllPages(function (offset, size) { return _super.loadAll.call(_this, offset, size, 'id', null, filter, {
|
|
29479
29485
|
debug: false,
|
|
29480
29486
|
fetchPolicy: 'network-only',
|
|
29481
29487
|
withTotal: (offset === 0),
|
|
29482
29488
|
toEntity: false
|
|
29483
|
-
}); }, progression,
|
|
29489
|
+
}); }, { progression: opts === null || opts === void 0 ? void 0 : opts.progression, maxProgression: maxProgression * 0.9 })];
|
|
29484
29490
|
case 1:
|
|
29485
29491
|
res = _a.sent();
|
|
29486
29492
|
// Save result locally
|
|
@@ -29498,7 +29504,7 @@
|
|
|
29498
29504
|
if (!source)
|
|
29499
29505
|
return undefined;
|
|
29500
29506
|
console.debug('TODO check isInstanceOf');
|
|
29501
|
-
if (!
|
|
29507
|
+
if (!(source instanceof exports.Person)) {
|
|
29502
29508
|
source = exports.Person.fromObject(source);
|
|
29503
29509
|
}
|
|
29504
29510
|
var target = source.asObject();
|