@sumaris-net/ngx-components 1.21.7 → 1.22.0

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 (56) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +1305 -200
  2. package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
  3. package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
  4. package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
  5. package/doc/changelog.md +3 -0
  6. package/esm2015/public_api.js +8 -1
  7. package/esm2015/src/app/core/form/editor.class.js +7 -11
  8. package/esm2015/src/app/core/icon/icon.component.js +5 -2
  9. package/esm2015/src/app/core/menu/menu.component.js +2 -2
  10. package/esm2015/src/app/shared/pipes/date-diff-duration.pipe.js +9 -5
  11. package/esm2015/src/app/shared/types.js +1 -1
  12. package/esm2015/src/app/social/job/job.model.js +26 -0
  13. package/esm2015/src/app/social/job/job.module.js +25 -0
  14. package/esm2015/src/app/social/job/job.service.js +54 -0
  15. package/esm2015/src/app/social/job/progression/job-progression.component.js +200 -0
  16. package/esm2015/src/app/social/job/progression/job-progression.list.js +20 -0
  17. package/esm2015/src/app/social/message/message.module.js +25 -0
  18. package/esm2015/src/app/social/social.errors.js +5 -2
  19. package/esm2015/src/app/social/social.module.js +10 -15
  20. package/esm2015/src/app/social/user-event/notification/user-event-notification.component.js +89 -0
  21. package/esm2015/src/app/social/user-event/notification/user-event-notification.list.js +78 -0
  22. package/esm2015/src/app/social/user-event/testing/user-event.testing.service.js +73 -0
  23. package/esm2015/src/app/social/user-event/user-event.model.js +58 -2
  24. package/esm2015/src/app/social/user-event/user-event.module.js +33 -0
  25. package/esm2015/src/app/social/user-event/user-event.service.js +412 -173
  26. package/esm2015/src/app/social/user-event/user-events.table.js +18 -13
  27. package/esm2015/sumaris-net.ngx-components.js +9 -6
  28. package/fesm2015/sumaris-net.ngx-components.js +1122 -259
  29. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  30. package/package.json +1 -1
  31. package/public_api.d.ts +7 -0
  32. package/src/app/core/icon/icon.component.d.ts +4 -4
  33. package/src/app/shared/material/badge/badge-icon.test.d.ts +1 -1
  34. package/src/app/shared/pipes/date-diff-duration.pipe.d.ts +6 -2
  35. package/src/app/shared/types.d.ts +4 -0
  36. package/src/app/social/job/job.model.d.ts +33 -0
  37. package/src/app/social/job/job.module.d.ts +2 -0
  38. package/src/app/social/job/job.service.d.ts +23 -0
  39. package/src/app/social/job/progression/job-progression.component.d.ts +44 -0
  40. package/src/app/social/job/progression/job-progression.list.d.ts +12 -0
  41. package/src/app/social/message/message.module.d.ts +2 -0
  42. package/src/app/social/social.errors.d.ts +3 -0
  43. package/src/app/social/social.module.d.ts +8 -0
  44. package/src/app/social/user-event/notification/user-event-notification.component.d.ts +22 -0
  45. package/src/app/social/user-event/notification/user-event-notification.list.d.ts +30 -0
  46. package/src/app/social/user-event/testing/user-event.testing.service.d.ts +35 -0
  47. package/src/app/social/user-event/user-event.model.d.ts +52 -8
  48. package/src/app/social/user-event/user-event.module.d.ts +2 -0
  49. package/src/app/social/user-event/user-event.service.d.ts +101 -51
  50. package/src/app/social/user-event/user-events.table.d.ts +6 -6
  51. package/src/assets/i18n/en-US.json +15 -2
  52. package/src/assets/i18n/en.json +16 -2
  53. package/src/assets/i18n/fr.json +15 -1
  54. package/src/theme/_ngx-components.scss +8 -0
  55. package/sumaris-net.ngx-components.d.ts +8 -5
  56. package/sumaris-net.ngx-components.metadata.json +1 -1
@@ -46,7 +46,7 @@
46
46
  var SPACE_PLACEHOLDER_CHAR = '\u2000';
47
47
  var KEYBOARD_HIDE_DELAY_MS = 250; // 1s
48
48
 
49
- /*! *****************************************************************************
49
+ /******************************************************************************
50
50
  Copyright (c) Microsoft Corporation.
51
51
 
52
52
  Permission to use, copy, modify, and/or distribute this software for any
@@ -208,7 +208,11 @@
208
208
  var __createBinding = Object.create ? (function (o, m, k, k2) {
209
209
  if (k2 === undefined)
210
210
  k2 = k;
211
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
211
+ var desc = Object.getOwnPropertyDescriptor(m, k);
212
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
213
+ desc = { enumerable: true, get: function () { return m[k]; } };
214
+ }
215
+ Object.defineProperty(o, k2, desc);
212
216
  }) : (function (o, m, k, k2) {
213
217
  if (k2 === undefined)
214
218
  k2 = k;
@@ -363,6 +367,11 @@
363
367
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
364
368
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
365
369
  }
370
+ function __classPrivateFieldIn(state, receiver) {
371
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
372
+ throw new TypeError("Cannot use 'in' operator on non-object");
373
+ return typeof state === "function" ? receiver === state : state.has(receiver);
374
+ }
366
375
 
367
376
  function isNil(obj) {
368
377
  return obj === undefined || obj === null;
@@ -2328,17 +2337,21 @@
2328
2337
  return '';
2329
2338
  var startDate = this.dateAdapter.parse(value.startValue, DATE_ISO_PATTERN);
2330
2339
  var endDate = this.dateAdapter.parse(value.endValue, DATE_ISO_PATTERN);
2331
- return this.format(startDate, endDate);
2340
+ return this.format(startDate, endDate, args);
2332
2341
  };
2333
- DateDiffDurationPipe.prototype.format = function (startDate, endDate) {
2342
+ DateDiffDurationPipe.prototype.format = function (startDate, endDate, args) {
2334
2343
  var duration = moment.duration(endDate.diff(startDate));
2335
2344
  if (duration.asMinutes() < 0)
2336
2345
  return '';
2346
+ var withSeconds = args === null || args === void 0 ? void 0 : args.seconds;
2337
2347
  var timeDuration = moment(0)
2338
2348
  .hour(duration.hours())
2339
2349
  .minute(duration.minutes());
2350
+ if (withSeconds) {
2351
+ timeDuration.second(duration.seconds());
2352
+ }
2340
2353
  var days = Math.floor(duration.asDays());
2341
- return (days > 0 ? days.toString() + (this.dayUnit + ' ') : '') + timeDuration.format('HH:mm');
2354
+ return (days > 0 ? days.toString() + (this.dayUnit + ' ') : '') + timeDuration.format(withSeconds ? 'HH:mm:ss' : 'HH:mm');
2342
2355
  };
2343
2356
  return DateDiffDurationPipe;
2344
2357
  }());
@@ -24818,7 +24831,7 @@
24818
24831
  MenuComponent.decorators = [
24819
24832
  { type: i0.Component, args: [{
24820
24833
  selector: 'app-menu',
24821
- 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 </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",
24834
+ 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",
24822
24835
  animations: [fadeInAnimation],
24823
24836
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
24824
24837
  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)}}"]
@@ -24886,6 +24899,7 @@
24886
24899
  this.icon = value.icon;
24887
24900
  this.matIcon = value.matIcon;
24888
24901
  this.matSvgIcon = value.matSvgIcon;
24902
+ this.color = value.color;
24889
24903
  },
24890
24904
  enumerable: false,
24891
24905
  configurable: true
@@ -24896,7 +24910,7 @@
24896
24910
  AppIconComponent.decorators = [
24897
24911
  { type: i0.Component, args: [{
24898
24912
  selector: 'app-icon',
24899
- template: "<ion-icon *ngIf=\"icon; else matIconTemplate\" slot=\"icon-only\"\n [color]=\"color\"\n [name]=\"icon\"\n></ion-icon>\n<ng-template #matIconTemplate>\n <mat-icon [svgIcon]=\"matSvgIcon\"\n [style.color]=\"'var(--ion-color-'+color+')'\">{{matIcon}}</mat-icon>\n</ng-template>\n\n"
24913
+ template: "<ion-icon *ngIf=\"icon; else matIconTemplate\" slot=\"icon-only\"\n [color]=\"color\"\n [name]=\"icon\"\n [style.height.px]=\"height\"\n [style.width.px]=\"width\"\n></ion-icon>\n<ng-template #matIconTemplate>\n <mat-icon [svgIcon]=\"matSvgIcon\"\n [style.color]=\"'var(--ion-color-'+color+')'\"\n [style.height.px]=\"height\"\n [style.width.px]=\"width\"\n [style.font-size.px]=\"height || width\"\n >{{matIcon}}</mat-icon>\n</ng-template>\n\n"
24900
24914
  },] }
24901
24915
  ];
24902
24916
  AppIconComponent.propDecorators = {
@@ -24904,6 +24918,8 @@
24904
24918
  matIcon: [{ type: i0.Input }],
24905
24919
  matSvgIcon: [{ type: i0.Input }],
24906
24920
  color: [{ type: i0.Input }],
24921
+ height: [{ type: i0.Input }],
24922
+ width: [{ type: i0.Input }],
24907
24923
  ref: [{ type: i0.Input }]
24908
24924
  };
24909
24925
 
@@ -28062,8 +28078,7 @@
28062
28078
  });
28063
28079
  Object.defineProperty(AppEditor.prototype, "dirty", {
28064
28080
  get: function () {
28065
- var _a;
28066
- return this._dirty || (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.dirty; })) !== -1) || false;
28081
+ return this._dirty || (this._children && this._children.findIndex(function (c) { return c.enabled && c.dirty; }) !== -1) || false;
28067
28082
  },
28068
28083
  enumerable: false,
28069
28084
  configurable: true
@@ -28081,24 +28096,21 @@
28081
28096
  });
28082
28097
  Object.defineProperty(AppEditor.prototype, "invalid", {
28083
28098
  get: function () {
28084
- var _a;
28085
- return (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.invalid; })) !== -1) || false;
28099
+ return (this._children && this._children.findIndex(function (c) { return c.enabled && c.invalid; }) !== -1) || false;
28086
28100
  },
28087
28101
  enumerable: false,
28088
28102
  configurable: true
28089
28103
  });
28090
28104
  Object.defineProperty(AppEditor.prototype, "pending", {
28091
28105
  get: function () {
28092
- var _a;
28093
- return (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.pending; })) !== -1) || false;
28106
+ return (this._children && this._children.findIndex(function (c) { return c.enabled && c.pending; }) !== -1) || false;
28094
28107
  },
28095
28108
  enumerable: false,
28096
28109
  configurable: true
28097
28110
  });
28098
28111
  Object.defineProperty(AppEditor.prototype, "loading", {
28099
28112
  get: function () {
28100
- var _a;
28101
- return this.loadingSubject.value || (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.loading; })) !== -1) || false;
28113
+ return this.loadingSubject.value || (this._children && this._children.findIndex(function (c) { return c.enabled && c.loading; }) !== -1) || false;
28102
28114
  },
28103
28115
  enumerable: false,
28104
28116
  configurable: true
@@ -28284,11 +28296,12 @@
28284
28296
  * @param opts
28285
28297
  */
28286
28298
  AppEditor.prototype.unload = function (opts) {
28299
+ var _a;
28287
28300
  return __awaiter(this, void 0, void 0, function () {
28288
28301
  return __generator(this, function (_b) {
28289
28302
  console.debug('[tab-page] Unloading data...');
28290
28303
  this.markAsLoading();
28291
- this._children.forEach(function (f) {
28304
+ (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
28292
28305
  if (f instanceof AppForm) {
28293
28306
  f.reset(null, opts);
28294
28307
  }
@@ -30192,7 +30205,10 @@
30192
30205
  var SocialErrorCodes = {
30193
30206
  LOAD_USER_EVENTS_ERROR: 50000,
30194
30207
  SAVE_USER_EVENT_ERROR: 50001,
30195
- SEND_MESSAGE_ERROR: 50003
30208
+ COUNT_USER_EVENT_ERROR: 50002,
30209
+ SEND_MESSAGE_ERROR: 50003,
30210
+ SUBSCRIBE_USER_EVENTS_ERROR: 50005,
30211
+ SUBSCRIBE_JOB_PROGRESSION_ERROR: 50010
30196
30212
  };
30197
30213
 
30198
30214
  var UserEvent_1;
@@ -30208,16 +30224,23 @@
30208
30224
  }
30209
30225
  UserEvent.prototype.asObject = function (opts) {
30210
30226
  var target = _super.prototype.asObject.call(this, opts);
30227
+ target.creationDate = toDateISOString(this.creationDate);
30228
+ target.readDate = toDateISOString(this.readDate);
30211
30229
  // Serialize content
30212
30230
  if (typeof target.content === 'object') {
30213
30231
  target.content = JSON.stringify(target.content);
30214
30232
  }
30233
+ delete target.avatar;
30234
+ delete target.avatarIcon;
30235
+ delete target.icon;
30236
+ delete target.actions;
30215
30237
  return target;
30216
30238
  };
30217
30239
  UserEvent.prototype.fromObject = function (source) {
30218
30240
  Object.assign(this, source); // Copy all properties
30219
30241
  _super.prototype.fromObject.call(this, source);
30220
30242
  this.creationDate = fromDateISOString(source.creationDate);
30243
+ this.readDate = fromDateISOString(source.readDate);
30221
30244
  try {
30222
30245
  // Deserialize content
30223
30246
  if (typeof source.content === 'string' && source.content.startsWith('{')) {
@@ -30237,36 +30260,48 @@
30237
30260
  exports.UserEvent = UserEvent_1 = __decorate([
30238
30261
  EntityClass({ typename: 'UserEventVO' })
30239
30262
  ], exports.UserEvent);
30240
-
30241
- var UserEventFragments = {
30242
- userEvent: core.gql(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["fragment UserEventFragment on UserEventVO {\n id\n issuer\n updateDate\n creationDate\n eventType\n recipient\n content\n hash\n signature\n readSignature\n __typename\n }"], ["fragment UserEventFragment on UserEventVO {\n id\n issuer\n updateDate\n creationDate\n eventType\n recipient\n content\n hash\n signature\n readSignature\n __typename\n }"]))),
30243
- lightUserEvent: core.gql(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["fragment LightUserEventFragment on UserEventVO {\n id\n issuer\n recipient\n updateDate\n creationDate\n eventType\n readSignature\n __typename\n }"], ["fragment LightUserEventFragment on UserEventVO {\n id\n issuer\n recipient\n updateDate\n creationDate\n eventType\n readSignature\n __typename\n }"])))
30244
- };
30245
- var templateObject_1$2, templateObject_2$2;
30246
-
30247
30263
  // @dynamic
30248
30264
  exports.UserEventFilter = /** @class */ (function (_super) {
30249
30265
  __extends(UserEventFilter, _super);
30250
30266
  function UserEventFilter() {
30251
30267
  var _this = _super.apply(this, __spread(arguments)) || this;
30252
- _this.issuer = null;
30253
- _this.recipient = null;
30268
+ _this.types = [];
30269
+ _this.levels = [];
30270
+ _this.issuers = [];
30271
+ _this.recipients = [];
30272
+ _this.startDate = null;
30273
+ _this.excludeRead = false;
30254
30274
  return _this;
30255
30275
  }
30256
30276
  UserEventFilter.prototype.fromObject = function (source, opts) {
30257
30277
  _super.prototype.fromObject.call(this, source, opts);
30258
- this.issuer = source.issuer;
30259
- this.recipient = source.recipient;
30278
+ this.types = source.types || [];
30279
+ this.levels = source.levels || [];
30280
+ this.issuers = source.issuers || [];
30281
+ this.recipients = source.recipients || [];
30282
+ this.startDate = fromDateISOString(source.startDate);
30283
+ this.excludeRead = source.excludeRead || false;
30260
30284
  };
30261
30285
  UserEventFilter.prototype.buildFilter = function () {
30262
30286
  var _this = this;
30263
30287
  var filterFns = _super.prototype.buildFilter.call(this);
30264
- // issuer
30265
- if (this.issuer) {
30266
- filterFns.push(function (t) { return (t.issuer === _this.issuer); });
30288
+ if (isNotEmptyArray(this.types)) {
30289
+ filterFns.push(function (t) { return _this.types.includes(t.type); });
30267
30290
  }
30268
- if (this.recipient) {
30269
- filterFns.push(function (t) { return (t.recipient === _this.recipient); });
30291
+ if (isNotEmptyArray(this.levels)) {
30292
+ filterFns.push(function (t) { return _this.levels.includes(t.level); });
30293
+ }
30294
+ if (isNotEmptyArray(this.issuers)) {
30295
+ filterFns.push(function (t) { return _this.issuers.includes(t.issuer); });
30296
+ }
30297
+ if (isNotEmptyArray(this.recipients)) {
30298
+ filterFns.push(function (t) { return _this.recipients.includes(t.recipient); });
30299
+ }
30300
+ if (isNotNil(this.startDate)) {
30301
+ filterFns.push(function (t) { return _this.startDate.isSameOrBefore(t.creationDate); });
30302
+ }
30303
+ if (this.excludeRead === true) {
30304
+ filterFns.push(function (t) { return isNil(t.readSignature); }); // todo or t.signature ?
30270
30305
  }
30271
30306
  return filterFns;
30272
30307
  };
@@ -30275,145 +30310,257 @@
30275
30310
  exports.UserEventFilter = __decorate([
30276
30311
  EntityClass({ typename: 'UserEventFilterVO' })
30277
30312
  ], exports.UserEventFilter);
30278
- var SaveQuery = core.gql(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n mutation SaveUserEvent($data: UserEventVOInput){\n data: saveUserEvent(userEvent: $data){\n ...UserEventFragment\n }\n }\n ", "\n"], ["\n mutation SaveUserEvent($data: UserEventVOInput){\n data: saveUserEvent(userEvent: $data){\n ...UserEventFragment\n }\n }\n ", "\n"])), UserEventFragments.userEvent);
30279
- var LoadAllQuery = core.gql(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query UserEvents($filter: UserEventFilterVOInput, $page: PageInput){\n data: userEvents(filter: $filter, page: $page){\n ...LightUserEventFragment\n }\n }\n ", "\n"], ["\n query UserEvents($filter: UserEventFilterVOInput, $page: PageInput){\n data: userEvents(filter: $filter, page: $page){\n ...LightUserEventFragment\n }\n }\n ", "\n"])), UserEventFragments.lightUserEvent);
30280
- var DeleteByIdsMutation = core.gql(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n mutation DeleteUserEvents($ids:[Int]){\n deleteUserEvents(ids: $ids)\n }\n"], ["\n mutation DeleteUserEvents($ids:[Int]){\n deleteUserEvents(ids: $ids)\n }\n"])));
30281
- var LoadAllWithContentQuery = core.gql(templateObject_4$2 || (templateObject_4$2 = __makeTemplateObject(["\n query UserEventsWithContent($filter: UserEventFilterVOInput, $page: PageInput){\n data: userEvents(filter: $filter, page: $page){\n ...UserEventFragment\n }\n }\n ", "\n"], ["\n query UserEventsWithContent($filter: UserEventFilterVOInput, $page: PageInput){\n data: userEvents(filter: $filter, page: $page){\n ...UserEventFragment\n }\n }\n ", "\n"])), UserEventFragments.userEvent);
30282
- var UserEventService = /** @class */ (function (_super) {
30283
- __extends(UserEventService, _super);
30284
- function UserEventService(graphql, accountService, network, translate, toastController, environment) {
30313
+
30314
+ var UserEventFragments = {
30315
+ userEvent: core.gql(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["fragment UserEventFragment on UserEventVO {\n id\n issuer\n updateDate\n creationDate\n eventType\n recipient\n content\n hash\n signature\n readSignature\n __typename\n }"], ["fragment UserEventFragment on UserEventVO {\n id\n issuer\n updateDate\n creationDate\n eventType\n recipient\n content\n hash\n signature\n readSignature\n __typename\n }"]))),
30316
+ lightUserEvent: core.gql(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["fragment LightUserEventFragment on UserEventVO {\n id\n issuer\n recipient\n updateDate\n creationDate\n eventType\n readSignature\n __typename\n }"], ["fragment LightUserEventFragment on UserEventVO {\n id\n issuer\n recipient\n updateDate\n creationDate\n eventType\n readSignature\n __typename\n }"])))
30317
+ };
30318
+ var templateObject_1$2, templateObject_2$2;
30319
+
30320
+ var moment$6 = momentImported__namespace;
30321
+ var UserEventServiceToken = new i0.InjectionToken('UserEventService');
30322
+ var AbstractUserEventService = /** @class */ (function (_super) {
30323
+ __extends(AbstractUserEventService, _super);
30324
+ function AbstractUserEventService(graphql, accountService, network, translate, queries, mutations, subscriptions, environment) {
30285
30325
  var _this = _super.call(this, graphql, environment) || this;
30286
30326
  _this.graphql = graphql;
30287
30327
  _this.accountService = accountService;
30288
30328
  _this.network = network;
30289
30329
  _this.translate = translate;
30290
- _this.toastController = toastController;
30330
+ _this.queries = queries;
30331
+ _this.mutations = mutations;
30332
+ _this.subscriptions = subscriptions;
30291
30333
  _this.environment = environment;
30292
- _this._userEventActions = [];
30334
+ _this.count$ = new rxjs.BehaviorSubject(0);
30335
+ _this.listeners = [];
30336
+ _this._subscriptions = new rxjs.Subscription();
30337
+ _this._logPrefix = '[user-event-service] ';
30293
30338
  // For DEV only
30294
- _this._debug = environment && !environment.production;
30339
+ _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
30295
30340
  return _this;
30296
30341
  }
30297
- /**
30298
- *
30299
- * @param offset
30300
- * @param size
30301
- * @param sortBy
30302
- * @param sortDirection
30303
- * @param filter
30304
- * @param options
30305
- * @deprecated use watchPage() instead
30306
- */
30307
- UserEventService.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter, options) {
30342
+ Object.defineProperty(AbstractUserEventService.prototype, "userEventCount", {
30343
+ get: function () {
30344
+ return this.count$.asObservable();
30345
+ },
30346
+ enumerable: false,
30347
+ configurable: true
30348
+ });
30349
+ AbstractUserEventService.prototype.ngOnStart = function () {
30350
+ return __awaiter(this, void 0, void 0, function () {
30351
+ var _this = this;
30352
+ return __generator(this, function (_b) {
30353
+ switch (_b.label) {
30354
+ case 0:
30355
+ // Update component when refresh is need (=login events)
30356
+ this._subscriptions.add(rxjs.merge(this.accountService.onLogin, this.accountService.onLogout)
30357
+ .pipe(
30358
+ // Wait account service ready (can be restarted)
30359
+ operators.mergeMap(function () { return _this.accountService.ready(); }), operators.map(function () { return _this.accountService.isLogin(); }), operators.distinctUntilChanged())
30360
+ .subscribe(function (login) {
30361
+ if (login) {
30362
+ _this.onLogin();
30363
+ }
30364
+ else {
30365
+ _this.onLogout();
30366
+ }
30367
+ }));
30368
+ // First attempt if account is ready
30369
+ return [4 /*yield*/, this.accountService.ready()];
30370
+ case 1:
30371
+ // First attempt if account is ready
30372
+ _b.sent();
30373
+ if (this.accountService.isLogin()) {
30374
+ setTimeout(function () { return _this.onLogin(); });
30375
+ }
30376
+ return [2 /*return*/];
30377
+ }
30378
+ });
30379
+ });
30380
+ };
30381
+ AbstractUserEventService.prototype.ngOnDestroy = function () {
30382
+ this._subscriptions.unsubscribe();
30383
+ };
30384
+ AbstractUserEventService.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter, options) {
30308
30385
  return this.watchPage({ offset: offset, size: size, sortBy: sortBy, sortDirection: sortDirection }, filter, options);
30309
30386
  };
30310
- UserEventService.prototype.watchPage = function (page, filter, options) {
30387
+ AbstractUserEventService.prototype.watchPage = function (page, filter, options) {
30388
+ var _this = this;
30389
+ var _a;
30311
30390
  var now = this._debug && Date.now();
30312
- //if (this._debug)
30313
- console.debug('[user-event-service] Loading user events...', filter);
30391
+ if (!filter) {
30392
+ filter = this.defaultFilter();
30393
+ }
30394
+ console.debug(this._logPrefix + "Loading user events...", filter);
30314
30395
  filter = this.asFilter(filter);
30315
30396
  // Force recipient to current issuer, if not admin and not specified
30316
- if (isNilOrBlank(filter.recipient) || !this.accountService.isAdmin()) {
30317
- var recipient = this.accountService.account.pubkey;
30318
- if (recipient !== filter.recipient) {
30397
+ if (isEmptyArray(filter === null || filter === void 0 ? void 0 : filter.recipients) || !this.accountService.isAdmin()) {
30398
+ var recipient = this.defaultRecipient();
30399
+ if (!((_a = filter === null || filter === void 0 ? void 0 : filter.recipients) === null || _a === void 0 ? void 0 : _a.includes(recipient))) {
30319
30400
  console.warn('[user-events-service] Force user event filter.recipient=' + recipient);
30320
- filter.recipient = recipient;
30401
+ filter.recipients = [recipient];
30321
30402
  }
30322
30403
  }
30323
- var withContent = options && options.withContent === true;
30404
+ var withContent = (options === null || options === void 0 ? void 0 : options.withContent) === true;
30324
30405
  return this.mutableWatchQuery({
30325
30406
  queryName: withContent ? 'LoadAllWithContent' : 'LoadAll',
30326
- query: withContent ? LoadAllWithContentQuery : LoadAllQuery,
30407
+ query: withContent ? this.queries.loadAllWithContent : this.queries.loadAll,
30327
30408
  variables: {
30328
- page: Object.assign(Object.assign({ sortBy: 'updateDate' }, page), { sortDirection: (page.sortDirection || 'DESC').toUpperCase() }),
30409
+ page: Object.assign(Object.assign({ sortBy: 'creationDate' }, page), {
30410
+ // @ts-ignore
30411
+ sortDirection: (page.sortDirection || 'desc').toUpperCase()
30412
+ }),
30329
30413
  filter: filter && filter.asPodObject()
30330
30414
  },
30331
30415
  arrayFieldName: 'data',
30332
30416
  error: { code: SocialErrorCodes.LOAD_USER_EVENTS_ERROR, message: 'SOCIAL.ERROR.LOAD_USER_EVENTS_ERROR' },
30333
- fetchPolicy: options && options.fetchPolicy || undefined
30417
+ fetchPolicy: (options === null || options === void 0 ? void 0 : options.fetchPolicy) || 'cache-first'
30334
30418
  })
30335
30419
  .pipe(operators.map(function (res) {
30336
- var data = res && (res.data || []).map(exports.UserEvent.fromObject);
30420
+ var data = ((res === null || res === void 0 ? void 0 : res.data) || []).map(function (value) { return _this.processUserEvent(value, _this); });
30337
30421
  if (now) {
30338
- console.debug("[user-event-service] " + data.length + " user events loaded in " + (Date.now() - now) + "ms");
30422
+ console.debug("" + _this._logPrefix + data.length + " user events loaded in " + (Date.now() - now) + "ms");
30339
30423
  now = null;
30340
30424
  }
30425
+ // Must re-order because of listenChanges result will add new event at the end
30426
+ data = EntityUtils.sort(data, page.sortBy, page.sortDirection);
30341
30427
  return {
30342
30428
  data: data,
30343
- total: res && toNumber(res.total, data.length)
30429
+ total: toNumber(res === null || res === void 0 ? void 0 : res.total, data.length)
30344
30430
  };
30345
30431
  }));
30346
30432
  };
30347
- UserEventService.prototype.saveAll = function (data, options) {
30348
- var _this = this;
30349
- return Promise.all(data
30350
- .map(function (entity) { return _this.save(entity, options); }));
30433
+ AbstractUserEventService.prototype.add = function (entity) {
30434
+ // TODO set an id !!!!!!!!!!!!!!!!!!!!!!!!!
30435
+ entity = this.processUserEvent(entity);
30436
+ var withContent = !!entity.content;
30437
+ // Add user event locally
30438
+ this.insertIntoMutableCachedQueries(this.graphql.cache, {
30439
+ query: withContent ? this.queries.loadAllWithContent : this.queries.loadAll,
30440
+ data: entity
30441
+ });
30442
+ // Update count
30443
+ this.count$.next(this.count$.value + 1);
30351
30444
  };
30352
- /**
30353
- * Save a userEvent entity
30354
- *
30355
- * @param entity
30356
- */
30357
- UserEventService.prototype.save = function (entity, options) {
30445
+ AbstractUserEventService.prototype.count = function (filter, options) {
30446
+ var _a;
30358
30447
  return __awaiter(this, void 0, void 0, function () {
30359
- var isNew, json, now;
30360
- var _this = this;
30361
- return __generator(this, function (_a) {
30362
- switch (_a.label) {
30448
+ var res;
30449
+ return __generator(this, function (_b) {
30450
+ switch (_b.label) {
30363
30451
  case 0:
30364
- this.fillDefaultProperties(entity);
30365
- isNew = isNil(entity.id);
30366
- json = entity.asObject();
30367
- now = Date.now();
30452
+ if (!((_a = this.queries) === null || _a === void 0 ? void 0 : _a.count)) {
30453
+ console.warn(this._logPrefix + "Query 'count' not provided, skip.");
30454
+ return [2 /*return*/, undefined];
30455
+ }
30456
+ if (!filter)
30457
+ filter = this.defaultFilter();
30458
+ // Apply last reset date as start date
30459
+ filter.startDate = this.resetCountDate;
30460
+ filter = this.asFilter(filter);
30368
30461
  if (this._debug)
30369
- console.debug("[user-event-service] Saving user event...", json);
30370
- return [4 /*yield*/, this.graphql.mutate({
30371
- mutation: SaveQuery,
30462
+ console.debug(this._logPrefix + "Counting user events with filter:", filter);
30463
+ return [4 /*yield*/, this.graphql.query({
30464
+ query: this.queries.count,
30372
30465
  variables: {
30373
- data: json
30466
+ filter: filter.asPodObject()
30374
30467
  },
30375
- error: { code: SocialErrorCodes.SAVE_USER_EVENT_ERROR, message: 'SOCIAL.ERROR.SAVE_USER_EVENT_ERROR' },
30376
- update: function (proxy, _a) {
30377
- var data = _a.data;
30378
- // Update entity
30379
- var savedEntity = data && data.data;
30380
- if (savedEntity) {
30381
- if (_this._debug)
30382
- console.debug("[user-event-service] User event saved in " + (Date.now() - now) + "ms", entity);
30383
- _this.copyIdAndUpdateDate(savedEntity, entity);
30384
- // Add to cache
30385
- if (isNew) {
30386
- _this.insertIntoMutableCachedQueries(proxy, {
30387
- query: LoadAllQuery,
30388
- data: Object.assign(Object.assign({}, savedEntity), { content: null })
30389
- });
30390
- _this.insertIntoMutableCachedQueries(proxy, {
30391
- query: LoadAllWithContentQuery,
30392
- data: savedEntity
30393
- });
30394
- }
30395
- }
30396
- }
30468
+ error: { code: SocialErrorCodes.COUNT_USER_EVENT_ERROR, message: 'SOCIAL.ERROR.COUNT_USER_EVENT_ERROR' },
30469
+ fetchPolicy: (options === null || options === void 0 ? void 0 : options.fetchPolicy) || 'network-only'
30397
30470
  })];
30398
30471
  case 1:
30399
- _a.sent();
30400
- return [2 /*return*/, entity];
30472
+ res = _b.sent();
30473
+ return [2 /*return*/, res.total];
30401
30474
  }
30402
30475
  });
30403
30476
  });
30404
30477
  };
30405
- /**
30406
- * Save many trips
30407
- *
30408
- * @param entities
30409
- * @param opts
30410
- */
30411
- UserEventService.prototype.deleteAll = function (entities, opts) {
30478
+ AbstractUserEventService.prototype.listenCountChanges = function (filter, options) {
30479
+ var _this = this;
30480
+ var _a;
30481
+ if (!((_a = this.subscriptions) === null || _a === void 0 ? void 0 : _a.listenCountChanges)) {
30482
+ console.warn(this._logPrefix + "Subscription query 'listenCountChanges' not provided, skip.");
30483
+ return rxjs.of();
30484
+ }
30485
+ if (!filter)
30486
+ filter = this.defaultFilter();
30487
+ // Apply last reset date as start date
30488
+ filter.startDate = this.resetCountDate;
30489
+ filter = this.asFilter(filter);
30490
+ if (this._debug)
30491
+ console.debug(this._logPrefix + "[WS] Listening count changes for user events with filter:", filter);
30492
+ return this.graphql.subscribe({
30493
+ query: this.subscriptions.listenCountChanges,
30494
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
30495
+ variables: { filter: filter.asPodObject(), interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
30496
+ error: {
30497
+ code: SocialErrorCodes.SUBSCRIBE_USER_EVENTS_ERROR,
30498
+ message: 'SOCIAL.ERROR.SUBSCRIBE_USER_EVENTS_ERROR'
30499
+ }
30500
+ }).pipe(operators.map(function (_b) {
30501
+ var total = _b.total;
30502
+ if (total && _this._debug)
30503
+ console.debug(_this._logPrefix + "Received new user events count:", total);
30504
+ // update count
30505
+ _this.count$.next(total);
30506
+ return total;
30507
+ }));
30508
+ };
30509
+ AbstractUserEventService.prototype.listenChanges = function (filter, options) {
30510
+ var _this = this;
30511
+ var _a;
30512
+ if (!((_a = this.subscriptions) === null || _a === void 0 ? void 0 : _a.listenChanges)) {
30513
+ console.warn(this._logPrefix + "Subscription query 'listenChanges' not provided, skip.");
30514
+ return rxjs.of();
30515
+ }
30516
+ if (!filter)
30517
+ filter = this.defaultFilter();
30518
+ filter = this.asFilter(filter);
30519
+ var withContent = (options === null || options === void 0 ? void 0 : options.withContent) === true;
30520
+ if (this._debug)
30521
+ console.debug(this._logPrefix + "[WS] Listening changes for user events with filter:", filter);
30522
+ return this.graphql.subscribe({
30523
+ query: this.subscriptions.listenChanges,
30524
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
30525
+ variables: { filter: filter.asPodObject(), interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
30526
+ error: {
30527
+ code: SocialErrorCodes.SUBSCRIBE_USER_EVENTS_ERROR,
30528
+ message: 'SOCIAL.ERROR.SUBSCRIBE_USER_EVENTS_ERROR'
30529
+ }
30530
+ }).pipe(operators.map(function (_b) {
30531
+ var data = _b.data;
30532
+ if (data && _this._debug)
30533
+ console.debug(_this._logPrefix + "Received new user events:", data);
30534
+ var updatedData = data === null || data === void 0 ? void 0 : data.map(function (value) { return _this.processUserEvent(value, _this); });
30535
+ // Update cache
30536
+ _this.insertIntoMutableCachedQueries(_this.graphql.cache, {
30537
+ query: withContent ? _this.queries.loadAllWithContent : _this.queries.loadAll,
30538
+ data: updatedData
30539
+ });
30540
+ return updatedData;
30541
+ }));
30542
+ };
30543
+ AbstractUserEventService.prototype.delete = function (entity) {
30544
+ return __awaiter(this, void 0, void 0, function () {
30545
+ return __generator(this, function (_b) {
30546
+ switch (_b.label) {
30547
+ case 0:
30548
+ if (!entity)
30549
+ return [2 /*return*/]; // skip
30550
+ return [4 /*yield*/, this.deleteAll([entity])];
30551
+ case 1:
30552
+ _b.sent();
30553
+ return [2 /*return*/];
30554
+ }
30555
+ });
30556
+ });
30557
+ };
30558
+ AbstractUserEventService.prototype.deleteAll = function (entities, opts) {
30412
30559
  return __awaiter(this, void 0, void 0, function () {
30413
30560
  var ids, now;
30414
30561
  var _this = this;
30415
- return __generator(this, function (_a) {
30416
- switch (_a.label) {
30562
+ return __generator(this, function (_b) {
30563
+ switch (_b.label) {
30417
30564
  case 0:
30418
30565
  ids = entities && entities
30419
30566
  .map(function (t) { return t.id; });
@@ -30421,68 +30568,364 @@
30421
30568
  return [2 /*return*/]; // stop, if nothing else to do
30422
30569
  now = Date.now();
30423
30570
  if (this._debug)
30424
- console.debug('[user-event-service] Deleting events... ids:', ids);
30571
+ console.debug(this._logPrefix + "Deleting events... ids:", ids);
30425
30572
  return [4 /*yield*/, this.graphql.mutate({
30426
- mutation: DeleteByIdsMutation,
30573
+ mutation: this.mutations.deleteByIds,
30427
30574
  variables: {
30428
30575
  ids: ids
30429
30576
  },
30430
30577
  update: function (proxy) {
30431
30578
  // Remove from caches
30432
30579
  _this.removeFromMutableCachedQueriesByIds(proxy, {
30433
- query: LoadAllQuery,
30580
+ query: _this.queries.loadAll,
30434
30581
  ids: ids
30435
30582
  });
30436
30583
  _this.removeFromMutableCachedQueriesByIds(proxy, {
30437
- query: LoadAllWithContentQuery,
30584
+ query: _this.queries.loadAllWithContent,
30438
30585
  ids: ids
30439
30586
  });
30440
30587
  if (_this._debug)
30441
- console.debug("[user-event-service] Events deleted in " + (Date.now() - now) + "ms");
30588
+ console.debug(_this._logPrefix + "Events deleted in " + (Date.now() - now) + "ms");
30442
30589
  }
30443
30590
  })];
30444
30591
  case 1:
30445
- _a.sent();
30592
+ _b.sent();
30446
30593
  return [2 /*return*/];
30447
30594
  }
30448
30595
  });
30449
30596
  });
30450
30597
  };
30451
- /**
30452
- * Delete userEvent entities
30453
- */
30454
- UserEventService.prototype.delete = function (data) {
30598
+ AbstractUserEventService.prototype.save = function (entity, options) {
30455
30599
  return __awaiter(this, void 0, void 0, function () {
30456
- return __generator(this, function (_a) {
30457
- switch (_a.label) {
30600
+ var withContent, json, now;
30601
+ var _this = this;
30602
+ return __generator(this, function (_b) {
30603
+ switch (_b.label) {
30458
30604
  case 0:
30459
- if (!data)
30460
- return [2 /*return*/]; // skip
30461
- return [4 /*yield*/, this.deleteAll([data])];
30605
+ this.fillDefaultProperties(entity);
30606
+ withContent = !!entity.content;
30607
+ json = entity.asObject();
30608
+ now = Date.now();
30609
+ if (this._debug)
30610
+ console.debug(this._logPrefix + "Saving user event...", json);
30611
+ return [4 /*yield*/, this.graphql.mutate({
30612
+ mutation: this.mutations.save,
30613
+ variables: {
30614
+ data: json
30615
+ },
30616
+ error: { code: SocialErrorCodes.SAVE_USER_EVENT_ERROR, message: 'SOCIAL.ERROR.SAVE_USER_EVENT_ERROR' },
30617
+ update: function (proxy, _b) {
30618
+ var data = _b.data;
30619
+ // Update entity
30620
+ var savedEntity = data && data.data;
30621
+ if (savedEntity) {
30622
+ if (_this._debug)
30623
+ console.debug(_this._logPrefix + "User event saved in " + (Date.now() - now) + "ms", entity);
30624
+ _this.copyIdAndUpdateDate(savedEntity, entity);
30625
+ // Add to cache
30626
+ if (withContent) {
30627
+ _this.insertIntoMutableCachedQueries(proxy, {
30628
+ query: _this.queries.loadAllWithContent,
30629
+ data: savedEntity
30630
+ });
30631
+ }
30632
+ else {
30633
+ _this.insertIntoMutableCachedQueries(proxy, {
30634
+ query: _this.queries.loadAll,
30635
+ data: Object.assign(Object.assign({}, savedEntity), { content: null })
30636
+ });
30637
+ }
30638
+ }
30639
+ }
30640
+ })];
30462
30641
  case 1:
30463
- _a.sent();
30642
+ _b.sent();
30643
+ return [2 /*return*/, entity];
30644
+ }
30645
+ });
30646
+ });
30647
+ };
30648
+ AbstractUserEventService.prototype.saveAll = function (entities, opts) {
30649
+ return __awaiter(this, void 0, void 0, function () {
30650
+ var _this = this;
30651
+ return __generator(this, function (_b) {
30652
+ return [2 /*return*/, Promise.all(entities
30653
+ .map(function (entity) { return _this.save(entity, opts); }))];
30654
+ });
30655
+ });
30656
+ };
30657
+ AbstractUserEventService.prototype.markAsRead = function (entities) {
30658
+ return __awaiter(this, void 0, void 0, function () {
30659
+ var userEventWithoutReadListeners, _loop_1, this_1, _b, _c, entity, e_1_1;
30660
+ var e_1, _d;
30661
+ return __generator(this, function (_e) {
30662
+ switch (_e.label) {
30663
+ case 0:
30664
+ userEventWithoutReadListeners = [];
30665
+ _loop_1 = function (entity) {
30666
+ var onReadListeners, onReadListeners_1, onReadListeners_1_1, listener, e_2_1;
30667
+ var e_2, _b;
30668
+ return __generator(this, function (_c) {
30669
+ switch (_c.label) {
30670
+ case 0:
30671
+ onReadListeners = (this_1.listeners || []).filter(function (listener) { return !!listener.onRead; }).filter(function (listener) { return listener.accept(entity); });
30672
+ if (!onReadListeners.length) return [3 /*break*/, 9];
30673
+ _c.label = 1;
30674
+ case 1:
30675
+ _c.trys.push([1, 6, 7, 8]);
30676
+ onReadListeners_1 = (e_2 = void 0, __values(onReadListeners)), onReadListeners_1_1 = onReadListeners_1.next();
30677
+ _c.label = 2;
30678
+ case 2:
30679
+ if (!!onReadListeners_1_1.done) return [3 /*break*/, 5];
30680
+ listener = onReadListeners_1_1.value;
30681
+ return [4 /*yield*/, listener.onRead(entity)];
30682
+ case 3:
30683
+ _c.sent();
30684
+ _c.label = 4;
30685
+ case 4:
30686
+ onReadListeners_1_1 = onReadListeners_1.next();
30687
+ return [3 /*break*/, 2];
30688
+ case 5: return [3 /*break*/, 8];
30689
+ case 6:
30690
+ e_2_1 = _c.sent();
30691
+ e_2 = { error: e_2_1 };
30692
+ return [3 /*break*/, 8];
30693
+ case 7:
30694
+ try {
30695
+ if (onReadListeners_1_1 && !onReadListeners_1_1.done && (_b = onReadListeners_1.return)) _b.call(onReadListeners_1);
30696
+ }
30697
+ finally { if (e_2) throw e_2.error; }
30698
+ return [7 /*endfinally*/];
30699
+ case 8: return [3 /*break*/, 10];
30700
+ case 9:
30701
+ // Add to this list for default operation
30702
+ userEventWithoutReadListeners.push(entity);
30703
+ _c.label = 10;
30704
+ case 10: return [2 /*return*/];
30705
+ }
30706
+ });
30707
+ };
30708
+ this_1 = this;
30709
+ _e.label = 1;
30710
+ case 1:
30711
+ _e.trys.push([1, 6, 7, 8]);
30712
+ _b = __values((entities || [])), _c = _b.next();
30713
+ _e.label = 2;
30714
+ case 2:
30715
+ if (!!_c.done) return [3 /*break*/, 5];
30716
+ entity = _c.value;
30717
+ return [5 /*yield**/, _loop_1(entity)];
30718
+ case 3:
30719
+ _e.sent();
30720
+ _e.label = 4;
30721
+ case 4:
30722
+ _c = _b.next();
30723
+ return [3 /*break*/, 2];
30724
+ case 5: return [3 /*break*/, 8];
30725
+ case 6:
30726
+ e_1_1 = _e.sent();
30727
+ e_1 = { error: e_1_1 };
30728
+ return [3 /*break*/, 8];
30729
+ case 7:
30730
+ try {
30731
+ if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
30732
+ }
30733
+ finally { if (e_1) throw e_1.error; }
30734
+ return [7 /*endfinally*/];
30735
+ case 8:
30736
+ // Use default
30737
+ return [4 /*yield*/, this.defaultMarkAsRead(userEventWithoutReadListeners)];
30738
+ case 9:
30739
+ // Use default
30740
+ _e.sent();
30464
30741
  return [2 /*return*/];
30465
30742
  }
30466
30743
  });
30467
30744
  });
30468
30745
  };
30469
- UserEventService.prototype.listenChanges = function (id, options) {
30470
- // TODO
30471
- console.warn('TODO: implement listen changes on user events');
30472
- return rxjs.of();
30746
+ AbstractUserEventService.prototype.registerListener = function (listener) {
30747
+ if (!this.listeners)
30748
+ this.listeners = [];
30749
+ this.listeners.push(listener);
30750
+ };
30751
+ AbstractUserEventService.prototype.resetCount = function () {
30752
+ this.count$.next(undefined);
30753
+ this.resetCountDate = moment$6();
30754
+ // restart listening count changes
30755
+ this.startListenCountChanges();
30756
+ };
30757
+ /* -- protected methods -- */
30758
+ AbstractUserEventService.prototype.onLogin = function () {
30759
+ return __awaiter(this, void 0, void 0, function () {
30760
+ var count;
30761
+ return __generator(this, function (_b) {
30762
+ switch (_b.label) {
30763
+ case 0: return [4 /*yield*/, this.count(undefined)];
30764
+ case 1:
30765
+ count = _b.sent();
30766
+ if (this._debug)
30767
+ console.debug(this._logPrefix + "Receiving user events count", count);
30768
+ // Update count
30769
+ this.count$.next(count);
30770
+ // Then listen changes
30771
+ this.startListenCountChanges();
30772
+ return [2 /*return*/];
30773
+ }
30774
+ });
30775
+ });
30473
30776
  };
30474
- UserEventService.prototype.registerAction = function (definition) {
30475
- console.info("[user-event-service] Registering action " + definition.name + " for " + definition.__typename);
30476
- this._userEventActions.push(definition);
30777
+ AbstractUserEventService.prototype.onLogout = function () {
30778
+ this.stopListenCountChanges();
30477
30779
  };
30478
- UserEventService.prototype.getActionsByTypename = function (typename) {
30479
- return this._userEventActions.filter(function (def) { return def.__typename === typename; });
30780
+ AbstractUserEventService.prototype.startListenCountChanges = function () {
30781
+ this.stopListenCountChanges();
30782
+ this._listenSubscription = this.listenCountChanges(undefined).subscribe();
30480
30783
  };
30784
+ AbstractUserEventService.prototype.stopListenCountChanges = function () {
30785
+ var _a;
30786
+ (_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
30787
+ this._listenSubscription = undefined;
30788
+ };
30789
+ AbstractUserEventService.prototype.processUserEvent = function (source, that) {
30790
+ var e_3, _b;
30791
+ that = that || this;
30792
+ // Convert json source to IUserEvent
30793
+ var target = that.fromObject(source);
30794
+ // Get listeners
30795
+ var listeners = (that.listeners || []).filter(function (listener) { return listener.onReceived; }).filter(function (listener) { return listener.accept(target); });
30796
+ try {
30797
+ for (var listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next(); !listeners_1_1.done; listeners_1_1 = listeners_1.next()) {
30798
+ var listener = listeners_1_1.value;
30799
+ if (target) {
30800
+ target = listener.onReceived(target);
30801
+ }
30802
+ else {
30803
+ if (that._debug)
30804
+ console.debug(that._logPrefix + "Event has been rejected by a listener", source);
30805
+ break;
30806
+ }
30807
+ }
30808
+ }
30809
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
30810
+ finally {
30811
+ try {
30812
+ if (listeners_1_1 && !listeners_1_1.done && (_b = listeners_1.return)) _b.call(listeners_1);
30813
+ }
30814
+ finally { if (e_3) throw e_3.error; }
30815
+ }
30816
+ return target;
30817
+ };
30818
+ AbstractUserEventService.prototype.defaultMarkAsRead = function (userEvents) {
30819
+ var _a;
30820
+ return __awaiter(this, void 0, void 0, function () {
30821
+ var localEntities, remoteEntities, ids, now;
30822
+ return __generator(this, function (_b) {
30823
+ switch (_b.label) {
30824
+ case 0:
30825
+ if (!userEvents)
30826
+ throw new Error(this._logPrefix + "Invalid event to save");
30827
+ if (!userEvents.length)
30828
+ return [2 /*return*/];
30829
+ // set read date
30830
+ userEvents.forEach(function (userEvent) { return userEvent.readDate = moment$6(); });
30831
+ localEntities = userEvents.filter(function (userEvent) { return !userEvent.id || userEvent.id < 0; });
30832
+ remoteEntities = userEvents.filter(function (userEvent) { return userEvent.id > 0; });
30833
+ // save local entities
30834
+ if (localEntities.length) {
30835
+ if (this._debug)
30836
+ console.debug(this._logPrefix + "Save local user event");
30837
+ // TODO !!!!!!!!!!!!!
30838
+ }
30839
+ if (!remoteEntities.length) return [3 /*break*/, 2];
30840
+ if (!((_a = this.mutations) === null || _a === void 0 ? void 0 : _a.markAsRead)) {
30841
+ console.warn(this._logPrefix + "Mutation query 'markAsRead' not provided, skip.");
30842
+ return [2 /*return*/];
30843
+ }
30844
+ ids = remoteEntities.map(function (value) { return value.id; });
30845
+ now = Date.now();
30846
+ if (this._debug)
30847
+ console.debug(this._logPrefix + "Mark user events as read...", ids);
30848
+ return [4 /*yield*/, this.graphql.mutate({
30849
+ mutation: this.mutations.markAsRead,
30850
+ variables: {
30851
+ ids: ids
30852
+ },
30853
+ error: { code: SocialErrorCodes.SAVE_USER_EVENT_ERROR, message: 'SOCIAL.ERROR.SAVE_USER_EVENT_ERROR' },
30854
+ })];
30855
+ case 1:
30856
+ _b.sent();
30857
+ if (this._debug)
30858
+ console.debug(this._logPrefix + "User events marked as read in " + (Date.now() - now) + "ms", ids);
30859
+ _b.label = 2;
30860
+ case 2: return [2 /*return*/];
30861
+ }
30862
+ });
30863
+ });
30864
+ };
30865
+ AbstractUserEventService.prototype.defaultFilter = function () {
30866
+ // By default
30867
+ return {
30868
+ recipients: [this.defaultRecipient()]
30869
+ };
30870
+ };
30871
+ AbstractUserEventService.prototype.defaultRecipient = function () {
30872
+ return this.accountService.person.pubkey;
30873
+ };
30874
+ AbstractUserEventService.prototype.fillDefaultProperties = function (entity) {
30875
+ };
30876
+ AbstractUserEventService.prototype.unreadEvents = function (events) {
30877
+ // default calculation on unread events from a list
30878
+ if (isEmptyArray(events))
30879
+ return undefined;
30880
+ var lastReadDate = events
30881
+ .filter(function (event) { return isNotNil(event.readDate); })
30882
+ .reduce(function (lastDate, event) { return DateUtils.max(lastDate, event.readDate); }, undefined);
30883
+ return events
30884
+ .filter(function (event) { return event.creationDate.isSameOrAfter(lastReadDate); }).length;
30885
+ };
30886
+ AbstractUserEventService.prototype.copyIdAndUpdateDate = function (source, target) {
30887
+ EntityUtils.copyIdAndUpdateDate(source, target);
30888
+ };
30889
+ return AbstractUserEventService;
30890
+ }(BaseGraphqlService));
30891
+ AbstractUserEventService.decorators = [
30892
+ { type: i0.Directive }
30893
+ ];
30894
+ AbstractUserEventService.ctorParameters = function () { return [
30895
+ { type: GraphqlService },
30896
+ { type: AccountService },
30897
+ { type: NetworkService },
30898
+ { type: i1$2.TranslateService },
30899
+ { type: undefined },
30900
+ { type: undefined },
30901
+ { type: undefined },
30902
+ { type: Environment, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [ENVIRONMENT,] }] }
30903
+ ]; };
30904
+ var userEventQueries = {
30905
+ loadAll: core.gql(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n query UserEvents($filter: UserEventFilterVOInput, $page: PageInput){\n data: userEvents(filter: $filter, page: $page){\n ...LightUserEventFragment\n }\n }\n ", "\n "], ["\n query UserEvents($filter: UserEventFilterVOInput, $page: PageInput){\n data: userEvents(filter: $filter, page: $page){\n ...LightUserEventFragment\n }\n }\n ", "\n "])), UserEventFragments.lightUserEvent),
30906
+ loadAllWithContent: core.gql(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query UserEventsWithContent($filter: UserEventFilterVOInput, $page: PageInput){\n data: userEvents(filter: $filter, page: $page){\n ...UserEventFragment\n }\n }\n ", "\n "], ["\n query UserEventsWithContent($filter: UserEventFilterVOInput, $page: PageInput){\n data: userEvents(filter: $filter, page: $page){\n ...UserEventFragment\n }\n }\n ", "\n "])), UserEventFragments.userEvent)
30907
+ };
30908
+ var userEventMutations = {
30909
+ deleteByIds: core.gql(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n mutation DeleteUserEvents($ids:[Int]){\n deleteUserEvents(ids: $ids)\n }\n "], ["\n mutation DeleteUserEvents($ids:[Int]){\n deleteUserEvents(ids: $ids)\n }\n "]))),
30910
+ save: core.gql(templateObject_4$2 || (templateObject_4$2 = __makeTemplateObject(["\n mutation SaveUserEvent($data: UserEventVOInput){\n data: saveUserEvent(userEvent: $data){\n ...UserEventFragment\n }\n }\n ", "\n "], ["\n mutation SaveUserEvent($data: UserEventVOInput){\n data: saveUserEvent(userEvent: $data){\n ...UserEventFragment\n }\n }\n ", "\n "])), UserEventFragments.userEvent)
30911
+ };
30912
+ var UserEventService = /** @class */ (function (_super) {
30913
+ __extends(UserEventService, _super);
30914
+ function UserEventService(graphql, accountService, network, translate, toastController, environment) {
30915
+ var _this = _super.call(this, graphql, accountService, network, translate, userEventQueries, userEventMutations, undefined, environment) || this;
30916
+ _this.graphql = graphql;
30917
+ _this.accountService = accountService;
30918
+ _this.network = network;
30919
+ _this.translate = translate;
30920
+ _this.toastController = toastController;
30921
+ _this.environment = environment;
30922
+ return _this;
30923
+ }
30481
30924
  UserEventService.prototype.showToastErrorWithContext = function (opts) {
30482
30925
  return __awaiter(this, void 0, void 0, function () {
30483
30926
  var message, res, context, userEvent, err_1;
30484
- return __generator(this, function (_a) {
30485
- switch (_a.label) {
30927
+ return __generator(this, function (_b) {
30928
+ switch (_b.label) {
30486
30929
  case 0:
30487
30930
  message = opts.message || (opts.error && opts.error.message || opts.error);
30488
30931
  // Make sure message a string
@@ -30511,12 +30954,12 @@
30511
30954
  }]
30512
30955
  })];
30513
30956
  case 1:
30514
- res = _a.sent();
30957
+ res = _b.sent();
30515
30958
  if (!res || res.role !== 'send')
30516
30959
  return [2 /*return*/];
30517
- _a.label = 2;
30960
+ _b.label = 2;
30518
30961
  case 2:
30519
- _a.trys.push([2, 6, , 7]);
30962
+ _b.trys.push([2, 6, , 7]);
30520
30963
  if (this._debug)
30521
30964
  console.debug('Sending debug data...');
30522
30965
  context = opts && opts.context;
@@ -30526,15 +30969,15 @@
30526
30969
  if (!(context instanceof Promise)) return [3 /*break*/, 4];
30527
30970
  return [4 /*yield*/, context];
30528
30971
  case 3:
30529
- context = _a.sent();
30530
- _a.label = 4;
30972
+ context = _b.sent();
30973
+ _b.label = 4;
30531
30974
  case 4: return [4 /*yield*/, this.sendDataForDebug({
30532
30975
  message: message,
30533
30976
  error: opts.error || undefined,
30534
30977
  context: this.convertObjectToString(context)
30535
30978
  })];
30536
30979
  case 5:
30537
- userEvent = _a.sent();
30980
+ userEvent = _b.sent();
30538
30981
  console.info('Debug data successfully sent to admin', userEvent);
30539
30982
  this.showToast({
30540
30983
  type: 'info',
@@ -30543,7 +30986,7 @@
30543
30986
  });
30544
30987
  return [3 /*break*/, 7];
30545
30988
  case 6:
30546
- err_1 = _a.sent();
30989
+ err_1 = _b.sent();
30547
30990
  console.error('Error while sending debug data:', err_1);
30548
30991
  return [3 /*break*/, 7];
30549
30992
  case 7: return [2 /*return*/];
@@ -30553,13 +30996,16 @@
30553
30996
  };
30554
30997
  UserEventService.prototype.sendDataForDebug = function (data) {
30555
30998
  var userEvent = new exports.UserEvent();
30556
- userEvent.eventType = UserEventTypes.DEBUG_DATA;
30999
+ userEvent.type = UserEventTypes.DEBUG_DATA;
30557
31000
  userEvent.content = this.convertObjectToString(data);
30558
31001
  return this.save(userEvent);
30559
31002
  };
30560
31003
  UserEventService.prototype.asFilter = function (filter) {
30561
31004
  return exports.UserEventFilter.fromObject(filter);
30562
31005
  };
31006
+ UserEventService.prototype.fromObject = function (source) {
31007
+ return exports.UserEvent.fromObject(source);
31008
+ };
30563
31009
  /* -- protected methods -- */
30564
31010
  UserEventService.prototype.convertObjectToString = function (data) {
30565
31011
  if (typeof data === 'string') {
@@ -30577,13 +31023,13 @@
30577
31023
  };
30578
31024
  UserEventService.prototype.showToast = function (opts) {
30579
31025
  return __awaiter(this, void 0, void 0, function () {
30580
- return __generator(this, function (_a) {
30581
- switch (_a.label) {
31026
+ return __generator(this, function (_b) {
31027
+ switch (_b.label) {
30582
31028
  case 0:
30583
31029
  if (!this.toastController)
30584
31030
  throw new Error('Missing toastController in component\'s constructor');
30585
31031
  return [4 /*yield*/, Toasts.show(this.toastController, this.translate, opts)];
30586
- case 1: return [2 /*return*/, _a.sent()];
31032
+ case 1: return [2 /*return*/, _b.sent()];
30587
31033
  }
30588
31034
  });
30589
31035
  });
@@ -30594,14 +31040,10 @@
30594
31040
  // TODO: compute sign
30595
31041
  console.warn('TODO: sign user event before sending');
30596
31042
  };
30597
- UserEventService.prototype.copyIdAndUpdateDate = function (source, target) {
30598
- EntityUtils.copyIdAndUpdateDate(source, target);
30599
- };
30600
31043
  return UserEventService;
30601
- }(BaseGraphqlService));
30602
- UserEventService.ɵprov = i0.ɵɵdefineInjectable({ factory: function UserEventService_Factory() { return new UserEventService(i0.ɵɵinject(GraphqlService), i0.ɵɵinject(AccountService), i0.ɵɵinject(NetworkService), i0.ɵɵinject(i1$2.TranslateService), i0.ɵɵinject(i1$5.ToastController), i0.ɵɵinject(ENVIRONMENT, 8)); }, token: UserEventService, providedIn: "root" });
31044
+ }(AbstractUserEventService));
30603
31045
  UserEventService.decorators = [
30604
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
31046
+ { type: i0.Injectable }
30605
31047
  ];
30606
31048
  UserEventService.ctorParameters = function () { return [
30607
31049
  { type: GraphqlService },
@@ -30615,7 +31057,7 @@
30615
31057
 
30616
31058
  var ICONS_MAP = {
30617
31059
  DEBUG_DATA: { matIcon: 'bug_report' },
30618
- INBOX_MESSAGE: { matIcon: 'mail' },
31060
+ INBOX_MESSAGE: { matIcon: 'mail' }
30619
31061
  };
30620
31062
  // TODO: refactor with a registration done by data service:
30621
31063
  // - userEventService.registerEventAction({__typename: 'TripVO', ...})
@@ -30683,7 +31125,7 @@
30683
31125
  }
30684
31126
  }));
30685
31127
  var filter = this.filter || new exports.UserEventFilter();
30686
- filter.recipient = this.recipient;
31128
+ filter.recipients = [this.recipient];
30687
31129
  this.setFilter(filter, { emitEvent: true });
30688
31130
  };
30689
31131
  UserEventsTable.prototype.start = function () {
@@ -30705,17 +31147,17 @@
30705
31147
  });
30706
31148
  };
30707
31149
  UserEventsTable.prototype.getIcon = function (source) {
30708
- return ICONS_MAP[source.eventType];
31150
+ return ICONS_MAP[source.type];
30709
31151
  };
30710
31152
  UserEventsTable.prototype.getDetail = function (source) {
30711
31153
  if (!source)
30712
31154
  return undefined;
30713
- if (source.content && source.eventType === UserEventTypes.DEBUG_DATA) {
31155
+ if (source.content && source.type === UserEventTypes.DEBUG_DATA) {
30714
31156
  var context = source.content.context;
30715
31157
  if (context && context.__typename) {
30716
- var actions = this.service.getActionsByTypename(context.__typename);
31158
+ // const actions = this.service.getActionsByTypename(context.__typename);
30717
31159
  return {
30718
- actions: actions,
31160
+ // actions,
30719
31161
  title: source.content.error && source.content.error.message || source.content.message,
30720
31162
  description: source.content.error && source.content.error.details || undefined
30721
31163
  };
@@ -30726,18 +31168,18 @@
30726
31168
  };
30727
31169
  UserEventsTable.prototype.doAction = function (action, row) {
30728
31170
  return __awaiter(this, void 0, void 0, function () {
30729
- var event, context, res, _a, err_1;
31171
+ var event, res, _a, err_1;
30730
31172
  return __generator(this, function (_b) {
30731
31173
  switch (_b.label) {
30732
31174
  case 0:
30733
31175
  event = row.currentData;
30734
- context = event.content && event.content.context;
31176
+ // const context = event.content && event.content.context;
30735
31177
  this.markAsLoading();
30736
31178
  if (!(action && typeof action.executeAction === 'function')) return [3 /*break*/, 7];
30737
31179
  _b.label = 1;
30738
31180
  case 1:
30739
31181
  _b.trys.push([1, 5, 6, 7]);
30740
- res = action.executeAction(event, context);
31182
+ res = action.executeAction(event /*, context*/);
30741
31183
  if (!(res instanceof Promise)) return [3 /*break*/, 3];
30742
31184
  return [4 /*yield*/, res];
30743
31185
  case 2:
@@ -30767,15 +31209,20 @@
30767
31209
  UserEventsTable.decorators = [
30768
31210
  { type: i0.Component, args: [{
30769
31211
  selector: 'app-user-events-table',
30770
- template: "\n<!-- Type = options menu -->\n<mat-menu #optionsMenu=\"matMenu\" xPosition=\"after\">\n\n <!-- display columns -->\n <button mat-menu-item\n (click)=\"openSelectColumnsModal($event)\">\n <mat-icon>view_column</mat-icon>\n <ion-label translate>COMMON.DISPLAYED_COLUMNS_DOTS</ion-label>\n </button>\n\n</mat-menu>\n\n<!-- top header -->\n<mat-toolbar>\n\n <ng-container *ngIf=\"!selection.hasValue(); else hasSelection\">\n\n <button mat-icon-button [title]=\"'COMMON.BTN_REFRESH'|translate\" (click)=\"onRefresh.emit()\">\n <mat-icon>refresh</mat-icon>\n </button>\n\n </ng-container>\n\n <!-- if row selection -->\n <ng-template #hasSelection>\n\n <!-- delete -->\n <button mat-icon-button class=\"hidden-xs hidden-sm\" *ngIf=\"canDelete\"\n [title]=\"'COMMON.BTN_DELETE'|translate\" (click)=\"deleteSelection($event)\">\n <mat-icon>delete</mat-icon>\n </button>\n </ng-template>\n\n <!-- error -->\n <ion-item *ngIf=\"error\" hidden-xs hidden-sm hidden-mobile lines=\"none\">\n <ion-icon color=\"danger\" slot=\"start\" name=\"alert-circle\"></ion-icon>\n <ion-label color=\"danger\" class=\"error\" [innerHTML]=\"error|translate\"></ion-label>\n </ion-item>\n\n <div class=\"toolbar-spacer\"></div>\n\n <button mat-icon-button\n [title]=\"'COMMON.BTN_OPTIONS'|translate\"\n [matMenuTriggerFor]=\"optionsMenu\">\n <mat-icon>more_vert</mat-icon>\n </button>\n</mat-toolbar>\n\n\n<mat-table [dataSource]=\"dataSource\" matSort\n [matSortActive]=\"defaultSortBy\"\n [matSortDirection]=\"defaultSortDirection\"\n matSortDisableClear [trackBy]=\"trackByFn\">\n\n <!-- select -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef [class.cdk-visually-hidden]=\"!canEdit\">\n <mat-checkbox (change)=\"$event ? masterToggle() : null\" [checked]=\"selection.hasValue() && isAllSelected()\"\n [indeterminate]=\"selection.hasValue() && !isAllSelected()\">\n </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\" [class.cdk-visually-hidden]=\"!canEdit\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(row) : null\" [checked]=\"selection.isSelected(row)\">\n </mat-checkbox>\n </mat-cell>\n </ng-container>\n\n <!-- id -->\n <ng-container matColumnDef=\"id\">\n <mat-header-cell *matHeaderCellDef mat-sort-header [class.cdk-visually-hidden]=\"!isAdmin\">\n <app-loading-spinner [loading]=\"loadingSubject|async\"><ion-label>#</ion-label></app-loading-spinner>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\" [class.cdk-visually-hidden]=\"!isAdmin\">{{ row.currentData.id | mathAbs }}</mat-cell>\n </ng-container>\n\n <!-- creationDate -->\n <ng-container matColumnDef=\"creationDate\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n <ion-label translate>SOCIAL.USER_EVENT.CREATION_DATE</ion-label>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\">\n <ion-text>\n {{row.currentData.creationDate | dateFromNow }}<br/>\n <ion-text color=\"medium\"><small>{{row.currentData.creationDate | dateFormat: {time: true} }}</small></ion-text>\n </ion-text>\n </mat-cell>\n </ng-container>\n\n <!-- icon -->\n <ng-container matColumnDef=\"icon\">\n <mat-header-cell *matHeaderCellDef>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row;\">\n <ng-container *ngIf=\"getIcon(row.currentData); let details\">\n <ion-icon slot=\"start\" *ngIf=\"details.icon\" [name]=\"details.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"details.matIcon\">{{details.matIcon}}</mat-icon>\n </ng-container>\n </mat-cell>\n </ng-container>\n\n <!-- event type -->\n <ng-container matColumnDef=\"eventType\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n <ion-label translate>SOCIAL.USER_EVENT.EVENT_TYPE</ion-label>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row;\">\n <span>{{'SOCIAL.USER_EVENT.TYPE_ENUM.' + row.currentData.eventType | translate}}</span>\n </mat-cell>\n </ng-container>\n\n <!-- message -->\n <ng-container matColumnDef=\"message\">\n <mat-header-cell *matHeaderCellDef>\n <ion-label translate>SOCIAL.USER_EVENT.MESSAGE</ion-label>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row;\">\n <ng-container *ngIf=\"getDetail(row.currentData); let details\">\n <ion-text [innerHTML]=\"details.title|translate\">\n </ion-text>\n </ng-container>\n </mat-cell>\n </ng-container>\n\n <!-- Actions buttons column -->\n <ng-container matColumnDef=\"actions\">\n <mat-header-cell *matHeaderCellDef>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\">\n <ng-container *ngIf=\"getDetail(row.currentData); let details\">\n <button mat-icon-button color=\"light\"\n *ngFor=\"let action of details.actions\"\n [title]=\"action.title |translate\"\n [color]=\"action.color\"\n (click)=\"doAction(action, row)\">\n <ion-icon slot=\"start\" *ngIf=\"action.icon\" [name]=\"action.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"action.matIcon\">{{action.matIcon}}</mat-icon>\n </button>\n </ng-container>\n </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns;\"\n class=\"mat-row-disabled\"\n (click)=\"clickRow($event, row)\"></mat-row>\n\n</mat-table>\n\n<ion-row class=\"ion-no-padding\">\n <ion-col></ion-col>\n <ion-col class=\"ion-no-padding\" size=\"auto\">\n <mat-paginator [length]=\"totalRowCount\" [pageSize]=\"defaultPageSize\" [pageSizeOptions]=\"defaultPageSizeOptions\" showFirstLastButtons>\n </mat-paginator>\n </ion-col>\n</ion-row>\n",
31212
+ template: "\n<!-- Type = options menu -->\n<mat-menu #optionsMenu=\"matMenu\" xPosition=\"after\">\n\n <!-- display columns -->\n <button mat-menu-item\n (click)=\"openSelectColumnsModal($event)\">\n <mat-icon>view_column</mat-icon>\n <ion-label translate>COMMON.DISPLAYED_COLUMNS_DOTS</ion-label>\n </button>\n\n</mat-menu>\n\n<!-- top header -->\n<mat-toolbar>\n\n <ng-container *ngIf=\"!selection.hasValue(); else hasSelection\">\n\n <button mat-icon-button [title]=\"'COMMON.BTN_REFRESH'|translate\" (click)=\"onRefresh.emit()\">\n <mat-icon>refresh</mat-icon>\n </button>\n\n </ng-container>\n\n <!-- if row selection -->\n <ng-template #hasSelection>\n\n <!-- delete -->\n <button mat-icon-button class=\"hidden-xs hidden-sm\" *ngIf=\"canDelete\"\n [title]=\"'COMMON.BTN_DELETE'|translate\" (click)=\"deleteSelection($event)\">\n <mat-icon>delete</mat-icon>\n </button>\n </ng-template>\n\n <!-- error -->\n <ion-item *ngIf=\"error\" hidden-xs hidden-sm hidden-mobile lines=\"none\">\n <ion-icon color=\"danger\" slot=\"start\" name=\"alert-circle\"></ion-icon>\n <ion-label color=\"danger\" class=\"error\" [innerHTML]=\"error|translate\"></ion-label>\n </ion-item>\n\n <div class=\"toolbar-spacer\"></div>\n\n <button mat-icon-button\n [title]=\"'COMMON.BTN_OPTIONS'|translate\"\n [matMenuTriggerFor]=\"optionsMenu\">\n <mat-icon>more_vert</mat-icon>\n </button>\n</mat-toolbar>\n\n\n<mat-table [dataSource]=\"dataSource\" matSort\n [matSortActive]=\"defaultSortBy\"\n [matSortDirection]=\"defaultSortDirection\"\n matSortDisableClear [trackBy]=\"trackByFn\">\n\n <!-- select -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef [class.cdk-visually-hidden]=\"!canEdit\">\n <mat-checkbox (change)=\"$event ? masterToggle() : null\" [checked]=\"selection.hasValue() && isAllSelected()\"\n [indeterminate]=\"selection.hasValue() && !isAllSelected()\">\n </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\" [class.cdk-visually-hidden]=\"!canEdit\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(row) : null\" [checked]=\"selection.isSelected(row)\">\n </mat-checkbox>\n </mat-cell>\n </ng-container>\n\n <!-- id -->\n <ng-container matColumnDef=\"id\">\n <mat-header-cell *matHeaderCellDef mat-sort-header [class.cdk-visually-hidden]=\"!isAdmin\">\n <app-loading-spinner [loading]=\"loadingSubject|async\"><ion-label>#</ion-label></app-loading-spinner>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\" [class.cdk-visually-hidden]=\"!isAdmin\">{{ row.currentData.id | mathAbs }}</mat-cell>\n </ng-container>\n\n <!-- creationDate -->\n <ng-container matColumnDef=\"creationDate\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n <ion-label translate>SOCIAL.USER_EVENT.CREATION_DATE</ion-label>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\">\n <ion-text>\n {{row.currentData.creationDate | dateFromNow }}<br/>\n <ion-text color=\"medium\"><small>{{row.currentData.creationDate | dateFormat: {time: true} }}</small></ion-text>\n </ion-text>\n </mat-cell>\n </ng-container>\n\n <!-- icon -->\n <ng-container matColumnDef=\"icon\">\n <mat-header-cell *matHeaderCellDef>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row;\">\n <ng-container *ngIf=\"getIcon(row.currentData); let details\">\n <ion-icon slot=\"start\" *ngIf=\"details.icon\" [name]=\"details.icon\"></ion-icon>\n <mat-icon slot=\"start\" *ngIf=\"details.matIcon\">{{details.matIcon}}</mat-icon>\n </ng-container>\n </mat-cell>\n </ng-container>\n\n <!-- event type -->\n <ng-container matColumnDef=\"eventType\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n <ion-label translate>SOCIAL.USER_EVENT.EVENT_TYPE</ion-label>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row;\">\n <span>{{'SOCIAL.USER_EVENT.TYPE_ENUM.' + row.currentData.eventType | translate}}</span>\n </mat-cell>\n </ng-container>\n\n <!-- message -->\n <ng-container matColumnDef=\"message\">\n <mat-header-cell *matHeaderCellDef>\n <ion-label translate>SOCIAL.USER_EVENT.MESSAGE</ion-label>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row;\">\n <ng-container *ngIf=\"getDetail(row.currentData); let details\">\n <ion-text [innerHTML]=\"details.title|translate\">\n </ion-text>\n </ng-container>\n </mat-cell>\n </ng-container>\n\n <!-- Actions buttons column -->\n <ng-container matColumnDef=\"actions\">\n <mat-header-cell *matHeaderCellDef>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let row\">\n <ng-container *ngIf=\"getDetail(row.currentData); let details\">\n <button mat-icon-button color=\"light\"\n *ngFor=\"let action of details.actions\"\n [title]=\"action.title |translate\"\n [color]=\"action.color\"\n (click)=\"doAction(action, row)\">\n <app-icon slot=\"start\" *ngIf=\"action.iconRef\" [ref]=\"action.iconRef\"></app-icon>\n </button>\n </ng-container>\n </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns;\"\n class=\"mat-row-disabled\"\n (click)=\"clickRow($event, row)\"></mat-row>\n\n</mat-table>\n\n<ion-row class=\"ion-no-padding\">\n <ion-col></ion-col>\n <ion-col class=\"ion-no-padding\" size=\"auto\">\n <mat-paginator [length]=\"totalRowCount\" [pageSize]=\"defaultPageSize\" [pageSizeOptions]=\"defaultPageSizeOptions\" showFirstLastButtons>\n </mat-paginator>\n </ion-col>\n</ion-row>\n",
30771
31213
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
31214
+ providers: [
31215
+ {
31216
+ provide: UserEventServiceToken, useClass: UserEventService
31217
+ }
31218
+ ],
30772
31219
  styles: [".mat-header-row .mat-column-icon,.mat-row .mat-column-icon{max-width:40px;padding-left:0}.mat-header-row .mat-column-icon ion-icon,.mat-header-row .mat-column-icon mat-icon,.mat-row .mat-column-icon ion-icon,.mat-row .mat-column-icon mat-icon{font-size:1.2em;height:1.2em;width:1.2em}.mat-header-row .mat-column-creationDate,.mat-row .mat-column-creationDate{min-width:100px;max-width:120px}"]
30773
31220
  },] }
30774
31221
  ];
30775
31222
  UserEventsTable.ctorParameters = function () { return [
30776
31223
  { type: i0.Injector },
30777
31224
  { type: AccountService },
30778
- { type: UserEventService },
31225
+ { type: undefined, decorators: [{ type: i0.Inject, args: [UserEventServiceToken,] }] },
30779
31226
  { type: EntitiesStorage },
30780
31227
  { type: i0.ChangeDetectorRef },
30781
31228
  { type: undefined, decorators: [{ type: i0.Inject, args: [ENVIRONMENT,] }] }
@@ -30787,6 +31234,310 @@
30787
31234
  defaultSortDirection: [{ type: i0.Input }]
30788
31235
  };
30789
31236
 
31237
+ var UserEventNotificationList = /** @class */ (function () {
31238
+ function UserEventNotificationList(cd, popoverController, userEventService) {
31239
+ this.cd = cd;
31240
+ this.popoverController = popoverController;
31241
+ this.userEventService = userEventService;
31242
+ this.debug = false;
31243
+ this.userEvents = new rxjs.BehaviorSubject(undefined);
31244
+ this.subscriptions = new rxjs.Subscription();
31245
+ }
31246
+ UserEventNotificationList.prototype.ngOnInit = function () {
31247
+ var _this = this;
31248
+ // Watch all user events
31249
+ this.subscriptions.add(this.userEventService
31250
+ .watchAll(0, 10, 'creationDate', "desc", undefined)
31251
+ .subscribe(function (result) {
31252
+ if (_this.debug)
31253
+ console.debug("[user-event-notification-list] receiving " + result.total + " user events", result.data);
31254
+ _this.userEvents.next(result.data);
31255
+ _this.markForCheck();
31256
+ }));
31257
+ // Listen changes
31258
+ this.subscriptions.add(this.userEventService.listenChanges(undefined)
31259
+ .subscribe(function (data) {
31260
+ if (_this.debug)
31261
+ console.debug("[user-event-notification-list] receiving " + data.length + " new user events", data);
31262
+ }));
31263
+ };
31264
+ UserEventNotificationList.prototype.ngOnDestroy = function () {
31265
+ this.subscriptions.unsubscribe();
31266
+ };
31267
+ UserEventNotificationList.prototype.read = function (event, userEvent) {
31268
+ var _a;
31269
+ if (userEvent === null || userEvent === void 0 ? void 0 : userEvent.readDate)
31270
+ return;
31271
+ (_a = this.readEvent) === null || _a === void 0 ? void 0 : _a.emit(userEvent);
31272
+ };
31273
+ UserEventNotificationList.prototype.readAll = function (event) {
31274
+ var _a;
31275
+ var unreadUserEvents = (this.userEvents.value || []).filter(function (value) { return !value.readDate; });
31276
+ if (!unreadUserEvents.length)
31277
+ return;
31278
+ (_a = this.readEvents) === null || _a === void 0 ? void 0 : _a.emit(unreadUserEvents);
31279
+ };
31280
+ UserEventNotificationList.prototype.executeAction = function (action, userEvent) {
31281
+ // Execute then close popover
31282
+ action.executeAction(userEvent);
31283
+ this.dismiss();
31284
+ };
31285
+ UserEventNotificationList.prototype.dismiss = function () {
31286
+ this.popoverController.dismiss();
31287
+ };
31288
+ UserEventNotificationList.prototype.markForCheck = function () {
31289
+ this.cd.markForCheck();
31290
+ };
31291
+ return UserEventNotificationList;
31292
+ }());
31293
+ UserEventNotificationList.decorators = [
31294
+ { type: i0.Component, args: [{
31295
+ selector: 'app-user-event-notification-list',
31296
+ 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-col class=\"top-action\">\n <a (click)=\"readAll($event)\">{{'SOCIAL.USER_EVENT.NOTIFICATION.READ_ALL' | translate}}</a>\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 message\">\n <ion-row>\n <ion-col>\n <p [class.unread]=\"!userEvent.readDate\" [innerHTML]=\"userEvent.message\"></p>\n </ion-col>\n </ion-row>\n <ion-row *ngIf=\"userEvent.actions?.length\">\n <ion-col>\n <span *ngFor=\"let action of userEvent.actions\" class=\"action\">\n <a (click)=\"executeAction(action, userEvent)\">\n <app-icon *ngIf=\"action.iconRef\" slot=\"start\" height=\"20\" width=\"20\" [ref]=\"action.iconRef\"></app-icon>\n {{ action.name }}\n </a>\n </span>\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; margin-right: 3px\"\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-row class=\"ion-list-footer column\">\n </ion-row>\n\n</ion-list>\n",
31297
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
31298
+ styles: [":host(.popover-viewport){overflow-y:auto;-webkit-user-select:none;-moz-user-select:none;user-select:none}.unread{font-weight:700}.message{font-size:.9em}.message p{margin-top:5px;margin-bottom:5px}.top-action{text-align:end;margin-right:8px}.top-action a{cursor:pointer;color:#f5f5f5;font-style:italic}.action a{margin-right:10px;cursor:pointer}.action app-icon{vertical-align:middle}"]
31299
+ },] }
31300
+ ];
31301
+ UserEventNotificationList.ctorParameters = function () { return [
31302
+ { type: i0.ChangeDetectorRef },
31303
+ { type: i1$5.PopoverController },
31304
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UserEventServiceToken,] }] }
31305
+ ]; };
31306
+ UserEventNotificationList.propDecorators = {
31307
+ debug: [{ type: i0.Input }],
31308
+ titleI18n: [{ type: i0.Input }],
31309
+ readEvent: [{ type: i0.Output }],
31310
+ readEvents: [{ type: i0.Output }]
31311
+ };
31312
+
31313
+ var UserEventNotificationComponent = /** @class */ (function () {
31314
+ function UserEventNotificationComponent(userEventService, accountService, popoverController) {
31315
+ this.userEventService = userEventService;
31316
+ this.accountService = accountService;
31317
+ this.popoverController = popoverController;
31318
+ this.debug = false;
31319
+ this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
31320
+ this.disabled = false;
31321
+ this._logPrefix = '[user-event-notification] ';
31322
+ this._readEvent = new i0.EventEmitter();
31323
+ this._readEvents = new i0.EventEmitter();
31324
+ }
31325
+ Object.defineProperty(UserEventNotificationComponent.prototype, "count", {
31326
+ get: function () {
31327
+ var _a;
31328
+ return (_a = this.userEventService) === null || _a === void 0 ? void 0 : _a.userEventCount.pipe(operators.map(function (value) { return value === 0 ? undefined : value; }));
31329
+ },
31330
+ enumerable: false,
31331
+ configurable: true
31332
+ });
31333
+ UserEventNotificationComponent.prototype.ngOnInit = function () {
31334
+ return __awaiter(this, void 0, void 0, function () {
31335
+ var _this = this;
31336
+ return __generator(this, function (_b) {
31337
+ switch (_b.label) {
31338
+ case 0:
31339
+ if (isNil(this.userEventService)) {
31340
+ console.warn(this._logPrefix + "No service injected");
31341
+ this.disabled = true;
31342
+ return [2 /*return*/];
31343
+ }
31344
+ // Wait service
31345
+ return [4 /*yield*/, this.userEventService.ready()];
31346
+ case 1:
31347
+ // Wait service
31348
+ _b.sent();
31349
+ // Subscribe to read event
31350
+ this._readEvent.subscribe(function (value) {
31351
+ // default: mark event as read
31352
+ _this.userEventService.markAsRead([value]);
31353
+ });
31354
+ this._readEvents.subscribe(function (value) {
31355
+ _this.userEventService.markAsRead(value);
31356
+ });
31357
+ return [2 /*return*/];
31358
+ }
31359
+ });
31360
+ });
31361
+ };
31362
+ UserEventNotificationComponent.prototype.showList = function (event) {
31363
+ return __awaiter(this, void 0, void 0, function () {
31364
+ var popover;
31365
+ return __generator(this, function (_b) {
31366
+ switch (_b.label) {
31367
+ case 0:
31368
+ // Reset count
31369
+ this.userEventService.resetCount();
31370
+ return [4 /*yield*/, this.popoverController.create({
31371
+ component: UserEventNotificationList,
31372
+ componentProps: {
31373
+ debug: this.debug,
31374
+ titleI18n: this.titleI18n,
31375
+ readEvent: this._readEvent,
31376
+ readEvents: this._readEvents
31377
+ },
31378
+ backdropDismiss: true,
31379
+ keyboardClose: true,
31380
+ event: event,
31381
+ translucent: true,
31382
+ cssClass: 'popover-large'
31383
+ })];
31384
+ case 1:
31385
+ popover = _b.sent();
31386
+ return [4 /*yield*/, popover.present()];
31387
+ case 2:
31388
+ _b.sent();
31389
+ return [2 /*return*/];
31390
+ }
31391
+ });
31392
+ });
31393
+ };
31394
+ UserEventNotificationComponent.prototype.ngOnDestroy = function () {
31395
+ if (this.debug) {
31396
+ console.debug(this._logPrefix + "Destroying");
31397
+ }
31398
+ };
31399
+ return UserEventNotificationComponent;
31400
+ }());
31401
+ UserEventNotificationComponent.decorators = [
31402
+ { type: i0.Component, args: [{
31403
+ selector: 'app-user-event-notification-component',
31404
+ 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]=\"count | async\"\n matBadgeColor=\"accent\"\n matBadgeSize=\"small\"\n matBadgePosition=\"above after\"\n >notifications\n </mat-icon>\n</button>\n\n",
31405
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
31406
+ styles: [""]
31407
+ },] }
31408
+ ];
31409
+ UserEventNotificationComponent.ctorParameters = function () { return [
31410
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UserEventServiceToken,] }] },
31411
+ { type: AccountService },
31412
+ { type: i1$5.PopoverController }
31413
+ ]; };
31414
+ UserEventNotificationComponent.propDecorators = {
31415
+ debug: [{ type: i0.Input }],
31416
+ titleI18n: [{ type: i0.Input }],
31417
+ disabled: [{ type: i0.Input }]
31418
+ };
31419
+
31420
+ var UserEventTestService = /** @class */ (function (_super) {
31421
+ __extends(UserEventTestService, _super);
31422
+ function UserEventTestService(graphql, accountService, network, translate, environment) {
31423
+ var _this = _super.call(this, graphql, accountService, network, translate, undefined, undefined, undefined, environment) || this;
31424
+ _this.graphql = graphql;
31425
+ _this.accountService = accountService;
31426
+ _this.network = network;
31427
+ _this.translate = translate;
31428
+ _this.environment = environment;
31429
+ _this.userEvents = [];
31430
+ return _this;
31431
+ }
31432
+ UserEventTestService.prototype.fromObject = function (source) {
31433
+ return exports.UserEvent.fromObject(source);
31434
+ };
31435
+ UserEventTestService.prototype.add = function (entity) {
31436
+ entity = this.processUserEvent(entity);
31437
+ entity.id = this.userEvents.length + 1;
31438
+ this.userEvents.push(entity);
31439
+ this.count$.next(this.userEvents.length);
31440
+ };
31441
+ UserEventTestService.prototype.asFilter = function (filter) {
31442
+ return filter;
31443
+ };
31444
+ UserEventTestService.prototype.count = function (filter, options) {
31445
+ return Promise.resolve(this.userEvents.length);
31446
+ };
31447
+ UserEventTestService.prototype.delete = function (entity) {
31448
+ return Promise.resolve(undefined);
31449
+ };
31450
+ UserEventTestService.prototype.deleteAll = function (data, opts) {
31451
+ return Promise.resolve(undefined);
31452
+ };
31453
+ UserEventTestService.prototype.listenChanges = function (filter, options) {
31454
+ return rxjs.of();
31455
+ };
31456
+ UserEventTestService.prototype.save = function (entity, options) {
31457
+ var _a;
31458
+ 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); });
31459
+ Object.assign(toSave, entity);
31460
+ return entity;
31461
+ };
31462
+ UserEventTestService.prototype.saveAll = function (data, opts) {
31463
+ return __awaiter(this, void 0, void 0, function () {
31464
+ var _b, _c, entity, e_1_1;
31465
+ var e_1, _d;
31466
+ return __generator(this, function (_e) {
31467
+ switch (_e.label) {
31468
+ case 0:
31469
+ _e.trys.push([0, 5, 6, 7]);
31470
+ _b = __values((data || [])), _c = _b.next();
31471
+ _e.label = 1;
31472
+ case 1:
31473
+ if (!!_c.done) return [3 /*break*/, 4];
31474
+ entity = _c.value;
31475
+ return [4 /*yield*/, this.save(entity)];
31476
+ case 2:
31477
+ _e.sent();
31478
+ _e.label = 3;
31479
+ case 3:
31480
+ _c = _b.next();
31481
+ return [3 /*break*/, 1];
31482
+ case 4: return [3 /*break*/, 7];
31483
+ case 5:
31484
+ e_1_1 = _e.sent();
31485
+ e_1 = { error: e_1_1 };
31486
+ return [3 /*break*/, 7];
31487
+ case 6:
31488
+ try {
31489
+ if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
31490
+ }
31491
+ finally { if (e_1) throw e_1.error; }
31492
+ return [7 /*endfinally*/];
31493
+ case 7: return [2 /*return*/, Promise.resolve(this.userEvents)];
31494
+ }
31495
+ });
31496
+ });
31497
+ };
31498
+ UserEventTestService.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter, options) {
31499
+ return rxjs.of({ data: this.userEvents });
31500
+ };
31501
+ return UserEventTestService;
31502
+ }(AbstractUserEventService));
31503
+ UserEventTestService.decorators = [
31504
+ { type: i0.Injectable }
31505
+ ];
31506
+ UserEventTestService.ctorParameters = function () { return [
31507
+ { type: GraphqlService },
31508
+ { type: AccountService },
31509
+ { type: NetworkService },
31510
+ { type: i1$2.TranslateService },
31511
+ { type: Environment, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [ENVIRONMENT,] }] }
31512
+ ]; };
31513
+
31514
+ var UserEventModule = /** @class */ (function () {
31515
+ function UserEventModule() {
31516
+ }
31517
+ return UserEventModule;
31518
+ }());
31519
+ UserEventModule.decorators = [
31520
+ { type: i0.NgModule, args: [{
31521
+ imports: [
31522
+ i1$4.CommonModule,
31523
+ CoreModule,
31524
+ SharedModule
31525
+ ],
31526
+ declarations: [
31527
+ UserEventsTable,
31528
+ UserEventNotificationComponent,
31529
+ UserEventNotificationList,
31530
+ ],
31531
+ exports: [
31532
+ UserEventsTable,
31533
+ UserEventNotificationComponent
31534
+ ],
31535
+ providers: [
31536
+ { provide: UserEventServiceToken, useClass: UserEventTestService }
31537
+ ]
31538
+ },] }
31539
+ ];
31540
+
30790
31541
  var MessageTypes = {
30791
31542
  INBOX_MESSAGE: 'INBOX_MESSAGE',
30792
31543
  EMAIL: 'EMAIL',
@@ -31020,12 +31771,12 @@
31020
31771
  canSelectType: [{ type: i0.Input }]
31021
31772
  };
31022
31773
 
31023
- var SocialModule = /** @class */ (function () {
31024
- function SocialModule() {
31774
+ var MessageModule = /** @class */ (function () {
31775
+ function MessageModule() {
31025
31776
  }
31026
- return SocialModule;
31777
+ return MessageModule;
31027
31778
  }());
31028
- SocialModule.decorators = [
31779
+ MessageModule.decorators = [
31029
31780
  { type: i0.NgModule, args: [{
31030
31781
  imports: [
31031
31782
  i1$4.CommonModule,
@@ -31033,19 +31784,359 @@
31033
31784
  SharedModule
31034
31785
  ],
31035
31786
  declarations: [
31036
- UserEventsTable,
31037
31787
  MessageModal,
31038
31788
  MessageForm
31039
31789
  ],
31040
31790
  exports: [
31041
- UserEventsTable,
31042
31791
  MessageModal
31043
31792
  ]
31044
31793
  },] }
31045
31794
  ];
31046
31795
 
31796
+ var JobProgression_1;
31797
+ // todo use entity
31798
+ var Job = /** @class */ (function () {
31799
+ function Job() {
31800
+ }
31801
+ return Job;
31802
+ }());
31803
+ // @dynamic
31804
+ exports.JobProgression = JobProgression_1 = /** @class */ (function (_super) {
31805
+ __extends(JobProgression, _super);
31806
+ function JobProgression(id) {
31807
+ var _this = _super.call(this, JobProgression_1.TYPENAME) || this;
31808
+ _this.id = id;
31809
+ return _this;
31810
+ }
31811
+ JobProgression.prototype.fromObject = function (source) {
31812
+ _super.prototype.fromObject.call(this, source);
31813
+ this.name = source.name;
31814
+ this.message = source.message;
31815
+ this.current = source.current;
31816
+ this.total = source.total;
31817
+ };
31818
+ return JobProgression;
31819
+ }(Entity));
31820
+ exports.JobProgression = JobProgression_1 = __decorate([
31821
+ EntityClass({ typename: 'JobProgressionVO' })
31822
+ ], exports.JobProgression);
31823
+
31824
+ var JobProgressionServiceToken = new i0.InjectionToken('JobProgressionService');
31825
+ var jobProgressionSubscription = core.gql(templateObject_1$4 || (templateObject_1$4 = __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}"])));
31826
+ var JobProgressionService = /** @class */ (function (_super) {
31827
+ __extends(JobProgressionService, _super);
31828
+ function JobProgressionService(graphql, environment) {
31829
+ var _this = _super.call(this, graphql, environment) || this;
31830
+ _this.graphql = graphql;
31831
+ _this.environment = environment;
31832
+ _this._logPrefix = '[job-progression-service] ';
31833
+ // For DEV only
31834
+ _this._debug = !(environment === null || environment === void 0 ? void 0 : environment.production);
31835
+ return _this;
31836
+ }
31837
+ JobProgressionService.prototype.listenChanges = function (id, options) {
31838
+ var _this = this;
31839
+ if (isNil(id))
31840
+ throw new Error(this._logPrefix + "Missing argument 'id'");
31841
+ if (this._debug)
31842
+ console.debug(this._logPrefix + "[WS] Listening changes for job progression {" + id + "}...");
31843
+ return this.graphql.subscribe({
31844
+ query: jobProgressionSubscription,
31845
+ fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
31846
+ variables: { id: id, interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
31847
+ error: { code: SocialErrorCodes.SUBSCRIBE_JOB_PROGRESSION_ERROR, message: 'SOCIAL.ERROR.SUBSCRIBE_JOB_PROGRESSION_ERROR' }
31848
+ }).pipe(operators.map(function (_a) {
31849
+ var data = _a.data;
31850
+ var progression = data && exports.JobProgression.fromObject(data);
31851
+ if (progression && _this._debug)
31852
+ console.debug(_this._logPrefix + "Job progression " + id + " updated on server", progression);
31853
+ return progression;
31854
+ }));
31855
+ };
31856
+ return JobProgressionService;
31857
+ }(BaseGraphqlService));
31858
+ JobProgressionService.decorators = [
31859
+ { type: i0.Injectable }
31860
+ ];
31861
+ JobProgressionService.ctorParameters = function () { return [
31862
+ { type: GraphqlService },
31863
+ { type: Environment, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [ENVIRONMENT,] }] }
31864
+ ]; };
31865
+ var templateObject_1$4;
31866
+
31867
+ var JobProgressionList = /** @class */ (function () {
31868
+ function JobProgressionList() {
31869
+ }
31870
+ JobProgressionList.prototype.ngOnInit = function () {
31871
+ };
31872
+ return JobProgressionList;
31873
+ }());
31874
+ JobProgressionList.decorators = [
31875
+ { type: i0.Component, args: [{
31876
+ selector: 'app-job-progression-list',
31877
+ template: "<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=\"!jobProgressions?.length\">\n {{'SOCIAL.JOB.PROGRESSION.EMPTY' | translate}}\n </ion-item>\n <ion-item *ngFor=\"let jobProgression of jobProgressions\" class=\"ion-item-job-progression\">\n <ion-grid class=\"ion-no-margin\">\n <ion-row class=\"name\">\n <ion-col>\n {{jobProgression.name}}\n </ion-col>\n </ion-row>\n <ion-row class=\"message\">\n <ion-col>\n {{jobProgression.message}}\n </ion-col>\n </ion-row>\n <ion-row class=\"progress-bar\">\n <ion-col>\n <ion-progress-bar\n [value]=\"jobProgression.total > 0 ? jobProgression.current / jobProgression.total : undefined\"\n [type]=\"jobProgression.total > 0 ? 'determinate' : 'indeterminate'\">\n </ion-progress-bar>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-item>\n\n</ion-list>\n",
31878
+ styles: [":host(.popover-viewport){overflow-y:auto;-webkit-user-select:none;-moz-user-select:none;user-select:none}.ion-item-job-progression{font-size:.9em}.ion-item-job-progression .message{font-style:italic}.ion-item-job-progression .progress-bar{margin-top:5px;margin-bottom:5px}"]
31879
+ },] }
31880
+ ];
31881
+ JobProgressionList.ctorParameters = function () { return []; };
31882
+ JobProgressionList.propDecorators = {
31883
+ titleI18n: [{ type: i0.Input }],
31884
+ jobProgressions: [{ type: i0.Input }]
31885
+ };
31886
+
31887
+ var JobProgressionComponent = /** @class */ (function () {
31888
+ function JobProgressionComponent(jobProgressionService, popoverController, cd) {
31889
+ this.jobProgressionService = jobProgressionService;
31890
+ this.popoverController = popoverController;
31891
+ this.cd = cd;
31892
+ this.debug = false;
31893
+ this.titleI18n = 'SOCIAL.JOB.PROGRESSION.TITLE';
31894
+ this.jobFinished = new i0.EventEmitter();
31895
+ this.disabled = true;
31896
+ this.color = 'accent';
31897
+ this.mode = 'determinate';
31898
+ this.value = 0;
31899
+ this.jobProgressions = [];
31900
+ this._subscriptions = new rxjs.Subscription();
31901
+ this._subscriptionsById = {};
31902
+ this._logPrefix = '[job-progression] ';
31903
+ }
31904
+ JobProgressionComponent.prototype.ngOnInit = function () {
31905
+ var _a, _b, _c, _d;
31906
+ if (isNil(this.jobProgressionService)) {
31907
+ console.warn(this._logPrefix + "No service injected");
31908
+ }
31909
+ // parse options
31910
+ this.autoHide = toBoolean((_a = this.options) === null || _a === void 0 ? void 0 : _a.autoHide, false);
31911
+ this.visible = !this.autoHide;
31912
+ this.autoHideDelay = toNumber((_b = this.options) === null || _b === void 0 ? void 0 : _b.autoHideDelay, 1000);
31913
+ this.autoRemove = toBoolean((_c = this.options) === null || _c === void 0 ? void 0 : _c.autoRemove, true);
31914
+ this.autoRemoveDelay = toNumber((_d = this.options) === null || _d === void 0 ? void 0 : _d.autoRemoveDelay, 1000);
31915
+ };
31916
+ JobProgressionComponent.prototype.addJob = function (id) {
31917
+ var _this = this;
31918
+ if (isNil(this.jobProgressionService)) {
31919
+ console.warn(this._logPrefix + "No service injected. Can't add a job");
31920
+ return;
31921
+ }
31922
+ if (!!this.getProgression(id)) {
31923
+ console.warn(this._logPrefix + "Job (id=" + id + ") already present");
31924
+ return;
31925
+ }
31926
+ if (this.debug) {
31927
+ console.debug(this._logPrefix + "Add job id=" + id);
31928
+ }
31929
+ // Adding empty job progression
31930
+ var progression = new exports.JobProgression(id);
31931
+ this.jobProgressions.push(progression);
31932
+ this.disabled = false;
31933
+ var sub = this.jobProgressionService.listenChanges(id)
31934
+ .pipe(operators.filter(function (progression) {
31935
+ if (id !== progression.id) {
31936
+ console.error(_this._logPrefix + "Job progression (id=" + progression.id + ") doesn't match expected job (id=" + id + ")");
31937
+ return false;
31938
+ }
31939
+ return true;
31940
+ }), operators.map(function (progression) {
31941
+ // Ensure visible
31942
+ _this.visible = true;
31943
+ // Get current progression object
31944
+ var currentProgression = _this.getProgression(id);
31945
+ if (!currentProgression) {
31946
+ // add it if absent
31947
+ _this.jobProgressions.push(progression);
31948
+ if (_this.debug) {
31949
+ console.debug(_this._logPrefix + "Progression added id=" + id, progression);
31950
+ }
31951
+ }
31952
+ else {
31953
+ // update current
31954
+ Object.assign(currentProgression, progression);
31955
+ if (_this.debug) {
31956
+ console.debug(_this._logPrefix + "Progression updated id=" + id, progression);
31957
+ }
31958
+ }
31959
+ return progression;
31960
+ }))
31961
+ .subscribe(function (progression) {
31962
+ // update value
31963
+ _this.updateValue();
31964
+ // job finished
31965
+ if (progression.total > 0 && progression.current == progression.total) {
31966
+ if (_this.debug) {
31967
+ console.debug(_this._logPrefix + "Finished job id=" + progression.id);
31968
+ }
31969
+ // emit event
31970
+ _this.jobFinished.emit(progression.id);
31971
+ if (_this.autoRemove) {
31972
+ setTimeout(function () {
31973
+ var _a;
31974
+ _this.removeJob(progression.id);
31975
+ // If last job
31976
+ if (_this.autoHide && !((_a = _this.jobProgressions) === null || _a === void 0 ? void 0 : _a.length)) {
31977
+ setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
31978
+ var _b;
31979
+ return __generator(this, function (_e) {
31980
+ (_b = this._listPopover) === null || _b === void 0 ? void 0 : _b.dismiss();
31981
+ this.visible = false;
31982
+ this.markForCheck();
31983
+ return [2 /*return*/];
31984
+ });
31985
+ }); }, _this.autoHideDelay);
31986
+ }
31987
+ }, _this.autoRemoveDelay);
31988
+ }
31989
+ }
31990
+ });
31991
+ this._subscriptionsById[id] = sub;
31992
+ this._subscriptions.add(sub);
31993
+ };
31994
+ JobProgressionComponent.prototype.removeJob = function (id) {
31995
+ if (this.debug) {
31996
+ console.debug(this._logPrefix + "Remove job id=" + id);
31997
+ }
31998
+ var sub = this._subscriptionsById[id];
31999
+ if (sub) {
32000
+ this._subscriptions.remove(sub);
32001
+ sub.unsubscribe();
32002
+ }
32003
+ var progression = this.getProgression(id);
32004
+ if (progression) {
32005
+ this.jobProgressions.splice(this.jobProgressions.indexOf(progression), 1);
32006
+ }
32007
+ this.updateValue();
32008
+ };
32009
+ JobProgressionComponent.prototype.getProgression = function (id) {
32010
+ return this.jobProgressions.find(function (progression) { return progression.id === id; });
32011
+ };
32012
+ JobProgressionComponent.prototype.updateValue = function () {
32013
+ if (this.debug) {
32014
+ console.debug(this._logPrefix + "Updating value");
32015
+ }
32016
+ var value = 0;
32017
+ var nbProgression = arraySize(this.jobProgressions);
32018
+ var allIndeterminate = nbProgression > 0;
32019
+ this.jobProgressions.forEach(function (progression) {
32020
+ var indeterminate = progression.total === 0;
32021
+ allIndeterminate = allIndeterminate && indeterminate;
32022
+ if (!indeterminate) {
32023
+ value = value + progression.current * 100 / progression.total;
32024
+ }
32025
+ });
32026
+ this.value = nbProgression > 0 ? value / nbProgression : 0;
32027
+ this.mode = allIndeterminate ? 'indeterminate' : 'determinate';
32028
+ if (this.debug) {
32029
+ console.debug(this._logPrefix + "Setting value=" + this.value + ", mode=" + this.mode);
32030
+ }
32031
+ this.markForCheck();
32032
+ };
32033
+ JobProgressionComponent.prototype.showList = function (event) {
32034
+ return __awaiter(this, void 0, void 0, function () {
32035
+ var _e;
32036
+ return __generator(this, function (_f) {
32037
+ switch (_f.label) {
32038
+ case 0:
32039
+ _e = this;
32040
+ return [4 /*yield*/, this.popoverController.create({
32041
+ component: JobProgressionList,
32042
+ componentProps: {
32043
+ titleI18n: this.titleI18n,
32044
+ jobProgressions: this.jobProgressions
32045
+ },
32046
+ backdropDismiss: true,
32047
+ keyboardClose: true,
32048
+ event: event,
32049
+ translucent: true,
32050
+ cssClass: 'popover-large'
32051
+ })];
32052
+ case 1:
32053
+ _e._listPopover = _f.sent();
32054
+ return [4 /*yield*/, this._listPopover.present()];
32055
+ case 2:
32056
+ _f.sent();
32057
+ return [4 /*yield*/, this._listPopover.onDidDismiss()];
32058
+ case 3:
32059
+ _f.sent();
32060
+ this._listPopover = undefined;
32061
+ return [2 /*return*/];
32062
+ }
32063
+ });
32064
+ });
32065
+ };
32066
+ JobProgressionComponent.prototype.markForCheck = function () {
32067
+ this.cd.markForCheck();
32068
+ };
32069
+ JobProgressionComponent.prototype.ngOnDestroy = function () {
32070
+ if (this.debug) {
32071
+ console.debug(this._logPrefix + "Destroying");
32072
+ }
32073
+ this._subscriptions.unsubscribe();
32074
+ };
32075
+ return JobProgressionComponent;
32076
+ }());
32077
+ JobProgressionComponent.decorators = [
32078
+ { type: i0.Component, args: [{
32079
+ selector: 'app-job-progression',
32080
+ 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",
32081
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
32082
+ styles: [".floating-spinner{position:absolute;top:6px;left:5px}"]
32083
+ },] }
32084
+ ];
32085
+ JobProgressionComponent.ctorParameters = function () { return [
32086
+ { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [JobProgressionServiceToken,] }] },
32087
+ { type: i1$5.PopoverController },
32088
+ { type: i0.ChangeDetectorRef }
32089
+ ]; };
32090
+ JobProgressionComponent.propDecorators = {
32091
+ debug: [{ type: i0.Input }],
32092
+ titleI18n: [{ type: i0.Input }],
32093
+ options: [{ type: i0.Input }],
32094
+ jobFinished: [{ type: i0.Output }]
32095
+ };
32096
+
32097
+ var JobModule = /** @class */ (function () {
32098
+ function JobModule() {
32099
+ }
32100
+ return JobModule;
32101
+ }());
32102
+ JobModule.decorators = [
32103
+ { type: i0.NgModule, args: [{
32104
+ imports: [
32105
+ i1$4.CommonModule,
32106
+ SharedModule,
32107
+ i1$2.TranslateModule.forChild(),
32108
+ ],
32109
+ declarations: [
32110
+ JobProgressionComponent,
32111
+ JobProgressionList
32112
+ ],
32113
+ exports: [
32114
+ JobProgressionComponent
32115
+ ]
32116
+ },] }
32117
+ ];
32118
+
32119
+ var SocialModuleOptionsToken = new i0.InjectionToken("SocialModuleOptions");
32120
+ var SocialModule = /** @class */ (function () {
32121
+ function SocialModule() {
32122
+ }
32123
+ return SocialModule;
32124
+ }());
32125
+ SocialModule.decorators = [
32126
+ { type: i0.NgModule, args: [{
32127
+ imports: [
32128
+ i1$4.CommonModule,
32129
+ CoreModule,
32130
+ SharedModule,
32131
+ UserEventModule,
32132
+ JobModule,
32133
+ MessageModule,
32134
+ ],
32135
+ },] }
32136
+ ];
32137
+
31047
32138
  var Mutations = {
31048
- send: core.gql(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["mutation SendMessage($data: MessageVOInput){\n done: sendMessage(message: $data)\n }"], ["mutation SendMessage($data: MessageVOInput){\n done: sendMessage(message: $data)\n }"])))
32139
+ send: core.gql(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["mutation SendMessage($data: MessageVOInput){\n done: sendMessage(message: $data)\n }"], ["mutation SendMessage($data: MessageVOInput){\n done: sendMessage(message: $data)\n }"])))
31049
32140
  };
31050
32141
  var MessageService = /** @class */ (function (_super) {
31051
32142
  __extends(MessageService, _super);
@@ -31129,7 +32220,7 @@
31129
32220
  { type: i1$5.ToastController },
31130
32221
  { type: Environment, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [ENVIRONMENT,] }] }
31131
32222
  ]; };
31132
- var templateObject_1$4;
32223
+ var templateObject_1$5;
31133
32224
 
31134
32225
  var PersonFilter_1;
31135
32226
  // @dynamic
@@ -31188,7 +32279,7 @@
31188
32279
  ], exports.PersonFilter);
31189
32280
 
31190
32281
  var PersonFragments = {
31191
- person: core.gql(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["fragment PersonFragment on PersonVO {\n id\n firstName\n lastName\n email\n pubkey\n avatar\n statusId\n updateDate\n creationDate\n profiles\n username\n usernameExtranet\n department {\n id\n label\n name\n logo\n __typename\n }\n __typename\n }"], ["fragment PersonFragment on PersonVO {\n id\n firstName\n lastName\n email\n pubkey\n avatar\n statusId\n updateDate\n creationDate\n profiles\n username\n usernameExtranet\n department {\n id\n label\n name\n logo\n __typename\n }\n __typename\n }"])))
32282
+ person: core.gql(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["fragment PersonFragment on PersonVO {\n id\n firstName\n lastName\n email\n pubkey\n avatar\n statusId\n updateDate\n creationDate\n profiles\n username\n usernameExtranet\n department {\n id\n label\n name\n logo\n __typename\n }\n __typename\n }"], ["fragment PersonFragment on PersonVO {\n id\n firstName\n lastName\n email\n pubkey\n avatar\n statusId\n updateDate\n creationDate\n profiles\n username\n usernameExtranet\n department {\n id\n label\n name\n logo\n __typename\n }\n __typename\n }"])))
31192
32283
  };
31193
32284
  // Load persons query
31194
32285
  var PersonQueries = {
@@ -31328,7 +32419,7 @@
31328
32419
  { type: NetworkService },
31329
32420
  { type: EntitiesStorage }
31330
32421
  ]; };
31331
- var templateObject_1$5, templateObject_2$4, templateObject_3$3, templateObject_4$3, templateObject_5$2;
32422
+ var templateObject_1$6, templateObject_2$4, templateObject_3$3, templateObject_4$3, templateObject_5$2;
31332
32423
 
31333
32424
  var PersonValidatorService = /** @class */ (function () {
31334
32425
  function PersonValidatorService(formBuilder, accountValidatorService) {
@@ -31932,13 +33023,13 @@
31932
33023
  { type: i1.FormBuilder }
31933
33024
  ]; };
31934
33025
 
31935
- var moment$6 = momentImported__namespace;
33026
+ var moment$7 = momentImported__namespace;
31936
33027
  var SwipeTestPage = /** @class */ (function () {
31937
33028
  function SwipeTestPage(formBuilder, dateFormatPipe) {
31938
33029
  this.formBuilder = formBuilder;
31939
33030
  this.dateFormatPipe = dateFormatPipe;
31940
33031
  this.$dates = new rxjs.BehaviorSubject(undefined);
31941
- this._today = moment$6().startOf('day');
33032
+ this._today = moment$7().startOf('day');
31942
33033
  this.form = formBuilder.group({
31943
33034
  empty: [null, i1.Validators.required],
31944
33035
  date: [null, i1.Validators.compose([i1.Validators.required, SharedValidators.validDate])],
@@ -31952,7 +33043,7 @@
31952
33043
  var _this = this;
31953
33044
  var dates = [];
31954
33045
  for (var d = 0; d < 7; d++) {
31955
- dates[d] = moment$6(this._today).add(d - 3, 'day');
33046
+ dates[d] = moment$7(this._today).add(d - 3, 'day');
31956
33047
  }
31957
33048
  this.$dates.next(dates);
31958
33049
  this.loadData();
@@ -31999,7 +33090,7 @@
31999
33090
  { type: DateFormatPipe }
32000
33091
  ]; };
32001
33092
 
32002
- var moment$7 = momentImported__namespace;
33093
+ var moment$8 = momentImported__namespace;
32003
33094
  var DateTimeTestPage = /** @class */ (function () {
32004
33095
  function DateTimeTestPage(platform, formBuilder, cd) {
32005
33096
  this.platform = platform;
@@ -32035,7 +33126,7 @@
32035
33126
  var now, data;
32036
33127
  var _this = this;
32037
33128
  return __generator(this, function (_a) {
32038
- now = moment$7();
33129
+ now = moment$8();
32039
33130
  data = {
32040
33131
  empty: null,
32041
33132
  emptyRequired: null,
@@ -32313,7 +33404,7 @@
32313
33404
  { type: i1.FormBuilder }
32314
33405
  ]; };
32315
33406
 
32316
- var moment$8 = momentImported__namespace;
33407
+ var moment$9 = momentImported__namespace;
32317
33408
  var DateTestPage = /** @class */ (function () {
32318
33409
  function DateTestPage(formBuilder, cd) {
32319
33410
  this.formBuilder = formBuilder;
@@ -32350,7 +33441,7 @@
32350
33441
  var now, nowAtMahe, data;
32351
33442
  var _this = this;
32352
33443
  return __generator(this, function (_a) {
32353
- now = moment$8();
33444
+ now = moment$9();
32354
33445
  nowAtMahe = now.clone().tz(this.timezone).startOf('day');
32355
33446
  data = {
32356
33447
  empty: null,
@@ -33189,6 +34280,7 @@
33189
34280
  exports.APP_MENU_ITEMS = APP_MENU_ITEMS;
33190
34281
  exports.APP_TESTING_PAGES = APP_TESTING_PAGES;
33191
34282
  exports.AboutModal = AboutModal;
34283
+ exports.AbstractUserEventService = AbstractUserEventService;
33192
34284
  exports.AccountPage = AccountPage;
33193
34285
  exports.AccountService = AccountService;
33194
34286
  exports.AccountToStringPipe = AccountToStringPipe;
@@ -33315,6 +34407,11 @@
33315
34407
  exports.IsNotNilOrBlankPipe = IsNotNilOrBlankPipe;
33316
34408
  exports.IsNotOnFieldModePipe = IsNotOnFieldModePipe;
33317
34409
  exports.IsOnFieldModePipe = IsOnFieldModePipe;
34410
+ exports.Job = Job;
34411
+ exports.JobModule = JobModule;
34412
+ exports.JobProgressionComponent = JobProgressionComponent;
34413
+ exports.JobProgressionService = JobProgressionService;
34414
+ exports.JobProgressionServiceToken = JobProgressionServiceToken;
33318
34415
  exports.JobUtils = JobUtils;
33319
34416
  exports.KEYBOARD_HIDE_DELAY_MS = KEYBOARD_HIDE_DELAY_MS;
33320
34417
  exports.LAT_LONG_DEFAULT_MAX_DECIMALS = LAT_LONG_DEFAULT_MAX_DECIMALS;
@@ -33352,6 +34449,7 @@
33352
34449
  exports.MenuService = MenuService;
33353
34450
  exports.MessageForm = MessageForm;
33354
34451
  exports.MessageModal = MessageModal;
34452
+ exports.MessageModule = MessageModule;
33355
34453
  exports.MessageService = MessageService;
33356
34454
  exports.MessageTypeList = MessageTypeList;
33357
34455
  exports.MessageTypes = MessageTypes;
@@ -33419,6 +34517,7 @@
33419
34517
  exports.SharedValidators = SharedValidators;
33420
34518
  exports.SocialErrorCodes = SocialErrorCodes;
33421
34519
  exports.SocialModule = SocialModule;
34520
+ exports.SocialModuleOptionsToken = SocialModuleOptionsToken;
33422
34521
  exports.StartableService = StartableService;
33423
34522
  exports.StatusById = StatusById;
33424
34523
  exports.StatusIds = StatusIds;
@@ -33447,7 +34546,10 @@
33447
34546
  exports.UploadFileTestingPage = UploadFileTestingPage;
33448
34547
  exports.UriUtils = UriUtils;
33449
34548
  exports.UserEventFragments = UserEventFragments;
34549
+ exports.UserEventModule = UserEventModule;
34550
+ exports.UserEventNotificationComponent = UserEventNotificationComponent;
33450
34551
  exports.UserEventService = UserEventService;
34552
+ exports.UserEventServiceToken = UserEventServiceToken;
33451
34553
  exports.UserEventTypes = UserEventTypes;
33452
34554
  exports.UserEventsTable = UserEventsTable;
33453
34555
  exports.UsersPage = UsersPage;
@@ -33613,11 +34715,14 @@
33613
34715
  exports.ɵh = LocalSettingsValidatorService;
33614
34716
  exports.ɵi = AppUpdateOfflineModeCard;
33615
34717
  exports.ɵj = AppIconComponent;
33616
- exports.ɵk = DateTestPage;
33617
- exports.ɵl = NumpadTestPage;
33618
- exports.ɵm = MatBadgeIconTestPage;
33619
- exports.ɵn = ToastTestingModule;
33620
- exports.ɵo = ToastTestingPage;
34718
+ exports.ɵk = UserEventNotificationList;
34719
+ exports.ɵl = UserEventTestService;
34720
+ exports.ɵm = JobProgressionList;
34721
+ exports.ɵn = DateTestPage;
34722
+ exports.ɵo = NumpadTestPage;
34723
+ exports.ɵp = MatBadgeIconTestPage;
34724
+ exports.ɵq = ToastTestingModule;
34725
+ exports.ɵr = ToastTestingPage;
33621
34726
 
33622
34727
  Object.defineProperty(exports, '__esModule', { value: true });
33623
34728