@sumaris-net/ngx-components 1.21.0-beta12 → 1.21.0-beta15

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.
@@ -24749,7 +24749,7 @@
24749
24749
  MenuComponent.decorators = [
24750
24750
  { type: i0.Component, args: [{
24751
24751
  selector: 'app-menu',
24752
- template: "<ion-split-pane #splitPane [contentId]=\"contentId\" (swiperight)=\"onSwipeRight($event)\">\n\n <ion-menu [id]=\"id\" [menuId]=\"menuId\" contentId=\"menu-content\">\n <ion-header>\n\n <ion-toolbar @fadeInAnimation *ngIf=\"isLogin; else notLogin\" class=\"ion-toolbar-top\">\n <ion-grid>\n <ion-row>\n <ion-col size=\"4\">\n <button type=\"button\" mat-flat-button\n class=\"user-avatar\" [class.primary]=\"!accountAvatar\"\n [style.background-image]=\"'url('+(accountAvatar||'./assets/img/person.png')+')'\"\n [routerLink]=\"['/account']\"\n routerDirection=\"root\"\n routerLinkActive=\"ion-color-primary\"\n (click)=\"close()\">\n </button>\n </ion-col>\n <ion-col size=\"8\" class=\"user-logo\">\n <img *ngIf=\"logo\" src=\"{{logo}}\" [title]=\"'APP_NAME'|translate: {appName: appName}\" width=\"108px;\"/>\n <span *ngIf=\"!logo\" width=\"108px;\">{{appName}}</span>\n </ion-col>\n </ion-row>\n <ion-row class=\"ion-no-padding\">\n\n <button mat-button type=\"button\"\n [routerLink]=\"['/account']\"\n routerDirection=\"root\"\n routerLinkActive=\"ion-color-primary\"\n (click)=\"close()\">\n <ion-label color=\"primary\" class=\"ion-text-wrap ion-text-start\">\n <h3 class=\"no-margin username\">\n <b>{{accountName}}</b>\n </h3>\n <h4>{{accountEmail}}</h4>\n </ion-label>\n </button>\n\n<!-- todo ajouter ici les 2 composants du module social -->\n\n </ion-row>\n </ion-grid>\n\n </ion-toolbar>\n\n <!-- User not logged -->\n <ng-template #notLogin>\n <mat-toolbar class=\"ion-padding\" @fadeInAnimation\n style=\"height: unset; display: block; margin: auto; text-align: center;\">\n <img *ngIf=\"logo\" src=\"{{logo}}\" [title]=\"'APP_NAME'|translate: {appName: appName}\" width=\"150px;\">\n <span *ngIf=\"!logo\" style=\"width: 150px\">{{appName}}</span>\n </mat-toolbar>\n </ng-template>\n </ion-header>\n\n <ion-content [class.has-user-header]=\"isLogin\">\n\n <ion-list lines=\"none\">\n <ion-menu-toggle auto-hide=\"false\"\n [class.flex-spacer]=\"item.cssClass == 'flex-spacer'\"\n *ngFor=\"let item of $items | async\">\n\n <!-- link -->\n <ion-item *ngIf=\"!loading && item.path\"\n @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}} text-1x\"\n tappable\n [routerLink]=\"item.path\"\n routerDirection=\"root\"\n routerLinkActive=\"selected\"\n [routerLinkActiveOptions]=\"{exact: (item.path === '/')}\">\n <ion-icon slot=\"start\" *ngIf=\"item.icon\" [name]=\"item.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"item.matIcon\">{{item.matIcon}}</mat-icon>\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item>\n\n <!-- action -->\n <ion-item *ngIf=\"!loading && item.action\"\n @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}} text-1x\"\n tappable\n (click)=\"doAction(item.action, $event)\">\n <ion-icon slot=\"start\" *ngIf=\"item.icon\" [name]=\"item.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"item.matIcon\">{{item.matIcon}}</mat-icon>\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item>\n\n <!-- divider -->\n <ion-item-divider @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}}\"\n *ngIf=\"!loading && !item.path && !item.action\">\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item-divider>\n\n </ion-menu-toggle>\n </ion-list>\n </ion-content>\n\n <ion-footer class=\"hidden-xs hidden-sm\">\n <ion-toolbar>\n\n <ion-buttons slot=\"start\">\n <ion-button mat-icon-button color=\"accent\" (click)=\"openAboutModal($event)\">\n <mat-icon slot=\"icon-only\">help_outline</mat-icon>\n </ion-button>\n </ion-buttons>\n\n <ion-title (click)=\"openAboutModal($event)\" color=\"medium\">\n {{'MENU.FOOTER_VERSION_ABOUT'| translate: {version: appVersion} }}\n </ion-title>\n\n <ion-buttons slot=\"end\">\n <button mat-icon-button color=\"accent\" (click)=\"toggleSplitPaneShow($event)\"\n class=\"hidden-xs hidden-sm hidden-md\"\n [title]=\"(splitPane.when ? 'COMMON.BTN_HIDE_MENU' : 'COMMON.BTN_SHOW_MENU') |translate\">\n <mat-icon><span>{{splitPane.when ? '&#xab;' : '&#xbb;'}}</span></mat-icon>\n </button>\n </ion-buttons>\n </ion-toolbar>\n </ion-footer>\n\n </ion-menu>\n\n <ng-content></ng-content>\n\n</ion-split-pane>\n",
24752
+ template: "<ion-split-pane #splitPane [contentId]=\"contentId\" (swiperight)=\"onSwipeRight($event)\">\n\n <ion-menu [id]=\"id\" [menuId]=\"menuId\" contentId=\"menu-content\">\n <ion-header>\n\n <ion-toolbar @fadeInAnimation *ngIf=\"isLogin; else notLogin\" class=\"ion-toolbar-top\">\n <ion-grid>\n <ion-row>\n <ion-col size=\"4\">\n <button type=\"button\" mat-flat-button\n class=\"user-avatar\" [class.primary]=\"!accountAvatar\"\n [style.background-image]=\"'url('+(accountAvatar||'./assets/img/person.png')+')'\"\n [routerLink]=\"['/account']\"\n routerDirection=\"root\"\n routerLinkActive=\"ion-color-primary\"\n (click)=\"close()\">\n </button>\n </ion-col>\n <ion-col size=\"8\" class=\"user-logo\">\n <img *ngIf=\"logo\" src=\"{{logo}}\" [title]=\"'APP_NAME'|translate: {appName: appName}\" width=\"108px;\"/>\n <span *ngIf=\"!logo\" width=\"108px;\">{{appName}}</span>\n </ion-col>\n </ion-row>\n <ion-row class=\"ion-no-padding\">\n\n <button mat-button type=\"button\"\n [routerLink]=\"['/account']\"\n routerDirection=\"root\"\n routerLinkActive=\"ion-color-primary\"\n (click)=\"close()\">\n <ion-label color=\"primary\" class=\"ion-text-wrap ion-text-start\">\n <h3 class=\"no-margin username\">\n <b>{{accountName}}</b>\n </h3>\n <h4>{{accountEmail}}</h4>\n </ion-label>\n </button>\n\n<!-- todo ajouter ici les 2 composants du module social ??? -->\n\n </ion-row>\n </ion-grid>\n\n </ion-toolbar>\n\n <!-- User not logged -->\n <ng-template #notLogin>\n <mat-toolbar class=\"ion-padding\" @fadeInAnimation\n style=\"height: unset; display: block; margin: auto; text-align: center;\">\n <img *ngIf=\"logo\" src=\"{{logo}}\" [title]=\"'APP_NAME'|translate: {appName: appName}\" width=\"150px;\">\n <span *ngIf=\"!logo\" style=\"width: 150px\">{{appName}}</span>\n </mat-toolbar>\n </ng-template>\n </ion-header>\n\n <ion-content [class.has-user-header]=\"isLogin\">\n\n <ion-list lines=\"none\">\n <ion-menu-toggle auto-hide=\"false\"\n [class.flex-spacer]=\"item.cssClass == 'flex-spacer'\"\n *ngFor=\"let item of $items | async\">\n\n <!-- link -->\n <ion-item *ngIf=\"!loading && item.path\"\n @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}} text-1x\"\n tappable\n [routerLink]=\"item.path\"\n routerDirection=\"root\"\n routerLinkActive=\"selected\"\n [routerLinkActiveOptions]=\"{exact: (item.path === '/')}\">\n <ion-icon slot=\"start\" *ngIf=\"item.icon\" [name]=\"item.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"item.matIcon\">{{item.matIcon}}</mat-icon>\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item>\n\n <!-- action -->\n <ion-item *ngIf=\"!loading && item.action\"\n @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}} text-1x\"\n tappable\n (click)=\"doAction(item.action, $event)\">\n <ion-icon slot=\"start\" *ngIf=\"item.icon\" [name]=\"item.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"item.matIcon\">{{item.matIcon}}</mat-icon>\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item>\n\n <!-- divider -->\n <ion-item-divider @fadeInAnimation\n class=\"{{item.cssClass}} {{item.color}}\"\n *ngIf=\"!loading && !item.path && !item.action\">\n <ion-label translate>{{item.title}}</ion-label>\n </ion-item-divider>\n\n </ion-menu-toggle>\n </ion-list>\n </ion-content>\n\n <ion-footer class=\"hidden-xs hidden-sm\">\n <ion-toolbar>\n\n <ion-buttons slot=\"start\">\n <ion-button mat-icon-button color=\"accent\" (click)=\"openAboutModal($event)\">\n <mat-icon slot=\"icon-only\">help_outline</mat-icon>\n </ion-button>\n </ion-buttons>\n\n <ion-title (click)=\"openAboutModal($event)\" color=\"medium\">\n {{'MENU.FOOTER_VERSION_ABOUT'| translate: {version: appVersion} }}\n </ion-title>\n\n <ion-buttons slot=\"end\">\n <button mat-icon-button color=\"accent\" (click)=\"toggleSplitPaneShow($event)\"\n class=\"hidden-xs hidden-sm hidden-md\"\n [title]=\"(splitPane.when ? 'COMMON.BTN_HIDE_MENU' : 'COMMON.BTN_SHOW_MENU') |translate\">\n <mat-icon><span>{{splitPane.when ? '&#xab;' : '&#xbb;'}}</span></mat-icon>\n </button>\n </ion-buttons>\n </ion-toolbar>\n </ion-footer>\n\n </ion-menu>\n\n <ng-content></ng-content>\n\n</ion-split-pane>\n",
24753
24753
  animations: [fadeInAnimation],
24754
24754
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
24755
24755
  styles: ["ion-menu{--ion-item-background:transparent;--ion-item-divider-background:transparent;--ion-item-icon-color:var(--ion-color-primary-tint);--ion-item-text-color:var(--ion-color-primary-tint);--ion-item-background-selected:var(--ion-color-secondary100);--ion-item-text-color-selected:var(--ion-color-primary);--ion-item-icon-color-selected:var(--ion-color-primary);--ion-item-text-color-disable:var(--ion-color-medium);--ion-item-icon-color-disable:var(--ion-color-medium)}ion-menu ion-header ion-text{color:var(--ion-color-primary)}ion-menu ion-header .user-avatar{background-size:cover;background-repeat:no-repeat;background-position:50%;background-color:var(--ion-color-secondary);border:1px solid var(--ion-color-primary);overflow:hidden!important;font-size:var(--avatar-size,60px)!important;line-height:var(--avatar-size,60px);height:var(--avatar-size,60px)!important;width:var(--avatar-size,60px)!important;border-radius:50%;display:inline-block}ion-menu ion-header .user-logo{text-align:right}ion-menu ion-header .user-logo img{max-width:120px;max-height:var(--avatar-size,60px);width:auto}ion-menu ion-header .username{padding-top:0;margin-top:0;margin-bottom:0;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}ion-menu ion-header button[mat-button]{padding:0;text-align:start!important;width:100%}ion-menu .scroll-content{margin-top:79px!important}ion-menu .has-user-header .scroll-content{margin-top:188px!important}ion-menu ion-content.has-profile-header{--offset-top:188px}ion-menu ion-content.no-profile-header{--offset-top:79px}ion-menu ion-content ion-list{min-height:100%;display:flex;flex-direction:column;justify-content:flex-start}ion-menu ion-content ion-list ion-menu-toggle.flex-spacer{flex:1 1 auto;display:flex;flex-direction:column;justify-content:flex-end}ion-menu ion-content ion-list ion-item.primary{--ion-item-icon-color:var(--ion-color-primary-tint);--ion-item-text-color:var(--ion-color-primary-tint)}ion-menu ion-content ion-list ion-item.secondary{--ion-item-icon-color:var(--ion-color-secondary-tint);--ion-item-text-color:var(--ion-color-secondary-tint)}ion-menu ion-content ion-list ion-item.tertiary{--ion-item-icon-color:var(--ion-color-tertiary-tint);--ion-item-text-color:var(--ion-color-tertiary-tint)}ion-menu ion-content ion-list ion-item.danger{--ion-item-icon-color:var(--ion-color-danger-tint);--ion-item-text-color:var(--ion-color-danger-tint)}ion-menu ion-content ion-list ion-item.medium{--ion-item-icon-color:var(--ion-color-medium-shade);--ion-item-text-color:var(--ion-color-medium-shade)}ion-menu ion-content ion-list ion-item.dark{--ion-item-icon-color:var(--ion-color-dark-tint);--ion-item-text-color:var(--ion-color-dark-tint)}ion-menu ion-content ion-list ion-item ion-icon,ion-menu ion-content ion-list ion-item mat-icon{color:var(--ion-item-icon-color)!important;fill:currentColor;stroke:currentColor}ion-menu ion-content ion-list ion-item ion-label,ion-menu ion-content ion-list ion-item ion-text{color:var(--ion-item-text-color)!important}ion-menu ion-content ion-list ion-item.selected{background-color:var(--ion-item-background-selected)!important;--color-hover:var(--ion-item-background-selected)!important}ion-menu ion-content ion-list ion-item.selected ion-icon,ion-menu ion-content ion-list ion-item.selected mat-icon{color:var(--ion-item-icon-color-selected)!important;fill:currentColor;stroke:currentColor}ion-menu ion-content ion-list ion-item.selected ion-label,ion-menu ion-content ion-list ion-item.selected ion-text{color:var(--ion-item-text-color-selected)!important}ion-menu ion-content ion-list ion-item.selected:hover{--color-hover:var(--ion-item-background-selected)!important;--ion-item-icon-color-selected:var(--ion-item-icon-color)!important;--ion-item-text-color-selected:var(--ion-item-text-color)!important}ion-menu ion-footer{display:block!important}ion-menu ion-footer ion-toolbar ion-title{cursor:pointer;font-size:12pt;font-weight:400;text-align:center;padding:0 8px}ion-menu ion-footer ion-toolbar ion-button{--width:40px}@media screen and (max-width:767px){ion-menu ion-footer{display:none!important;visibility:hidden!important}}@media screen and (min-width:768px){ion-menu ion-scroll{overflow-y:auto!important}ion-menu .user-avatar{font-size:var(--avatar-size,80px)!important;line-height:var(--avatar-size,80px);height:var(--avatar-size,80px)!important;width:var(--avatar-size,80px)!important}ion-menu .user-logo img{max-height:var(--avatar-size,80px)}}"]
@@ -30188,22 +30188,6 @@
30188
30188
  _this._logPrefix = '[user-event-service] ';
30189
30189
  // For DEV only
30190
30190
  _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
30191
- // listen login/logout
30192
- _this._subscriptions.add(accountService.onLogin.subscribe(function () { return __awaiter(_this, void 0, void 0, function () {
30193
- var count;
30194
- return __generator(this, function (_b) {
30195
- switch (_b.label) {
30196
- case 0: return [4 /*yield*/, this.count(undefined)];
30197
- case 1:
30198
- count = _b.sent();
30199
- if (count && this._debug) {
30200
- console.debug(this._logPrefix + "Received " + count + " unread notifications");
30201
- }
30202
- this._count$.next(count);
30203
- return [2 /*return*/];
30204
- }
30205
- });
30206
- }); }));
30207
30191
  return _this;
30208
30192
  }
30209
30193
  Object.defineProperty(AbstractUserEventService.prototype, "userEventCount", {
@@ -30257,11 +30241,13 @@
30257
30241
  console.debug("" + _this._logPrefix + data.length + " user events loaded in " + (Date.now() - now) + "ms");
30258
30242
  now = null;
30259
30243
  }
30260
- var unreadCount = _this.unreadEvents(data);
30261
- _this._count$.next(unreadCount);
30244
+ // const unreadCount = this.unreadEvents(data);
30245
+ // this._count$.next(unreadCount);
30246
+ // Must re-order because of listenChanges result will add new event at the end
30247
+ data = EntityUtils.sort(data, page.sortBy, page.sortDirection);
30262
30248
  return {
30263
30249
  data: data,
30264
- total: toNumber(res === null || res === void 0 ? void 0 : res.total, unreadCount)
30250
+ total: toNumber(res === null || res === void 0 ? void 0 : res.total, data.length)
30265
30251
  };
30266
30252
  }));
30267
30253
  };
@@ -30280,7 +30266,7 @@
30280
30266
  AbstractUserEventService.prototype.count = function (filter, options) {
30281
30267
  var _a;
30282
30268
  return __awaiter(this, void 0, void 0, function () {
30283
- var res;
30269
+ var res, total;
30284
30270
  return __generator(this, function (_b) {
30285
30271
  switch (_b.label) {
30286
30272
  case 0:
@@ -30303,11 +30289,42 @@
30303
30289
  })];
30304
30290
  case 1:
30305
30291
  res = _b.sent();
30306
- return [2 /*return*/, res.total];
30292
+ total = res.total;
30293
+ // update count
30294
+ this._count$.next(total);
30295
+ return [2 /*return*/, total];
30307
30296
  }
30308
30297
  });
30309
30298
  });
30310
30299
  };
30300
+ AbstractUserEventService.prototype.listenCountChanges = function (filter, options) {
30301
+ var _this = this;
30302
+ if (!this.subscriptions.listenCountChanges) {
30303
+ console.warn(this._logPrefix + "Subscription query 'listenCountChanges' not provided, skip.");
30304
+ return rxjs.of();
30305
+ }
30306
+ if (!filter)
30307
+ filter = this.defaultFilter();
30308
+ filter = this.asFilter(filter);
30309
+ if (this._debug)
30310
+ console.debug(this._logPrefix + "[WS] Listening count changes for user events with filter:", filter);
30311
+ return this.graphql.subscribe({
30312
+ query: this.subscriptions.listenCountChanges,
30313
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
30314
+ variables: { filter: filter.asPodObject(), interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
30315
+ error: {
30316
+ code: SocialErrorCodes.SUBSCRIBE_USER_EVENTS_ERROR,
30317
+ message: 'SOCIAL.ERROR.SUBSCRIBE_USER_EVENTS_ERROR'
30318
+ }
30319
+ }).pipe(operators.map(function (_b) {
30320
+ var total = _b.total;
30321
+ if (total && _this._debug)
30322
+ console.debug(_this._logPrefix + "Received new user events count:", total);
30323
+ // update count
30324
+ _this._count$.next(total);
30325
+ return total;
30326
+ }));
30327
+ };
30311
30328
  AbstractUserEventService.prototype.listenChanges = function (filter, options) {
30312
30329
  var _this = this;
30313
30330
  var _a;
@@ -30340,7 +30357,7 @@
30340
30357
  data: updatedData
30341
30358
  });
30342
30359
  // update count
30343
- _this._count$.next(_this.unreadEvents(updatedData));
30360
+ // this._count$.next(this.unreadEvents(updatedData));
30344
30361
  return updatedData;
30345
30362
  }));
30346
30363
  };
@@ -30930,10 +30947,34 @@
30930
30947
  };
30931
30948
 
30932
30949
  var UserEventNotificationList = /** @class */ (function () {
30933
- function UserEventNotificationList(popoverController) {
30950
+ function UserEventNotificationList(cd, popoverController, userEventService) {
30951
+ this.cd = cd;
30934
30952
  this.popoverController = popoverController;
30953
+ this.userEventService = userEventService;
30954
+ this.debug = false;
30955
+ this.userEvents = new rxjs.BehaviorSubject(undefined);
30956
+ this.subscriptions = new rxjs.Subscription();
30935
30957
  }
30936
30958
  UserEventNotificationList.prototype.ngOnInit = function () {
30959
+ var _this = this;
30960
+ // Watch all user events
30961
+ this.subscriptions.add(this.userEventService
30962
+ .watchAll(0, 10, 'creationDate', "desc", undefined)
30963
+ .subscribe(function (result) {
30964
+ if (_this.debug)
30965
+ console.debug("[user-event-notification-list] receiving " + result.total + " user events", result.data);
30966
+ _this.userEvents.next(result.data);
30967
+ _this.markForCheck();
30968
+ }));
30969
+ // Listen changes
30970
+ this.subscriptions.add(this.userEventService.listenChanges(undefined)
30971
+ .subscribe(function (data) {
30972
+ if (_this.debug)
30973
+ console.debug("[user-event-notification-list] receiving " + data.length + " new user events", data);
30974
+ }));
30975
+ };
30976
+ UserEventNotificationList.prototype.ngOnDestroy = function () {
30977
+ this.subscriptions.unsubscribe();
30937
30978
  };
30938
30979
  UserEventNotificationList.prototype.read = function ($event, userEvent) {
30939
30980
  var _a;
@@ -30949,21 +30990,27 @@
30949
30990
  UserEventNotificationList.prototype.dismiss = function () {
30950
30991
  this.popoverController.dismiss();
30951
30992
  };
30993
+ UserEventNotificationList.prototype.markForCheck = function () {
30994
+ this.cd.markForCheck();
30995
+ };
30952
30996
  return UserEventNotificationList;
30953
30997
  }());
30954
30998
  UserEventNotificationList.decorators = [
30955
30999
  { type: i0.Component, args: [{
30956
31000
  selector: 'app-user-event-notification-list',
30957
31001
  template: "\n<ion-list class=\"ion-list-popover\">\n\n <ion-row class=\"ion-list-header column\">\n <ion-col>\n <ion-label>{{titleI18n | translate}}</ion-label>\n </ion-col>\n </ion-row>\n\n <ion-item *ngIf=\"!(userEvents | async)?.length\">\n {{'SOCIAL.USER_EVENT.NOTIFICATION.EMPTY' | translate}}\n </ion-item>\n <ion-item\n *ngFor=\"let userEvent of userEvents | async\"\n (click)=\"read($event, userEvent)\"\n >\n\n <ion-avatar slot=\"start\">\n\n <img *ngIf=\"userEvent.avatar; else avatarIcon\" src=\"{{ userEvent.avatar }}\">\n\n <ng-template #avatarIcon>\n <app-icon\n *ngIf=\"userEvent.avatarIcon\"\n [ref]=\"userEvent.avatarIcon\"\n height=\"40\"\n width=\"40\"\n ></app-icon>\n </ng-template>\n\n </ion-avatar>\n\n <ion-grid class=\"ion-no-margin ion-no-padding\">\n <ion-row>\n <ion-col>\n <p [class.unread]=\"!userEvent.readDate\">\n {{userEvent.message}}\n </p>\n </ion-col>\n </ion-row>\n <ion-row *ngIf=\"userEvent.actions?.length\">\n <ion-col>\n <p>\n <span *ngFor=\"let action of userEvent.actions\">\n <a\n [style.margin-right.px]=\"8\"\n [style.cursor]=\"'pointer'\"\n (click)=\"executeAction(action, userEvent)\"\n >\n {{ '&#10142;&nbsp;' + action.name}}\n </a>\n </span>\n </p>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col>\n <app-icon\n *ngIf=\"userEvent.icon\"\n [ref]=\"userEvent.icon\"\n height=\"16\"\n width=\"16\"\n [style.vertical-align]=\"'sub'\"\n ></app-icon>\n <small>\n <span>{{userEvent.creationDate|dateFromNow}}</span>\n <span [style.color]=\"'gray'\">{{ ' | ' + (userEvent.creationDate|dateFormat:{time:true}) }}</span>\n </small>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-item>\n\n</ion-list>\n",
31002
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
30958
31003
  styles: [":host(.popover-viewport){overflow-y:auto;-webkit-user-select:none;-moz-user-select:none;user-select:none}.unread{font-weight:700}"]
30959
31004
  },] }
30960
31005
  ];
30961
31006
  UserEventNotificationList.ctorParameters = function () { return [
30962
- { type: i1$5.PopoverController }
31007
+ { type: i0.ChangeDetectorRef },
31008
+ { type: i1$5.PopoverController },
31009
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UserEventServiceToken,] }] }
30963
31010
  ]; };
30964
31011
  UserEventNotificationList.propDecorators = {
31012
+ debug: [{ type: i0.Input }],
30965
31013
  titleI18n: [{ type: i0.Input }],
30966
- userEvents: [{ type: i0.Input }],
30967
31014
  readEvent: [{ type: i0.Output }]
30968
31015
  };
30969
31016
 
@@ -30976,7 +31023,6 @@
30976
31023
  this.debug = false;
30977
31024
  this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
30978
31025
  this.disabled = false;
30979
- this.userEventsSubject = new rxjs.BehaviorSubject(undefined);
30980
31026
  this._subscriptions = new rxjs.Subscription();
30981
31027
  this._logPrefix = '[user-event-notification] ';
30982
31028
  this._readEvent = new i0.EventEmitter();
@@ -30990,28 +31036,53 @@
30990
31036
  configurable: true
30991
31037
  });
30992
31038
  UserEventNotificationComponent.prototype.ngOnInit = function () {
30993
- var _this = this;
30994
- if (isNil(this.userEventService)) {
30995
- console.warn(this._logPrefix + "No service injected");
30996
- this.disabled = true;
30997
- return;
30998
- }
30999
- // Watch first
31000
- this._subscriptions.add(this.userEventService.watchAll(0, 10, 'creationDate', 'desc').subscribe(function (value) {
31001
- var data = value.data;
31002
- if (_this.debug) {
31003
- console.debug(_this._logPrefix + "Receiving user events", data);
31004
- }
31005
- _this.userEventsSubject.next(data);
31006
- }));
31007
- // Then listen changes
31008
- this._subscriptions.add(this.userEventService.listenChanges(undefined).subscribe(function (data) {
31009
- if (_this.debug) {
31010
- console.debug(_this._logPrefix + "Receiving new user events", data);
31011
- }
31012
- }));
31013
- this._readEvent.subscribe(function (value) {
31014
- _this.userEventService.markAsRead(value);
31039
+ return __awaiter(this, void 0, void 0, function () {
31040
+ var _this = this;
31041
+ return __generator(this, function (_b) {
31042
+ switch (_b.label) {
31043
+ case 0:
31044
+ if (isNil(this.userEventService)) {
31045
+ console.warn(this._logPrefix + "No service injected");
31046
+ this.disabled = true;
31047
+ return [2 /*return*/];
31048
+ }
31049
+ return [4 /*yield*/, this.accountService.ready()];
31050
+ case 1:
31051
+ _b.sent();
31052
+ // listen login/logout
31053
+ this._loginSubscription = this.accountService.onLogin.subscribe(function () { return __awaiter(_this, void 0, void 0, function () {
31054
+ var count;
31055
+ var _this = this;
31056
+ return __generator(this, function (_b) {
31057
+ switch (_b.label) {
31058
+ case 0: return [4 /*yield*/, this.userEventService.count(undefined)];
31059
+ case 1:
31060
+ count = _b.sent();
31061
+ if (this.debug)
31062
+ console.debug(this._logPrefix + "Receiving user events count", count);
31063
+ this.markForCheck();
31064
+ // Then listen changes
31065
+ return [2 /*return*/, this.userEventService.listenCountChanges(undefined).subscribe(function (count) {
31066
+ if (_this.debug)
31067
+ console.debug(_this._logPrefix + "Receiving new user events count", count);
31068
+ _this.markForCheck();
31069
+ })];
31070
+ }
31071
+ });
31072
+ }); });
31073
+ this._subscriptions.add(this._loginSubscription);
31074
+ this._subscriptions.add(this.accountService.onLogout.subscribe(function () {
31075
+ if (_this._loginSubscription)
31076
+ _this._subscriptions.remove(_this._loginSubscription);
31077
+ }));
31078
+ // Subscribe to read event
31079
+ this._readEvent.subscribe(function (value) {
31080
+ // default: mark event as read
31081
+ _this.userEventService.markAsRead(value);
31082
+ });
31083
+ return [2 /*return*/];
31084
+ }
31085
+ });
31015
31086
  });
31016
31087
  };
31017
31088
  UserEventNotificationComponent.prototype.showList = function (event) {
@@ -31022,8 +31093,8 @@
31022
31093
  case 0: return [4 /*yield*/, this.popoverController.create({
31023
31094
  component: UserEventNotificationList,
31024
31095
  componentProps: {
31096
+ debug: this.debug,
31025
31097
  titleI18n: this.titleI18n,
31026
- userEvents: this.userEventsSubject,
31027
31098
  readEvent: this._readEvent
31028
31099
  },
31029
31100
  backdropDismiss: true,
@@ -31073,6 +31144,75 @@
31073
31144
  disabled: [{ type: i0.Input }]
31074
31145
  };
31075
31146
 
31147
+ var UserEventTestService = /** @class */ (function (_super) {
31148
+ __extends(UserEventTestService, _super);
31149
+ function UserEventTestService(graphql, accountService, network, translate, environment) {
31150
+ var _this = _super.call(this, graphql, accountService, network, translate, undefined, undefined, undefined, environment) || this;
31151
+ _this.graphql = graphql;
31152
+ _this.accountService = accountService;
31153
+ _this.network = network;
31154
+ _this.translate = translate;
31155
+ _this.environment = environment;
31156
+ _this.userEvents = [];
31157
+ _this.count$ = new rxjs.BehaviorSubject(0);
31158
+ return _this;
31159
+ }
31160
+ UserEventTestService.prototype.fromObject = function (source) {
31161
+ return exports.UserEvent.fromObject(source);
31162
+ };
31163
+ UserEventTestService.prototype.add = function (entity) {
31164
+ entity = this.processUserEvent(entity);
31165
+ entity.id = this.userEvents.length + 1;
31166
+ this.userEvents.push(entity);
31167
+ this.count$.next(this.userEvents.length);
31168
+ };
31169
+ Object.defineProperty(UserEventTestService.prototype, "userEventCount", {
31170
+ get: function () {
31171
+ return this.count$.asObservable();
31172
+ },
31173
+ enumerable: false,
31174
+ configurable: true
31175
+ });
31176
+ UserEventTestService.prototype.asFilter = function (filter) {
31177
+ return filter;
31178
+ };
31179
+ UserEventTestService.prototype.count = function (filter, options) {
31180
+ return Promise.resolve(this.userEvents.length);
31181
+ };
31182
+ UserEventTestService.prototype.delete = function (entity) {
31183
+ return Promise.resolve(undefined);
31184
+ };
31185
+ UserEventTestService.prototype.deleteAll = function (data, opts) {
31186
+ return Promise.resolve(undefined);
31187
+ };
31188
+ UserEventTestService.prototype.listenChanges = function (filter, options) {
31189
+ return rxjs.of();
31190
+ };
31191
+ UserEventTestService.prototype.save = function (entity, options) {
31192
+ var _a;
31193
+ var toSave = (_a = this.userEvents) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id == (entity === null || entity === void 0 ? void 0 : entity.id); });
31194
+ Object.assign(toSave, entity);
31195
+ return entity;
31196
+ };
31197
+ UserEventTestService.prototype.saveAll = function (data, opts) {
31198
+ return Promise.resolve([]);
31199
+ };
31200
+ UserEventTestService.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter, options) {
31201
+ return rxjs.of({ data: this.userEvents });
31202
+ };
31203
+ return UserEventTestService;
31204
+ }(AbstractUserEventService));
31205
+ UserEventTestService.decorators = [
31206
+ { type: i0.Injectable }
31207
+ ];
31208
+ UserEventTestService.ctorParameters = function () { return [
31209
+ { type: GraphqlService },
31210
+ { type: AccountService },
31211
+ { type: NetworkService },
31212
+ { type: i1$2.TranslateService },
31213
+ { type: Environment, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [ENVIRONMENT,] }] }
31214
+ ]; };
31215
+
31076
31216
  var UserEventModule = /** @class */ (function () {
31077
31217
  function UserEventModule() {
31078
31218
  }
@@ -31093,6 +31233,9 @@
31093
31233
  exports: [
31094
31234
  UserEventsTable,
31095
31235
  UserEventNotificationComponent
31236
+ ],
31237
+ providers: [
31238
+ { provide: UserEventServiceToken, useClass: UserEventTestService }
31096
31239
  ]
31097
31240
  },] }
31098
31241
  ];
@@ -34255,12 +34398,13 @@
34255
34398
  exports.ɵi = AppUpdateOfflineModeCard;
34256
34399
  exports.ɵj = AppIconComponent;
34257
34400
  exports.ɵk = UserEventNotificationList;
34258
- exports.ɵl = JobProgressionList;
34259
- exports.ɵm = DateTestPage;
34260
- exports.ɵn = NumpadTestPage;
34261
- exports.ɵo = MatBadgeIconTestPage;
34262
- exports.ɵp = ToastTestingModule;
34263
- exports.ɵq = ToastTestingPage;
34401
+ exports.ɵl = UserEventTestService;
34402
+ exports.ɵm = JobProgressionList;
34403
+ exports.ɵn = DateTestPage;
34404
+ exports.ɵo = NumpadTestPage;
34405
+ exports.ɵp = MatBadgeIconTestPage;
34406
+ exports.ɵq = ToastTestingModule;
34407
+ exports.ɵr = ToastTestingPage;
34264
34408
 
34265
34409
  Object.defineProperty(exports, '__esModule', { value: true });
34266
34410