@sumaris-net/ngx-components 1.10.1 → 1.10.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 +36 -38
- 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/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/fesm2015/sumaris-net.ngx-components.js +35 -36
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -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
|
@@ -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({
|
|
@@ -24222,7 +24219,7 @@
|
|
|
24222
24219
|
throw Error('Not implemented!');
|
|
24223
24220
|
var variables = opts && opts.variables || {
|
|
24224
24221
|
id: id,
|
|
24225
|
-
interval: opts && opts.interval
|
|
24222
|
+
interval: toNumber(opts && opts.interval, 0) // no timer by default
|
|
24226
24223
|
};
|
|
24227
24224
|
if (this._debug)
|
|
24228
24225
|
console.debug(this._logPrefix + ("[WS] Listening for changes on " + this._logTypeName + " {" + id + "}..."));
|
|
@@ -27299,17 +27296,16 @@
|
|
|
27299
27296
|
var AppEntityEditor = /** @class */ (function (_super) {
|
|
27300
27297
|
__extends(AppEntityEditor, _super);
|
|
27301
27298
|
function AppEntityEditor(injector, dataType, dataService, options) {
|
|
27302
|
-
var _this = this;
|
|
27303
|
-
var _a;
|
|
27304
|
-
_this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
|
|
27299
|
+
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;
|
|
27305
27300
|
_this.dataType = dataType;
|
|
27306
27301
|
_this.dataService = dataService;
|
|
27307
27302
|
_this.saving = false;
|
|
27308
27303
|
_this.$title = new rxjs.Subject();
|
|
27309
27304
|
_this.onUpdateView = new i0.EventEmitter();
|
|
27305
|
+
_this.environement = injector.get(ENVIRONMENT);
|
|
27310
27306
|
options = Object.assign({
|
|
27311
27307
|
// Default options
|
|
27312
|
-
enableListenChanges:
|
|
27308
|
+
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: ''
|
|
27313
27309
|
}, options);
|
|
27314
27310
|
_this.settings = injector.get(LocalSettingsService);
|
|
27315
27311
|
_this.errorTranslator = injector.get(FormErrorTranslator);
|
|
@@ -27317,6 +27313,7 @@
|
|
|
27317
27313
|
_this.dateFormat = injector.get(DateFormatPipe);
|
|
27318
27314
|
_this.toastController = injector.get(i1$5.ToastController);
|
|
27319
27315
|
_this._enableListenChanges = options.enableListenChanges;
|
|
27316
|
+
_this._listenIntervalInSeconds = options.listenIntervalInSeconds;
|
|
27320
27317
|
_this._pathIdAttribute = options.pathIdAttribute;
|
|
27321
27318
|
_this._autoLoad = options.autoLoad;
|
|
27322
27319
|
_this._autoLoadDelay = options.autoLoadDelay;
|
|
@@ -27406,7 +27403,7 @@
|
|
|
27406
27403
|
};
|
|
27407
27404
|
AppEntityEditor.prototype.ngOnDestroy = function () {
|
|
27408
27405
|
_super.prototype.ngOnDestroy.call(this);
|
|
27409
|
-
this.
|
|
27406
|
+
this._listenChangesSubscription = null; // already unsubscribe in the super function
|
|
27410
27407
|
this.$title.complete();
|
|
27411
27408
|
this.$title.unsubscribe();
|
|
27412
27409
|
this.onUpdateView.complete();
|
|
@@ -27503,32 +27500,33 @@
|
|
|
27503
27500
|
AppEntityEditor.prototype.startListenRemoteChanges = function () {
|
|
27504
27501
|
var _this = this;
|
|
27505
27502
|
// Skip if disable, or already listening
|
|
27506
|
-
if (this.
|
|
27503
|
+
if (this._listenChangesSubscription || !this._enableListenChanges || this.isNewData)
|
|
27507
27504
|
return;
|
|
27508
27505
|
// Listen for changes on server
|
|
27509
|
-
this.
|
|
27506
|
+
this._listenChangesSubscription = this.dataService.listenChanges(this.data.id, { interval: this._listenIntervalInSeconds })
|
|
27510
27507
|
.pipe(operators.filter(isNotNil))
|
|
27511
27508
|
.subscribe(function (data) {
|
|
27512
27509
|
if (data.updateDate && data.updateDate.isAfter(_this.data.updateDate)) {
|
|
27513
27510
|
if (!_this.dirty) {
|
|
27514
27511
|
if (_this.debug)
|
|
27515
|
-
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}
|
|
27512
|
+
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}: reloading page...");
|
|
27516
27513
|
_this.updateView(data);
|
|
27517
27514
|
}
|
|
27518
27515
|
else {
|
|
27519
27516
|
if (_this.debug)
|
|
27520
27517
|
console.debug("[data-editor] Changes detected on server, at {" + data.updateDate + "}, but page is dirty: skip reloading.");
|
|
27518
|
+
// TODO: alter user (with a toast ?)
|
|
27521
27519
|
}
|
|
27522
27520
|
}
|
|
27523
27521
|
});
|
|
27524
|
-
this.
|
|
27525
|
-
this.registerSubscription(this.
|
|
27522
|
+
this._listenChangesSubscription.add(function () { return _this._listenChangesSubscription = null; });
|
|
27523
|
+
this.registerSubscription(this._listenChangesSubscription);
|
|
27526
27524
|
};
|
|
27527
27525
|
AppEntityEditor.prototype.stopListenRemoteChanges = function () {
|
|
27528
|
-
if (this.
|
|
27529
|
-
this.unregisterSubscription(this.
|
|
27530
|
-
this.
|
|
27531
|
-
this.
|
|
27526
|
+
if (this._listenChangesSubscription) {
|
|
27527
|
+
this.unregisterSubscription(this._listenChangesSubscription);
|
|
27528
|
+
this._listenChangesSubscription.unsubscribe();
|
|
27529
|
+
this._listenChangesSubscription = null;
|
|
27532
27530
|
}
|
|
27533
27531
|
};
|
|
27534
27532
|
AppEntityEditor.prototype.updateView = function (data, opts) {
|
|
@@ -27725,7 +27723,7 @@
|
|
|
27725
27723
|
// Update the view (e.g metadata)
|
|
27726
27724
|
_b.sent();
|
|
27727
27725
|
// Subscribe to remote changes
|
|
27728
|
-
if (!this.
|
|
27726
|
+
if (!this._listenChangesSubscription)
|
|
27729
27727
|
this.startListenRemoteChanges();
|
|
27730
27728
|
this.submitted = false;
|
|
27731
27729
|
return [2 /*return*/, true];
|