@sumaris-net/ngx-components 1.8.0 → 1.9.1

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 (36) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +211 -196
  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/doc/changelog.md +7 -2
  6. package/esm2015/public_api.js +2 -1
  7. package/esm2015/src/app/admin/users/list/users.js +5 -22
  8. package/esm2015/src/app/core/form/entity-editor.class.js +5 -1
  9. package/esm2015/src/app/core/home/home.js +2 -2
  10. package/esm2015/src/app/core/services/account.service.js +38 -27
  11. package/esm2015/src/app/core/services/base-entity-service.class.js +2 -2
  12. package/esm2015/src/app/core/services/local-settings.service.js +18 -14
  13. package/esm2015/src/app/core/services/model/settings.model.js +1 -1
  14. package/esm2015/src/app/core/services/platform.service.js +35 -31
  15. package/esm2015/src/app/core/table/memory-table.class.js +2 -7
  16. package/esm2015/src/app/core/table/table.class.js +21 -24
  17. package/esm2015/src/app/shared/directives/autofocus.directive.js +15 -24
  18. package/esm2015/src/app/shared/platforms.js +36 -0
  19. package/esm2015/src/app/shared/services/progress-bar.service.js +1 -1
  20. package/esm2015/src/app/social/list/user-events.table.js +3 -8
  21. package/fesm2015/sumaris-net.ngx-components.js +165 -135
  22. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  23. package/package.json +1 -1
  24. package/public_api.d.ts +1 -0
  25. package/src/app/admin/users/list/users.d.ts +1 -12
  26. package/src/app/core/form/entity-editor.class.d.ts +1 -1
  27. package/src/app/core/services/account.service.d.ts +2 -0
  28. package/src/app/core/services/local-settings.service.d.ts +0 -2
  29. package/src/app/core/services/model/settings.model.d.ts +0 -1
  30. package/src/app/core/services/platform.service.d.ts +8 -5
  31. package/src/app/core/table/memory-table.class.d.ts +0 -1
  32. package/src/app/core/table/table.class.d.ts +7 -9
  33. package/src/app/shared/directives/autofocus.directive.d.ts +4 -5
  34. package/src/app/shared/platforms.d.ts +13 -0
  35. package/src/app/social/list/user-events.table.d.ts +0 -1
  36. package/sumaris-net.ngx-components.metadata.json +1 -1
@@ -1279,7 +1279,7 @@
1279
1279
  return MatAutocompleteConfigHolder;
1280
1280
  }());
1281
1281
  var noop$8 = function (_) { };
1282
- var ɵ0$b = noop$8;
1282
+ var ɵ0$c = noop$8;
1283
1283
  var MatAutocompleteField = /** @class */ (function () {
1284
1284
  function MatAutocompleteField(cd, formGroupDir) {
1285
1285
  this.cd = cd;
@@ -4469,27 +4469,56 @@
4469
4469
  },] }
4470
4470
  ];
4471
4471
 
4472
+ /* ---
4473
+ * Source: https://github.com/ionic-team/ionic-framework/blob/b0d53ca73619585671d8cf4dc24e47f826495a0a/core/src/utils/platform.ts
4474
+ * --- */
4475
+ var matchMedia = function (win, query) { return win.matchMedia(query).matches; };
4476
+ var testUserAgent = function (win, expr) {
4477
+ var userAgent = win.navigator.userAgent || win.navigator.vendor || window.opera;
4478
+ return expr.test(userAgent);
4479
+ };
4480
+ var isWindow = function (win) {
4481
+ var userAgent = win.navigator.userAgent || win.navigator.vendor || window.opera;
4482
+ return /windows/i.test(userAgent);
4483
+ };
4484
+ /**
4485
+ * Detect desktop, by fine cursor. See https://github.com/ionic-team/ionic-framework/issues/19942
4486
+ * @param win
4487
+ */
4488
+ var isDesktop = function (win) { return matchMedia(win, '(any-pointer:fine)'); };
4489
+ var isTouchUi = function (win) { return matchMedia(win, '(any-pointer:coarse)'); };
4490
+ var isMobile = function (win) { return isTouchUi(win) && !isDesktop(win); };
4491
+ var isIpad = function (win) {
4492
+ // iOS 12 and below
4493
+ if (testUserAgent(win, /iPad/i)) {
4494
+ return true;
4495
+ }
4496
+ // iOS 13+
4497
+ if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
4498
+ return true;
4499
+ }
4500
+ return false;
4501
+ };
4502
+ var ɵ0$b = isIpad;
4503
+ var isIOS = function (win) { return testUserAgent(win, /iPhone|iPod/i) || isIpad(win); };
4504
+ var isAndroid = function (win) { return testUserAgent(win, /android|sink/i); };
4505
+ var isCordova = function (win) { return !!(win['cordova'] || win['phonegap'] || win['PhoneGap']); };
4506
+
4472
4507
  // Import the core angular services.
4473
4508
  // ----------------------------------------------------------------------------------- //
4474
4509
  // ----------------------------------------------------------------------------------- //
4475
4510
  var BASE_TIMER_DELAY = 100;
4476
4511
  var AutofocusDirective = /** @class */ (function () {
4477
4512
  // I initialize the autofocus directive.
4478
- function AutofocusDirective(elementRef, platform, keyboard) {
4479
- var _this = this;
4513
+ function AutofocusDirective(elementRef, keyboard) {
4480
4514
  this.keyboard = keyboard;
4481
- this.timer = null;
4482
- this.elementRef = elementRef;
4515
+ this._timer = null;
4516
+ this._elementRef = elementRef;
4483
4517
  this.shouldFocusElement = '';
4484
- this.timer = null;
4518
+ this._timer = null;
4485
4519
  this.timerDelay = BASE_TIMER_DELAY;
4486
- platform.ready().then(function () {
4487
- _this.touchUi = platform.is('mobile') || platform.is('tablet');
4488
- });
4520
+ this._mobile = isMobile(window);
4489
4521
  }
4490
- // ---
4491
- // PUBLIC METHODS.
4492
- // ---
4493
4522
  // I get called once after the contents have been fully initialized.
4494
4523
  AutofocusDirective.prototype.ngAfterContentInit = function () {
4495
4524
  // Because this directive can act on the stand-only "autofocus" attribute or
@@ -4524,30 +4553,27 @@
4524
4553
  AutofocusDirective.prototype.ngOnDestroy = function () {
4525
4554
  this.stopFocusWorkflow();
4526
4555
  };
4527
- // ---
4528
- // PRIVATE METHODS.
4529
- // ---
4556
+ /* --- private functions -- */
4530
4557
  // I start the timer-based workflow that will focus the current element.
4531
4558
  AutofocusDirective.prototype.startFocusWorkflow = function () {
4532
4559
  var _this = this;
4533
4560
  // if touch UI: do NOT focus when keyboard hide
4534
- if (this.touchUi && this.keyboard && this.keyboard.isVisible === false)
4561
+ if (this._mobile && this.keyboard && this.keyboard.isVisible === false)
4535
4562
  return;
4536
4563
  // If there is already a timer running for this element, just let it play out -
4537
4564
  // resetting it at this point will only push-out the time at which the focus is
4538
4565
  // applied to the element.
4539
- if (this.timer) {
4566
+ if (this._timer)
4540
4567
  return;
4541
- }
4542
- this.timer = setTimeout(function () {
4543
- _this.timer = null;
4544
- _this.elementRef.nativeElement.focus();
4568
+ this._timer = setTimeout(function () {
4569
+ _this._timer = null;
4570
+ _this._elementRef.nativeElement.focus();
4545
4571
  }, this.timerDelay);
4546
4572
  };
4547
4573
  // I stop the timer-based workflow, preventing focus from taking place.
4548
4574
  AutofocusDirective.prototype.stopFocusWorkflow = function () {
4549
- clearTimeout(this.timer);
4550
- this.timer = null;
4575
+ clearTimeout(this._timer);
4576
+ this._timer = null;
4551
4577
  };
4552
4578
  return AutofocusDirective;
4553
4579
  }());
@@ -4562,7 +4588,6 @@
4562
4588
  ];
4563
4589
  AutofocusDirective.ctorParameters = function () { return [
4564
4590
  { type: i0.ElementRef },
4565
- { type: i1$5.Platform },
4566
4591
  { type: ngx.Keyboard, decorators: [{ type: i0.Optional }] }
4567
4592
  ]; };
4568
4593
 
@@ -11244,7 +11269,7 @@
11244
11269
 
11245
11270
  var moment$3 = momentImported__namespace;
11246
11271
  var SETTINGS_STORAGE_KEY = 'settings';
11247
- var SETTINGS_TRANSIENT_PROPERTIES = ['mobile', 'touchUi'];
11272
+ var SETTINGS_TRANSIENT_PROPERTIES = ['mobile', 'touchUi' /*deprecated*/];
11248
11273
  // fixme: this constant points to static environment
11249
11274
  var DEFAULT_SETTINGS = {
11250
11275
  accountInheritance: true,
@@ -11295,14 +11320,24 @@
11295
11320
  });
11296
11321
  Object.defineProperty(LocalSettingsService.prototype, "usageMode", {
11297
11322
  get: function () {
11298
- return (this._data && this._data.usageMode || (this.mobile ? 'FIELD' : 'DESK'));
11323
+ var _a;
11324
+ if (isNil((_a = this._data) === null || _a === void 0 ? void 0 : _a.mobile)) {
11325
+ console.warn("[settings] Accessing to property 'usageMode' BEFORE service started! Please use ready()");
11326
+ return isCordova(window) ? 'FIELD' : 'DESK';
11327
+ }
11328
+ return this._data.usageMode;
11299
11329
  },
11300
11330
  enumerable: false,
11301
11331
  configurable: true
11302
11332
  });
11303
11333
  Object.defineProperty(LocalSettingsService.prototype, "mobile", {
11304
11334
  get: function () {
11305
- return this._data && toBoolean(this._data.mobile, this.platform.is('mobile'));
11335
+ var _a;
11336
+ if (isNil((_a = this._data) === null || _a === void 0 ? void 0 : _a.mobile)) {
11337
+ console.warn("[settings] Accessing to property 'mobile' BEFORE service started! Please use ready()");
11338
+ return isMobile(window);
11339
+ }
11340
+ return this._data.mobile;
11306
11341
  },
11307
11342
  set: function (value) {
11308
11343
  this._data.mobile = value;
@@ -11310,16 +11345,6 @@
11310
11345
  enumerable: false,
11311
11346
  configurable: true
11312
11347
  });
11313
- Object.defineProperty(LocalSettingsService.prototype, "touchUi", {
11314
- get: function () {
11315
- return this._data.touchUi;
11316
- },
11317
- set: function (value) {
11318
- this._data.touchUi = value;
11319
- },
11320
- enumerable: false,
11321
- configurable: true
11322
- });
11323
11348
  Object.defineProperty(LocalSettingsService.prototype, "pageHistory", {
11324
11349
  get: function () {
11325
11350
  return (this._data && this._data.pageHistory || []);
@@ -11330,9 +11355,8 @@
11330
11355
  LocalSettingsService.prototype.ngOnStart = function () {
11331
11356
  console.info('[settings] Starting service...');
11332
11357
  // Restoring local settings
11333
- this._data.mobile = toBoolean(this._data.mobile, this.platform.is('mobile'));
11334
- this._data.touchUi = this._data.mobile || this.platform.is('phablet') || this.platform.is('tablet');
11335
- this._data.usageMode = this.platform.is('android') || this.platform.is('ios') ? 'FIELD' : 'DESK'; // FIELD by default if Android or iOs
11358
+ this._data.mobile = isNotNil(this._data.mobile) ? this._data.mobile : isMobile(window);
11359
+ this._data.usageMode = (isAndroid(window) || isIOS(window)) ? 'FIELD' : 'DESK'; // FIELD by default if Android or iOS
11336
11360
  // Restoring local settings
11337
11361
  return this.restoreLocally();
11338
11362
  };
@@ -11345,13 +11369,13 @@
11345
11369
  LocalSettingsService.prototype.restoreLocally = function () {
11346
11370
  return __awaiter(this, void 0, void 0, function () {
11347
11371
  var data, settingsStr, restoredData_1;
11348
- return __generator(this, function (_a) {
11349
- switch (_a.label) {
11372
+ return __generator(this, function (_b) {
11373
+ switch (_b.label) {
11350
11374
  case 0:
11351
11375
  data = this._data || {};
11352
11376
  return [4 /*yield*/, this.storage.get(SETTINGS_STORAGE_KEY)];
11353
11377
  case 1:
11354
- settingsStr = _a.sent();
11378
+ settingsStr = _b.sent();
11355
11379
  // Restore local settings (or keep old settings)
11356
11380
  if (isNotNilOrBlank(settingsStr)) {
11357
11381
  console.info('[settings] Restoring previous settings...');
@@ -11408,14 +11432,14 @@
11408
11432
  LocalSettingsService.prototype.apply = function (settings, opts) {
11409
11433
  return __awaiter(this, void 0, void 0, function () {
11410
11434
  var data;
11411
- return __generator(this, function (_a) {
11412
- switch (_a.label) {
11435
+ return __generator(this, function (_b) {
11436
+ switch (_b.label) {
11413
11437
  case 0:
11414
11438
  if (!!this.started) return [3 /*break*/, 2];
11415
11439
  return [4 /*yield*/, this.ready()];
11416
11440
  case 1:
11417
- _a.sent();
11418
- _a.label = 2;
11441
+ _b.sent();
11442
+ _b.label = 2;
11419
11443
  case 2:
11420
11444
  data = Object.assign(Object.assign({}, this._data), settings);
11421
11445
  if (equals(data, this._data))
@@ -11424,11 +11448,11 @@
11424
11448
  if (!(opts && opts.persistImmediate)) return [3 /*break*/, 4];
11425
11449
  return [4 /*yield*/, this.persistLocally(true)];
11426
11450
  case 3:
11427
- _a.sent();
11451
+ _b.sent();
11428
11452
  return [3 /*break*/, 5];
11429
11453
  case 4:
11430
11454
  this.persistLocally(); // No AWAIT
11431
- _a.label = 5;
11455
+ _b.label = 5;
11432
11456
  case 5:
11433
11457
  // Emit event
11434
11458
  if (!opts || opts.emitEvent !== false) {
@@ -11442,14 +11466,14 @@
11442
11466
  LocalSettingsService.prototype.applyProperty = function (key, value, opts) {
11443
11467
  return __awaiter(this, void 0, void 0, function () {
11444
11468
  var changes;
11445
- return __generator(this, function (_a) {
11446
- switch (_a.label) {
11469
+ return __generator(this, function (_b) {
11470
+ switch (_b.label) {
11447
11471
  case 0:
11448
11472
  changes = {};
11449
11473
  changes[key] = value;
11450
11474
  return [4 /*yield*/, this.apply(changes, opts)];
11451
11475
  case 1:
11452
- _a.sent();
11476
+ _b.sent();
11453
11477
  return [2 /*return*/];
11454
11478
  }
11455
11479
  });
@@ -11467,7 +11491,7 @@
11467
11491
  LocalSettingsService.prototype.savePageSetting = function (pageId, value, propertyName) {
11468
11492
  return __awaiter(this, void 0, void 0, function () {
11469
11493
  var key;
11470
- return __generator(this, function (_a) {
11494
+ return __generator(this, function (_b) {
11471
11495
  this._data = this._data || this.defaultSettings;
11472
11496
  this._data.pages = this._data.pages || {};
11473
11497
  key = pageId.replace(/[/]/g, '__');
@@ -11593,8 +11617,8 @@
11593
11617
  ) {
11594
11618
  return __awaiter(this, void 0, void 0, function () {
11595
11619
  var index, existingPage, removedPages;
11596
- return __generator(this, function (_a) {
11597
- switch (_a.label) {
11620
+ return __generator(this, function (_b) {
11621
+ switch (_b.label) {
11598
11622
  case 0:
11599
11623
  // If not inside recursive call: fill page history defaults
11600
11624
  if (!pageHistory)
@@ -11631,8 +11655,8 @@
11631
11655
  return [4 /*yield*/, this.addToPageHistory(page, opts, existingPage.children)];
11632
11656
  case 3:
11633
11657
  // Add page as parent's children (recursive call)
11634
- _a.sent();
11635
- _a.label = 4;
11658
+ _b.sent();
11659
+ _b.label = 4;
11636
11660
  case 4:
11637
11661
  if (!(pageHistory === this._data.pageHistory)) return [3 /*break*/, 6];
11638
11662
  // If max has been reached, remove old pages
@@ -11644,8 +11668,8 @@
11644
11668
  return [4 /*yield*/, this.applyProperty('pageHistory', pageHistory)];
11645
11669
  case 5:
11646
11670
  // Apply new value
11647
- _a.sent();
11648
- _a.label = 6;
11671
+ _b.sent();
11672
+ _b.label = 6;
11649
11673
  case 6: return [2 /*return*/];
11650
11674
  }
11651
11675
  });
@@ -11656,8 +11680,8 @@
11656
11680
  return __awaiter(this, void 0, void 0, function () {
11657
11681
  var index, found;
11658
11682
  var _this = this;
11659
- return __generator(this, function (_a) {
11660
- switch (_a.label) {
11683
+ return __generator(this, function (_b) {
11684
+ switch (_b.label) {
11661
11685
  case 0:
11662
11686
  pageHistory = pageHistory || this._data.pageHistory;
11663
11687
  index = pageHistory.findIndex(function (p) { return p.path === path; });
@@ -11679,8 +11703,8 @@
11679
11703
  return [4 /*yield*/, this.applyProperty('pageHistory', this._data.pageHistory)];
11680
11704
  case 1:
11681
11705
  // Apply changes
11682
- _a.sent();
11683
- _a.label = 2;
11706
+ _b.sent();
11707
+ _b.label = 2;
11684
11708
  case 2: return [2 /*return*/, found];
11685
11709
  }
11686
11710
  });
@@ -11688,14 +11712,14 @@
11688
11712
  };
11689
11713
  LocalSettingsService.prototype.clearPageHistory = function () {
11690
11714
  return __awaiter(this, void 0, void 0, function () {
11691
- return __generator(this, function (_a) {
11692
- switch (_a.label) {
11715
+ return __generator(this, function (_b) {
11716
+ switch (_b.label) {
11693
11717
  case 0:
11694
11718
  // Reset all page history
11695
11719
  return [4 /*yield*/, this.applyProperty('pageHistory', [], { persistImmediate: true })];
11696
11720
  case 1:
11697
11721
  // Reset all page history
11698
- _a.sent();
11722
+ _b.sent();
11699
11723
  return [2 /*return*/];
11700
11724
  }
11701
11725
  });
@@ -15419,6 +15443,7 @@
15419
15443
  _this.onChange = new rxjs.Subject();
15420
15444
  _this.onAuthTokenChange = new rxjs.Subject();
15421
15445
  _this.onAuthBasicChange = new rxjs.Subject();
15446
+ _this._stopWatching$ = new rxjs.Subject();
15422
15447
  _this._cache = {
15423
15448
  loaded: false,
15424
15449
  keypair: null,
@@ -15945,6 +15970,7 @@
15945
15970
  if (hadAuthBasic)
15946
15971
  this.onAuthBasicChange.next(undefined);
15947
15972
  this.onChange.next(undefined);
15973
+ this._stopWatching$.next();
15948
15974
  return [2 /*return*/];
15949
15975
  }
15950
15976
  });
@@ -16104,13 +16130,18 @@
16104
16130
  });
16105
16131
  });
16106
16132
  };
16107
- AccountService.prototype.listenChanges = function () {
16133
+ AccountService.prototype.watch = function () {
16108
16134
  var _this = this;
16109
16135
  if (!this._cache.pubkey)
16110
- return rxjs.Subscription.EMPTY;
16111
- var self = this;
16112
- console.debug('[account] [WS] Listening changes');
16113
- var subscription = this.graphql.subscribe({
16136
+ throw new Error('Not logged in');
16137
+ if (!this.started) {
16138
+ // Wait service ready, then loop
16139
+ return rxjs.from(this.ready())
16140
+ .pipe(operators.switchMap(function () { return _this.watch(); }));
16141
+ }
16142
+ this._stopWatching$.next(); // Stop previous listening
16143
+ console.debug('[account] [WS] Watching changes');
16144
+ return this.graphql.subscribe({
16114
16145
  query: AccountSubscriptions.listenChanges,
16115
16146
  variables: {
16116
16147
  interval: 10
@@ -16119,57 +16150,40 @@
16119
16150
  code: ErrorCodes$2.SUBSCRIBE_ACCOUNT_ERROR,
16120
16151
  message: 'ERROR.ACCOUNT.SUBSCRIBE_ACCOUNT_ERROR'
16121
16152
  }
16122
- }).subscribe({
16123
- next: function (_b) {
16124
- var data = _b.data;
16125
- return __awaiter(_this, void 0, void 0, function () {
16126
- var _a, existingUpdateDate;
16127
- return __generator(this, function (_b) {
16128
- switch (_b.label) {
16129
- case 0:
16130
- if (!data)
16131
- return [2 /*return*/];
16132
- existingUpdateDate = toDateISOString((_a = self._data) === null || _a === void 0 ? void 0 : _a.updateDate);
16133
- if (!(existingUpdateDate !== data.updateDate)) return [3 /*break*/, 2];
16134
- console.debug("[account] [WS] Detected update on {" + data.updateDate + "}");
16135
- return [4 /*yield*/, self.refresh()];
16136
- case 1:
16137
- _b.sent();
16138
- _b.label = 2;
16139
- case 2: return [2 /*return*/];
16140
- }
16141
- });
16142
- });
16143
- },
16144
- error: function (err) { return __awaiter(_this, void 0, void 0, function () {
16145
- return __generator(this, function (_b) {
16146
- switch (_b.label) {
16147
- case 0:
16148
- if (!(err && +err.code === ServerErrorCodes.NOT_FOUND)) return [3 /*break*/, 2];
16149
- console.info('[account] Account not exists anymore: force user to logout...', err);
16150
- return [4 /*yield*/, self.logout()];
16151
- case 1:
16152
- _b.sent();
16153
- return [3 /*break*/, 5];
16154
- case 2:
16155
- if (!(err && +err.code === ServerErrorCodes.UNAUTHORIZED)) return [3 /*break*/, 4];
16156
- console.info('[account] Account not authorized: force user to logout...', err);
16157
- return [4 /*yield*/, self.logout()];
16158
- case 3:
16159
- _b.sent();
16160
- return [3 /*break*/, 5];
16161
- case 4:
16162
- console.warn('[account] [WS] Received error:', err);
16163
- _b.label = 5;
16164
- case 5: return [2 /*return*/];
16165
- }
16166
- });
16167
- }); },
16168
- complete: function () {
16169
- console.debug('[account] [WS] Completed');
16153
+ })
16154
+ .pipe(
16155
+ // Stop this pipe next time we call watch()
16156
+ operators.takeUntil(this._stopWatching$), operators.map(function (_b) {
16157
+ var data = _b.data;
16158
+ var _a;
16159
+ if (!data)
16160
+ return;
16161
+ var existingUpdateDate = toDateISOString((_a = _this._data) === null || _a === void 0 ? void 0 : _a.updateDate);
16162
+ if (existingUpdateDate === data.updateDate)
16163
+ return;
16164
+ console.debug("[account] [WS] Detected update on {" + data.updateDate + "}");
16165
+ return exports.Account.fromObject(data);
16166
+ }), operators.filter(isNotNil));
16167
+ };
16168
+ AccountService.prototype.listenChanges = function () {
16169
+ var self = this;
16170
+ var subscription = this.watch()
16171
+ .subscribe({
16172
+ next: function (data) { return self.refresh(); },
16173
+ error: function (err) {
16174
+ if (err && +err.code === ServerErrorCodes.NOT_FOUND) {
16175
+ console.info('[account] Account not exists anymore: force user to logout...', err);
16176
+ self.logout();
16177
+ }
16178
+ else if (err && +err.code === ServerErrorCodes.UNAUTHORIZED) {
16179
+ console.info('[account] Account not authorized: force user to logout...', err);
16180
+ self.logout();
16181
+ }
16182
+ else {
16183
+ console.warn('[account] [WS] Received error:', err);
16184
+ }
16170
16185
  }
16171
16186
  });
16172
- // Add log when closing WS
16173
16187
  subscription.add(function () { return console.debug('[account] [WS] Stop listening changes'); });
16174
16188
  return subscription;
16175
16189
  };
@@ -17303,29 +17317,44 @@
17303
17317
  console.debug('[platform] Creating service');
17304
17318
  return _this;
17305
17319
  }
17320
+ PlatformService.prototype.is = function (platformName) {
17321
+ switch (platformName) {
17322
+ case 'mobile':
17323
+ // Use custom mobile detection - see SUMARIS issue #323
17324
+ return isMobile(window);
17325
+ default:
17326
+ return this.platform.is(platformName);
17327
+ }
17328
+ };
17306
17329
  Object.defineProperty(PlatformService.prototype, "mobile", {
17307
17330
  get: function () {
17308
- return isNotNil(this._mobile) ? this._mobile : this.platform.is('mobile');
17331
+ return isNotNil(this._mobile) ? this._mobile : isMobile(window);
17309
17332
  },
17310
17333
  enumerable: false,
17311
17334
  configurable: true
17312
17335
  });
17313
- PlatformService.prototype.is = function (platformName) {
17314
- return this.platform.is(platformName);
17315
- };
17316
17336
  /**
17317
- * Say if opened has been opened from a web browser (and NOT inside an Android or iOs App).
17337
+ * Say if opened has been opened inside an Android or iOs App.
17318
17338
  * This is used to known if there is cordova features
17319
17339
  */
17320
- PlatformService.prototype.isWebOrDesktop = function () {
17321
- return !this.platform.is('mobile') || this.platform.is('mobileweb');
17340
+ PlatformService.prototype.isCordova = function () {
17341
+ return this._cordova;
17322
17342
  };
17323
17343
  PlatformService.prototype.isAndroidCordova = function () {
17324
17344
  return this._android && this._cordova || false;
17325
17345
  };
17346
+ PlatformService.prototype.isIOSCordova = function () {
17347
+ return this._ios && this._cordova || false;
17348
+ };
17349
+ PlatformService.prototype.isWeb = function () {
17350
+ return !this._cordova || (!this._android && !this._ios);
17351
+ };
17352
+ PlatformService.prototype.isApp = function () {
17353
+ return this._cordova && (this._android || this._ios);
17354
+ };
17326
17355
  Object.defineProperty(PlatformService.prototype, "canDownload", {
17327
17356
  get: function () {
17328
- return this._android && this._cordova && isNotNil(this.downloader);
17357
+ return !!this.downloader && this.isAndroidCordova();
17329
17358
  },
17330
17359
  enumerable: false,
17331
17360
  configurable: true
@@ -17356,16 +17385,13 @@
17356
17385
  _b.label = 1;
17357
17386
  case 1:
17358
17387
  _b.trys.push([1, 6, , 7]);
17359
- this._mobile = this.platform.is('mobile');
17360
- this._cordova = this.platform.is('cordova');
17361
- this._android = this.platform.is('android');
17362
- this.configureCordovaPlugins(this._mobile);
17363
- this.touchUi = this._mobile || this.platform.is('tablet') || this.platform.is('phablet');
17364
- // Force mobile in settings
17365
- if (this._mobile) {
17366
- this.settings.mobile = this._mobile;
17367
- this.settings.touchUi = this.touchUi;
17368
- }
17388
+ this._mobile = this.is('mobile');
17389
+ this._cordova = this.is('cordova');
17390
+ this._android = this.is('android');
17391
+ this._ios = this.is('ios');
17392
+ this.configureCordovaPlugins();
17393
+ // Force some settings
17394
+ this.settings.mobile = this._mobile;
17369
17395
  // Configure translation
17370
17396
  return [4 /*yield*/, this.configureTranslate()];
17371
17397
  case 2:
@@ -17388,7 +17414,7 @@
17388
17414
  case 5:
17389
17415
  // Start root services
17390
17416
  _b.sent();
17391
- console.info("[platform] Starting platform [OK] {mobile: " + this._mobile + ", touchUi: " + this.touchUi + ", downloader: " + this.canDownload + ", fileOpener: " + this.canOpenFile + "} in " + (Date.now() - now) + "ms");
17417
+ console.info("[platform] Starting platform [OK] {mobile: " + this._mobile + ", downloader: " + this.canDownload + ", fileOpener: " + this.canOpenFile + "} in " + (Date.now() - now) + "ms");
17392
17418
  // Update cache configuration when network changed
17393
17419
  this.networkService.onNetworkStatusChanges
17394
17420
  .pipe(operators.skip(1)) // Skip the first event (behavior subject send event immediately)
@@ -17400,7 +17426,7 @@
17400
17426
  console.info("[platform] Using auth token type {" + tokenType + "}");
17401
17427
  _this.accountService.tokenType = tokenType;
17402
17428
  });
17403
- // Hide the splashscreen (if mobile) - after 1s
17429
+ // Hide the splashscreen (if mobile) - after 1s - and play start sound
17404
17430
  if (this.mobile) {
17405
17431
  setTimeout(function () {
17406
17432
  var _a;
@@ -17479,7 +17505,7 @@
17479
17505
  //}
17480
17506
  };
17481
17507
  /* -- protected methods -- */
17482
- PlatformService.prototype.configureCordovaPlugins = function (mobile) {
17508
+ PlatformService.prototype.configureCordovaPlugins = function () {
17483
17509
  console.info('[platform] Configuring Cordova plugins...');
17484
17510
  if (this.statusBar) {
17485
17511
  this.statusBar.styleDefault();
@@ -17488,15 +17514,6 @@
17488
17514
  if (this.keyboard) {
17489
17515
  this.keyboard.hideFormAccessoryBar(true);
17490
17516
  }
17491
- // Force to use InAppBrowser instead of default window.open()
17492
- if (this.browser) {
17493
- // FIXME: this create a infinite loop (e.g. when downloading an extraction file)
17494
- // window.open = (url?: string, target?: string, features?: string, replace?: boolean) => {
17495
- // console.debug("[platform] Call to window.open() redirected to InAppBrowser.open()");
17496
- // this.browser.create(url, target, features).show();
17497
- // return window;
17498
- // };
17499
- }
17500
17517
  };
17501
17518
  PlatformService.prototype.configureTranslate = function () {
17502
17519
  var _this = this;
@@ -20714,7 +20731,7 @@
20714
20731
  this.appName = config.label || this.environment.defaultAppName || 'SUMARiS';
20715
20732
  this.logo = config.largeLogo || config.smallLogo || undefined;
20716
20733
  this.description = config.name;
20717
- this.isWeb = this.platform.isWebOrDesktop();
20734
+ this.isWeb = this.platform.isWeb();
20718
20735
  this.canRegister = config.getPropertyAsBoolean(CORE_CONFIG_OPTIONS.REGISTRATION_ENABLE);
20719
20736
  var partners = (config.partners || []).filter(function (p) { return p && p.logo; });
20720
20737
  this.$partners.next(partners);
@@ -23826,7 +23843,7 @@
23826
23843
  });
23827
23844
  };
23828
23845
  BaseEntityService.prototype.canUserWrite = function (data, opts) {
23829
- return true;
23846
+ return !!data;
23830
23847
  };
23831
23848
  BaseEntityService.prototype.saveAll = function (entities, opts) {
23832
23849
  return __awaiter(this, void 0, void 0, function () {
@@ -24599,13 +24616,8 @@
24599
24616
  // @dynamic
24600
24617
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
24601
24618
  var AppTable = /** @class */ (function () {
24602
- function AppTable(route, router, platform, location, modalCtrl, settings, columns, _dataSource, _filter, injector) {
24603
- this.route = route;
24604
- this.router = router;
24605
- this.platform = platform;
24606
- this.location = location;
24607
- this.modalCtrl = modalCtrl;
24608
- this.settings = settings;
24619
+ function AppTable(injector, columns, _dataSource, _filter) {
24620
+ var _this = this;
24609
24621
  this.columns = columns;
24610
24622
  this._dataSource = _dataSource;
24611
24623
  this._filter = _filter;
@@ -24648,13 +24660,19 @@
24648
24660
  this.onDirty = new i0.EventEmitter();
24649
24661
  this.onError = new i0.EventEmitter();
24650
24662
  this._paginator = null;
24651
- this.mobile = this.platform.is('mobile');
24652
- this.translate = injector === null || injector === void 0 ? void 0 : injector.get(i1$2.TranslateService);
24653
- this.formErrorAdapter = injector === null || injector === void 0 ? void 0 : injector.get(FormErrorTranslator);
24654
- this.alertCtrl = injector === null || injector === void 0 ? void 0 : injector.get(i1$5.AlertController);
24655
- this.toastController = injector === null || injector === void 0 ? void 0 : injector.get(i1$5.ToastController);
24663
+ this.route = injector.get(i3.ActivatedRoute);
24664
+ this.router = injector.get(i3.Router);
24665
+ this.location = injector.get(i1$4.Location);
24666
+ this.settings = injector.get(LocalSettingsService);
24667
+ this.translate = injector.get(i1$2.TranslateService);
24668
+ this.modalCtrl = injector.get(i1$5.ModalController);
24669
+ this.alertCtrl = injector.get(i1$5.AlertController);
24670
+ this.toastController = injector.get(i1$5.ToastController);
24671
+ this.formErrorAdapter = injector.get(FormErrorTranslator);
24672
+ this.mobile = this.settings.mobile;
24673
+ // Autocomplete fields
24656
24674
  this._autocompleteConfigHolder = new MatAutocompleteConfigHolder({
24657
- getUserAttributes: function (a, b) { return settings.getFieldDisplayAttributes(a, b); }
24675
+ getUserAttributes: function (a, b) { return _this.settings.getFieldDisplayAttributes(a, b); }
24658
24676
  });
24659
24677
  this.autocompleteFields = this._autocompleteConfigHolder.fields;
24660
24678
  }
@@ -26092,9 +26110,12 @@
26092
26110
  return (this.i18nColumnPrefix || '') + changeCaseToUnderscore(columnName).toUpperCase();
26093
26111
  };
26094
26112
  AppTable.prototype.generateTableId = function () {
26095
- return this.location.path(true).replace(/[?].*$/g, '').replace(/\/[\d]+/g, '_id') + '_' + this.constructor.name;
26113
+ var id = this.location.path(true)
26114
+ .replace(/[?].*$/g, '')
26115
+ .replace(/\/[\d]+/g, '_id')
26116
+ + '_' + this.constructor.name;
26096
26117
  //if (this.debug) console.debug("[table] id = " + id);
26097
- //return id;
26118
+ return id;
26098
26119
  };
26099
26120
  AppTable.prototype.addRowToTable = function (insertAt) {
26100
26121
  return __awaiter(this, void 0, void 0, function () {
@@ -26389,16 +26410,10 @@
26389
26410
  { type: i0.Directive }
26390
26411
  ];
26391
26412
  AppTable.ctorParameters = function () { return [
26392
- { type: i3.ActivatedRoute },
26393
- { type: i3.Router },
26394
- { type: undefined },
26395
- { type: i1$4.Location },
26396
- { type: i1$5.ModalController },
26397
- { type: LocalSettingsService },
26413
+ { type: i0.Injector },
26398
26414
  { type: Array },
26399
26415
  { type: EntitiesTableDataSource },
26400
- { type: undefined },
26401
- { type: i0.Injector }
26416
+ { type: undefined }
26402
26417
  ]; };
26403
26418
  AppTable.propDecorators = {
26404
26419
  settingsId: [{ type: i0.Input }],
@@ -27742,6 +27757,10 @@
27742
27757
  if (!opts || opts.emitEvent !== false)
27743
27758
  this.markForCheck();
27744
27759
  };
27760
+ /* -- public abstract methods (to override) -- */
27761
+ AppEntityEditor.prototype.canUserWrite = function (data, opts) {
27762
+ return this.dataService.canUserWrite(data, opts);
27763
+ };
27745
27764
  /* -- protected methods -- */
27746
27765
  /**
27747
27766
  * Return undefined to keep same tab
@@ -27939,8 +27958,7 @@
27939
27958
  var AppInMemoryTable = /** @class */ (function (_super) {
27940
27959
  __extends(AppInMemoryTable, _super);
27941
27960
  function AppInMemoryTable(injector, columns, dataType, memoryDataService, validatorService, options, filter) {
27942
- var _this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.Platform), injector.get(i1$4.Location), injector.get(i1$5.ModalController), injector.get(LocalSettingsService), columns, new EntitiesTableDataSource(dataType, memoryDataService, validatorService, options), filter, injector) || this;
27943
- _this.injector = injector;
27961
+ var _this = _super.call(this, injector, columns, new EntitiesTableDataSource(dataType, memoryDataService, validatorService, options), filter) || this;
27944
27962
  _this.columns = columns;
27945
27963
  _this.dataType = dataType;
27946
27964
  _this.memoryDataService = memoryDataService;
@@ -28449,7 +28467,7 @@
28449
28467
  var UserEventsTable = /** @class */ (function (_super) {
28450
28468
  __extends(UserEventsTable, _super);
28451
28469
  function UserEventsTable(injector, accountService, service, entities, cd, environment) {
28452
- var _this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.Platform), injector.get(i1$4.Location), injector.get(i1$5.ModalController), injector.get(LocalSettingsService),
28470
+ var _this = _super.call(this, injector,
28453
28471
  // columns
28454
28472
  RESERVED_START_COLUMNS
28455
28473
  .concat([
@@ -28458,8 +28476,7 @@
28458
28476
  'eventType',
28459
28477
  'message'
28460
28478
  ])
28461
- .concat(RESERVED_END_COLUMNS), null, null, injector) || this;
28462
- _this.injector = injector;
28479
+ .concat(RESERVED_END_COLUMNS), null, null) || this;
28463
28480
  _this.accountService = accountService;
28464
28481
  _this.service = service;
28465
28482
  _this.entities = entities;
@@ -28857,8 +28874,8 @@
28857
28874
 
28858
28875
  var UsersPage = /** @class */ (function (_super) {
28859
28876
  __extends(UsersPage, _super);
28860
- function UsersPage(route, router, platform, location, modalCtrl, accountService, settings, validatorService, configService, dataService, cd, formBuilder, injector, environment) {
28861
- var _this = _super.call(this, route, router, platform, location, modalCtrl, settings, RESERVED_START_COLUMNS
28877
+ function UsersPage(injector, accountService, validatorService, configService, dataService, cd, formBuilder, environment) {
28878
+ var _this = _super.call(this, injector, RESERVED_START_COLUMNS
28862
28879
  .concat([
28863
28880
  'avatar',
28864
28881
  'lastName',
@@ -28877,14 +28894,8 @@
28877
28894
  dataServiceOptions: {
28878
28895
  saveOnlyDirtyRows: true
28879
28896
  }
28880
- }), null, injector) || this;
28881
- _this.route = route;
28882
- _this.router = router;
28883
- _this.platform = platform;
28884
- _this.location = location;
28885
- _this.modalCtrl = modalCtrl;
28897
+ }), null) || this;
28886
28898
  _this.accountService = accountService;
28887
- _this.settings = settings;
28888
28899
  _this.validatorService = validatorService;
28889
28900
  _this.configService = configService;
28890
28901
  _this.dataService = dataService;
@@ -29023,19 +29034,13 @@
29023
29034
  },] }
29024
29035
  ];
29025
29036
  UsersPage.ctorParameters = function () { return [
29026
- { type: i3.ActivatedRoute },
29027
- { type: i3.Router },
29028
- { type: PlatformService },
29029
- { type: i1$4.Location },
29030
- { type: i1$5.ModalController },
29037
+ { type: i0.Injector },
29031
29038
  { type: AccountService },
29032
- { type: LocalSettingsService },
29033
29039
  { type: ngxMaterialTable.ValidatorService },
29034
29040
  { type: ConfigService },
29035
29041
  { type: PersonService },
29036
29042
  { type: i0.ChangeDetectorRef },
29037
29043
  { type: i1.FormBuilder },
29038
- { type: i0.Injector },
29039
29044
  { type: undefined, decorators: [{ type: i0.Inject, args: [ENVIRONMENT,] }] }
29040
29045
  ]; };
29041
29046
  UsersPage.propDecorators = {
@@ -29395,11 +29400,16 @@
29395
29400
  exports.getRandomImage = getRandomImage;
29396
29401
  exports.hexToRgb = hexToRgb;
29397
29402
  exports.hexToRgbArray = hexToRgbArray;
29403
+ exports.isAndroid = isAndroid;
29398
29404
  exports.isControlHasInput = isControlHasInput;
29405
+ exports.isCordova = isCordova;
29406
+ exports.isDesktop = isDesktop;
29399
29407
  exports.isEmptyArray = isEmptyArray;
29408
+ exports.isIOS = isIOS;
29400
29409
  exports.isInputElement = isInputElement;
29401
29410
  exports.isInstanceOf = isInstanceOf;
29402
29411
  exports.isInt = isInt;
29412
+ exports.isMobile = isMobile;
29403
29413
  exports.isNil = isNil;
29404
29414
  exports.isNilOrBlank = isNilOrBlank;
29405
29415
  exports.isNilOrNaN = isNilOrNaN;
@@ -29410,6 +29420,8 @@
29410
29420
  exports.isNotNilString = isNotNilString;
29411
29421
  exports.isNumber = isNumber;
29412
29422
  exports.isNumberRange = isNumberRange;
29423
+ exports.isTouchUi = isTouchUi;
29424
+ exports.isWindow = isWindow;
29413
29425
  exports.joinProperties = joinProperties;
29414
29426
  exports.joinPropertiesPath = joinPropertiesPath;
29415
29427
  exports.logFormErrors = logFormErrors;
@@ -29417,6 +29429,7 @@
29417
29429
  exports.markAsUntouched = markAsUntouched;
29418
29430
  exports.markControlAsTouched = markControlAsTouched;
29419
29431
  exports.markFormGroupAsTouched = markFormGroupAsTouched;
29432
+ exports.matchMedia = matchMedia;
29420
29433
  exports.matchUpperCase = matchUpperCase;
29421
29434
  exports.mergeLoadResult = mergeLoadResult;
29422
29435
  exports.mixHex = mixHex;
@@ -29457,6 +29470,7 @@
29457
29470
  exports.suggestFromArray = suggestFromArray;
29458
29471
  exports.suggestFromStringArray = suggestFromStringArray;
29459
29472
  exports.tabindexComparator = tabindexComparator;
29473
+ exports.testUserAgent = testUserAgent;
29460
29474
  exports.toBoolean = toBoolean;
29461
29475
  exports.toDateISOString = toDateISOString;
29462
29476
  exports.toDuration = toDuration;
@@ -29471,6 +29485,7 @@
29471
29485
  exports.waitForTrue = waitForTrue;
29472
29486
  exports.waitIdle = waitIdle;
29473
29487
  exports.waitWhilePending = waitWhilePending;
29488
+ exports["ɵ0"] = ɵ0$b;
29474
29489
  exports["ɵa"] = CustomReuseStrategy;
29475
29490
  exports["ɵb"] = MatNumpadDomService;
29476
29491
  exports["ɵc"] = SharedMatBadgeIconModule;