@sumaris-net/ngx-components 1.10.0 → 1.10.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 +62 -56
- 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/doc/changelog.md +4 -0
- package/esm2015/src/app/core/core.module.js +7 -3
- package/esm2015/src/app/core/form/entity-editor.class.js +17 -15
- package/esm2015/src/app/core/services/account.service.js +21 -24
- package/esm2015/src/app/core/services/base-entity-service.class.js +3 -3
- package/esm2015/src/app/core/table/table.class.js +31 -19
- package/esm2015/src/environments/environment.js +3 -3
- package/fesm2015/sumaris-net.ngx-components.js +71 -57
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/core.module.d.ts +2 -1
- package/src/app/core/form/entity-editor.class.d.ts +9 -5
- package/src/app/core/services/account.service.d.ts +3 -2
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -10672,11 +10672,11 @@
|
|
|
10672
10672
|
},
|
|
10673
10673
|
account: {
|
|
10674
10674
|
enableListenChanges: true,
|
|
10675
|
-
listenIntervalInSeconds:
|
|
10675
|
+
listenIntervalInSeconds: 60
|
|
10676
10676
|
},
|
|
10677
10677
|
entityEditor: {
|
|
10678
10678
|
enableListenChanges: true,
|
|
10679
|
-
listenIntervalInSeconds:
|
|
10679
|
+
listenIntervalInSeconds: 60
|
|
10680
10680
|
}
|
|
10681
10681
|
});
|
|
10682
10682
|
|
|
@@ -15465,7 +15465,8 @@
|
|
|
15465
15465
|
};
|
|
15466
15466
|
_this._$additionalFields = new rxjs.BehaviorSubject([]);
|
|
15467
15467
|
_this._tokenType$ = new rxjs.BehaviorSubject(undefined);
|
|
15468
|
-
_this._enableListenChanges = (!environment.account || environment.account.enableListenChanges !== false);
|
|
15468
|
+
_this._enableListenChanges = (!environment.account || environment.account.enableListenChanges !== false); // True by default
|
|
15469
|
+
_this._listenIntervalInSeconds = toNumber(environment.account && environment.account.listenIntervalInSeconds, 0); // no timer by default
|
|
15469
15470
|
_this._debug = !environment.production;
|
|
15470
15471
|
if (_this._debug)
|
|
15471
15472
|
console.debug('[account-service] Creating service');
|
|
@@ -15711,7 +15712,7 @@
|
|
|
15711
15712
|
this.onChange.next(this._data);
|
|
15712
15713
|
// Listen remote changes
|
|
15713
15714
|
if (this._enableListenChanges)
|
|
15714
|
-
this.
|
|
15715
|
+
this.startListenRemoteChanges();
|
|
15715
15716
|
return [2 /*return*/, this._data];
|
|
15716
15717
|
case 6:
|
|
15717
15718
|
error_1 = _b.sent();
|
|
@@ -15867,7 +15868,7 @@
|
|
|
15867
15868
|
this.onLogin.next(this._data);
|
|
15868
15869
|
this.onChange.next(this._data);
|
|
15869
15870
|
if (this._enableListenChanges)
|
|
15870
|
-
this.
|
|
15871
|
+
this.startListenRemoteChanges();
|
|
15871
15872
|
return [2 /*return*/, this._data];
|
|
15872
15873
|
}
|
|
15873
15874
|
});
|
|
@@ -16007,7 +16008,6 @@
|
|
|
16007
16008
|
if (hadAuthBasic)
|
|
16008
16009
|
this.onAuthBasicChange.next(undefined);
|
|
16009
16010
|
this.onChange.next(undefined);
|
|
16010
|
-
this.stopListenChanges();
|
|
16011
16011
|
return [2 /*return*/];
|
|
16012
16012
|
}
|
|
16013
16013
|
});
|
|
@@ -16170,7 +16170,7 @@
|
|
|
16170
16170
|
AccountService.prototype.listenChanges = function (opts) {
|
|
16171
16171
|
if (this._enableListenChanges)
|
|
16172
16172
|
return new rxjs.Subscription(); // Already started: skip
|
|
16173
|
-
return this.
|
|
16173
|
+
return this.startListenRemoteChanges(opts);
|
|
16174
16174
|
};
|
|
16175
16175
|
Object.defineProperty(AccountService.prototype, "additionalFields", {
|
|
16176
16176
|
get: function () {
|
|
@@ -16200,7 +16200,7 @@
|
|
|
16200
16200
|
};
|
|
16201
16201
|
/* -- protected method -- */
|
|
16202
16202
|
AccountService.prototype.resetData = function () {
|
|
16203
|
-
this.
|
|
16203
|
+
this.stopListenRemoteChanges();
|
|
16204
16204
|
this._cache.loaded = false;
|
|
16205
16205
|
this._cache.keypair = null;
|
|
16206
16206
|
this._cache.authToken = null;
|
|
@@ -16352,7 +16352,7 @@
|
|
|
16352
16352
|
this.onLogin.next(this._data);
|
|
16353
16353
|
this.onChange.next(this._data);
|
|
16354
16354
|
if (this._enableListenChanges)
|
|
16355
|
-
this.
|
|
16355
|
+
this.startListenRemoteChanges();
|
|
16356
16356
|
if (this._debug)
|
|
16357
16357
|
console.debug("[account] Account restoration [OK] {pubkey: " + pubkey.substr(0, 8) + "}, {profile: " + this._cache.mainProfile + "}");
|
|
16358
16358
|
return [2 /*return*/, account];
|
|
@@ -16602,13 +16602,13 @@
|
|
|
16602
16602
|
});
|
|
16603
16603
|
});
|
|
16604
16604
|
};
|
|
16605
|
-
AccountService.prototype.
|
|
16605
|
+
AccountService.prototype.startListenRemoteChanges = function (opts) {
|
|
16606
16606
|
var _this = this;
|
|
16607
16607
|
if (this._listenChangesSubscription)
|
|
16608
|
-
this.
|
|
16608
|
+
this.stopListenRemoteChanges(); // Stop previous subscription
|
|
16609
16609
|
if (this.network.offline)
|
|
16610
16610
|
return new rxjs.Subscription(); // Offline: skip
|
|
16611
|
-
|
|
16611
|
+
this._listenChangesSubscription = this.watchChanges(opts)
|
|
16612
16612
|
.subscribe({
|
|
16613
16613
|
next: function (data) {
|
|
16614
16614
|
console.debug("[account] Remote update detected at " + data.updateDate);
|
|
@@ -16628,21 +16628,18 @@
|
|
|
16628
16628
|
}
|
|
16629
16629
|
}
|
|
16630
16630
|
});
|
|
16631
|
-
|
|
16632
|
-
|
|
16633
|
-
|
|
16634
|
-
|
|
16635
|
-
return
|
|
16631
|
+
this._listenChangesSubscription.add(function () {
|
|
16632
|
+
console.debug("[account] Stop watching remote changes");
|
|
16633
|
+
_this._listenChangesSubscription = null;
|
|
16634
|
+
});
|
|
16635
|
+
return this._listenChangesSubscription;
|
|
16636
16636
|
};
|
|
16637
|
-
AccountService.prototype.
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
this._listenChangesSubscription = null;
|
|
16641
|
-
}
|
|
16637
|
+
AccountService.prototype.stopListenRemoteChanges = function () {
|
|
16638
|
+
var _a;
|
|
16639
|
+
(_a = this._listenChangesSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
16642
16640
|
};
|
|
16643
16641
|
AccountService.prototype.watchChanges = function (opts) {
|
|
16644
16642
|
var _this = this;
|
|
16645
|
-
var _a;
|
|
16646
16643
|
if (!this.started) {
|
|
16647
16644
|
// Wait service ready, then loop
|
|
16648
16645
|
return rxjs.from(this.ready())
|
|
@@ -16653,7 +16650,7 @@
|
|
|
16653
16650
|
if (this.network.offline)
|
|
16654
16651
|
throw new Error('Cannot watch account changes: network is offline.');
|
|
16655
16652
|
var variables = {
|
|
16656
|
-
interval:
|
|
16653
|
+
interval: toNumber(opts && opts.intervalInSeconds, this._listenIntervalInSeconds)
|
|
16657
16654
|
};
|
|
16658
16655
|
console.debug("[account] Watching remote changes, every " + variables.interval + "s");
|
|
16659
16656
|
return this.graphql.subscribe({
|
|
@@ -23629,11 +23626,14 @@
|
|
|
23629
23626
|
var CoreModule = /** @class */ (function () {
|
|
23630
23627
|
function CoreModule() {
|
|
23631
23628
|
}
|
|
23632
|
-
CoreModule.forRoot = function () {
|
|
23629
|
+
CoreModule.forRoot = function (environment) {
|
|
23633
23630
|
console.info('[core] Creating module (root)');
|
|
23634
23631
|
return {
|
|
23635
23632
|
ngModule: CoreModule,
|
|
23636
|
-
providers: [
|
|
23633
|
+
providers: [
|
|
23634
|
+
PlatformService,
|
|
23635
|
+
{ provide: ENVIRONMENT, useValue: environment }
|
|
23636
|
+
]
|
|
23637
23637
|
};
|
|
23638
23638
|
};
|
|
23639
23639
|
return CoreModule;
|
|
@@ -24222,7 +24222,7 @@
|
|
|
24222
24222
|
throw Error('Not implemented!');
|
|
24223
24223
|
var variables = opts && opts.variables || {
|
|
24224
24224
|
id: id,
|
|
24225
|
-
interval: opts && opts.interval
|
|
24225
|
+
interval: toNumber(opts && opts.interval, 0) // no timer by default
|
|
24226
24226
|
};
|
|
24227
24227
|
if (this._debug)
|
|
24228
24228
|
console.debug(this._logPrefix + ("[WS] Listening for changes on " + this._logTypeName + " {" + id + "}..."));
|
|
@@ -25622,7 +25622,7 @@
|
|
|
25622
25622
|
AppTable.prototype.deleteRows = function (event, rows, opts) {
|
|
25623
25623
|
var _a;
|
|
25624
25624
|
return __awaiter(this, void 0, void 0, function () {
|
|
25625
|
-
var confirmed, canDelete, saved,
|
|
25625
|
+
var confirmed, canDelete, saved, deleteCount, err_2;
|
|
25626
25626
|
var _this = this;
|
|
25627
25627
|
return __generator(this, function (_e) {
|
|
25628
25628
|
switch (_e.label) {
|
|
@@ -25658,13 +25658,16 @@
|
|
|
25658
25658
|
if (deleted) {
|
|
25659
25659
|
_this.visibleRowCount--;
|
|
25660
25660
|
_this.totalRowCount--;
|
|
25661
|
+
// Forget is was the edited row
|
|
25662
|
+
if (row === _this.editedRow) {
|
|
25663
|
+
_this.editedRow = undefined;
|
|
25664
|
+
}
|
|
25661
25665
|
return res;
|
|
25662
25666
|
}
|
|
25663
25667
|
}
|
|
25664
25668
|
return res.concat(row);
|
|
25665
25669
|
}, []);
|
|
25666
|
-
if (
|
|
25667
|
-
return [2 /*return*/, 0];
|
|
25670
|
+
if (!isNotEmptyArray(rows)) return [3 /*break*/, 3];
|
|
25668
25671
|
return [4 /*yield*/, this.saveBeforeAction('delete')];
|
|
25669
25672
|
case 2:
|
|
25670
25673
|
saved = _e.sent();
|
|
@@ -25674,20 +25677,21 @@
|
|
|
25674
25677
|
}
|
|
25675
25678
|
_e.label = 3;
|
|
25676
25679
|
case 3:
|
|
25680
|
+
_e.trys.push([3, 6, , 7]);
|
|
25681
|
+
deleteCount = rows.length;
|
|
25682
|
+
if (!deleteCount) return [3 /*break*/, 5];
|
|
25677
25683
|
if (this.debug)
|
|
25678
|
-
console.debug('[table] Delete
|
|
25679
|
-
|
|
25680
|
-
|
|
25681
|
-
|
|
25682
|
-
|
|
25684
|
+
console.debug('[table] Delete selected rows...');
|
|
25685
|
+
// Reverse row order (on a copy)
|
|
25686
|
+
// This is a workaround, need because row.delete() has async execution
|
|
25687
|
+
// and index cache is updated with a delay
|
|
25688
|
+
rows = rows.slice()
|
|
25683
25689
|
.sort(function (a, b) { return a.id > b.id ? -1 : 1; });
|
|
25684
|
-
|
|
25690
|
+
return [4 /*yield*/, this._dataSource.deleteAll(rows)];
|
|
25685
25691
|
case 4:
|
|
25686
|
-
_e.trys.push([4, 6, , 7]);
|
|
25687
|
-
deleteCount = rowsToDelete.length;
|
|
25688
|
-
return [4 /*yield*/, this._dataSource.deleteAll(rowsToDelete)];
|
|
25689
|
-
case 5:
|
|
25690
25692
|
_e.sent();
|
|
25693
|
+
_e.label = 5;
|
|
25694
|
+
case 5:
|
|
25691
25695
|
// DO not update manually, because watchALl().subscribe() will update this count
|
|
25692
25696
|
//this.totalRowCount -= deleteCount;
|
|
25693
25697
|
//this.visibleRowCount -= deleteCount;
|
|
@@ -25695,7 +25699,8 @@
|
|
|
25695
25699
|
this.editedRow = undefined;
|
|
25696
25700
|
this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
|
|
25697
25701
|
this.markForCheck();
|
|
25698
|
-
|
|
25702
|
+
if (deleteCount)
|
|
25703
|
+
this.onAfterDeletedRows.next(rows);
|
|
25699
25704
|
return [2 /*return*/, deleteCount];
|
|
25700
25705
|
case 6:
|
|
25701
25706
|
err_2 = _e.sent();
|
|
@@ -27294,17 +27299,16 @@
|
|
|
27294
27299
|
var AppEntityEditor = /** @class */ (function (_super) {
|
|
27295
27300
|
__extends(AppEntityEditor, _super);
|
|
27296
27301
|
function AppEntityEditor(injector, dataType, dataService, options) {
|
|
27297
|
-
var _this = this;
|
|
27298
|
-
var _a;
|
|
27299
|
-
_this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
|
|
27302
|
+
var _this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
|
|
27300
27303
|
_this.dataType = dataType;
|
|
27301
27304
|
_this.dataService = dataService;
|
|
27302
27305
|
_this.saving = false;
|
|
27303
27306
|
_this.$title = new rxjs.Subject();
|
|
27304
27307
|
_this.onUpdateView = new i0.EventEmitter();
|
|
27308
|
+
_this.environement = injector.get(ENVIRONMENT);
|
|
27305
27309
|
options = Object.assign({
|
|
27306
27310
|
// Default options
|
|
27307
|
-
enableListenChanges:
|
|
27311
|
+
enableListenChanges: !_this.environement.entityEditor || _this.environement.entityEditor.enableListenChanges !== false, listenIntervalInSeconds: toNumber(_this.environement.entityEditor && _this.environement.entityEditor.listenIntervalInSeconds, 0), pathIdAttribute: 'id', autoLoad: true, autoUpdateRoute: true, i18nPrefix: ''
|
|
27308
27312
|
}, options);
|
|
27309
27313
|
_this.settings = injector.get(LocalSettingsService);
|
|
27310
27314
|
_this.errorTranslator = injector.get(FormErrorTranslator);
|
|
@@ -27312,6 +27316,7 @@
|
|
|
27312
27316
|
_this.dateFormat = injector.get(DateFormatPipe);
|
|
27313
27317
|
_this.toastController = injector.get(i1$5.ToastController);
|
|
27314
27318
|
_this._enableListenChanges = options.enableListenChanges;
|
|
27319
|
+
_this._listenIntervalInSeconds = options.listenIntervalInSeconds;
|
|
27315
27320
|
_this._pathIdAttribute = options.pathIdAttribute;
|
|
27316
27321
|
_this._autoLoad = options.autoLoad;
|
|
27317
27322
|
_this._autoLoadDelay = options.autoLoadDelay;
|
|
@@ -27401,7 +27406,7 @@
|
|
|
27401
27406
|
};
|
|
27402
27407
|
AppEntityEditor.prototype.ngOnDestroy = function () {
|
|
27403
27408
|
_super.prototype.ngOnDestroy.call(this);
|
|
27404
|
-
this.
|
|
27409
|
+
this._listenChangesSubscription = null; // already unsubscribe in the super function
|
|
27405
27410
|
this.$title.complete();
|
|
27406
27411
|
this.$title.unsubscribe();
|
|
27407
27412
|
this.onUpdateView.complete();
|
|
@@ -27498,32 +27503,33 @@
|
|
|
27498
27503
|
AppEntityEditor.prototype.startListenRemoteChanges = function () {
|
|
27499
27504
|
var _this = this;
|
|
27500
27505
|
// Skip if disable, or already listening
|
|
27501
|
-
if (this.
|
|
27506
|
+
if (this._listenChangesSubscription || !this._enableListenChanges || this.isNewData)
|
|
27502
27507
|
return;
|
|
27503
27508
|
// Listen for changes on server
|
|
27504
|
-
this.
|
|
27509
|
+
this._listenChangesSubscription = this.dataService.listenChanges(this.data.id, { interval: this._listenIntervalInSeconds })
|
|
27505
27510
|
.pipe(operators.filter(isNotNil))
|
|
27506
27511
|
.subscribe(function (data) {
|
|
27507
27512
|
if (data.updateDate && data.updateDate.isAfter(_this.data.updateDate)) {
|
|
27508
27513
|
if (!_this.dirty) {
|
|
27509
27514
|
if (_this.debug)
|
|
27510
|
-
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}
|
|
27515
|
+
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}: reloading page...");
|
|
27511
27516
|
_this.updateView(data);
|
|
27512
27517
|
}
|
|
27513
27518
|
else {
|
|
27514
27519
|
if (_this.debug)
|
|
27515
27520
|
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}, but page is dirty: skip reloading.");
|
|
27521
|
+
// TODO: alter user (with a toast ?)
|
|
27516
27522
|
}
|
|
27517
27523
|
}
|
|
27518
27524
|
});
|
|
27519
|
-
this.
|
|
27520
|
-
this.registerSubscription(this.
|
|
27525
|
+
this._listenChangesSubscription.add(function () { return _this._listenChangesSubscription = null; });
|
|
27526
|
+
this.registerSubscription(this._listenChangesSubscription);
|
|
27521
27527
|
};
|
|
27522
27528
|
AppEntityEditor.prototype.stopListenRemoteChanges = function () {
|
|
27523
|
-
if (this.
|
|
27524
|
-
this.unregisterSubscription(this.
|
|
27525
|
-
this.
|
|
27526
|
-
this.
|
|
27529
|
+
if (this._listenChangesSubscription) {
|
|
27530
|
+
this.unregisterSubscription(this._listenChangesSubscription);
|
|
27531
|
+
this._listenChangesSubscription.unsubscribe();
|
|
27532
|
+
this._listenChangesSubscription = null;
|
|
27527
27533
|
}
|
|
27528
27534
|
};
|
|
27529
27535
|
AppEntityEditor.prototype.updateView = function (data, opts) {
|
|
@@ -27720,7 +27726,7 @@
|
|
|
27720
27726
|
// Update the view (e.g metadata)
|
|
27721
27727
|
_b.sent();
|
|
27722
27728
|
// Subscribe to remote changes
|
|
27723
|
-
if (!this.
|
|
27729
|
+
if (!this._listenChangesSubscription)
|
|
27724
27730
|
this.startListenRemoteChanges();
|
|
27725
27731
|
this.submitted = false;
|
|
27726
27732
|
return [2 /*return*/, true];
|