@sumaris-net/ngx-components 1.23.15 → 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 +486 -225
  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 +54 -26
  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 +372 -168
  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 +5 -5
  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,25 +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
- this.savingSubject.next(false);
20857
- this.dirtySubject.next(false);
20858
21016
  this.dataSubject.complete();
20859
- this.dataSubject = new rxjs.BehaviorSubject(null);
21017
+ this.dataSubject.unsubscribe();
21018
+ this._hiddenData = null;
21019
+ this.markAsSaved();
21020
+ this.markAsPristine();
20860
21021
  return [2 /*return*/];
20861
21022
  });
20862
21023
  });
@@ -20866,19 +21027,24 @@
20866
21027
  };
20867
21028
  InMemoryEntitiesService.prototype.setValue = function (data) {
20868
21029
  if (this.dataSubject.value !== data) {
20869
- if (!this.started)
20870
- this.start();
20871
- this._hiddenData = [];
20872
- 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
+ }
20873
21040
  }
20874
- this.markAsPristine();
20875
21041
  };
20876
21042
  InMemoryEntitiesService.prototype.loadAll = function (offset, size, sortBy, sortDirection, filter, opts) {
20877
21043
  return __awaiter(this, void 0, void 0, function () {
20878
- var originalData, excludedDataByFilter, excludedDataByPagination, data, total, res, nextOffset_1;
21044
+ var originalData, err_1, excludedDataByFilter, excludedDataByPagination, data, total, res, nextOffset_1;
20879
21045
  var _this = this;
20880
- return __generator(this, function (_b) {
20881
- switch (_b.label) {
21046
+ return __generator(this, function (_c) {
21047
+ switch (_c.label) {
20882
21048
  case 0:
20883
21049
  offset = offset >= 0 ? offset : 0;
20884
21050
  size = size >= 0 ? size : -1;
@@ -20886,32 +21052,44 @@
20886
21052
  if (isNil(originalData)) {
20887
21053
  console.warn('[memory-data-service] Cannot load all: no value set. Will return empty result');
20888
21054
  }
20889
- if (!!this.started) return [3 /*break*/, 2];
20890
- return [4 /*yield*/, this.ready()];
21055
+ _c.label = 1;
20891
21056
  case 1:
20892
- _b.sent();
20893
- _b.label = 2;
21057
+ _c.trys.push([1, 4, , 5]);
21058
+ // Wait service is ready
21059
+ return [4 /*yield*/, this.ready()];
20894
21060
  case 2:
20895
- if (!this.saving) return [3 /*break*/, 4];
20896
- return [4 /*yield*/, this.waitWhileSaving()];
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*/ })];
20897
21065
  case 3:
20898
- _b.sent();
20899
- _b.label = 4;
21066
+ // Wait while busy (e.g. when saving, or deleting)
21067
+ _c.sent();
21068
+ return [3 /*break*/, 5];
20900
21069
  case 4:
20901
- excludedDataByFilter = [];
20902
- _b.label = 5;
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];
20903
21075
  case 5:
20904
- _b.trys.push([5, , 8, 9]);
21076
+ // Make sure service is not stopped
21077
+ if (this.stopped)
21078
+ return [2 /*return*/, undefined];
21079
+ excludedDataByFilter = [];
21080
+ _c.label = 6;
21081
+ case 6:
21082
+ _c.trys.push([6, , 9, 10]);
20905
21083
  if (isEmptyArray(originalData)) {
20906
21084
  return [2 /*return*/, { data: [], total: 0 }];
20907
21085
  }
20908
21086
  data = this._sortFn(originalData, sortBy, sortDirection);
20909
- if (!this._onLoad) return [3 /*break*/, 7];
21087
+ if (!this._onLoad) return [3 /*break*/, 8];
20910
21088
  return [4 /*yield*/, this._onLoad(data)];
20911
- case 6:
20912
- data = _b.sent();
20913
- _b.label = 7;
20914
21089
  case 7:
21090
+ data = _c.sent();
21091
+ _c.label = 8;
21092
+ case 8:
20915
21093
  // Apply filter (will update hiddenData)
20916
21094
  data = this.filter(data, filter, excludedDataByFilter);
20917
21095
  total = data.length;
@@ -20959,22 +21137,22 @@
20959
21137
  if (nextOffset_1 < total) {
20960
21138
  res.fetchMore = function () { return _this.loadAll(nextOffset_1, size, sortBy, sortDirection, filter, opts)
20961
21139
  .then(function (res) {
20962
- var _a;
21140
+ var _a, _b;
20963
21141
  // Update hidden data (remove new fetched item)
20964
21142
  if ((_a = res.data) === null || _a === void 0 ? void 0 : _a.length) {
20965
- _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); });
20966
21144
  }
20967
21145
  return res;
20968
21146
  }); };
20969
21147
  }
20970
21148
  return [2 /*return*/, res];
20971
- case 8:
21149
+ case 9:
20972
21150
  // Remember hidden data
20973
21151
  if (offset === 0) {
20974
21152
  this._hiddenData = !excludedDataByPagination ? excludedDataByFilter : excludedDataByFilter.concat.apply(excludedDataByFilter, __spread(excludedDataByPagination));
20975
21153
  }
20976
21154
  return [7 /*endfinally*/];
20977
- case 9: return [2 /*return*/];
21155
+ case 10: return [2 /*return*/];
20978
21156
  }
20979
21157
  });
20980
21158
  });
@@ -20986,20 +21164,21 @@
20986
21164
  return this.dataSubject
20987
21165
  .pipe(operators.takeUntil(this.stopSubject),
20988
21166
  // Warn if waiting value to be set
20989
- operators.tap(function (data) { return _this.debug && !data && console.debug('[memory-data-service] Waiting value to be set...'); }), operators.filter(isNotNil), operators.mergeMap(function (_) { return _this.loadAll(offset, size, sortBy, sortDirection, filterData, options); }));
21167
+ operators.tap(function (data) { return _this.debug && !data && console.debug('[memory-data-service] Waiting value to be set...'); }), operators.filter(isNotNil), operators.mergeMap(function (_) { return _this.loadAll(offset, size, sortBy, sortDirection, filterData, options); }), operators.filter(isNotNil) // Skip no result (e.g. when stopped)
21168
+ );
20990
21169
  };
20991
21170
  InMemoryEntitiesService.prototype.saveAll = function (data, options) {
20992
21171
  return __awaiter(this, void 0, void 0, function () {
20993
- var res, _b;
20994
- return __generator(this, function (_c) {
20995
- switch (_c.label) {
21172
+ var res, _c;
21173
+ return __generator(this, function (_d) {
21174
+ switch (_d.label) {
20996
21175
  case 0:
20997
21176
  if (!this.dataSubject.value)
20998
21177
  throw new Error('[memory-service] Could not save, because value not set');
20999
21178
  this.markAsSaving();
21000
- _c.label = 1;
21179
+ _d.label = 1;
21001
21180
  case 1:
21002
- _c.trys.push([1, , 6, 7]);
21181
+ _d.trys.push([1, , 6, 7]);
21003
21182
  // Restore hidden data
21004
21183
  if (isNotEmptyArray(this._hiddenData))
21005
21184
  data = data.concat.apply(data, __spread(this._hiddenData));
@@ -21008,14 +21187,14 @@
21008
21187
  if (!((res instanceof Promise))) return [3 /*break*/, 3];
21009
21188
  return [4 /*yield*/, res];
21010
21189
  case 2:
21011
- _b = _c.sent();
21190
+ _c = _d.sent();
21012
21191
  return [3 /*break*/, 4];
21013
21192
  case 3:
21014
- _b = res;
21015
- _c.label = 4;
21193
+ _c = res;
21194
+ _d.label = 4;
21016
21195
  case 4:
21017
- data = _b;
21018
- _c.label = 5;
21196
+ data = _c;
21197
+ _d.label = 5;
21019
21198
  case 5:
21020
21199
  this.dataSubject.next(data);
21021
21200
  this.markAsDirty();
@@ -21032,7 +21211,7 @@
21032
21211
  return __awaiter(this, void 0, void 0, function () {
21033
21212
  var data, updatedData, deleteCount;
21034
21213
  var _this = this;
21035
- return __generator(this, function (_b) {
21214
+ return __generator(this, function (_c) {
21036
21215
  data = this.dataSubject.value;
21037
21216
  if (!data)
21038
21217
  throw new Error('[memory-service] Could not delete, because value not set');
@@ -21093,6 +21272,18 @@
21093
21272
  enumerable: false,
21094
21273
  configurable: true
21095
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
+ };
21096
21287
  /* -- protected methods -- */
21097
21288
  InMemoryEntitiesService.prototype.filter = function (data, _filter, hiddenData) {
21098
21289
  // if filter is DataFilter instance, use its test function
@@ -21118,9 +21309,14 @@
21118
21309
  }));
21119
21310
  };
21120
21311
  InMemoryEntitiesService.prototype.waitWhileSaving = function (opts) {
21121
- if (!this.saving)
21122
- return;
21123
- 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
+ });
21124
21320
  };
21125
21321
  InMemoryEntitiesService.prototype.markAsSaving = function () {
21126
21322
  if (!this.savingSubject.value) {
@@ -21143,7 +21339,7 @@
21143
21339
  }
21144
21340
  };
21145
21341
  return InMemoryEntitiesService;
21146
- }(StartableService));
21342
+ }(StartableObservableService));
21147
21343
  InMemoryEntitiesService.decorators = [
21148
21344
  { type: i0.Directive }
21149
21345
  ];
@@ -25855,8 +26051,8 @@
25855
26051
  _this._debug = false;
25856
26052
  _this._creating = false;
25857
26053
  _this._saving = false;
25858
- _this._stopWatching$ = new rxjs.Subject();
25859
26054
  _this._fetchMoreFn = null;
26055
+ _this._stopWatchSubject = new rxjs.Subject();
25860
26056
  _this.loadingSubject = new rxjs.BehaviorSubject(undefined);
25861
26057
  _this._entityName = removeEnd((new dataType()).__typename || 'UnknownVO', 'VO');
25862
26058
  _this._debug = (options === null || options === void 0 ? void 0 : options.suppressErrors) === false && !environment.production;
@@ -25914,16 +26110,28 @@
25914
26110
  enumerable: false,
25915
26111
  configurable: true
25916
26112
  });
26113
+ /**
26114
+ * @deprecated use disconnect
26115
+ */
25917
26116
  EntitiesTableDataSource.prototype.ngOnDestroy = function () {
25918
- this._stopWatching$.next();
25919
- this._stopWatching$.complete();
25920
- this._stopWatching$.unsubscribe();
25921
- this.loadingSubject.complete();
25922
- 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
+ }
25923
26131
  };
25924
26132
  EntitiesTableDataSource.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter) {
25925
26133
  var _this = this;
25926
- this._stopWatching$.next();
26134
+ this._stopWatchSubject.next();
25927
26135
  this._fetchMoreFn = null;
25928
26136
  this.markAsLoading();
25929
26137
  return this.dataService.watchAll(offset, size, sortBy, sortDirection, filter, this.serviceOptions)
@@ -25941,7 +26149,7 @@
25941
26149
  return res;
25942
26150
  }),
25943
26151
  // Stop this pipe next time we call watchAll()
25944
- operators.takeUntil(this._stopWatching$)
26152
+ operators.takeUntil(this._stopWatchSubject)
25945
26153
  // ⚠ Notice: Don't put any operator after takeUntil to avoid potential subscription leaks
25946
26154
  );
25947
26155
  };
@@ -26051,11 +26259,13 @@
26051
26259
  };
26052
26260
  EntitiesTableDataSource.prototype.connect = function (collectionViewer) {
26053
26261
  // DEBUG console.debug("[entities-datasource] connect");
26262
+ this.viewer = collectionViewer;
26054
26263
  return _super_1.prototype.connect.call(this, collectionViewer);
26055
26264
  };
26056
26265
  EntitiesTableDataSource.prototype.disconnect = function (collectionViewer) {
26266
+ console.debug('[table-datasource] Disconnecting...');
26057
26267
  _super_1.prototype.disconnect.call(this, collectionViewer);
26058
- this._stopWatching$.next();
26268
+ this.close();
26059
26269
  };
26060
26270
  EntitiesTableDataSource.prototype.waitIdle = function (debounceTimeMs) {
26061
26271
  return firstFalsePromise(this.loadingSubject
@@ -26736,7 +26946,6 @@
26736
26946
  };
26737
26947
  AppTable.prototype.ngOnDestroy = function () {
26738
26948
  var _this = this;
26739
- var _a;
26740
26949
  this._subscription.unsubscribe();
26741
26950
  // Unsubscribe column value changes
26742
26951
  Object.keys(this._cellValueChangesDefs).forEach(function (col) { return _this.stopCellValueChanges(col, true); });
@@ -26761,7 +26970,6 @@
26761
26970
  this.onError.unsubscribe();
26762
26971
  this.destroySubject.next();
26763
26972
  this.destroySubject.unsubscribe();
26764
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
26765
26973
  };
26766
26974
  AppTable.prototype.updateView = function (res, opts) {
26767
26975
  return __awaiter(this, void 0, void 0, function () {
@@ -26799,12 +27007,11 @@
26799
27007
  }
26800
27008
  };
26801
27009
  AppTable.prototype.resetDataSource = function () {
26802
- var _a;
26803
27010
  if (this._dataSourceLoadingSubscription) {
26804
27011
  this._dataSourceLoadingSubscription.unsubscribe();
26805
27012
  this._subscription.remove(this._dataSourceLoadingSubscription);
26806
27013
  }
26807
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
27014
+ //this._dataSource?.close();
26808
27015
  this._dataSource = null;
26809
27016
  };
26810
27017
  AppTable.prototype.addColumnDef = function (column) {
@@ -30431,7 +30638,7 @@
30431
30638
  };
30432
30639
 
30433
30640
  var moment$6 = momentImported__namespace;
30434
- var USER_EVENT_SERVICE = new i0.InjectionToken('UserEventService');
30641
+ var APP_USER_EVENT_SERVICE = new i0.InjectionToken('UserEventService');
30435
30642
  var AbstractUserEventService = /** @class */ (function (_super) {
30436
30643
  __extends(AbstractUserEventService, _super);
30437
30644
  function AbstractUserEventService(graphql, accountService, network, translate, options) {
@@ -31347,7 +31554,7 @@
31347
31554
  { type: i0.ChangeDetectorRef },
31348
31555
  { type: i1$5.PopoverController },
31349
31556
  { type: LocalSettingsService, decorators: [{ type: i0.Optional }] },
31350
- { 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,] }] }
31351
31558
  ]; };
31352
31559
  UserEventNotificationList.propDecorators = {
31353
31560
  debug: [{ type: i0.Input }],
@@ -31364,11 +31571,12 @@
31364
31571
  ionItems: [{ type: i0.ViewChildren, args: [i1$5.IonItem,] }]
31365
31572
  };
31366
31573
 
31367
- var AppUserEventNotificationIcon = /** @class */ (function () {
31368
- function AppUserEventNotificationIcon(userEventService, accountService, popoverController) {
31574
+ var UserEventNotificationIcon = /** @class */ (function () {
31575
+ function UserEventNotificationIcon(userEventService, accountService, popoverController, cd) {
31369
31576
  this.userEventService = userEventService;
31370
31577
  this.accountService = accountService;
31371
31578
  this.popoverController = popoverController;
31579
+ this.cd = cd;
31372
31580
  this.debug = false;
31373
31581
  this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
31374
31582
  this.disabled = false;
@@ -31377,18 +31585,25 @@
31377
31585
  this._readEvent = new i0.EventEmitter();
31378
31586
  this._readEvents = new i0.EventEmitter();
31379
31587
  }
31380
- Object.defineProperty(AppUserEventNotificationIcon.prototype, "countChanges", {
31588
+ Object.defineProperty(UserEventNotificationIcon.prototype, "countChanges", {
31381
31589
  get: function () {
31590
+ var _this = this;
31382
31591
  if (!this.userEventService)
31383
31592
  return rxjs.of();
31384
31593
  return this.userEventService
31385
31594
  .countSubject
31386
- .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; }));
31387
31602
  },
31388
31603
  enumerable: false,
31389
31604
  configurable: true
31390
31605
  });
31391
- AppUserEventNotificationIcon.prototype.ngOnInit = function () {
31606
+ UserEventNotificationIcon.prototype.ngOnInit = function () {
31392
31607
  return __awaiter(this, void 0, void 0, function () {
31393
31608
  var _this = this;
31394
31609
  return __generator(this, function (_a) {
@@ -31397,8 +31612,10 @@
31397
31612
  if (isNil(this.userEventService)) {
31398
31613
  console.warn(this._logPrefix + "No service injected");
31399
31614
  this.disabled = true;
31615
+ this.visible = false;
31400
31616
  return [2 /*return*/];
31401
31617
  }
31618
+ this.visible = toBoolean(this.visible, !this.autoHide);
31402
31619
  // Wait service
31403
31620
  return [4 /*yield*/, this.userEventService.ready()];
31404
31621
  case 1:
@@ -31417,7 +31634,7 @@
31417
31634
  });
31418
31635
  });
31419
31636
  };
31420
- AppUserEventNotificationIcon.prototype.showList = function (event) {
31637
+ UserEventNotificationIcon.prototype.showList = function (event) {
31421
31638
  return __awaiter(this, void 0, void 0, function () {
31422
31639
  var popover;
31423
31640
  return __generator(this, function (_a) {
@@ -31450,30 +31667,32 @@
31450
31667
  });
31451
31668
  });
31452
31669
  };
31453
- AppUserEventNotificationIcon.prototype.ngOnDestroy = function () {
31670
+ UserEventNotificationIcon.prototype.ngOnDestroy = function () {
31454
31671
  if (this.debug) {
31455
31672
  console.debug(this._logPrefix + "Destroying");
31456
31673
  }
31457
31674
  };
31458
- return AppUserEventNotificationIcon;
31675
+ return UserEventNotificationIcon;
31459
31676
  }());
31460
- AppUserEventNotificationIcon.decorators = [
31677
+ UserEventNotificationIcon.decorators = [
31461
31678
  { type: i0.Component, args: [{
31462
31679
  selector: 'app-user-event-notification-icon',
31463
- 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",
31464
31681
  changeDetection: i0.ChangeDetectionStrategy.OnPush
31465
31682
  },] }
31466
31683
  ];
31467
- AppUserEventNotificationIcon.ctorParameters = function () { return [
31468
- { 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,] }] },
31469
31686
  { type: AccountService },
31470
- { type: i1$5.PopoverController }
31687
+ { type: i1$5.PopoverController },
31688
+ { type: i0.ChangeDetectorRef }
31471
31689
  ]; };
31472
- AppUserEventNotificationIcon.propDecorators = {
31690
+ UserEventNotificationIcon.propDecorators = {
31473
31691
  debug: [{ type: i0.Input }],
31474
31692
  titleI18n: [{ type: i0.Input }],
31475
31693
  disabled: [{ type: i0.Input }],
31476
- filter: [{ type: i0.Input }]
31694
+ filter: [{ type: i0.Input }],
31695
+ autoHide: [{ type: i0.Input }]
31477
31696
  };
31478
31697
 
31479
31698
  var UserEventModule = /** @class */ (function () {
@@ -31490,11 +31709,11 @@
31490
31709
  ngxJdenticon.NgxJdenticonModule
31491
31710
  ],
31492
31711
  declarations: [
31493
- AppUserEventNotificationIcon,
31712
+ UserEventNotificationIcon,
31494
31713
  UserEventNotificationList
31495
31714
  ],
31496
31715
  exports: [
31497
- AppUserEventNotificationIcon
31716
+ UserEventNotificationIcon
31498
31717
  ]
31499
31718
  },] }
31500
31719
  ];
@@ -31782,8 +32001,10 @@
31782
32001
  EntityClass({ typename: 'JobProgressionVO' })
31783
32002
  ], exports.JobProgression);
31784
32003
 
31785
- var JobProgressionServiceToken = new i0.InjectionToken('JobProgressionService');
31786
- 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
+ };
31787
32008
  var JobProgressionService = /** @class */ (function (_super) {
31788
32009
  __extends(JobProgressionService, _super);
31789
32010
  function JobProgressionService(graphql, environment) {
@@ -31795,6 +32016,15 @@
31795
32016
  _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
31796
32017
  return _this;
31797
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
+ };
31798
32028
  JobProgressionService.prototype.listenChanges = function (id, options) {
31799
32029
  var _this = this;
31800
32030
  if (isNil(id))
@@ -31802,7 +32032,7 @@
31802
32032
  if (this._debug)
31803
32033
  console.debug(this._logPrefix + "[WS] Listening changes for job progression {" + id + "}...");
31804
32034
  return this.graphql.subscribe({
31805
- query: jobProgressionSubscription,
32035
+ query: QUERIES.listenChanges,
31806
32036
  fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
31807
32037
  variables: { id: id, interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
31808
32038
  error: { code: SocialErrorCodes.SUBSCRIBE_JOB_PROGRESSION_ERROR, message: 'SOCIAL.ERROR.SUBSCRIBE_JOB_PROGRESSION_ERROR' }
@@ -31845,8 +32075,8 @@
31845
32075
  jobProgressions: [{ type: i0.Input }]
31846
32076
  };
31847
32077
 
31848
- var JobProgressionComponent = /** @class */ (function () {
31849
- function JobProgressionComponent(jobProgressionService, popoverController, cd) {
32078
+ var JobProgressionIcon = /** @class */ (function () {
32079
+ function JobProgressionIcon(jobProgressionService, popoverController, cd) {
31850
32080
  this.jobProgressionService = jobProgressionService;
31851
32081
  this.popoverController = popoverController;
31852
32082
  this.cd = cd;
@@ -31862,19 +32092,24 @@
31862
32092
  this._subscriptionsById = {};
31863
32093
  this._logPrefix = '[job-progression] ';
31864
32094
  }
31865
- JobProgressionComponent.prototype.ngOnInit = function () {
32095
+ JobProgressionIcon.prototype.ngOnInit = function () {
32096
+ var _this = this;
31866
32097
  var _a, _b, _c, _d;
31867
32098
  if (isNil(this.jobProgressionService)) {
31868
32099
  console.warn(this._logPrefix + "No service injected");
31869
32100
  }
31870
32101
  // parse options
31871
- 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);
31872
32103
  this.visible = !this.autoHide;
31873
32104
  this.autoHideDelay = toNumber((_b = this.options) === null || _b === void 0 ? void 0 : _b.autoHideDelay, 1000);
31874
32105
  this.autoRemove = toBoolean((_c = this.options) === null || _c === void 0 ? void 0 : _c.autoRemove, true);
31875
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
+ }));
31876
32111
  };
31877
- JobProgressionComponent.prototype.addJob = function (id) {
32112
+ JobProgressionIcon.prototype.addJob = function (id, job) {
31878
32113
  var _this = this;
31879
32114
  if (isNil(this.jobProgressionService)) {
31880
32115
  console.warn(this._logPrefix + "No service injected. Can't add a job");
@@ -31888,8 +32123,11 @@
31888
32123
  console.debug(this._logPrefix + "Add job id=" + id);
31889
32124
  }
31890
32125
  // Adding empty job progression
31891
- var progression = new exports.JobProgression(id);
31892
- 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
+ }
31893
32131
  this.disabled = false;
31894
32132
  var sub = this.jobProgressionService.listenChanges(id)
31895
32133
  .pipe(operators.filter(function (progression) {
@@ -31952,7 +32190,7 @@
31952
32190
  this._subscriptionsById[id] = sub;
31953
32191
  this._subscriptions.add(sub);
31954
32192
  };
31955
- JobProgressionComponent.prototype.removeJob = function (id) {
32193
+ JobProgressionIcon.prototype.removeJob = function (id) {
31956
32194
  if (this.debug) {
31957
32195
  console.debug(this._logPrefix + "Remove job id=" + id);
31958
32196
  }
@@ -31967,10 +32205,10 @@
31967
32205
  }
31968
32206
  this.updateValue();
31969
32207
  };
31970
- JobProgressionComponent.prototype.getProgression = function (id) {
32208
+ JobProgressionIcon.prototype.getProgression = function (id) {
31971
32209
  return this.jobProgressions.find(function (progression) { return progression.id === id; });
31972
32210
  };
31973
- JobProgressionComponent.prototype.updateValue = function () {
32211
+ JobProgressionIcon.prototype.updateValue = function () {
31974
32212
  if (this.debug) {
31975
32213
  console.debug(this._logPrefix + "Updating value");
31976
32214
  }
@@ -31991,7 +32229,7 @@
31991
32229
  }
31992
32230
  this.markForCheck();
31993
32231
  };
31994
- JobProgressionComponent.prototype.showList = function (event) {
32232
+ JobProgressionIcon.prototype.showList = function (event) {
31995
32233
  return __awaiter(this, void 0, void 0, function () {
31996
32234
  var _e;
31997
32235
  return __generator(this, function (_f) {
@@ -32024,34 +32262,35 @@
32024
32262
  });
32025
32263
  });
32026
32264
  };
32027
- JobProgressionComponent.prototype.markForCheck = function () {
32265
+ JobProgressionIcon.prototype.markForCheck = function () {
32028
32266
  this.cd.markForCheck();
32029
32267
  };
32030
- JobProgressionComponent.prototype.ngOnDestroy = function () {
32268
+ JobProgressionIcon.prototype.ngOnDestroy = function () {
32031
32269
  if (this.debug) {
32032
32270
  console.debug(this._logPrefix + "Destroying");
32033
32271
  }
32034
32272
  this._subscriptions.unsubscribe();
32035
32273
  };
32036
- return JobProgressionComponent;
32274
+ return JobProgressionIcon;
32037
32275
  }());
32038
- JobProgressionComponent.decorators = [
32276
+ JobProgressionIcon.decorators = [
32039
32277
  { type: i0.Component, args: [{
32040
- selector: 'app-job-progression',
32278
+ selector: 'app-job-progression-icon',
32041
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",
32042
32280
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
32043
32281
  styles: [".floating-spinner{position:absolute;top:6px;left:5px}"]
32044
32282
  },] }
32045
32283
  ];
32046
- JobProgressionComponent.ctorParameters = function () { return [
32047
- { 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,] }] },
32048
32286
  { type: i1$5.PopoverController },
32049
32287
  { type: i0.ChangeDetectorRef }
32050
32288
  ]; };
32051
- JobProgressionComponent.propDecorators = {
32289
+ JobProgressionIcon.propDecorators = {
32052
32290
  debug: [{ type: i0.Input }],
32053
32291
  titleI18n: [{ type: i0.Input }],
32054
32292
  options: [{ type: i0.Input }],
32293
+ autoHide: [{ type: i0.Input }],
32055
32294
  jobFinished: [{ type: i0.Output }]
32056
32295
  };
32057
32296
 
@@ -32068,11 +32307,11 @@
32068
32307
  i1$2.TranslateModule.forChild(),
32069
32308
  ],
32070
32309
  declarations: [
32071
- JobProgressionComponent,
32310
+ JobProgressionIcon,
32072
32311
  JobProgressionList
32073
32312
  ],
32074
32313
  exports: [
32075
- JobProgressionComponent
32314
+ JobProgressionIcon
32076
32315
  ]
32077
32316
  },] }
32078
32317
  ];
@@ -33937,7 +34176,7 @@
33937
34176
  console.debug('[test-table] Destroying table...');
33938
34177
  _super_1.prototype.ngOnDestroy.call(this);
33939
34178
  this.stopTimer();
33940
- this.dataService.stop();
34179
+ //this.dataService.stop();
33941
34180
  };
33942
34181
  TableTestPage.prototype.restoreFilter = function () {
33943
34182
  var json = this.settings.getPageSettings(this.settingsId, 'filter');
@@ -34242,79 +34481,51 @@
34242
34481
  },] }
34243
34482
  ];
34244
34483
 
34245
- var JobProgressionTestService = /** @class */ (function () {
34246
- function JobProgressionTestService() {
34247
- }
34248
- JobProgressionTestService.prototype.listenChanges = function (id, options) {
34249
- return rxjs.interval(100).pipe(operators.take(111), operators.map(function (value) {
34250
- if (value <= 10) {
34251
- return {
34252
- id: id,
34253
- name: "Job #" + id,
34254
- current: 0,
34255
- total: 0,
34256
- message: "Progression pending"
34257
- };
34258
- }
34259
- value = value - 10;
34260
- return {
34261
- id: id,
34262
- name: "Job #" + id,
34263
- current: value,
34264
- total: 100,
34265
- message: "Progression " + value + "/100"
34266
- };
34267
- }));
34268
- };
34269
- return JobProgressionTestService;
34270
- }());
34271
- JobProgressionTestService.decorators = [
34272
- { type: i0.Injectable }
34273
- ];
34274
-
34275
34484
  var JobProgressionTestingPage = /** @class */ (function () {
34276
- function JobProgressionTestingPage() {
34277
- this.nJob = 0;
34485
+ function JobProgressionTestingPage(jobProgressionService) {
34486
+ this.jobProgressionService = jobProgressionService;
34487
+ this.jobId = 0;
34488
+ this.job = null;
34278
34489
  this.options = {
34279
34490
  autoHide: true
34280
34491
  };
34281
- this.job = new exports.JobProgression();
34282
- this.job.id = 0;
34283
- this.job.name = 'test';
34284
- this.job.current = 0;
34285
- this.job.total = 100;
34286
34492
  }
34287
34493
  JobProgressionTestingPage.prototype.incrementJob = function (value) {
34288
- this.job.current = Math.max(0, this.job.current + value);
34494
+ this.job = this.job || this.createJob();
34495
+ this.job.current += value || 0;
34289
34496
  this.job.message = "Fake progression (very long message very long message very long message very long message) " + this.job.current + "/100";
34290
34497
  if (this.job.current > this.job.total) {
34291
- this.jobProgression.removeJob(0);
34498
+ this.jobProgressionService.removeJob(this.job.id);
34292
34499
  this.job.current = 0;
34500
+ this.job = null; // Forget the job
34293
34501
  }
34294
- else if (!this.jobProgression.getProgression(0)) {
34295
- this.jobProgression.jobProgressions.push(this.job);
34296
- }
34297
- this.jobProgression.updateValue();
34502
+ this.jobProgressionIcon.updateValue();
34298
34503
  };
34299
34504
  JobProgressionTestingPage.prototype.addJob = function () {
34300
- // Add fake job
34301
- this.nJob++;
34302
- 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;
34303
34515
  };
34304
34516
  return JobProgressionTestingPage;
34305
34517
  }());
34306
34518
  JobProgressionTestingPage.decorators = [
34307
34519
  { type: i0.Component, args: [{
34308
34520
  selector: 'job-progression-testing',
34309
- 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",
34310
- providers: [
34311
- { provide: JobProgressionServiceToken, useClass: JobProgressionTestService }
34312
- ]
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"
34313
34522
  },] }
34314
34523
  ];
34315
- JobProgressionTestingPage.ctorParameters = function () { return []; };
34524
+ JobProgressionTestingPage.ctorParameters = function () { return [
34525
+ { type: JobProgressionService, decorators: [{ type: i0.Inject, args: [APP_JOB_PROGRESSION_SERVICE,] }] }
34526
+ ]; };
34316
34527
  JobProgressionTestingPage.propDecorators = {
34317
- jobProgression: [{ type: i0.ViewChild, args: ['jobProgression',] }]
34528
+ jobProgressionIcon: [{ type: i0.ViewChild, args: ['icon',] }]
34318
34529
  };
34319
34530
 
34320
34531
  var JobTestingModule = /** @class */ (function () {
@@ -34804,7 +35015,7 @@
34804
35015
  },] }
34805
35016
  ];
34806
35017
  UserEventTestingPage.ctorParameters = function () { return [
34807
- { type: UserEventTestService, decorators: [{ type: i0.Inject, args: [USER_EVENT_SERVICE,] }] },
35018
+ { type: UserEventTestService, decorators: [{ type: i0.Inject, args: [APP_USER_EVENT_SERVICE,] }] },
34808
35019
  { type: i3.Router },
34809
35020
  { type: i1$5.AlertController },
34810
35021
  { type: i1$2.TranslateService }
@@ -34869,6 +35080,55 @@
34869
35080
  },] }
34870
35081
  ];
34871
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
+
34872
35132
  // Environment
34873
35133
 
34874
35134
  /**
@@ -34881,6 +35141,7 @@
34881
35141
  exports.APP_FORM_ERROR_I18N_KEYS = APP_FORM_ERROR_I18N_KEYS;
34882
35142
  exports.APP_GRAPHQL_TYPE_POLICIES = APP_GRAPHQL_TYPE_POLICIES;
34883
35143
  exports.APP_HOME_BUTTONS = APP_HOME_BUTTONS;
35144
+ exports.APP_JOB_PROGRESSION_SERVICE = APP_JOB_PROGRESSION_SERVICE;
34884
35145
  exports.APP_LOCALES = APP_LOCALES;
34885
35146
  exports.APP_LOCAL_SETTINGS = APP_LOCAL_SETTINGS;
34886
35147
  exports.APP_LOCAL_SETTINGS_OPTIONS = APP_LOCAL_SETTINGS_OPTIONS;
@@ -34888,6 +35149,7 @@
34888
35149
  exports.APP_MENU_ITEMS = APP_MENU_ITEMS;
34889
35150
  exports.APP_MENU_OPTIONS = APP_MENU_OPTIONS;
34890
35151
  exports.APP_TESTING_PAGES = APP_TESTING_PAGES;
35152
+ exports.APP_USER_EVENT_SERVICE = APP_USER_EVENT_SERVICE;
34891
35153
  exports.AboutModal = AboutModal;
34892
35154
  exports.AbstractUserEventService = AbstractUserEventService;
34893
35155
  exports.AccountPage = AccountPage;
@@ -34923,7 +35185,6 @@
34923
35185
  exports.AppTabEditorOptions = AppTabEditorOptions;
34924
35186
  exports.AppTable = AppTable;
34925
35187
  exports.AppTableUtils = AppTableUtils;
34926
- exports.AppUserEventNotificationIcon = AppUserEventNotificationIcon;
34927
35188
  exports.AppValidatorService = AppValidatorService;
34928
35189
  exports.AppendToInputDirective = AppendToInputDirective;
34929
35190
  exports.ArrayFilterPipe = ArrayFilterPipe;
@@ -35022,9 +35283,9 @@
35022
35283
  exports.IsOnFieldModePipe = IsOnFieldModePipe;
35023
35284
  exports.Job = Job;
35024
35285
  exports.JobModule = JobModule;
35025
- exports.JobProgressionComponent = JobProgressionComponent;
35286
+ exports.JobProgressionIcon = JobProgressionIcon;
35287
+ exports.JobProgressionList = JobProgressionList;
35026
35288
  exports.JobProgressionService = JobProgressionService;
35027
- exports.JobProgressionServiceToken = JobProgressionServiceToken;
35028
35289
  exports.JobProgressionTestService = JobProgressionTestService;
35029
35290
  exports.JobProgressionTestingPage = JobProgressionTestingPage;
35030
35291
  exports.JobTestingModule = JobTestingModule;
@@ -35159,7 +35420,6 @@
35159
35420
  exports.TranslatablePipe = TranslatablePipe;
35160
35421
  exports.TranslateContextPipe = TranslateContextPipe;
35161
35422
  exports.TranslateContextService = TranslateContextService;
35162
- exports.USER_EVENT_SERVICE = USER_EVENT_SERVICE;
35163
35423
  exports.UploadFile = UploadFile;
35164
35424
  exports.UploadFileComponent = UploadFileComponent;
35165
35425
  exports.UploadFilePopover = UploadFilePopover;
@@ -35167,6 +35427,7 @@
35167
35427
  exports.UploadFileTestingPage = UploadFileTestingPage;
35168
35428
  exports.UriUtils = UriUtils;
35169
35429
  exports.UserEventModule = UserEventModule;
35430
+ exports.UserEventNotificationIcon = UserEventNotificationIcon;
35170
35431
  exports.UserEventTestService = UserEventTestService;
35171
35432
  exports.UserEventTestingModule = UserEventTestingModule;
35172
35433
  exports.UserEventTestingPage = UserEventTestingPage;
@@ -35325,15 +35586,15 @@
35325
35586
  exports.ɵ0 = ɵ0;
35326
35587
  exports.ɵa = CustomReuseStrategy;
35327
35588
  exports.ɵb = MatNumpadDomService;
35328
- exports.ɵc = isFocusableElement;
35329
- exports.ɵd = RegisterForm;
35330
- exports.ɵe = AccountValidatorService;
35331
- exports.ɵf = RegisterModal;
35332
- exports.ɵg = UserSettingsValidatorService;
35333
- exports.ɵh = LocalSettingsValidatorService;
35334
- exports.ɵi = AppUpdateOfflineModeCard;
35335
- exports.ɵj = UserEventNotificationList;
35336
- 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;
35337
35598
  exports.ɵl = DateTestPage;
35338
35599
  exports.ɵm = NumpadTestPage;
35339
35600
  exports.ɵn = MatBadgeIconTestPage;