@sumaris-net/ngx-components 1.21.0-beta20 → 1.21.0-beta23

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.
@@ -30182,9 +30182,9 @@
30182
30182
  _this.mutations = mutations;
30183
30183
  _this.subscriptions = subscriptions;
30184
30184
  _this.environment = environment;
30185
- _this._count$ = new rxjs.BehaviorSubject(0);
30186
- _this._subscriptions = new rxjs.Subscription();
30185
+ _this.count$ = new rxjs.BehaviorSubject(0);
30187
30186
  _this.listeners = [];
30187
+ _this._subscriptions = new rxjs.Subscription();
30188
30188
  _this._logPrefix = '[user-event-service] ';
30189
30189
  // For DEV only
30190
30190
  _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
@@ -30192,7 +30192,7 @@
30192
30192
  }
30193
30193
  Object.defineProperty(AbstractUserEventService.prototype, "userEventCount", {
30194
30194
  get: function () {
30195
- return this._count$.asObservable();
30195
+ return this.count$.asObservable();
30196
30196
  },
30197
30197
  enumerable: false,
30198
30198
  configurable: true
@@ -30291,7 +30291,7 @@
30291
30291
  data: entity
30292
30292
  });
30293
30293
  // Update count
30294
- this._count$.next(this._count$.value + 1);
30294
+ this.count$.next(this.count$.value + 1);
30295
30295
  };
30296
30296
  AbstractUserEventService.prototype.count = function (filter, options) {
30297
30297
  var _a;
@@ -30306,6 +30306,8 @@
30306
30306
  }
30307
30307
  if (!filter)
30308
30308
  filter = this.defaultFilter();
30309
+ // Apply last reset date as start date
30310
+ filter.startDate = this.resetCountDate;
30309
30311
  filter = this.asFilter(filter);
30310
30312
  if (this._debug)
30311
30313
  console.debug(this._logPrefix + "Counting user events with filter:", filter);
@@ -30332,6 +30334,8 @@
30332
30334
  }
30333
30335
  if (!filter)
30334
30336
  filter = this.defaultFilter();
30337
+ // Apply last reset date as start date
30338
+ filter.startDate = this.resetCountDate;
30335
30339
  filter = this.asFilter(filter);
30336
30340
  if (this._debug)
30337
30341
  console.debug(this._logPrefix + "[WS] Listening count changes for user events with filter:", filter);
@@ -30348,7 +30352,7 @@
30348
30352
  if (total && _this._debug)
30349
30353
  console.debug(_this._logPrefix + "Received new user events count:", total);
30350
30354
  // update count
30351
- _this._count$.next(total);
30355
+ _this.count$.next(total);
30352
30356
  return total;
30353
30357
  }));
30354
30358
  };
@@ -30648,7 +30652,10 @@
30648
30652
  this.listeners.push(listener);
30649
30653
  };
30650
30654
  AbstractUserEventService.prototype.resetCount = function () {
30651
- this._count$.next(undefined);
30655
+ this.count$.next(undefined);
30656
+ this.resetCountDate = moment$6();
30657
+ // restart listening count changes
30658
+ this.startListenCountChanges();
30652
30659
  };
30653
30660
  /* -- protected methods -- */
30654
30661
  AbstractUserEventService.prototype.onLogin = function () {
@@ -30662,17 +30669,25 @@
30662
30669
  if (this._debug)
30663
30670
  console.debug(this._logPrefix + "Receiving user events count", count);
30664
30671
  // Update count
30665
- this._count$.next(count);
30672
+ this.count$.next(count);
30666
30673
  // Then listen changes
30667
- this._listenSubscription = this.listenCountChanges(undefined).subscribe();
30674
+ this.startListenCountChanges();
30668
30675
  return [2 /*return*/];
30669
30676
  }
30670
30677
  });
30671
30678
  });
30672
30679
  };
30673
30680
  AbstractUserEventService.prototype.onLogout = function () {
30681
+ this.stopListenCountChanges();
30682
+ };
30683
+ AbstractUserEventService.prototype.startListenCountChanges = function () {
30684
+ this.stopListenCountChanges();
30685
+ this._listenSubscription = this.listenCountChanges(undefined).subscribe();
30686
+ };
30687
+ AbstractUserEventService.prototype.stopListenCountChanges = function () {
30674
30688
  var _a;
30675
30689
  (_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
30690
+ this._listenSubscription = undefined;
30676
30691
  };
30677
30692
  AbstractUserEventService.prototype.processUserEvent = function (source, that) {
30678
30693
  var e_3, _b;
@@ -31299,7 +31314,7 @@
31299
31314
  entity = this.processUserEvent(entity);
31300
31315
  entity.id = this.userEvents.length + 1;
31301
31316
  this.userEvents.push(entity);
31302
- this._count$.next(this.userEvents.length);
31317
+ this.count$.next(this.userEvents.length);
31303
31318
  };
31304
31319
  UserEventTestService.prototype.asFilter = function (filter) {
31305
31320
  return filter;
@@ -31666,8 +31681,10 @@
31666
31681
  // @dynamic
31667
31682
  exports.JobProgression = JobProgression_1 = /** @class */ (function (_super) {
31668
31683
  __extends(JobProgression, _super);
31669
- function JobProgression() {
31670
- return _super.call(this, JobProgression_1.TYPENAME) || this;
31684
+ function JobProgression(id) {
31685
+ var _this = _super.call(this, JobProgression_1.TYPENAME) || this;
31686
+ _this.id = id;
31687
+ return _this;
31671
31688
  }
31672
31689
  JobProgression.prototype.fromObject = function (source) {
31673
31690
  _super.prototype.fromObject.call(this, source);
@@ -31779,13 +31796,16 @@
31779
31796
  console.warn(this._logPrefix + "No service injected. Can't add a job");
31780
31797
  return;
31781
31798
  }
31782
- if (this.debug) {
31783
- console.debug(this._logPrefix + "Add job id=" + id);
31784
- }
31785
31799
  if (!!this.getProgression(id)) {
31786
31800
  console.warn(this._logPrefix + "Job (id=" + id + ") already present");
31787
31801
  return;
31788
31802
  }
31803
+ if (this.debug) {
31804
+ console.debug(this._logPrefix + "Add job id=" + id);
31805
+ }
31806
+ // Adding empty job progression
31807
+ var progression = new exports.JobProgression(id);
31808
+ this.jobProgressions.push(progression);
31789
31809
  this.disabled = false;
31790
31810
  var sub = this.jobProgressionService.listenChanges(id)
31791
31811
  .pipe(operators.filter(function (progression) {
@@ -31800,7 +31820,7 @@
31800
31820
  // Get current progression object
31801
31821
  var currentProgression = _this.getProgression(id);
31802
31822
  if (!currentProgression) {
31803
- // add it
31823
+ // add it if absent
31804
31824
  _this.jobProgressions.push(progression);
31805
31825
  if (_this.debug) {
31806
31826
  console.debug(_this._logPrefix + "Progression added id=" + id, progression);