@sumaris-net/ngx-components 1.23.16 → 1.23.17

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 +483 -232
  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 +24 -10
  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 +367 -171
  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,16 +26110,28 @@
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
+ console.debug('[table-datasource] Closing...');
26125
+ this._stopWatchSubject.next();
26126
+ this._stopWatchSubject.complete();
26127
+ this._stopWatchSubject.unsubscribe();
26128
+ this.loadingSubject.complete();
26129
+ this.loadingSubject.unsubscribe();
26130
+ }
25933
26131
  };
25934
26132
  EntitiesTableDataSource.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter) {
25935
26133
  var _this = this;
25936
- this._stopWatching$.next();
26134
+ this._stopWatchSubject.next();
25937
26135
  this._fetchMoreFn = null;
25938
26136
  this.markAsLoading();
25939
26137
  return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
@@ -25951,7 +26149,7 @@
25951
26149
  return res;
25952
26150
  }),
25953
26151
  // Stop this pipe next time we call watchAll()
25954
- operators.takeUntil(this._stopWatching$)
26152
+ operators.takeUntil(this._stopWatchSubject)
25955
26153
  // ⚠ Notice: Don't put any operator after takeUntil to avoid potential subscription leaks
25956
26154
  );
25957
26155
  };
@@ -26061,11 +26259,13 @@
26061
26259
  };
26062
26260
  EntitiesTableDataSource.prototype.connect = function (collectionViewer) {
26063
26261
  // DEBUG console.debug("[entities-datasource] connect");
26262
+ this.viewer = collectionViewer;
26064
26263
  return _super_1.prototype.connect.call(this, collectionViewer);
26065
26264
  };
26066
26265
  EntitiesTableDataSource.prototype.disconnect = function (collectionViewer) {
26266
+ console.debug('[table-datasource] Disconnecting...');
26067
26267
  _super_1.prototype.disconnect.call(this, collectionViewer);
26068
- this._stopWatching$.next();
26268
+ this.close();
26069
26269
  };
26070
26270
  EntitiesTableDataSource.prototype.waitIdle = function (debounceTimeMs) {
26071
26271
  return firstFalsePromise(this.loadingSubject
@@ -26746,7 +26946,6 @@
26746
26946
  };
26747
26947
  AppTable.prototype.ngOnDestroy = function () {
26748
26948
  var _this = this;
26749
- var _a;
26750
26949
  this._subscription.unsubscribe();
26751
26950
  // Unsubscribe column value changes
26752
26951
  Object.keys(this._cellValueChangesDefs).forEach(function (col) { return _this.stopCellValueChanges(col, true); });
@@ -26771,7 +26970,6 @@
26771
26970
  this.onError.unsubscribe();
26772
26971
  this.destroySubject.next();
26773
26972
  this.destroySubject.unsubscribe();
26774
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
26775
26973
  };
26776
26974
  AppTable.prototype.updateView = function (res, opts) {
26777
26975
  return __awaiter(this, void 0, void 0, function () {
@@ -26809,12 +27007,11 @@
26809
27007
  }
26810
27008
  };
26811
27009
  AppTable.prototype.resetDataSource = function () {
26812
- var _a;
26813
27010
  if (this._dataSourceLoadingSubscription) {
26814
27011
  this._dataSourceLoadingSubscription.unsubscribe();
26815
27012
  this._subscription.remove(this._dataSourceLoadingSubscription);
26816
27013
  }
26817
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
27014
+ //this._dataSource?.close();
26818
27015
  this._dataSource = null;
26819
27016
  };
26820
27017
  AppTable.prototype.addColumnDef = function (column) {
@@ -30441,7 +30638,7 @@
30441
30638
  };
30442
30639
 
30443
30640
  var moment$6 = momentImported__namespace;
30444
- var USER_EVENT_SERVICE = new i0.InjectionToken('UserEventService');
30641
+ var APP_USER_EVENT_SERVICE = new i0.InjectionToken('UserEventService');
30445
30642
  var AbstractUserEventService = /** @class */ (function (_super) {
30446
30643
  __extends(AbstractUserEventService, _super);
30447
30644
  function AbstractUserEventService(graphql, accountService, network, translate, options) {
@@ -31357,7 +31554,7 @@
31357
31554
  { type: i0.ChangeDetectorRef },
31358
31555
  { type: i1$5.PopoverController },
31359
31556
  { type: LocalSettingsService, decorators: [{ type: i0.Optional }] },
31360
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [USER_EVENT_SERVICE,] }] }
31557
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [APP_USER_EVENT_SERVICE,] }] }
31361
31558
  ]; };
31362
31559
  UserEventNotificationList.propDecorators = {
31363
31560
  debug: [{ type: i0.Input }],
@@ -31374,11 +31571,12 @@
31374
31571
  ionItems: [{ type: i0.ViewChildren, args: [i1$5.IonItem,] }]
31375
31572
  };
31376
31573
 
31377
- var AppUserEventNotificationIcon = /** @class */ (function () {
31378
- function AppUserEventNotificationIcon(userEventService, accountService, popoverController) {
31574
+ var UserEventNotificationIcon = /** @class */ (function () {
31575
+ function UserEventNotificationIcon(userEventService, accountService, popoverController, cd) {
31379
31576
  this.userEventService = userEventService;
31380
31577
  this.accountService = accountService;
31381
31578
  this.popoverController = popoverController;
31579
+ this.cd = cd;
31382
31580
  this.debug = false;
31383
31581
  this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
31384
31582
  this.disabled = false;
@@ -31387,18 +31585,25 @@
31387
31585
  this._readEvent = new i0.EventEmitter();
31388
31586
  this._readEvents = new i0.EventEmitter();
31389
31587
  }
31390
- Object.defineProperty(AppUserEventNotificationIcon.prototype, "countChanges", {
31588
+ Object.defineProperty(UserEventNotificationIcon.prototype, "countChanges", {
31391
31589
  get: function () {
31590
+ var _this = this;
31392
31591
  if (!this.userEventService)
31393
31592
  return rxjs.of();
31394
31593
  return this.userEventService
31395
31594
  .countSubject
31396
- .pipe(operators.map(function (value) { return value === 0 ? undefined : value; }));
31595
+ .pipe(operators.tap(function (value) {
31596
+ var visible = !_this.autoHide || value > 0;
31597
+ if (_this.visible !== visible) {
31598
+ _this.visible = visible;
31599
+ _this.cd.markForCheck();
31600
+ }
31601
+ }), operators.map(function (value) { return value === 0 ? undefined : value; }));
31397
31602
  },
31398
31603
  enumerable: false,
31399
31604
  configurable: true
31400
31605
  });
31401
- AppUserEventNotificationIcon.prototype.ngOnInit = function () {
31606
+ UserEventNotificationIcon.prototype.ngOnInit = function () {
31402
31607
  return __awaiter(this, void 0, void 0, function () {
31403
31608
  var _this = this;
31404
31609
  return __generator(this, function (_a) {
@@ -31407,8 +31612,10 @@
31407
31612
  if (isNil(this.userEventService)) {
31408
31613
  console.warn(this._logPrefix + "No service injected");
31409
31614
  this.disabled = true;
31615
+ this.visible = false;
31410
31616
  return [2 /*return*/];
31411
31617
  }
31618
+ this.visible = toBoolean(this.visible, !this.autoHide);
31412
31619
  // Wait service
31413
31620
  return [4 /*yield*/, this.userEventService.ready()];
31414
31621
  case 1:
@@ -31427,7 +31634,7 @@
31427
31634
  });
31428
31635
  });
31429
31636
  };
31430
- AppUserEventNotificationIcon.prototype.showList = function (event) {
31637
+ UserEventNotificationIcon.prototype.showList = function (event) {
31431
31638
  return __awaiter(this, void 0, void 0, function () {
31432
31639
  var popover;
31433
31640
  return __generator(this, function (_a) {
@@ -31460,30 +31667,32 @@
31460
31667
  });
31461
31668
  });
31462
31669
  };
31463
- AppUserEventNotificationIcon.prototype.ngOnDestroy = function () {
31670
+ UserEventNotificationIcon.prototype.ngOnDestroy = function () {
31464
31671
  if (this.debug) {
31465
31672
  console.debug(this._logPrefix + "Destroying");
31466
31673
  }
31467
31674
  };
31468
- return AppUserEventNotificationIcon;
31675
+ return UserEventNotificationIcon;
31469
31676
  }());
31470
- AppUserEventNotificationIcon.decorators = [
31677
+ UserEventNotificationIcon.decorators = [
31471
31678
  { type: i0.Component, args: [{
31472
31679
  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",
31680
+ 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
31681
  changeDetection: i0.ChangeDetectionStrategy.OnPush
31475
31682
  },] }
31476
31683
  ];
31477
- AppUserEventNotificationIcon.ctorParameters = function () { return [
31478
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [USER_EVENT_SERVICE,] }] },
31684
+ UserEventNotificationIcon.ctorParameters = function () { return [
31685
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [APP_USER_EVENT_SERVICE,] }] },
31479
31686
  { type: AccountService },
31480
- { type: i1$5.PopoverController }
31687
+ { type: i1$5.PopoverController },
31688
+ { type: i0.ChangeDetectorRef }
31481
31689
  ]; };
31482
- AppUserEventNotificationIcon.propDecorators = {
31690
+ UserEventNotificationIcon.propDecorators = {
31483
31691
  debug: [{ type: i0.Input }],
31484
31692
  titleI18n: [{ type: i0.Input }],
31485
31693
  disabled: [{ type: i0.Input }],
31486
- filter: [{ type: i0.Input }]
31694
+ filter: [{ type: i0.Input }],
31695
+ autoHide: [{ type: i0.Input }]
31487
31696
  };
31488
31697
 
31489
31698
  var UserEventModule = /** @class */ (function () {
@@ -31500,11 +31709,11 @@
31500
31709
  ngxJdenticon.NgxJdenticonModule
31501
31710
  ],
31502
31711
  declarations: [
31503
- AppUserEventNotificationIcon,
31712
+ UserEventNotificationIcon,
31504
31713
  UserEventNotificationList
31505
31714
  ],
31506
31715
  exports: [
31507
- AppUserEventNotificationIcon
31716
+ UserEventNotificationIcon
31508
31717
  ]
31509
31718
  },] }
31510
31719
  ];
@@ -31792,8 +32001,10 @@
31792
32001
  EntityClass({ typename: 'JobProgressionVO' })
31793
32002
  ], exports.JobProgression);
31794
32003
 
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}"])));
32004
+ var APP_JOB_PROGRESSION_SERVICE = new i0.InjectionToken('JobProgressionService');
32005
+ var QUERIES = {
32006
+ 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 }"])))
32007
+ };
31797
32008
  var JobProgressionService = /** @class */ (function (_super) {
31798
32009
  __extends(JobProgressionService, _super);
31799
32010
  function JobProgressionService(graphql, environment) {
@@ -31805,6 +32016,15 @@
31805
32016
  _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
31806
32017
  return _this;
31807
32018
  }
32019
+ JobProgressionService.prototype.watchAll = function (options) {
32020
+ return rxjs.of([]); // TODO
32021
+ };
32022
+ JobProgressionService.prototype.addJob = function (id, job) {
32023
+ throw new Error('no implemented');
32024
+ };
32025
+ JobProgressionService.prototype.removeJob = function (id) {
32026
+ throw new Error('no implemented');
32027
+ };
31808
32028
  JobProgressionService.prototype.listenChanges = function (id, options) {
31809
32029
  var _this = this;
31810
32030
  if (isNil(id))
@@ -31812,7 +32032,7 @@
31812
32032
  if (this._debug)
31813
32033
  console.debug(this._logPrefix + "[WS] Listening changes for job progression {" + id + "}...");
31814
32034
  return this.graphql.subscribe({
31815
- query: jobProgressionSubscription,
32035
+ query: QUERIES.listenChanges,
31816
32036
  fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
31817
32037
  variables: { id: id, interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
31818
32038
  error: { code: SocialErrorCodes.SUBSCRIBE_JOB_PROGRESSION_ERROR, message: 'SOCIAL.ERROR.SUBSCRIBE_JOB_PROGRESSION_ERROR' }
@@ -31855,8 +32075,8 @@
31855
32075
  jobProgressions: [{ type: i0.Input }]
31856
32076
  };
31857
32077
 
31858
- var JobProgressionComponent = /** @class */ (function () {
31859
- function JobProgressionComponent(jobProgressionService, popoverController, cd) {
32078
+ var JobProgressionIcon = /** @class */ (function () {
32079
+ function JobProgressionIcon(jobProgressionService, popoverController, cd) {
31860
32080
  this.jobProgressionService = jobProgressionService;
31861
32081
  this.popoverController = popoverController;
31862
32082
  this.cd = cd;
@@ -31872,19 +32092,24 @@
31872
32092
  this._subscriptionsById = {};
31873
32093
  this._logPrefix = '[job-progression] ';
31874
32094
  }
31875
- JobProgressionComponent.prototype.ngOnInit = function () {
32095
+ JobProgressionIcon.prototype.ngOnInit = function () {
32096
+ var _this = this;
31876
32097
  var _a, _b, _c, _d;
31877
32098
  if (isNil(this.jobProgressionService)) {
31878
32099
  console.warn(this._logPrefix + "No service injected");
31879
32100
  }
31880
32101
  // parse options
31881
- this.autoHide = toBoolean((_a = this.options) === null || _a === void 0 ? void 0 : _a.autoHide, false);
32102
+ this.autoHide = toBoolean(this.autoHide, ((_a = this.options) === null || _a === void 0 ? void 0 : _a.autoHide) || false);
31882
32103
  this.visible = !this.autoHide;
31883
32104
  this.autoHideDelay = toNumber((_b = this.options) === null || _b === void 0 ? void 0 : _b.autoHideDelay, 1000);
31884
32105
  this.autoRemove = toBoolean((_c = this.options) === null || _c === void 0 ? void 0 : _c.autoRemove, true);
31885
32106
  this.autoRemoveDelay = toNumber((_d = this.options) === null || _d === void 0 ? void 0 : _d.autoRemoveDelay, 1000);
32107
+ this._subscriptions.add(this.jobProgressionService.watchAll()
32108
+ .subscribe(function (items) {
32109
+ (items || []).forEach(function (item) { return _this.addJob(item.id, item); });
32110
+ }));
31886
32111
  };
31887
- JobProgressionComponent.prototype.addJob = function (id) {
32112
+ JobProgressionIcon.prototype.addJob = function (id, job) {
31888
32113
  var _this = this;
31889
32114
  if (isNil(this.jobProgressionService)) {
31890
32115
  console.warn(this._logPrefix + "No service injected. Can't add a job");
@@ -31898,8 +32123,11 @@
31898
32123
  console.debug(this._logPrefix + "Add job id=" + id);
31899
32124
  }
31900
32125
  // Adding empty job progression
31901
- var progression = new exports.JobProgression(id);
31902
- this.jobProgressions.push(progression);
32126
+ var progression = this.getProgression(id);
32127
+ if (!progression) {
32128
+ progression = job || new exports.JobProgression(id);
32129
+ this.jobProgressions.push(progression);
32130
+ }
31903
32131
  this.disabled = false;
31904
32132
  var sub = this.jobProgressionService.listenChanges(id)
31905
32133
  .pipe(operators.filter(function (progression) {
@@ -31962,7 +32190,7 @@
31962
32190
  this._subscriptionsById[id] = sub;
31963
32191
  this._subscriptions.add(sub);
31964
32192
  };
31965
- JobProgressionComponent.prototype.removeJob = function (id) {
32193
+ JobProgressionIcon.prototype.removeJob = function (id) {
31966
32194
  if (this.debug) {
31967
32195
  console.debug(this._logPrefix + "Remove job id=" + id);
31968
32196
  }
@@ -31977,10 +32205,10 @@
31977
32205
  }
31978
32206
  this.updateValue();
31979
32207
  };
31980
- JobProgressionComponent.prototype.getProgression = function (id) {
32208
+ JobProgressionIcon.prototype.getProgression = function (id) {
31981
32209
  return this.jobProgressions.find(function (progression) { return progression.id === id; });
31982
32210
  };
31983
- JobProgressionComponent.prototype.updateValue = function () {
32211
+ JobProgressionIcon.prototype.updateValue = function () {
31984
32212
  if (this.debug) {
31985
32213
  console.debug(this._logPrefix + "Updating value");
31986
32214
  }
@@ -32001,7 +32229,7 @@
32001
32229
  }
32002
32230
  this.markForCheck();
32003
32231
  };
32004
- JobProgressionComponent.prototype.showList = function (event) {
32232
+ JobProgressionIcon.prototype.showList = function (event) {
32005
32233
  return __awaiter(this, void 0, void 0, function () {
32006
32234
  var _e;
32007
32235
  return __generator(this, function (_f) {
@@ -32034,34 +32262,35 @@
32034
32262
  });
32035
32263
  });
32036
32264
  };
32037
- JobProgressionComponent.prototype.markForCheck = function () {
32265
+ JobProgressionIcon.prototype.markForCheck = function () {
32038
32266
  this.cd.markForCheck();
32039
32267
  };
32040
- JobProgressionComponent.prototype.ngOnDestroy = function () {
32268
+ JobProgressionIcon.prototype.ngOnDestroy = function () {
32041
32269
  if (this.debug) {
32042
32270
  console.debug(this._logPrefix + "Destroying");
32043
32271
  }
32044
32272
  this._subscriptions.unsubscribe();
32045
32273
  };
32046
- return JobProgressionComponent;
32274
+ return JobProgressionIcon;
32047
32275
  }());
32048
- JobProgressionComponent.decorators = [
32276
+ JobProgressionIcon.decorators = [
32049
32277
  { type: i0.Component, args: [{
32050
- selector: 'app-job-progression',
32278
+ selector: 'app-job-progression-icon',
32051
32279
  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
32280
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
32053
32281
  styles: [".floating-spinner{position:absolute;top:6px;left:5px}"]
32054
32282
  },] }
32055
32283
  ];
32056
- JobProgressionComponent.ctorParameters = function () { return [
32057
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [JobProgressionServiceToken,] }] },
32284
+ JobProgressionIcon.ctorParameters = function () { return [
32285
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [APP_JOB_PROGRESSION_SERVICE,] }] },
32058
32286
  { type: i1$5.PopoverController },
32059
32287
  { type: i0.ChangeDetectorRef }
32060
32288
  ]; };
32061
- JobProgressionComponent.propDecorators = {
32289
+ JobProgressionIcon.propDecorators = {
32062
32290
  debug: [{ type: i0.Input }],
32063
32291
  titleI18n: [{ type: i0.Input }],
32064
32292
  options: [{ type: i0.Input }],
32293
+ autoHide: [{ type: i0.Input }],
32065
32294
  jobFinished: [{ type: i0.Output }]
32066
32295
  };
32067
32296
 
@@ -32078,11 +32307,11 @@
32078
32307
  i1$2.TranslateModule.forChild(),
32079
32308
  ],
32080
32309
  declarations: [
32081
- JobProgressionComponent,
32310
+ JobProgressionIcon,
32082
32311
  JobProgressionList
32083
32312
  ],
32084
32313
  exports: [
32085
- JobProgressionComponent
32314
+ JobProgressionIcon
32086
32315
  ]
32087
32316
  },] }
32088
32317
  ];
@@ -33947,7 +34176,7 @@
33947
34176
  console.debug('[test-table] Destroying table...');
33948
34177
  _super_1.prototype.ngOnDestroy.call(this);
33949
34178
  this.stopTimer();
33950
- this.dataService.stop();
34179
+ //this.dataService.stop();
33951
34180
  };
33952
34181
  TableTestPage.prototype.restoreFilter = function () {
33953
34182
  var json = this.settings.getPageSettings(this.settingsId, 'filter');
@@ -34252,79 +34481,51 @@
34252
34481
  },] }
34253
34482
  ];
34254
34483
 
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
34484
  var JobProgressionTestingPage = /** @class */ (function () {
34286
- function JobProgressionTestingPage() {
34287
- this.nJob = 0;
34485
+ function JobProgressionTestingPage(jobProgressionService) {
34486
+ this.jobProgressionService = jobProgressionService;
34487
+ this.jobId = 0;
34488
+ this.job = null;
34288
34489
  this.options = {
34289
34490
  autoHide: true
34290
34491
  };
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
34492
  }
34297
34493
  JobProgressionTestingPage.prototype.incrementJob = function (value) {
34298
- this.job.current = Math.max(0, this.job.current + value);
34494
+ this.job = this.job || this.createJob();
34495
+ this.job.current += value || 0;
34299
34496
  this.job.message = "Fake progression (very long message very long message very long message very long message) " + this.job.current + "/100";
34300
34497
  if (this.job.current > this.job.total) {
34301
- this.jobProgression.removeJob(0);
34498
+ this.jobProgressionService.removeJob(this.job.id);
34302
34499
  this.job.current = 0;
34500
+ this.job = null; // Forget the job
34303
34501
  }
34304
- else if (!this.jobProgression.getProgression(0)) {
34305
- this.jobProgression.jobProgressions.push(this.job);
34306
- }
34307
- this.jobProgression.updateValue();
34502
+ this.jobProgressionIcon.updateValue();
34308
34503
  };
34309
34504
  JobProgressionTestingPage.prototype.addJob = function () {
34310
- // Add fake job
34311
- this.nJob++;
34312
- this.jobProgression.addJob(this.nJob);
34505
+ this.job = this.createJob();
34506
+ };
34507
+ JobProgressionTestingPage.prototype.createJob = function () {
34508
+ var job = new exports.JobProgression();
34509
+ job.id = ++this.jobId;
34510
+ job.name = 'test';
34511
+ job.current = 0;
34512
+ job.total = 100;
34513
+ this.jobProgressionService.addJob(job.id, job);
34514
+ return job;
34313
34515
  };
34314
34516
  return JobProgressionTestingPage;
34315
34517
  }());
34316
34518
  JobProgressionTestingPage.decorators = [
34317
34519
  { type: i0.Component, args: [{
34318
34520
  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
- ]
34521
+ 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
34522
  },] }
34324
34523
  ];
34325
- JobProgressionTestingPage.ctorParameters = function () { return []; };
34524
+ JobProgressionTestingPage.ctorParameters = function () { return [
34525
+ { type: JobProgressionService, decorators: [{ type: i0.Inject, args: [APP_JOB_PROGRESSION_SERVICE,] }] }
34526
+ ]; };
34326
34527
  JobProgressionTestingPage.propDecorators = {
34327
- jobProgression: [{ type: i0.ViewChild, args: ['jobProgression',] }]
34528
+ jobProgressionIcon: [{ type: i0.ViewChild, args: ['icon',] }]
34328
34529
  };
34329
34530
 
34330
34531
  var JobTestingModule = /** @class */ (function () {
@@ -34814,7 +35015,7 @@
34814
35015
  },] }
34815
35016
  ];
34816
35017
  UserEventTestingPage.ctorParameters = function () { return [
34817
- { type: UserEventTestService, decorators: [{ type: i0.Inject, args: [USER_EVENT_SERVICE,] }] },
35018
+ { type: UserEventTestService, decorators: [{ type: i0.Inject, args: [APP_USER_EVENT_SERVICE,] }] },
34818
35019
  { type: i3.Router },
34819
35020
  { type: i1$5.AlertController },
34820
35021
  { type: i1$2.TranslateService }
@@ -34879,6 +35080,55 @@
34879
35080
  },] }
34880
35081
  ];
34881
35082
 
35083
+ var JobProgressionTestService = /** @class */ (function () {
35084
+ function JobProgressionTestService() {
35085
+ this.jobsSubject = new rxjs.BehaviorSubject([]);
35086
+ }
35087
+ JobProgressionTestService.prototype.addJob = function (id, job) {
35088
+ var exists = this.jobsSubject.value.some(function (j) { return j.id === id; });
35089
+ if (!exists) {
35090
+ job = job || new exports.JobProgression(id);
35091
+ this.jobsSubject.next(__spread(this.jobsSubject.value, [job]));
35092
+ }
35093
+ };
35094
+ JobProgressionTestService.prototype.removeJob = function (id) {
35095
+ var jobs = this.jobsSubject.value;
35096
+ var index = jobs.findIndex(function (j) { return j.id === id; });
35097
+ if (index !== -1) {
35098
+ jobs.splice(index, 1);
35099
+ this.jobsSubject.next(jobs);
35100
+ }
35101
+ };
35102
+ JobProgressionTestService.prototype.watchAll = function () {
35103
+ return this.jobsSubject.asObservable();
35104
+ };
35105
+ JobProgressionTestService.prototype.listenChanges = function (id, options) {
35106
+ return rxjs.interval(100).pipe(operators.take(111), operators.map(function (value) {
35107
+ if (value <= 10) {
35108
+ return {
35109
+ id: id,
35110
+ name: "Job #" + id,
35111
+ current: 0,
35112
+ total: 0,
35113
+ message: "Progression pending"
35114
+ };
35115
+ }
35116
+ value = value - 10;
35117
+ return {
35118
+ id: id,
35119
+ name: "Job #" + id,
35120
+ current: value,
35121
+ total: 100,
35122
+ message: "Progression " + value + "/100"
35123
+ };
35124
+ }));
35125
+ };
35126
+ return JobProgressionTestService;
35127
+ }());
35128
+ JobProgressionTestService.decorators = [
35129
+ { type: i0.Injectable }
35130
+ ];
35131
+
34882
35132
  // Environment
34883
35133
 
34884
35134
  /**
@@ -34891,6 +35141,7 @@
34891
35141
  exports.APP_FORM_ERROR_I18N_KEYS = APP_FORM_ERROR_I18N_KEYS;
34892
35142
  exports.APP_GRAPHQL_TYPE_POLICIES = APP_GRAPHQL_TYPE_POLICIES;
34893
35143
  exports.APP_HOME_BUTTONS = APP_HOME_BUTTONS;
35144
+ exports.APP_JOB_PROGRESSION_SERVICE = APP_JOB_PROGRESSION_SERVICE;
34894
35145
  exports.APP_LOCALES = APP_LOCALES;
34895
35146
  exports.APP_LOCAL_SETTINGS = APP_LOCAL_SETTINGS;
34896
35147
  exports.APP_LOCAL_SETTINGS_OPTIONS = APP_LOCAL_SETTINGS_OPTIONS;
@@ -34898,6 +35149,7 @@
34898
35149
  exports.APP_MENU_ITEMS = APP_MENU_ITEMS;
34899
35150
  exports.APP_MENU_OPTIONS = APP_MENU_OPTIONS;
34900
35151
  exports.APP_TESTING_PAGES = APP_TESTING_PAGES;
35152
+ exports.APP_USER_EVENT_SERVICE = APP_USER_EVENT_SERVICE;
34901
35153
  exports.AboutModal = AboutModal;
34902
35154
  exports.AbstractUserEventService = AbstractUserEventService;
34903
35155
  exports.AccountPage = AccountPage;
@@ -34933,7 +35185,6 @@
34933
35185
  exports.AppTabEditorOptions = AppTabEditorOptions;
34934
35186
  exports.AppTable = AppTable;
34935
35187
  exports.AppTableUtils = AppTableUtils;
34936
- exports.AppUserEventNotificationIcon = AppUserEventNotificationIcon;
34937
35188
  exports.AppValidatorService = AppValidatorService;
34938
35189
  exports.AppendToInputDirective = AppendToInputDirective;
34939
35190
  exports.ArrayFilterPipe = ArrayFilterPipe;
@@ -35032,9 +35283,9 @@
35032
35283
  exports.IsOnFieldModePipe = IsOnFieldModePipe;
35033
35284
  exports.Job = Job;
35034
35285
  exports.JobModule = JobModule;
35035
- exports.JobProgressionComponent = JobProgressionComponent;
35286
+ exports.JobProgressionIcon = JobProgressionIcon;
35287
+ exports.JobProgressionList = JobProgressionList;
35036
35288
  exports.JobProgressionService = JobProgressionService;
35037
- exports.JobProgressionServiceToken = JobProgressionServiceToken;
35038
35289
  exports.JobProgressionTestService = JobProgressionTestService;
35039
35290
  exports.JobProgressionTestingPage = JobProgressionTestingPage;
35040
35291
  exports.JobTestingModule = JobTestingModule;
@@ -35169,7 +35420,6 @@
35169
35420
  exports.TranslatablePipe = TranslatablePipe;
35170
35421
  exports.TranslateContextPipe = TranslateContextPipe;
35171
35422
  exports.TranslateContextService = TranslateContextService;
35172
- exports.USER_EVENT_SERVICE = USER_EVENT_SERVICE;
35173
35423
  exports.UploadFile = UploadFile;
35174
35424
  exports.UploadFileComponent = UploadFileComponent;
35175
35425
  exports.UploadFilePopover = UploadFilePopover;
@@ -35177,6 +35427,7 @@
35177
35427
  exports.UploadFileTestingPage = UploadFileTestingPage;
35178
35428
  exports.UriUtils = UriUtils;
35179
35429
  exports.UserEventModule = UserEventModule;
35430
+ exports.UserEventNotificationIcon = UserEventNotificationIcon;
35180
35431
  exports.UserEventTestService = UserEventTestService;
35181
35432
  exports.UserEventTestingModule = UserEventTestingModule;
35182
35433
  exports.UserEventTestingPage = UserEventTestingPage;
@@ -35335,15 +35586,15 @@
35335
35586
  exports.ɵ0 = ɵ0;
35336
35587
  exports.ɵa = CustomReuseStrategy;
35337
35588
  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;
35589
+ exports.ɵc = StartableObservableService;
35590
+ exports.ɵd = isFocusableElement;
35591
+ exports.ɵe = RegisterForm;
35592
+ exports.ɵf = AccountValidatorService;
35593
+ exports.ɵg = RegisterModal;
35594
+ exports.ɵh = UserSettingsValidatorService;
35595
+ exports.ɵi = LocalSettingsValidatorService;
35596
+ exports.ɵj = AppUpdateOfflineModeCard;
35597
+ exports.ɵk = UserEventNotificationList;
35347
35598
  exports.ɵl = DateTestPage;
35348
35599
  exports.ɵm = NumpadTestPage;
35349
35600
  exports.ɵn = MatBadgeIconTestPage;