@sumaris-net/ngx-components 1.23.16 → 1.23.18

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.
Files changed (44) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +505 -252
  2. package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
  3. package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
  4. package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
  5. package/esm2015/public_api.js +3 -2
  6. package/esm2015/src/app/core/services/network.service.js +17 -25
  7. package/esm2015/src/app/core/table/entities-table-datasource.class.js +46 -30
  8. package/esm2015/src/app/core/table/table.class.js +2 -5
  9. package/esm2015/src/app/core/table/testing/table.testing.js +2 -2
  10. package/esm2015/src/app/shared/services/memory-entity-service.class.js +49 -29
  11. package/esm2015/src/app/shared/services/startable-observable-service.class.js +122 -0
  12. package/esm2015/src/app/shared/services/startable-service.class.js +23 -21
  13. package/esm2015/src/app/social/job/job.module.js +4 -4
  14. package/esm2015/src/app/social/job/job.service.js +24 -12
  15. package/esm2015/src/app/social/job/progression/job-progression.icon.js +208 -0
  16. package/esm2015/src/app/social/job/testing/job-progression.testing.js +27 -26
  17. package/esm2015/src/app/social/job/testing/job-progression.testing.service.js +24 -2
  18. package/esm2015/src/app/social/social.module.js +1 -1
  19. package/esm2015/src/app/social/user-event/notification/user-event-notification.icon.js +26 -15
  20. package/esm2015/src/app/social/user-event/notification/user-event-notification.list.js +3 -3
  21. package/esm2015/src/app/social/user-event/testing/user-event.testing.js +3 -3
  22. package/esm2015/src/app/social/user-event/user-event.module.js +4 -4
  23. package/esm2015/src/app/social/user-event/user-event.service.js +2 -2
  24. package/esm2015/sumaris-net.ngx-components.js +10 -10
  25. package/fesm2015/sumaris-net.ngx-components.js +389 -191
  26. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  27. package/package.json +1 -1
  28. package/public_api.d.ts +2 -1
  29. package/src/app/core/services/network.service.d.ts +5 -7
  30. package/src/app/core/table/entities-table-datasource.class.d.ts +9 -1
  31. package/src/app/shared/services/memory-entity-service.class.d.ts +4 -4
  32. package/src/app/shared/services/startable-observable-service.class.d.ts +33 -0
  33. package/src/app/shared/services/startable-service.class.d.ts +9 -8
  34. package/src/app/social/job/job.service.d.ts +10 -2
  35. package/src/app/social/job/progression/{job-progression.component.d.ts → job-progression.icon.d.ts} +3 -3
  36. package/src/app/social/job/testing/job-progression.testing.d.ts +7 -4
  37. package/src/app/social/job/testing/job-progression.testing.service.d.ts +4 -0
  38. package/src/app/social/social.module.d.ts +1 -1
  39. package/src/app/social/user-event/notification/user-event-notification.icon.d.ts +6 -3
  40. package/src/app/social/user-event/testing/user-event.testing.d.ts +2 -2
  41. package/src/app/social/user-event/user-event.service.d.ts +1 -1
  42. package/sumaris-net.ngx-components.d.ts +9 -9
  43. package/sumaris-net.ngx-components.metadata.json +1 -1
  44. package/esm2015/src/app/social/job/progression/job-progression.component.js +0 -200
@@ -10097,20 +10097,20 @@
10097
10097
  ? function () { return prerequisiteService.ready(); }
10098
10098
  : function () { return Promise.resolve(); };
10099
10099
  }
10100
- StartableService.prototype.start = function () {
10100
+ StartableService.prototype.start = function (opts) {
10101
10101
  var _this = this;
10102
10102
  if (this._startPromise)
10103
10103
  return this._startPromise;
10104
10104
  if (this._started)
10105
10105
  return Promise.resolve(this._data);
10106
10106
  this._startPromise = this._startPrerequisite()
10107
- .then(function () { return _this.ngOnStart(); })
10107
+ .then(function () { return _this.ngOnStart(opts); })
10108
10108
  .then(function (data) {
10109
10109
  _this._data = data;
10110
10110
  _this._started = true;
10111
10111
  _this._startPromise = undefined;
10112
- _this.startSubject.next(_this._data);
10113
- return _this._data;
10112
+ _this.startSubject.next(data);
10113
+ return data;
10114
10114
  })
10115
10115
  .catch(function (err) {
10116
10116
  console.error('Failed to start a service: ' + (err && err.message || err), err);
@@ -10120,6 +10120,17 @@
10120
10120
  });
10121
10121
  return this._startPromise;
10122
10122
  };
10123
+ StartableService.prototype.ready = function () {
10124
+ if (this._started)
10125
+ return Promise.resolve(this._data);
10126
+ if (this._startPromise)
10127
+ return this._startPromise;
10128
+ if (this._startByReadyFunction)
10129
+ return this.start();
10130
+ return this.startSubject
10131
+ .pipe(operators.takeUntil(this.stopSubject))
10132
+ .toPromise();
10133
+ };
10123
10134
  StartableService.prototype.stop = function () {
10124
10135
  return __awaiter(this, void 0, void 0, function () {
10125
10136
  var err_1;
@@ -10147,7 +10158,7 @@
10147
10158
  });
10148
10159
  });
10149
10160
  };
10150
- StartableService.prototype.restart = function () {
10161
+ StartableService.prototype.restart = function (opts) {
10151
10162
  return __awaiter(this, void 0, void 0, function () {
10152
10163
  return __generator(this, function (_b) {
10153
10164
  switch (_b.label) {
@@ -10164,7 +10175,7 @@
10164
10175
  _b.sent(); // Then stop if started
10165
10176
  _b.label = 4;
10166
10177
  case 4: // Then stop if started
10167
- return [2 /*return*/, this.start()]; // Then start again
10178
+ return [2 /*return*/, this.start(opts)]; // Then start again
10168
10179
  }
10169
10180
  });
10170
10181
  });
@@ -10183,23 +10194,20 @@
10183
10194
  enumerable: false,
10184
10195
  configurable: true
10185
10196
  });
10186
- StartableService.prototype.ready = function () {
10187
- if (this._started)
10188
- return Promise.resolve(this._data);
10189
- if (this._startPromise)
10190
- return this._startPromise;
10191
- if (this._startByReadyFunction)
10192
- return this.start();
10193
- return this.startSubject
10194
- .pipe(operators.takeUntil(this.stopSubject))
10195
- .toPromise();
10196
- };
10197
+ Object.defineProperty(StartableService.prototype, "stopped", {
10198
+ get: function () {
10199
+ return !this._started && !this._startPromise;
10200
+ },
10201
+ enumerable: false,
10202
+ configurable: true
10203
+ });
10197
10204
  StartableService.prototype.registerSubscription = function (sub) {
10198
10205
  this._subscription = this._subscription || new rxjs.Subscription();
10199
10206
  return this._subscription.add(sub);
10200
10207
  };
10201
10208
  StartableService.prototype.unregisterSubscription = function (sub) {
10202
- this._subscription.remove(sub);
10209
+ var _a;
10210
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.remove(sub);
10203
10211
  };
10204
10212
  StartableService.prototype.unsubscribe = function () {
10205
10213
  var _a;
@@ -10207,11 +10215,7 @@
10207
10215
  this._subscription = null;
10208
10216
  };
10209
10217
  StartableService.prototype.ngOnStop = function () {
10210
- return __awaiter(this, void 0, void 0, function () {
10211
- return __generator(this, function (_b) {
10212
- return [2 /*return*/];
10213
- });
10214
- });
10218
+ // Can be overwritten by subclasses
10215
10219
  };
10216
10220
  return StartableService;
10217
10221
  }());
@@ -12735,6 +12739,166 @@
12735
12739
  Toasts.counter = 0;
12736
12740
  Toasts.stackSize = 0;
12737
12741
 
12742
+ /**
12743
+ * Same as StartableService, bu with a dataSubject instead of a simple 'data' property
12744
+ */
12745
+ var StartableObservableService = /** @class */ (function () {
12746
+ function StartableObservableService(prerequisiteService) {
12747
+ this.dataSubject = new rxjs.BehaviorSubject(null);
12748
+ this.startSubject = new rxjs.Subject();
12749
+ this.stopSubject = new rxjs.Subject();
12750
+ this._debug = false;
12751
+ this._startByReadyFunction = true; // should start when calling ready() ?
12752
+ this._started = false;
12753
+ this._startPromise = null;
12754
+ this._startPrerequisite = null;
12755
+ this._subscription = null;
12756
+ this._startPrerequisite = prerequisiteService
12757
+ ? function () { return prerequisiteService.ready(); }
12758
+ : function () { return Promise.resolve(); };
12759
+ }
12760
+ StartableObservableService.prototype.start = function (opts) {
12761
+ var _this = this;
12762
+ if (this._startPromise)
12763
+ return this._startPromise;
12764
+ if (this._started)
12765
+ return Promise.resolve(this.dataSubject.value);
12766
+ this._startPromise = this._startPrerequisite()
12767
+ .then(function () { return _this.ngOnStart(opts); })
12768
+ .then(function (data) {
12769
+ _this._started = true;
12770
+ _this._startPromise = undefined;
12771
+ // Should be done AFTER 'this._started = true', because of the 'filter' operator, inside ready() function
12772
+ _this.dataSubject.next(data);
12773
+ _this.startSubject.next(data);
12774
+ return data;
12775
+ })
12776
+ .catch(function (err) {
12777
+ console.error('Failed to start a service: ' + (err && err.message || err), err);
12778
+ _this._started = false;
12779
+ _this._startPromise = null;
12780
+ return null;
12781
+ });
12782
+ return this._startPromise;
12783
+ };
12784
+ StartableObservableService.prototype.ready = function () {
12785
+ var _this = this;
12786
+ if (this._started)
12787
+ return Promise.resolve(this.dataSubject.value);
12788
+ if (this._startPromise)
12789
+ return this._startPromise;
12790
+ if (this._startByReadyFunction)
12791
+ return this.start();
12792
+ return this.dataSubject
12793
+ .pipe(operators.takeUntil(this.stopSubject),
12794
+ // Wait start() to be called, to exclude the initial 'null' value
12795
+ operators.filter(function (_) { return _this._started; }))
12796
+ .toPromise();
12797
+ };
12798
+ StartableObservableService.prototype.stop = function () {
12799
+ return __awaiter(this, void 0, void 0, function () {
12800
+ var err_1;
12801
+ return __generator(this, function (_b) {
12802
+ switch (_b.label) {
12803
+ case 0:
12804
+ _b.trys.push([0, 2, 3, 4]);
12805
+ this.unsubscribe();
12806
+ return [4 /*yield*/, this.ngOnStop()];
12807
+ case 1:
12808
+ _b.sent();
12809
+ return [3 /*break*/, 4];
12810
+ case 2:
12811
+ err_1 = _b.sent();
12812
+ console.error('Failed to stop a service: ' + (err_1 && err_1.message || err_1), err_1);
12813
+ return [3 /*break*/, 4];
12814
+ case 3:
12815
+ this._started = false;
12816
+ this._startPromise = undefined;
12817
+ this.stopSubject.next(); // Stop all running observables
12818
+ this.dataSubject.next(null); // Reset data
12819
+ return [7 /*endfinally*/];
12820
+ case 4: return [2 /*return*/];
12821
+ }
12822
+ });
12823
+ });
12824
+ };
12825
+ StartableObservableService.prototype.restart = function (opts) {
12826
+ return __awaiter(this, void 0, void 0, function () {
12827
+ return __generator(this, function (_b) {
12828
+ switch (_b.label) {
12829
+ case 0:
12830
+ if (!this._startPromise) return [3 /*break*/, 2];
12831
+ return [4 /*yield*/, this._startPromise];
12832
+ case 1:
12833
+ _b.sent(); // Wait end of previous loading
12834
+ _b.label = 2;
12835
+ case 2:
12836
+ if (!this._started) return [3 /*break*/, 4];
12837
+ return [4 /*yield*/, this.stop()];
12838
+ case 3:
12839
+ _b.sent(); // Then stop if started
12840
+ _b.label = 4;
12841
+ case 4: // Then stop if started
12842
+ return [2 /*return*/, this.start(opts)]; // Then start again
12843
+ }
12844
+ });
12845
+ });
12846
+ };
12847
+ Object.defineProperty(StartableObservableService.prototype, "started", {
12848
+ get: function () {
12849
+ return this._started;
12850
+ },
12851
+ enumerable: false,
12852
+ configurable: true
12853
+ });
12854
+ Object.defineProperty(StartableObservableService.prototype, "starting", {
12855
+ get: function () {
12856
+ return !!this._startPromise;
12857
+ },
12858
+ enumerable: false,
12859
+ configurable: true
12860
+ });
12861
+ Object.defineProperty(StartableObservableService.prototype, "stopped", {
12862
+ get: function () {
12863
+ return !this._started && !this._startPromise;
12864
+ },
12865
+ enumerable: false,
12866
+ configurable: true
12867
+ });
12868
+ Object.defineProperty(StartableObservableService.prototype, "data", {
12869
+ get: function () {
12870
+ return this.dataSubject.value;
12871
+ },
12872
+ set: function (value) {
12873
+ if (this.dataSubject.value !== value) {
12874
+ this.dataSubject.next(value);
12875
+ }
12876
+ },
12877
+ enumerable: false,
12878
+ configurable: true
12879
+ });
12880
+ StartableObservableService.prototype.registerSubscription = function (sub) {
12881
+ this._subscription = this._subscription || new rxjs.Subscription();
12882
+ return this._subscription.add(sub);
12883
+ };
12884
+ StartableObservableService.prototype.unregisterSubscription = function (sub) {
12885
+ var _a;
12886
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.remove(sub);
12887
+ };
12888
+ StartableObservableService.prototype.unsubscribe = function () {
12889
+ var _a;
12890
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
12891
+ this._subscription = null;
12892
+ };
12893
+ StartableObservableService.prototype.ngOnStop = function () {
12894
+ // Can be overwritten by subclasses
12895
+ };
12896
+ return StartableObservableService;
12897
+ }());
12898
+ StartableObservableService.ctorParameters = function () { return [
12899
+ { type: undefined, decorators: [{ type: i0.Optional }] }
12900
+ ]; };
12901
+
12738
12902
  function getConnectionType(type) {
12739
12903
  switch (type) {
12740
12904
  case ngx$4.Connection.NONE:
@@ -12780,7 +12944,7 @@
12780
12944
  _this.splashScreen = splashScreen;
12781
12945
  _this.translate = translate;
12782
12946
  _this.toastController = toastController;
12783
- _this.onPeerChanges = _this.startSubject.pipe(operators.map(function (peer) { return peer && peer.url; }), operators.filter(isNotNilOrBlank), operators.distinctUntilChanged());
12947
+ _this.onPeerChanges = _this.startSubject.pipe(operators.map(function (peer) { return peer === null || peer === void 0 ? void 0 : peer.url; }), operators.filter(isNotNilOrBlank), operators.distinctUntilChanged());
12784
12948
  _this.onNetworkStatusChanges = new rxjs.BehaviorSubject(null);
12785
12949
  _this.onResetNetworkCache = new i0.EventEmitter(true);
12786
12950
  _this._listeners = {};
@@ -12793,8 +12957,7 @@
12793
12957
  _this._timerRefreshPeriod = NetworkRefreshTimerPeriod.DESKTOP;
12794
12958
  _this._timerRefreshCondition = function () { return true; }; // Always check
12795
12959
  }
12796
- _this.resetData();
12797
- _this.startSubject.subscribe(function () { return _this.ngOnAfterStart(); });
12960
+ _this.startSubject.subscribe(function (peer) { return _this.ngOnAfterStart(peer); });
12798
12961
  // For DEV only
12799
12962
  _this._debug = !environment.production;
12800
12963
  return _this;
@@ -12825,11 +12988,11 @@
12825
12988
  });
12826
12989
  Object.defineProperty(NetworkService.prototype, "peer", {
12827
12990
  get: function () {
12828
- return this._data && this._data.clone();
12991
+ var _a;
12992
+ return (_a = this.dataSubject.value) === null || _a === void 0 ? void 0 : _a.clone();
12829
12993
  },
12830
12994
  set: function (peer) {
12831
- this._startingPeer = peer;
12832
- this.restart();
12995
+ this.restart(peer);
12833
12996
  },
12834
12997
  enumerable: false,
12835
12998
  configurable: true
@@ -12895,9 +13058,9 @@
12895
13058
  // Disable the offline mode
12896
13059
  this.setForceOffline(false);
12897
13060
  // Restart
12898
- this._startingPeer = peer;
12899
- return [4 /*yield*/, this.restart()];
13061
+ return [4 /*yield*/, this.restart(peer)];
12900
13062
  case 7:
13063
+ // Restart
12901
13064
  _c.sent();
12902
13065
  // Wait a promise, before recheck
12903
13066
  return [4 /*yield*/, this.emit('beforeTryOnlineFinish', this.online)];
@@ -13209,20 +13372,21 @@
13209
13372
  });
13210
13373
  };
13211
13374
  /* -- protected functions -- */
13212
- NetworkService.prototype.ngOnStart = function () {
13375
+ NetworkService.prototype.ngOnStart = function (peer) {
13213
13376
  return __awaiter(this, void 0, void 0, function () {
13214
- var peer, _b;
13377
+ var _b;
13215
13378
  return __generator(this, function (_c) {
13216
13379
  switch (_c.label) {
13217
13380
  case 0:
13218
13381
  console.info('[network] Starting network...');
13219
- _b = this._startingPeer;
13382
+ _b = peer;
13220
13383
  if (_b) return [3 /*break*/, 2];
13221
13384
  return [4 /*yield*/, this.restoreLocally()];
13222
13385
  case 1:
13223
13386
  _b = (_c.sent());
13224
13387
  _c.label = 2;
13225
13388
  case 2:
13389
+ // Restoring local settings
13226
13390
  peer = _b;
13227
13391
  // Make sure to hide the splashscreen, before open the modal
13228
13392
  if (!peer && this.splashScreen)
@@ -13242,7 +13406,7 @@
13242
13406
  });
13243
13407
  });
13244
13408
  };
13245
- NetworkService.prototype.ngOnAfterStart = function () {
13409
+ NetworkService.prototype.ngOnAfterStart = function (peer) {
13246
13410
  var _a;
13247
13411
  return __awaiter(this, void 0, void 0, function () {
13248
13412
  var _this = this;
@@ -13250,7 +13414,7 @@
13250
13414
  switch (_b.label) {
13251
13415
  case 0:
13252
13416
  // Wait settings starts, then save peer in settings
13253
- return [4 /*yield*/, this.settings.apply({ peerUrl: this._data.url })];
13417
+ return [4 /*yield*/, this.settings.apply({ peerUrl: peer.url })];
13254
13418
  case 1:
13255
13419
  // Wait settings starts, then save peer in settings
13256
13420
  _b.sent();
@@ -13268,16 +13432,10 @@
13268
13432
  });
13269
13433
  };
13270
13434
  NetworkService.prototype.ngOnStop = function () {
13271
- return __awaiter(this, void 0, void 0, function () {
13272
- return __generator(this, function (_b) {
13273
- this.resetData();
13274
- // Stop timer if cannot refresh anymore
13275
- if (this._timerRefreshCondition() === false) {
13276
- this.stopRefreshTimer();
13277
- }
13278
- return [2 /*return*/];
13279
- });
13280
- });
13435
+ // Stop timer, if cannot refresh anymore
13436
+ if (this._timerRefreshCondition() === false) {
13437
+ this.stopRefreshTimer();
13438
+ }
13281
13439
  };
13282
13440
  /**
13283
13441
  * Try to restore peer from the local storage
@@ -13425,9 +13583,6 @@
13425
13583
  }
13426
13584
  }
13427
13585
  };
13428
- NetworkService.prototype.resetData = function () {
13429
- this._data = null;
13430
- };
13431
13586
  /**
13432
13587
  * Get default peers, from environment
13433
13588
  */
@@ -13474,7 +13629,7 @@
13474
13629
  });
13475
13630
  };
13476
13631
  return NetworkService;
13477
- }(StartableService));
13632
+ }(StartableObservableService));
13478
13633
  NetworkService.ɵprov = i0.ɵɵdefineInjectable({ factory: function NetworkService_Factory() { return new NetworkService(i0.ɵɵinject(i1$4.DOCUMENT), i0.ɵɵinject(i1$5.Platform), i0.ɵɵinject(i1$5.ModalController), i0.ɵɵinject(CryptoService), i0.ɵɵinject(i3$2.Storage), i0.ɵɵinject(LocalSettingsService), i0.ɵɵinject(i6.CacheService), i0.ɵɵinject(i2$1.HttpClient), i0.ɵɵinject(ENVIRONMENT), i0.ɵɵinject(i9.Network, 8), i0.ɵɵinject(i10.SplashScreen, 8), i0.ɵɵinject(i1$2.TranslateService, 8), i0.ɵɵinject(i1$5.ToastController, 8)); }, token: NetworkService, providedIn: "root" });
13479
13634
  NetworkService.decorators = [
13480
13635
  { type: i0.Injectable, args: [{ providedIn: 'root' },] }
@@ -20793,7 +20948,7 @@
20793
20948
  _this.dataType = dataType;
20794
20949
  _this.filterType = filterType;
20795
20950
  _this.debug = false;
20796
- _this.dataSubject = new rxjs.BehaviorSubject(null);
20951
+ _this._hiddenData = null;
20797
20952
  _this.dirtySubject = new rxjs.BehaviorSubject(false);
20798
20953
  _this.savingSubject = new rxjs.BehaviorSubject(false);
20799
20954
  options = Object.assign({ onSort: _this.sort }, options);
@@ -20808,6 +20963,7 @@
20808
20963
  }
20809
20964
  return undefined;
20810
20965
  });
20966
+ _this._startByReadyFunction = false; // Need setValue() to be called, to start the service
20811
20967
  _this._sortByReplacement = Object.assign({
20812
20968
  // Detect rankOrder on the entity class
20813
20969
  id: (Object.getOwnPropertyNames(new dataType()).findIndex(function (key) { return key === 'rankOrder'; }) !== -1) ? 'rankOrder' : undefined
@@ -20838,26 +20994,30 @@
20838
20994
  enumerable: false,
20839
20995
  configurable: true
20840
20996
  });
20841
- InMemoryEntitiesService.prototype.ngOnStart = function () {
20997
+ InMemoryEntitiesService.prototype.ngOnStart = function (data) {
20842
20998
  return __awaiter(this, void 0, void 0, function () {
20843
- return __generator(this, function (_b) {
20999
+ return __generator(this, function (_c) {
21000
+ if (!data)
21001
+ throw new Error('Missing required data, to start this service');
20844
21002
  if (this.debug)
20845
21003
  console.debug('[memory-data-service] Starting...');
20846
- return [2 /*return*/, firstNotNil(this.dataSubject, { stop: this.stopSubject })
20847
- .toPromise()];
21004
+ this._hiddenData = [];
21005
+ this.markAsSaved();
21006
+ this.markAsPristine();
21007
+ return [2 /*return*/, data];
20848
21008
  });
20849
21009
  });
20850
21010
  };
20851
21011
  InMemoryEntitiesService.prototype.ngOnStop = function () {
20852
21012
  return __awaiter(this, void 0, void 0, function () {
20853
- return __generator(this, function (_b) {
21013
+ return __generator(this, function (_c) {
20854
21014
  if (this.debug)
20855
21015
  console.debug('[memory-data-service] Stopping...');
20856
21016
  this.dataSubject.complete();
20857
21017
  this.dataSubject.unsubscribe();
20858
- this.dataSubject = new rxjs.BehaviorSubject(null);
20859
- this.savingSubject.next(false);
20860
- this.dirtySubject.next(false);
21018
+ this._hiddenData = null;
21019
+ this.markAsSaved();
21020
+ this.markAsPristine();
20861
21021
  return [2 /*return*/];
20862
21022
  });
20863
21023
  });
@@ -20867,19 +21027,24 @@
20867
21027
  };
20868
21028
  InMemoryEntitiesService.prototype.setValue = function (data) {
20869
21029
  if (this.dataSubject.value !== data) {
20870
- if (!this.started)
20871
- this.start();
20872
- this._hiddenData = [];
20873
- this.dataSubject.next(data);
21030
+ // If service already started, then update data
21031
+ if (this.started) {
21032
+ this._hiddenData = [];
21033
+ this.dataSubject.next(data);
21034
+ this.markAsPristine();
21035
+ }
21036
+ // if service not started yet, then start it, using given data
21037
+ else {
21038
+ this.start(data);
21039
+ }
20874
21040
  }
20875
- this.markAsPristine();
20876
21041
  };
20877
21042
  InMemoryEntitiesService.prototype.loadAll = function (offset, size, sortBy, sortDirection, filter, opts) {
20878
21043
  return __awaiter(this, void 0, void 0, function () {
20879
- var originalData, excludedDataByFilter, excludedDataByPagination, data, total, res, nextOffset_1;
21044
+ var originalData, err_1, excludedDataByFilter, excludedDataByPagination, data, total, res, nextOffset_1;
20880
21045
  var _this = this;
20881
- return __generator(this, function (_b) {
20882
- switch (_b.label) {
21046
+ return __generator(this, function (_c) {
21047
+ switch (_c.label) {
20883
21048
  case 0:
20884
21049
  offset = offset >= 0 ? offset : 0;
20885
21050
  size = size >= 0 ? size : -1;
@@ -20887,40 +21052,44 @@
20887
21052
  if (isNil(originalData)) {
20888
21053
  console.warn('[memory-data-service] Cannot load all: no value set. Will return empty result');
20889
21054
  }
20890
- _b.label = 1;
21055
+ _c.label = 1;
20891
21056
  case 1:
20892
- _b.trys.push([1, , 6, 7]);
20893
- if (!!this.started) return [3 /*break*/, 3];
21057
+ _c.trys.push([1, 4, , 5]);
21058
+ // Wait service is ready
20894
21059
  return [4 /*yield*/, this.ready()];
20895
21060
  case 2:
20896
- _b.sent();
20897
- _b.label = 3;
21061
+ // Wait service is ready
21062
+ _c.sent();
21063
+ // Wait while busy (e.g. when saving, or deleting)
21064
+ return [4 /*yield*/, this.waitIdle({ stopError: false /*avoid error when stopped*/ })];
20898
21065
  case 3:
20899
- if (!this.saving) return [3 /*break*/, 5];
20900
- return [4 /*yield*/, this.waitWhileSaving()];
21066
+ // Wait while busy (e.g. when saving, or deleting)
21067
+ _c.sent();
21068
+ return [3 /*break*/, 5];
20901
21069
  case 4:
20902
- _b.sent();
20903
- _b.label = 5;
20904
- case 5: return [3 /*break*/, 7];
20905
- case 6:
20906
- if (!this.started)
20907
- return [2 /*return*/, undefined]; // Stopped (e.g. after saved)
20908
- return [7 /*endfinally*/];
20909
- case 7:
21070
+ err_1 = _c.sent();
21071
+ // Should be a stop error: log and continue
21072
+ if (!this.stopped)
21073
+ console.error('Unexpected error, while waiting :', err_1);
21074
+ return [3 /*break*/, 5];
21075
+ case 5:
21076
+ // Make sure service is not stopped
21077
+ if (this.stopped)
21078
+ return [2 /*return*/, undefined];
20910
21079
  excludedDataByFilter = [];
20911
- _b.label = 8;
20912
- case 8:
20913
- _b.trys.push([8, , 11, 12]);
21080
+ _c.label = 6;
21081
+ case 6:
21082
+ _c.trys.push([6, , 9, 10]);
20914
21083
  if (isEmptyArray(originalData)) {
20915
21084
  return [2 /*return*/, { data: [], total: 0 }];
20916
21085
  }
20917
21086
  data = this._sortFn(originalData, sortBy, sortDirection);
20918
- if (!this._onLoad) return [3 /*break*/, 10];
21087
+ if (!this._onLoad) return [3 /*break*/, 8];
20919
21088
  return [4 /*yield*/, this._onLoad(data)];
20920
- case 9:
20921
- data = _b.sent();
20922
- _b.label = 10;
20923
- case 10:
21089
+ case 7:
21090
+ data = _c.sent();
21091
+ _c.label = 8;
21092
+ case 8:
20924
21093
  // Apply filter (will update hiddenData)
20925
21094
  data = this.filter(data, filter, excludedDataByFilter);
20926
21095
  total = data.length;
@@ -20968,22 +21137,22 @@
20968
21137
  if (nextOffset_1 < total) {
20969
21138
  res.fetchMore = function () { return _this.loadAll(nextOffset_1, size, sortBy, sortDirection, filter, opts)
20970
21139
  .then(function (res) {
20971
- var _a;
21140
+ var _a, _b;
20972
21141
  // Update hidden data (remove new fetched item)
20973
21142
  if ((_a = res.data) === null || _a === void 0 ? void 0 : _a.length) {
20974
- _this._hiddenData = _this._hiddenData.filter(function (item) { return !res.data.includes(item); });
21143
+ _this._hiddenData = (_b = _this._hiddenData) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return !res.data.includes(item); });
20975
21144
  }
20976
21145
  return res;
20977
21146
  }); };
20978
21147
  }
20979
21148
  return [2 /*return*/, res];
20980
- case 11:
21149
+ case 9:
20981
21150
  // Remember hidden data
20982
21151
  if (offset === 0) {
20983
21152
  this._hiddenData = !excludedDataByPagination ? excludedDataByFilter : excludedDataByFilter.concat.apply(excludedDataByFilter, __spread(excludedDataByPagination));
20984
21153
  }
20985
21154
  return [7 /*endfinally*/];
20986
- case 12: return [2 /*return*/];
21155
+ case 10: return [2 /*return*/];
20987
21156
  }
20988
21157
  });
20989
21158
  });
@@ -21000,16 +21169,16 @@
21000
21169
  };
21001
21170
  InMemoryEntitiesService.prototype.saveAll = function (data, options) {
21002
21171
  return __awaiter(this, void 0, void 0, function () {
21003
- var res, _b;
21004
- return __generator(this, function (_c) {
21005
- switch (_c.label) {
21172
+ var res, _c;
21173
+ return __generator(this, function (_d) {
21174
+ switch (_d.label) {
21006
21175
  case 0:
21007
21176
  if (!this.dataSubject.value)
21008
21177
  throw new Error('[memory-service] Could not save, because value not set');
21009
21178
  this.markAsSaving();
21010
- _c.label = 1;
21179
+ _d.label = 1;
21011
21180
  case 1:
21012
- _c.trys.push([1, , 6, 7]);
21181
+ _d.trys.push([1, , 6, 7]);
21013
21182
  // Restore hidden data
21014
21183
  if (isNotEmptyArray(this._hiddenData))
21015
21184
  data = data.concat.apply(data, __spread(this._hiddenData));
@@ -21018,14 +21187,14 @@
21018
21187
  if (!((res instanceof Promise))) return [3 /*break*/, 3];
21019
21188
  return [4 /*yield*/, res];
21020
21189
  case 2:
21021
- _b = _c.sent();
21190
+ _c = _d.sent();
21022
21191
  return [3 /*break*/, 4];
21023
21192
  case 3:
21024
- _b = res;
21025
- _c.label = 4;
21193
+ _c = res;
21194
+ _d.label = 4;
21026
21195
  case 4:
21027
- data = _b;
21028
- _c.label = 5;
21196
+ data = _c;
21197
+ _d.label = 5;
21029
21198
  case 5:
21030
21199
  this.dataSubject.next(data);
21031
21200
  this.markAsDirty();
@@ -21042,7 +21211,7 @@
21042
21211
  return __awaiter(this, void 0, void 0, function () {
21043
21212
  var data, updatedData, deleteCount;
21044
21213
  var _this = this;
21045
- return __generator(this, function (_b) {
21214
+ return __generator(this, function (_c) {
21046
21215
  data = this.dataSubject.value;
21047
21216
  if (!data)
21048
21217
  throw new Error('[memory-service] Could not delete, because value not set');
@@ -21103,6 +21272,18 @@
21103
21272
  enumerable: false,
21104
21273
  configurable: true
21105
21274
  });
21275
+ InMemoryEntitiesService.prototype.waitIdle = function (opts) {
21276
+ return __awaiter(this, void 0, void 0, function () {
21277
+ return __generator(this, function (_c) {
21278
+ switch (_c.label) {
21279
+ case 0: return [4 /*yield*/, this.waitWhileSaving(opts)];
21280
+ case 1:
21281
+ _c.sent();
21282
+ return [2 /*return*/];
21283
+ }
21284
+ });
21285
+ });
21286
+ };
21106
21287
  /* -- protected methods -- */
21107
21288
  InMemoryEntitiesService.prototype.filter = function (data, _filter, hiddenData) {
21108
21289
  // if filter is DataFilter instance, use its test function
@@ -21128,9 +21309,14 @@
21128
21309
  }));
21129
21310
  };
21130
21311
  InMemoryEntitiesService.prototype.waitWhileSaving = function (opts) {
21131
- if (!this.saving)
21132
- return;
21133
- return firstFalsePromise(this.savingSubject, Object.assign({ stop: (opts === null || opts === void 0 ? void 0 : opts.stop) || rxjs.merge(this.stopSubject, this.dataSubject) }, opts));
21312
+ return __awaiter(this, void 0, void 0, function () {
21313
+ return __generator(this, function (_c) {
21314
+ if (this.saving) {
21315
+ return [2 /*return*/, firstFalsePromise(this.savingSubject, Object.assign({ stop: (opts === null || opts === void 0 ? void 0 : opts.stop) || rxjs.merge(this.stopSubject, this.dataSubject), stopError: false }, opts))];
21316
+ }
21317
+ return [2 /*return*/];
21318
+ });
21319
+ });
21134
21320
  };
21135
21321
  InMemoryEntitiesService.prototype.markAsSaving = function () {
21136
21322
  if (!this.savingSubject.value) {
@@ -21153,7 +21339,7 @@
21153
21339
  }
21154
21340
  };
21155
21341
  return InMemoryEntitiesService;
21156
- }(StartableService));
21342
+ }(StartableObservableService));
21157
21343
  InMemoryEntitiesService.decorators = [
21158
21344
  { type: i0.Directive }
21159
21345
  ];
@@ -25865,8 +26051,8 @@
25865
26051
  _this._debug = false;
25866
26052
  _this._creating = false;
25867
26053
  _this._saving = false;
25868
- _this._stopWatching$ = new rxjs.Subject();
25869
26054
  _this._fetchMoreFn = null;
26055
+ _this._stopWatchSubject = new rxjs.Subject();
25870
26056
  _this.loadingSubject = new rxjs.BehaviorSubject(undefined);
25871
26057
  _this._entityName = removeEnd((new dataType()).__typename || 'UnknownVO', 'VO');
25872
26058
  _this._debug = (options === null || options === void 0 ? void 0 : options.suppressErrors) === false && !environment.production;
@@ -25924,25 +26110,38 @@
25924
26110
  enumerable: false,
25925
26111
  configurable: true
25926
26112
  });
26113
+ /**
26114
+ * @deprecated use disconnect
26115
+ */
25927
26116
  EntitiesTableDataSource.prototype.ngOnDestroy = function () {
25928
- this._stopWatching$.next();
25929
- this._stopWatching$.complete();
25930
- this._stopWatching$.unsubscribe();
25931
- this.loadingSubject.complete();
25932
- this.loadingSubject.unsubscribe();
26117
+ this.close();
26118
+ };
26119
+ /**
26120
+ * @deprecated use disconnect
26121
+ */
26122
+ EntitiesTableDataSource.prototype.close = function () {
26123
+ if (!this._stopWatchSubject.closed) {
26124
+ if (this._debug)
26125
+ console.debug('[entities-table-datasource] Closing...');
26126
+ this._stopWatchSubject.next();
26127
+ this._stopWatchSubject.complete();
26128
+ this._stopWatchSubject.unsubscribe();
26129
+ this.loadingSubject.complete();
26130
+ this.loadingSubject.unsubscribe();
26131
+ }
25933
26132
  };
25934
26133
  EntitiesTableDataSource.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter) {
25935
26134
  var _this = this;
25936
- this._stopWatching$.next();
26135
+ this._stopWatchSubject.next();
25937
26136
  this._fetchMoreFn = null;
25938
26137
  this.markAsLoading();
25939
26138
  return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
25940
26139
  .pipe(operators.catchError(function (err) { return _this.handleError(err, 'ERROR.LOAD_DATA_ERROR'); }), operators.map(function (res) {
25941
26140
  if (_this._saving) {
25942
- console.info("[table-datasource] Received " + _this._entityName + " data (from service), but still saving: skip");
26141
+ console.info("[entities-table-datasource] Received " + _this._entityName + " data (from service), but still saving: skip");
25943
26142
  }
25944
26143
  else if (_this.hasSomeEditingRow()) {
25945
- console.warn("[table-datasource] Received " + _this._entityName + " data, while some row still editing: skip; Please check save() implementation in the table!");
26144
+ console.warn("[entities-table-datasource] Received " + _this._entityName + " data, while some row still editing: skip; Please check save() implementation in the table!");
25946
26145
  }
25947
26146
  else {
25948
26147
  _this.updateDatasource((res.data || []));
@@ -25951,7 +26150,7 @@
25951
26150
  return res;
25952
26151
  }),
25953
26152
  // Stop this pipe next time we call watchAll()
25954
- operators.takeUntil(this._stopWatching$)
26153
+ operators.takeUntil(this._stopWatchSubject)
25955
26154
  // ⚠ Notice: Don't put any operator after takeUntil to avoid potential subscription leaks
25956
26155
  );
25957
26156
  };
@@ -25960,11 +26159,11 @@
25960
26159
  // Avoid to update dataSourceSubject, when not need
25961
26160
  if ((_a = this.datasourceSubject.observers) === null || _a === void 0 ? void 0 : _a.length) {
25962
26161
  if (!this.config.suppressErrors)
25963
- console.warn('[table-datasource] Update datasource subject. Please prefer using \'rowsSubject\' instead of \'datasourceSubject\'');
26162
+ console.warn('[entities-table-datasource] Update datasource subject. Please prefer using \'rowsSubject\' instead of \'datasourceSubject\'');
25964
26163
  _super_1.prototype.updateDatasourceFromRows.call(this, rows);
25965
26164
  }
25966
26165
  else {
25967
- console.debug('[table-datasource] Skipping datasourceSubject update (not used yet).');
26166
+ console.debug('[entities-table-datasource] Skipping datasourceSubject update (not used yet).');
25968
26167
  }
25969
26168
  };
25970
26169
  EntitiesTableDataSource.prototype.save = function () {
@@ -25975,12 +26174,12 @@
25975
26174
  switch (_b.label) {
25976
26175
  case 0:
25977
26176
  if (this.config.readOnly) {
25978
- console.error('[table-datasource] Enable to save, because config.readOnly=true');
26177
+ console.error('[entities-table-datasource] Enable to save, because config.readOnly=true');
25979
26178
  return [2 /*return*/, false];
25980
26179
  }
25981
26180
  // Saving twice (should never occur)
25982
26181
  if (this._saving) {
25983
- console.warn("[table-datasource] Trying to save " + this._entityName + " rows twice. Skip");
26182
+ console.warn("[entities-table-datasource] Trying to save " + this._entityName + " rows twice. Skip");
25984
26183
  return [2 /*return*/, false];
25985
26184
  }
25986
26185
  this._saving = true;
@@ -25990,14 +26189,14 @@
25990
26189
  case 1:
25991
26190
  _b.trys.push([1, 3, 4, 5]);
25992
26191
  if (this._debug)
25993
- console.debug("[table-datasource] Saving " + this._entityName + " rows... {onlyDirtyRows: " + onlyDirtyRows + "}");
26192
+ console.debug("[entities-table-datasource] Saving " + this._entityName + " rows... {onlyDirtyRows: " + onlyDirtyRows + "}");
25994
26193
  rows = this.getRows();
25995
26194
  invalidRows = rows.filter(function (row) { return row.editing && !row.confirmEditCreate(); });
25996
26195
  // Cannot finish some rows: error
25997
26196
  if (invalidRows.length) {
25998
26197
  // log errors
25999
26198
  if (this._debug)
26000
- invalidRows.forEach(function (row) { return AppTableUtils.logRowErrors(row, "[table-datasource] " + _this._entityName + " row #" + row.id); });
26199
+ invalidRows.forEach(function (row) { return AppTableUtils.logRowErrors(row, "[entities-table-datasource] " + _this._entityName + " row #" + row.id); });
26001
26200
  // Stop with an error
26002
26201
  throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
26003
26202
  }
@@ -26024,23 +26223,23 @@
26024
26223
  // If no data to save: exit
26025
26224
  if (onlyDirtyRows && !dataToSave_1.length) {
26026
26225
  if (this._debug)
26027
- console.debug("[table-datasource] No " + this._entityName + " data to save. Skip");
26226
+ console.debug("[entities-table-datasource] No " + this._entityName + " data to save. Skip");
26028
26227
  return [2 /*return*/, false];
26029
26228
  }
26030
26229
  if (this._debug)
26031
- console.debug("[table-datasource] Asking service to save this " + this._entityName + " data:", dataToSave_1);
26230
+ console.debug("[entities-table-datasource] Asking service to save this " + this._entityName + " data:", dataToSave_1);
26032
26231
  return [4 /*yield*/, this.dataService.saveAll(dataToSave_1, this.serviceOptions)];
26033
26232
  case 2:
26034
26233
  _b.sent();
26035
26234
  if (this._debug)
26036
- console.debug("[table-datasource] Saving " + this._entityName + " data [OK]");
26235
+ console.debug("[entities-table-datasource] Saving " + this._entityName + " data [OK]");
26037
26236
  // LP 23/03/2021: update datasource is necessary but can be changed to a refetch() on QueryRef (must be created and registered in GraphqlService.watchQuery)
26038
26237
  this.updateDatasource(data, { emitEvent: false });
26039
26238
  return [2 /*return*/, true];
26040
26239
  case 3:
26041
26240
  error_1 = _b.sent();
26042
26241
  if (this._debug)
26043
- console.error('[table-datasource] Error while saving: ' + error_1 && error_1.message || error_1);
26242
+ console.error('[entities-table-datasource] Error while saving: ' + error_1 && error_1.message || error_1);
26044
26243
  throw error_1;
26045
26244
  case 4:
26046
26245
  this._saving = false;
@@ -26053,7 +26252,7 @@
26053
26252
  };
26054
26253
  EntitiesTableDataSource.prototype.updateDatasource = function (data, opts) {
26055
26254
  if (this._debug)
26056
- console.debug("[table-datasource] Updating datasource with data:", data);
26255
+ console.debug("[entities-table-datasource] Updating datasource with data:", data);
26057
26256
  _super_1.prototype.updateDatasource.call(this, data, opts);
26058
26257
  if (!opts || opts.emitEvent !== false) {
26059
26258
  this.markAsLoaded();
@@ -26061,11 +26260,14 @@
26061
26260
  };
26062
26261
  EntitiesTableDataSource.prototype.connect = function (collectionViewer) {
26063
26262
  // DEBUG console.debug("[entities-datasource] connect");
26263
+ this.viewer = collectionViewer;
26064
26264
  return _super_1.prototype.connect.call(this, collectionViewer);
26065
26265
  };
26066
26266
  EntitiesTableDataSource.prototype.disconnect = function (collectionViewer) {
26267
+ if (this._debug)
26268
+ console.debug('[entities-table-datasource] Disconnecting...');
26067
26269
  _super_1.prototype.disconnect.call(this, collectionViewer);
26068
- this._stopWatching$.next();
26270
+ this.close();
26069
26271
  };
26070
26272
  EntitiesTableDataSource.prototype.waitIdle = function (debounceTimeMs) {
26071
26273
  return firstFalsePromise(this.loadingSubject
@@ -26077,7 +26279,7 @@
26077
26279
  if (!_super_1.prototype.confirmCreate.call(this, row))
26078
26280
  return false;
26079
26281
  if (row.editing && row.validator) {
26080
- console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
26282
+ console.warn('[entities-table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
26081
26283
  row.validator.disable({ onlySelf: true, emitEvent: false });
26082
26284
  }
26083
26285
  return true;
@@ -26086,7 +26288,7 @@
26086
26288
  if (!_super_1.prototype.confirmEdit.call(this, row))
26087
26289
  return false;
26088
26290
  if (row.editing && row.validator) {
26089
- console.warn('[table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
26291
+ console.warn('[entities-table-datasource] Row still has {editing: true} after confirmEdit()! Force editing to false');
26090
26292
  row.validator.disable({ onlySelf: true, emitEvent: false });
26091
26293
  }
26092
26294
  return true;
@@ -26095,19 +26297,19 @@
26095
26297
  if (!_super_1.prototype.startEdit.call(this, row))
26096
26298
  return false;
26097
26299
  if (!row.editing && row.validator) {
26098
- console.warn('[table-datasource] Row still has {editing: false} after startEdit()! Force editing');
26300
+ console.warn('[entities-table-datasource] Row still has {editing: false} after startEdit()! Force editing');
26099
26301
  row.validator.enable({ onlySelf: true, emitEvent: false });
26100
26302
  }
26101
26303
  };
26102
26304
  EntitiesTableDataSource.prototype.handleError = function (error, message) {
26103
26305
  var errorMsg = error && error.message || error;
26104
- console.error("[table-datasource] Service " + this._entityName + " sent error: " + errorMsg, error);
26306
+ console.error("[entities-table-datasource] Service " + this._entityName + " sent error: " + errorMsg, error);
26105
26307
  this.markAsLoaded();
26106
26308
  throw new Error(message || errorMsg);
26107
26309
  };
26108
26310
  EntitiesTableDataSource.prototype.handleServiceError = function (error) {
26109
26311
  var errorMsg = error && error.message || error;
26110
- console.error("[table-datasource] Service " + this._entityName + " sent error: " + errorMsg, error);
26312
+ console.error("[entities-table-datasource] Service " + this._entityName + " sent error: " + errorMsg, error);
26111
26313
  this.markAsLoaded();
26112
26314
  throw error;
26113
26315
  };
@@ -26119,7 +26321,7 @@
26119
26321
  }
26120
26322
  var row = this.getRow(id);
26121
26323
  if (!row) {
26122
- console.error("[table-datasource] Row to delete with id=" + id + " not found");
26324
+ console.error("[entities-table-datasource] Row to delete with id=" + id + " not found");
26123
26325
  return;
26124
26326
  }
26125
26327
  this.markAsLoading();
@@ -26157,7 +26359,7 @@
26157
26359
  _b.sent();
26158
26360
  rowNotDeleted = this.getRows().filter(function (row) { return rows.includes(row); });
26159
26361
  if (isNotEmptyArray(rowNotDeleted)) {
26160
- console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows! Please check that data service update the cache, after deletion");
26362
+ console.warn("[entities-table-datasource] Force deletion of " + rowNotDeleted.length + " rows! Please check that data service update the cache, after deletion");
26161
26363
  rowNotDeleted
26162
26364
  // Start at the end
26163
26365
  .sort(function (a, b) { return a.id > b.id ? -1 : 1; })
@@ -26746,7 +26948,6 @@
26746
26948
  };
26747
26949
  AppTable.prototype.ngOnDestroy = function () {
26748
26950
  var _this = this;
26749
- var _a;
26750
26951
  this._subscription.unsubscribe();
26751
26952
  // Unsubscribe column value changes
26752
26953
  Object.keys(this._cellValueChangesDefs).forEach(function (col) { return _this.stopCellValueChanges(col, true); });
@@ -26771,7 +26972,6 @@
26771
26972
  this.onError.unsubscribe();
26772
26973
  this.destroySubject.next();
26773
26974
  this.destroySubject.unsubscribe();
26774
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
26775
26975
  };
26776
26976
  AppTable.prototype.updateView = function (res, opts) {
26777
26977
  return __awaiter(this, void 0, void 0, function () {
@@ -26809,12 +27009,11 @@
26809
27009
  }
26810
27010
  };
26811
27011
  AppTable.prototype.resetDataSource = function () {
26812
- var _a;
26813
27012
  if (this._dataSourceLoadingSubscription) {
26814
27013
  this._dataSourceLoadingSubscription.unsubscribe();
26815
27014
  this._subscription.remove(this._dataSourceLoadingSubscription);
26816
27015
  }
26817
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
27016
+ //this._dataSource?.close();
26818
27017
  this._dataSource = null;
26819
27018
  };
26820
27019
  AppTable.prototype.addColumnDef = function (column) {
@@ -30441,7 +30640,7 @@
30441
30640
  };
30442
30641
 
30443
30642
  var moment$6 = momentImported__namespace;
30444
- var USER_EVENT_SERVICE = new i0.InjectionToken('UserEventService');
30643
+ var APP_USER_EVENT_SERVICE = new i0.InjectionToken('UserEventService');
30445
30644
  var AbstractUserEventService = /** @class */ (function (_super) {
30446
30645
  __extends(AbstractUserEventService, _super);
30447
30646
  function AbstractUserEventService(graphql, accountService, network, translate, options) {
@@ -31357,7 +31556,7 @@
31357
31556
  { type: i0.ChangeDetectorRef },
31358
31557
  { type: i1$5.PopoverController },
31359
31558
  { type: LocalSettingsService, decorators: [{ type: i0.Optional }] },
31360
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [USER_EVENT_SERVICE,] }] }
31559
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [APP_USER_EVENT_SERVICE,] }] }
31361
31560
  ]; };
31362
31561
  UserEventNotificationList.propDecorators = {
31363
31562
  debug: [{ type: i0.Input }],
@@ -31374,11 +31573,12 @@
31374
31573
  ionItems: [{ type: i0.ViewChildren, args: [i1$5.IonItem,] }]
31375
31574
  };
31376
31575
 
31377
- var AppUserEventNotificationIcon = /** @class */ (function () {
31378
- function AppUserEventNotificationIcon(userEventService, accountService, popoverController) {
31576
+ var UserEventNotificationIcon = /** @class */ (function () {
31577
+ function UserEventNotificationIcon(userEventService, accountService, popoverController, cd) {
31379
31578
  this.userEventService = userEventService;
31380
31579
  this.accountService = accountService;
31381
31580
  this.popoverController = popoverController;
31581
+ this.cd = cd;
31382
31582
  this.debug = false;
31383
31583
  this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
31384
31584
  this.disabled = false;
@@ -31387,18 +31587,25 @@
31387
31587
  this._readEvent = new i0.EventEmitter();
31388
31588
  this._readEvents = new i0.EventEmitter();
31389
31589
  }
31390
- Object.defineProperty(AppUserEventNotificationIcon.prototype, "countChanges", {
31590
+ Object.defineProperty(UserEventNotificationIcon.prototype, "countChanges", {
31391
31591
  get: function () {
31592
+ var _this = this;
31392
31593
  if (!this.userEventService)
31393
31594
  return rxjs.of();
31394
31595
  return this.userEventService
31395
31596
  .countSubject
31396
- .pipe(operators.map(function (value) { return value === 0 ? undefined : value; }));
31597
+ .pipe(operators.tap(function (value) {
31598
+ var visible = !_this.autoHide || value > 0;
31599
+ if (_this.visible !== visible) {
31600
+ _this.visible = visible;
31601
+ _this.cd.markForCheck();
31602
+ }
31603
+ }), operators.map(function (value) { return value === 0 ? undefined : value; }));
31397
31604
  },
31398
31605
  enumerable: false,
31399
31606
  configurable: true
31400
31607
  });
31401
- AppUserEventNotificationIcon.prototype.ngOnInit = function () {
31608
+ UserEventNotificationIcon.prototype.ngOnInit = function () {
31402
31609
  return __awaiter(this, void 0, void 0, function () {
31403
31610
  var _this = this;
31404
31611
  return __generator(this, function (_a) {
@@ -31407,8 +31614,10 @@
31407
31614
  if (isNil(this.userEventService)) {
31408
31615
  console.warn(this._logPrefix + "No service injected");
31409
31616
  this.disabled = true;
31617
+ this.visible = false;
31410
31618
  return [2 /*return*/];
31411
31619
  }
31620
+ this.visible = toBoolean(this.visible, !this.autoHide);
31412
31621
  // Wait service
31413
31622
  return [4 /*yield*/, this.userEventService.ready()];
31414
31623
  case 1:
@@ -31427,7 +31636,7 @@
31427
31636
  });
31428
31637
  });
31429
31638
  };
31430
- AppUserEventNotificationIcon.prototype.showList = function (event) {
31639
+ UserEventNotificationIcon.prototype.showList = function (event) {
31431
31640
  return __awaiter(this, void 0, void 0, function () {
31432
31641
  var popover;
31433
31642
  return __generator(this, function (_a) {
@@ -31460,30 +31669,32 @@
31460
31669
  });
31461
31670
  });
31462
31671
  };
31463
- AppUserEventNotificationIcon.prototype.ngOnDestroy = function () {
31672
+ UserEventNotificationIcon.prototype.ngOnDestroy = function () {
31464
31673
  if (this.debug) {
31465
31674
  console.debug(this._logPrefix + "Destroying");
31466
31675
  }
31467
31676
  };
31468
- return AppUserEventNotificationIcon;
31677
+ return UserEventNotificationIcon;
31469
31678
  }());
31470
- AppUserEventNotificationIcon.decorators = [
31679
+ UserEventNotificationIcon.decorators = [
31471
31680
  { type: i0.Component, args: [{
31472
31681
  selector: 'app-user-event-notification-icon',
31473
- template: "<button\n #button\n mat-icon-button\n [title]=\"titleI18n | translate\"\n [disabled]=\"disabled\"\n (click)=\"showList($event)\"\n>\n <mat-icon\n [matBadge]=\"countChanges | async\"\n matBadgeColor=\"accent\"\n matBadgeSize=\"small\"\n matBadgePosition=\"above after\"\n >notifications\n </mat-icon>\n</button>\n\n",
31682
+ template: "<button\n #button\n mat-icon-button\n [title]=\"titleI18n | translate\"\n [disabled]=\"disabled\"\n *ngIf=\"visible\"\n (click)=\"showList($event)\"\n>\n <mat-icon\n [matBadge]=\"countChanges | async\"\n matBadgeColor=\"accent\"\n matBadgeSize=\"small\"\n matBadgePosition=\"above after\"\n >notifications\n </mat-icon>\n</button>\n\n",
31474
31683
  changeDetection: i0.ChangeDetectionStrategy.OnPush
31475
31684
  },] }
31476
31685
  ];
31477
- AppUserEventNotificationIcon.ctorParameters = function () { return [
31478
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [USER_EVENT_SERVICE,] }] },
31686
+ UserEventNotificationIcon.ctorParameters = function () { return [
31687
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [APP_USER_EVENT_SERVICE,] }] },
31479
31688
  { type: AccountService },
31480
- { type: i1$5.PopoverController }
31689
+ { type: i1$5.PopoverController },
31690
+ { type: i0.ChangeDetectorRef }
31481
31691
  ]; };
31482
- AppUserEventNotificationIcon.propDecorators = {
31692
+ UserEventNotificationIcon.propDecorators = {
31483
31693
  debug: [{ type: i0.Input }],
31484
31694
  titleI18n: [{ type: i0.Input }],
31485
31695
  disabled: [{ type: i0.Input }],
31486
- filter: [{ type: i0.Input }]
31696
+ filter: [{ type: i0.Input }],
31697
+ autoHide: [{ type: i0.Input }]
31487
31698
  };
31488
31699
 
31489
31700
  var UserEventModule = /** @class */ (function () {
@@ -31500,11 +31711,11 @@
31500
31711
  ngxJdenticon.NgxJdenticonModule
31501
31712
  ],
31502
31713
  declarations: [
31503
- AppUserEventNotificationIcon,
31714
+ UserEventNotificationIcon,
31504
31715
  UserEventNotificationList
31505
31716
  ],
31506
31717
  exports: [
31507
- AppUserEventNotificationIcon
31718
+ UserEventNotificationIcon
31508
31719
  ]
31509
31720
  },] }
31510
31721
  ];
@@ -31792,8 +32003,10 @@
31792
32003
  EntityClass({ typename: 'JobProgressionVO' })
31793
32004
  ], exports.JobProgression);
31794
32005
 
31795
- var JobProgressionServiceToken = new i0.InjectionToken('JobProgressionService');
31796
- var jobProgressionSubscription = core.gql(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["subscription UpdateJobProgression($id: Int!, $interval: Int){\n data: updateJobProgression(id: $id, interval: $interval) {\n id\n name\n message\n current\n total\n }\n}"], ["subscription UpdateJobProgression($id: Int!, $interval: Int){\n data: updateJobProgression(id: $id, interval: $interval) {\n id\n name\n message\n current\n total\n }\n}"])));
32006
+ var APP_JOB_PROGRESSION_SERVICE = new i0.InjectionToken('JobProgressionService');
32007
+ var QUERIES = {
32008
+ listenChanges: core.gql(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["subscription UpdateJobProgression($id: Int!, $interval: Int){\n data: updateJobProgression(id: $id, interval: $interval) {\n id\n name\n message\n current\n total\n }\n }"], ["subscription UpdateJobProgression($id: Int!, $interval: Int){\n data: updateJobProgression(id: $id, interval: $interval) {\n id\n name\n message\n current\n total\n }\n }"])))
32009
+ };
31797
32010
  var JobProgressionService = /** @class */ (function (_super) {
31798
32011
  __extends(JobProgressionService, _super);
31799
32012
  function JobProgressionService(graphql, environment) {
@@ -31805,6 +32018,15 @@
31805
32018
  _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
31806
32019
  return _this;
31807
32020
  }
32021
+ JobProgressionService.prototype.watchAll = function (options) {
32022
+ return rxjs.of([]); // TODO
32023
+ };
32024
+ JobProgressionService.prototype.addJob = function (id, job) {
32025
+ throw new Error('no implemented');
32026
+ };
32027
+ JobProgressionService.prototype.removeJob = function (id) {
32028
+ throw new Error('no implemented');
32029
+ };
31808
32030
  JobProgressionService.prototype.listenChanges = function (id, options) {
31809
32031
  var _this = this;
31810
32032
  if (isNil(id))
@@ -31812,7 +32034,7 @@
31812
32034
  if (this._debug)
31813
32035
  console.debug(this._logPrefix + "[WS] Listening changes for job progression {" + id + "}...");
31814
32036
  return this.graphql.subscribe({
31815
- query: jobProgressionSubscription,
32037
+ query: QUERIES.listenChanges,
31816
32038
  fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
31817
32039
  variables: { id: id, interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
31818
32040
  error: { code: SocialErrorCodes.SUBSCRIBE_JOB_PROGRESSION_ERROR, message: 'SOCIAL.ERROR.SUBSCRIBE_JOB_PROGRESSION_ERROR' }
@@ -31855,8 +32077,8 @@
31855
32077
  jobProgressions: [{ type: i0.Input }]
31856
32078
  };
31857
32079
 
31858
- var JobProgressionComponent = /** @class */ (function () {
31859
- function JobProgressionComponent(jobProgressionService, popoverController, cd) {
32080
+ var JobProgressionIcon = /** @class */ (function () {
32081
+ function JobProgressionIcon(jobProgressionService, popoverController, cd) {
31860
32082
  this.jobProgressionService = jobProgressionService;
31861
32083
  this.popoverController = popoverController;
31862
32084
  this.cd = cd;
@@ -31872,19 +32094,24 @@
31872
32094
  this._subscriptionsById = {};
31873
32095
  this._logPrefix = '[job-progression] ';
31874
32096
  }
31875
- JobProgressionComponent.prototype.ngOnInit = function () {
32097
+ JobProgressionIcon.prototype.ngOnInit = function () {
32098
+ var _this = this;
31876
32099
  var _a, _b, _c, _d;
31877
32100
  if (isNil(this.jobProgressionService)) {
31878
32101
  console.warn(this._logPrefix + "No service injected");
31879
32102
  }
31880
32103
  // parse options
31881
- this.autoHide = toBoolean((_a = this.options) === null || _a === void 0 ? void 0 : _a.autoHide, false);
32104
+ this.autoHide = toBoolean(this.autoHide, ((_a = this.options) === null || _a === void 0 ? void 0 : _a.autoHide) || false);
31882
32105
  this.visible = !this.autoHide;
31883
32106
  this.autoHideDelay = toNumber((_b = this.options) === null || _b === void 0 ? void 0 : _b.autoHideDelay, 1000);
31884
32107
  this.autoRemove = toBoolean((_c = this.options) === null || _c === void 0 ? void 0 : _c.autoRemove, true);
31885
32108
  this.autoRemoveDelay = toNumber((_d = this.options) === null || _d === void 0 ? void 0 : _d.autoRemoveDelay, 1000);
32109
+ this._subscriptions.add(this.jobProgressionService.watchAll()
32110
+ .subscribe(function (items) {
32111
+ (items || []).forEach(function (item) { return _this.addJob(item.id, item); });
32112
+ }));
31886
32113
  };
31887
- JobProgressionComponent.prototype.addJob = function (id) {
32114
+ JobProgressionIcon.prototype.addJob = function (id, job) {
31888
32115
  var _this = this;
31889
32116
  if (isNil(this.jobProgressionService)) {
31890
32117
  console.warn(this._logPrefix + "No service injected. Can't add a job");
@@ -31898,8 +32125,11 @@
31898
32125
  console.debug(this._logPrefix + "Add job id=" + id);
31899
32126
  }
31900
32127
  // Adding empty job progression
31901
- var progression = new exports.JobProgression(id);
31902
- this.jobProgressions.push(progression);
32128
+ var progression = this.getProgression(id);
32129
+ if (!progression) {
32130
+ progression = job || new exports.JobProgression(id);
32131
+ this.jobProgressions.push(progression);
32132
+ }
31903
32133
  this.disabled = false;
31904
32134
  var sub = this.jobProgressionService.listenChanges(id)
31905
32135
  .pipe(operators.filter(function (progression) {
@@ -31962,7 +32192,7 @@
31962
32192
  this._subscriptionsById[id] = sub;
31963
32193
  this._subscriptions.add(sub);
31964
32194
  };
31965
- JobProgressionComponent.prototype.removeJob = function (id) {
32195
+ JobProgressionIcon.prototype.removeJob = function (id) {
31966
32196
  if (this.debug) {
31967
32197
  console.debug(this._logPrefix + "Remove job id=" + id);
31968
32198
  }
@@ -31977,10 +32207,10 @@
31977
32207
  }
31978
32208
  this.updateValue();
31979
32209
  };
31980
- JobProgressionComponent.prototype.getProgression = function (id) {
32210
+ JobProgressionIcon.prototype.getProgression = function (id) {
31981
32211
  return this.jobProgressions.find(function (progression) { return progression.id === id; });
31982
32212
  };
31983
- JobProgressionComponent.prototype.updateValue = function () {
32213
+ JobProgressionIcon.prototype.updateValue = function () {
31984
32214
  if (this.debug) {
31985
32215
  console.debug(this._logPrefix + "Updating value");
31986
32216
  }
@@ -32001,7 +32231,7 @@
32001
32231
  }
32002
32232
  this.markForCheck();
32003
32233
  };
32004
- JobProgressionComponent.prototype.showList = function (event) {
32234
+ JobProgressionIcon.prototype.showList = function (event) {
32005
32235
  return __awaiter(this, void 0, void 0, function () {
32006
32236
  var _e;
32007
32237
  return __generator(this, function (_f) {
@@ -32034,34 +32264,35 @@
32034
32264
  });
32035
32265
  });
32036
32266
  };
32037
- JobProgressionComponent.prototype.markForCheck = function () {
32267
+ JobProgressionIcon.prototype.markForCheck = function () {
32038
32268
  this.cd.markForCheck();
32039
32269
  };
32040
- JobProgressionComponent.prototype.ngOnDestroy = function () {
32270
+ JobProgressionIcon.prototype.ngOnDestroy = function () {
32041
32271
  if (this.debug) {
32042
32272
  console.debug(this._logPrefix + "Destroying");
32043
32273
  }
32044
32274
  this._subscriptions.unsubscribe();
32045
32275
  };
32046
- return JobProgressionComponent;
32276
+ return JobProgressionIcon;
32047
32277
  }());
32048
- JobProgressionComponent.decorators = [
32278
+ JobProgressionIcon.decorators = [
32049
32279
  { type: i0.Component, args: [{
32050
- selector: 'app-job-progression',
32280
+ selector: 'app-job-progression-icon',
32051
32281
  template: "<button\n #button\n mat-icon-button\n [title]=\"titleI18n | translate\"\n [disabled]=\"disabled\"\n *ngIf=\"visible\"\n (click)=\"showList($event)\"\n>\n <mat-icon\n [matBadge]=\"jobProgressions?.length\"\n [matBadgeHidden]=\"!jobProgressions?.length\"\n matBadgeColor=\"accent\"\n matBadgeSize=\"small\"\n matBadgePosition=\"above after\"\n >{{ disabled || jobProgressions?.length ? 'schedule' : 'task_alt' }}\n </mat-icon>\n <mat-spinner\n #spinner\n *ngIf=\"jobProgressions?.length\"\n class=\"floating-spinner\"\n [color]=\"color\"\n [mode]=\"mode\"\n [value]=\"value\"\n diameter=\"30\"\n strokeWidth=\"3\"\n ></mat-spinner>\n</button>\n\n",
32052
32282
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
32053
32283
  styles: [".floating-spinner{position:absolute;top:6px;left:5px}"]
32054
32284
  },] }
32055
32285
  ];
32056
- JobProgressionComponent.ctorParameters = function () { return [
32057
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [JobProgressionServiceToken,] }] },
32286
+ JobProgressionIcon.ctorParameters = function () { return [
32287
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [APP_JOB_PROGRESSION_SERVICE,] }] },
32058
32288
  { type: i1$5.PopoverController },
32059
32289
  { type: i0.ChangeDetectorRef }
32060
32290
  ]; };
32061
- JobProgressionComponent.propDecorators = {
32291
+ JobProgressionIcon.propDecorators = {
32062
32292
  debug: [{ type: i0.Input }],
32063
32293
  titleI18n: [{ type: i0.Input }],
32064
32294
  options: [{ type: i0.Input }],
32295
+ autoHide: [{ type: i0.Input }],
32065
32296
  jobFinished: [{ type: i0.Output }]
32066
32297
  };
32067
32298
 
@@ -32078,11 +32309,11 @@
32078
32309
  i1$2.TranslateModule.forChild(),
32079
32310
  ],
32080
32311
  declarations: [
32081
- JobProgressionComponent,
32312
+ JobProgressionIcon,
32082
32313
  JobProgressionList
32083
32314
  ],
32084
32315
  exports: [
32085
- JobProgressionComponent
32316
+ JobProgressionIcon
32086
32317
  ]
32087
32318
  },] }
32088
32319
  ];
@@ -33947,7 +34178,7 @@
33947
34178
  console.debug('[test-table] Destroying table...');
33948
34179
  _super_1.prototype.ngOnDestroy.call(this);
33949
34180
  this.stopTimer();
33950
- this.dataService.stop();
34181
+ //this.dataService.stop();
33951
34182
  };
33952
34183
  TableTestPage.prototype.restoreFilter = function () {
33953
34184
  var json = this.settings.getPageSettings(this.settingsId, 'filter');
@@ -34252,79 +34483,51 @@
34252
34483
  },] }
34253
34484
  ];
34254
34485
 
34255
- var JobProgressionTestService = /** @class */ (function () {
34256
- function JobProgressionTestService() {
34257
- }
34258
- JobProgressionTestService.prototype.listenChanges = function (id, options) {
34259
- return rxjs.interval(100).pipe(operators.take(111), operators.map(function (value) {
34260
- if (value <= 10) {
34261
- return {
34262
- id: id,
34263
- name: "Job #" + id,
34264
- current: 0,
34265
- total: 0,
34266
- message: "Progression pending"
34267
- };
34268
- }
34269
- value = value - 10;
34270
- return {
34271
- id: id,
34272
- name: "Job #" + id,
34273
- current: value,
34274
- total: 100,
34275
- message: "Progression " + value + "/100"
34276
- };
34277
- }));
34278
- };
34279
- return JobProgressionTestService;
34280
- }());
34281
- JobProgressionTestService.decorators = [
34282
- { type: i0.Injectable }
34283
- ];
34284
-
34285
34486
  var JobProgressionTestingPage = /** @class */ (function () {
34286
- function JobProgressionTestingPage() {
34287
- this.nJob = 0;
34487
+ function JobProgressionTestingPage(jobProgressionService) {
34488
+ this.jobProgressionService = jobProgressionService;
34489
+ this.jobId = 0;
34490
+ this.job = null;
34288
34491
  this.options = {
34289
34492
  autoHide: true
34290
34493
  };
34291
- this.job = new exports.JobProgression();
34292
- this.job.id = 0;
34293
- this.job.name = 'test';
34294
- this.job.current = 0;
34295
- this.job.total = 100;
34296
34494
  }
34297
34495
  JobProgressionTestingPage.prototype.incrementJob = function (value) {
34298
- this.job.current = Math.max(0, this.job.current + value);
34496
+ this.job = this.job || this.createJob();
34497
+ this.job.current += value || 0;
34299
34498
  this.job.message = "Fake progression (very long message very long message very long message very long message) " + this.job.current + "/100";
34300
34499
  if (this.job.current > this.job.total) {
34301
- this.jobProgression.removeJob(0);
34500
+ this.jobProgressionService.removeJob(this.job.id);
34302
34501
  this.job.current = 0;
34502
+ this.job = null; // Forget the job
34303
34503
  }
34304
- else if (!this.jobProgression.getProgression(0)) {
34305
- this.jobProgression.jobProgressions.push(this.job);
34306
- }
34307
- this.jobProgression.updateValue();
34504
+ this.jobProgressionIcon.updateValue();
34308
34505
  };
34309
34506
  JobProgressionTestingPage.prototype.addJob = function () {
34310
- // Add fake job
34311
- this.nJob++;
34312
- this.jobProgression.addJob(this.nJob);
34507
+ this.job = this.createJob();
34508
+ };
34509
+ JobProgressionTestingPage.prototype.createJob = function () {
34510
+ var job = new exports.JobProgression();
34511
+ job.id = ++this.jobId;
34512
+ job.name = 'test';
34513
+ job.current = 0;
34514
+ job.total = 100;
34515
+ this.jobProgressionService.addJob(job.id, job);
34516
+ return job;
34313
34517
  };
34314
34518
  return JobProgressionTestingPage;
34315
34519
  }());
34316
34520
  JobProgressionTestingPage.decorators = [
34317
34521
  { type: i0.Component, args: [{
34318
34522
  selector: 'job-progression-testing',
34319
- template: "<ion-toolbar color=\"primary\">\n <ion-title>Job progression</ion-title>\n</ion-toolbar>\n\n<ion-content class=\"ion-padding\">\n\n <app-job-progression #jobProgression [debug]=\"true\" [options]=\"options\" ></app-job-progression>\n\n <p>\n <ion-button (click)=\"incrementJob(10)\">\n +10\n </ion-button>\n <ion-button (click)=\"incrementJob(-10)\">\n -10\n </ion-button>\n </p>\n <p>\n <ion-button (click)=\"addJob()\">Add Job</ion-button>\n </p>\n</ion-content>\n",
34320
- providers: [
34321
- { provide: JobProgressionServiceToken, useClass: JobProgressionTestService }
34322
- ]
34523
+ template: "<ion-toolbar color=\"primary\">\n <ion-title>Job progression</ion-title>\n</ion-toolbar>\n\n<ion-content class=\"ion-padding\">\n\n <app-job-progression-icon #icon [debug]=\"true\" [options]=\"options\" ></app-job-progression-icon>\n\n <p>\n <ion-button (click)=\"incrementJob(10)\">\n +10\n </ion-button>\n <ion-button (click)=\"incrementJob(-10)\">\n -10\n </ion-button>\n </p>\n <p>\n <ion-button (click)=\"addJob()\">Add Job</ion-button>\n </p>\n</ion-content>\n"
34323
34524
  },] }
34324
34525
  ];
34325
- JobProgressionTestingPage.ctorParameters = function () { return []; };
34526
+ JobProgressionTestingPage.ctorParameters = function () { return [
34527
+ { type: JobProgressionService, decorators: [{ type: i0.Inject, args: [APP_JOB_PROGRESSION_SERVICE,] }] }
34528
+ ]; };
34326
34529
  JobProgressionTestingPage.propDecorators = {
34327
- jobProgression: [{ type: i0.ViewChild, args: ['jobProgression',] }]
34530
+ jobProgressionIcon: [{ type: i0.ViewChild, args: ['icon',] }]
34328
34531
  };
34329
34532
 
34330
34533
  var JobTestingModule = /** @class */ (function () {
@@ -34814,7 +35017,7 @@
34814
35017
  },] }
34815
35018
  ];
34816
35019
  UserEventTestingPage.ctorParameters = function () { return [
34817
- { type: UserEventTestService, decorators: [{ type: i0.Inject, args: [USER_EVENT_SERVICE,] }] },
35020
+ { type: UserEventTestService, decorators: [{ type: i0.Inject, args: [APP_USER_EVENT_SERVICE,] }] },
34818
35021
  { type: i3.Router },
34819
35022
  { type: i1$5.AlertController },
34820
35023
  { type: i1$2.TranslateService }
@@ -34879,6 +35082,55 @@
34879
35082
  },] }
34880
35083
  ];
34881
35084
 
35085
+ var JobProgressionTestService = /** @class */ (function () {
35086
+ function JobProgressionTestService() {
35087
+ this.jobsSubject = new rxjs.BehaviorSubject([]);
35088
+ }
35089
+ JobProgressionTestService.prototype.addJob = function (id, job) {
35090
+ var exists = this.jobsSubject.value.some(function (j) { return j.id === id; });
35091
+ if (!exists) {
35092
+ job = job || new exports.JobProgression(id);
35093
+ this.jobsSubject.next(__spread(this.jobsSubject.value, [job]));
35094
+ }
35095
+ };
35096
+ JobProgressionTestService.prototype.removeJob = function (id) {
35097
+ var jobs = this.jobsSubject.value;
35098
+ var index = jobs.findIndex(function (j) { return j.id === id; });
35099
+ if (index !== -1) {
35100
+ jobs.splice(index, 1);
35101
+ this.jobsSubject.next(jobs);
35102
+ }
35103
+ };
35104
+ JobProgressionTestService.prototype.watchAll = function () {
35105
+ return this.jobsSubject.asObservable();
35106
+ };
35107
+ JobProgressionTestService.prototype.listenChanges = function (id, options) {
35108
+ return rxjs.interval(100).pipe(operators.take(111), operators.map(function (value) {
35109
+ if (value <= 10) {
35110
+ return {
35111
+ id: id,
35112
+ name: "Job #" + id,
35113
+ current: 0,
35114
+ total: 0,
35115
+ message: "Progression pending"
35116
+ };
35117
+ }
35118
+ value = value - 10;
35119
+ return {
35120
+ id: id,
35121
+ name: "Job #" + id,
35122
+ current: value,
35123
+ total: 100,
35124
+ message: "Progression " + value + "/100"
35125
+ };
35126
+ }));
35127
+ };
35128
+ return JobProgressionTestService;
35129
+ }());
35130
+ JobProgressionTestService.decorators = [
35131
+ { type: i0.Injectable }
35132
+ ];
35133
+
34882
35134
  // Environment
34883
35135
 
34884
35136
  /**
@@ -34891,6 +35143,7 @@
34891
35143
  exports.APP_FORM_ERROR_I18N_KEYS = APP_FORM_ERROR_I18N_KEYS;
34892
35144
  exports.APP_GRAPHQL_TYPE_POLICIES = APP_GRAPHQL_TYPE_POLICIES;
34893
35145
  exports.APP_HOME_BUTTONS = APP_HOME_BUTTONS;
35146
+ exports.APP_JOB_PROGRESSION_SERVICE = APP_JOB_PROGRESSION_SERVICE;
34894
35147
  exports.APP_LOCALES = APP_LOCALES;
34895
35148
  exports.APP_LOCAL_SETTINGS = APP_LOCAL_SETTINGS;
34896
35149
  exports.APP_LOCAL_SETTINGS_OPTIONS = APP_LOCAL_SETTINGS_OPTIONS;
@@ -34898,6 +35151,7 @@
34898
35151
  exports.APP_MENU_ITEMS = APP_MENU_ITEMS;
34899
35152
  exports.APP_MENU_OPTIONS = APP_MENU_OPTIONS;
34900
35153
  exports.APP_TESTING_PAGES = APP_TESTING_PAGES;
35154
+ exports.APP_USER_EVENT_SERVICE = APP_USER_EVENT_SERVICE;
34901
35155
  exports.AboutModal = AboutModal;
34902
35156
  exports.AbstractUserEventService = AbstractUserEventService;
34903
35157
  exports.AccountPage = AccountPage;
@@ -34933,7 +35187,6 @@
34933
35187
  exports.AppTabEditorOptions = AppTabEditorOptions;
34934
35188
  exports.AppTable = AppTable;
34935
35189
  exports.AppTableUtils = AppTableUtils;
34936
- exports.AppUserEventNotificationIcon = AppUserEventNotificationIcon;
34937
35190
  exports.AppValidatorService = AppValidatorService;
34938
35191
  exports.AppendToInputDirective = AppendToInputDirective;
34939
35192
  exports.ArrayFilterPipe = ArrayFilterPipe;
@@ -35032,9 +35285,9 @@
35032
35285
  exports.IsOnFieldModePipe = IsOnFieldModePipe;
35033
35286
  exports.Job = Job;
35034
35287
  exports.JobModule = JobModule;
35035
- exports.JobProgressionComponent = JobProgressionComponent;
35288
+ exports.JobProgressionIcon = JobProgressionIcon;
35289
+ exports.JobProgressionList = JobProgressionList;
35036
35290
  exports.JobProgressionService = JobProgressionService;
35037
- exports.JobProgressionServiceToken = JobProgressionServiceToken;
35038
35291
  exports.JobProgressionTestService = JobProgressionTestService;
35039
35292
  exports.JobProgressionTestingPage = JobProgressionTestingPage;
35040
35293
  exports.JobTestingModule = JobTestingModule;
@@ -35169,7 +35422,6 @@
35169
35422
  exports.TranslatablePipe = TranslatablePipe;
35170
35423
  exports.TranslateContextPipe = TranslateContextPipe;
35171
35424
  exports.TranslateContextService = TranslateContextService;
35172
- exports.USER_EVENT_SERVICE = USER_EVENT_SERVICE;
35173
35425
  exports.UploadFile = UploadFile;
35174
35426
  exports.UploadFileComponent = UploadFileComponent;
35175
35427
  exports.UploadFilePopover = UploadFilePopover;
@@ -35177,6 +35429,7 @@
35177
35429
  exports.UploadFileTestingPage = UploadFileTestingPage;
35178
35430
  exports.UriUtils = UriUtils;
35179
35431
  exports.UserEventModule = UserEventModule;
35432
+ exports.UserEventNotificationIcon = UserEventNotificationIcon;
35180
35433
  exports.UserEventTestService = UserEventTestService;
35181
35434
  exports.UserEventTestingModule = UserEventTestingModule;
35182
35435
  exports.UserEventTestingPage = UserEventTestingPage;
@@ -35335,15 +35588,15 @@
35335
35588
  exports.ɵ0 = ɵ0;
35336
35589
  exports.ɵa = CustomReuseStrategy;
35337
35590
  exports.ɵb = MatNumpadDomService;
35338
- exports.ɵc = isFocusableElement;
35339
- exports.ɵd = RegisterForm;
35340
- exports.ɵe = AccountValidatorService;
35341
- exports.ɵf = RegisterModal;
35342
- exports.ɵg = UserSettingsValidatorService;
35343
- exports.ɵh = LocalSettingsValidatorService;
35344
- exports.ɵi = AppUpdateOfflineModeCard;
35345
- exports.ɵj = UserEventNotificationList;
35346
- exports.ɵk = JobProgressionList;
35591
+ exports.ɵc = StartableObservableService;
35592
+ exports.ɵd = isFocusableElement;
35593
+ exports.ɵe = RegisterForm;
35594
+ exports.ɵf = AccountValidatorService;
35595
+ exports.ɵg = RegisterModal;
35596
+ exports.ɵh = UserSettingsValidatorService;
35597
+ exports.ɵi = LocalSettingsValidatorService;
35598
+ exports.ɵj = AppUpdateOfflineModeCard;
35599
+ exports.ɵk = UserEventNotificationList;
35347
35600
  exports.ɵl = DateTestPage;
35348
35601
  exports.ɵm = NumpadTestPage;
35349
35602
  exports.ɵn = MatBadgeIconTestPage;