@sumaris-net/ngx-components 1.21.8 → 1.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +4056 -2920
  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 +6 -0
  6. package/esm2015/public_api.js +8 -1
  7. package/esm2015/src/app/core/core.module.js +5 -5
  8. package/esm2015/src/app/core/icon/icon.component.js +5 -2
  9. package/esm2015/src/app/core/icon/icon.module.js +26 -0
  10. package/esm2015/src/app/core/menu/menu.component.js +9 -5
  11. package/esm2015/src/app/core/menu/menu.model.js +3 -1
  12. package/esm2015/src/app/core/menu/menu.module.js +4 -2
  13. package/esm2015/src/app/shared/pipes/date-diff-duration.pipe.js +9 -5
  14. package/esm2015/src/app/shared/types.js +1 -1
  15. package/esm2015/src/app/social/job/job.model.js +26 -0
  16. package/esm2015/src/app/social/job/job.module.js +25 -0
  17. package/esm2015/src/app/social/job/job.service.js +54 -0
  18. package/esm2015/src/app/social/job/progression/job-progression.component.js +200 -0
  19. package/esm2015/src/app/social/job/progression/job-progression.list.js +20 -0
  20. package/esm2015/src/app/social/message/message.module.js +25 -0
  21. package/esm2015/src/app/social/social.errors.js +5 -2
  22. package/esm2015/src/app/social/social.module.js +10 -15
  23. package/esm2015/src/app/social/user-event/notification/user-event-notification.component.js +89 -0
  24. package/esm2015/src/app/social/user-event/notification/user-event-notification.list.js +78 -0
  25. package/esm2015/src/app/social/user-event/testing/user-event.testing.service.js +73 -0
  26. package/esm2015/src/app/social/user-event/user-event.model.js +58 -2
  27. package/esm2015/src/app/social/user-event/user-event.module.js +33 -0
  28. package/esm2015/src/app/social/user-event/user-event.service.js +412 -173
  29. package/esm2015/src/app/social/user-event/user-events.table.js +18 -13
  30. package/esm2015/sumaris-net.ngx-components.js +17 -13
  31. package/fesm2015/sumaris-net.ngx-components.js +3269 -2374
  32. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  33. package/package.json +1 -1
  34. package/public_api.d.ts +7 -0
  35. package/src/app/core/icon/icon.component.d.ts +4 -4
  36. package/src/app/core/icon/icon.module.d.ts +2 -0
  37. package/src/app/core/menu/menu.component.d.ts +7 -5
  38. package/src/app/core/menu/menu.model.d.ts +3 -0
  39. package/src/app/shared/material/badge/badge-icon.test.d.ts +1 -1
  40. package/src/app/shared/pipes/date-diff-duration.pipe.d.ts +6 -2
  41. package/src/app/shared/types.d.ts +4 -0
  42. package/src/app/social/job/job.model.d.ts +33 -0
  43. package/src/app/social/job/job.module.d.ts +2 -0
  44. package/src/app/social/job/job.service.d.ts +23 -0
  45. package/src/app/social/job/progression/job-progression.component.d.ts +44 -0
  46. package/src/app/social/job/progression/job-progression.list.d.ts +12 -0
  47. package/src/app/social/message/message.module.d.ts +2 -0
  48. package/src/app/social/social.errors.d.ts +3 -0
  49. package/src/app/social/social.module.d.ts +8 -0
  50. package/src/app/social/user-event/notification/user-event-notification.component.d.ts +22 -0
  51. package/src/app/social/user-event/notification/user-event-notification.list.d.ts +30 -0
  52. package/src/app/social/user-event/testing/user-event.testing.service.d.ts +35 -0
  53. package/src/app/social/user-event/user-event.model.d.ts +52 -8
  54. package/src/app/social/user-event/user-event.module.d.ts +2 -0
  55. package/src/app/social/user-event/user-event.service.d.ts +101 -51
  56. package/src/app/social/user-event/user-events.table.d.ts +6 -6
  57. package/src/assets/i18n/en-US.json +17 -3
  58. package/src/assets/i18n/en.json +18 -3
  59. package/src/assets/i18n/fr.json +17 -2
  60. package/src/theme/_ngx-components.scss +8 -0
  61. package/sumaris-net.ngx-components.d.ts +16 -12
  62. package/sumaris-net.ngx-components.metadata.json +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sumaris-net/ngx-components",
3
3
  "description": "SUMARiS Angular components",
4
- "version": "1.21.8",
4
+ "version": "1.22.1",
5
5
  "author": "contact@e-is.pro",
6
6
  "license": "AGPL-3.0",
7
7
  "readmeFilename": "README.md",
package/public_api.d.ts CHANGED
@@ -165,10 +165,17 @@ export * from './src/app/core/menu/menu.service';
165
165
  export { EntityClass, EntityClasses } from './src/app/core/services/model/entity.decorators';
166
166
  export * from './src/app/social/social.module';
167
167
  export * from './src/app/social/social.errors';
168
+ export * from './src/app/social/user-event/user-event.module';
168
169
  export * from './src/app/social/user-event/user-event.model';
169
170
  export * from './src/app/social/user-event/user-event.fragments';
170
171
  export * from './src/app/social/user-event/user-event.service';
171
172
  export * from './src/app/social/user-event/user-events.table';
173
+ export * from './src/app/social/user-event/notification/user-event-notification.component';
174
+ export * from './src/app/social/job/job.module';
175
+ export * from './src/app/social/job/job.model';
176
+ export * from './src/app/social/job/job.service';
177
+ export * from './src/app/social/job/progression/job-progression.component';
178
+ export * from './src/app/social/message/message.module';
172
179
  export * from './src/app/social/message/message.model';
173
180
  export * from './src/app/social/message/message.service';
174
181
  export * from './src/app/social/message/message.form';
@@ -1,10 +1,10 @@
1
- import { IconRef } from '../../shared/types';
2
- import { PredefinedColors } from '@ionic/core';
3
- import { ThemePalette } from '@angular/material/core';
1
+ import { AppColors, IconRef } from '../../shared/types';
4
2
  export declare class AppIconComponent {
5
3
  icon: string;
6
4
  matIcon: string;
7
5
  matSvgIcon: string;
8
- color: PredefinedColors | ThemePalette;
6
+ color: AppColors;
7
+ height: number;
8
+ width: number;
9
9
  set ref(value: IconRef);
10
10
  }
@@ -0,0 +1,2 @@
1
+ export declare class AppIconModule {
2
+ }
@@ -9,8 +9,9 @@ import { ConfigService } from '../services/config.service';
9
9
  import { HammerSwipeEvent } from '../../shared/gesture/hammer.utils';
10
10
  import { PlatformService } from '../services/platform.service';
11
11
  import { MenuService, SplitPaneShowWhen } from './menu.service';
12
- import { MenuItem } from './menu.model';
12
+ import { MenuConfig, MenuItem } from './menu.model';
13
13
  export declare const APP_MENU_ITEMS: InjectionToken<MenuItem[]>;
14
+ export declare const APP_MENU_CONFIG: InjectionToken<MenuConfig>;
14
15
  export declare class MenuComponent implements OnInit {
15
16
  protected platformService: PlatformService;
16
17
  protected accountService: AccountService;
@@ -37,11 +38,12 @@ export declare class MenuComponent implements OnInit {
37
38
  menuId: string;
38
39
  side: string;
39
40
  contentId: string;
40
- logo: String;
41
- appName: String;
42
- appVersion: String;
41
+ logo: string;
42
+ appName: string;
43
+ appVersion: string;
44
+ showNotification: boolean;
43
45
  splitPane: IonSplitPane;
44
- constructor(platformService: PlatformService, accountService: AccountService, router: Router, menu: MenuController, modalCtrl: ModalController, alertController: AlertController, translate: TranslateService, configService: ConfigService, cd: ChangeDetectorRef, menuService: MenuService, environment: any, items: MenuItem[]);
46
+ constructor(platformService: PlatformService, accountService: AccountService, router: Router, menu: MenuController, modalCtrl: ModalController, alertController: AlertController, translate: TranslateService, configService: ConfigService, cd: ChangeDetectorRef, menuService: MenuService, environment: any, config: MenuConfig, items: MenuItem[]);
45
47
  ngOnInit(): Promise<void>;
46
48
  onLogin(account: Account): Promise<void>;
47
49
  onLogout(skipRedirect?: boolean): Promise<void>;
@@ -24,3 +24,6 @@ export declare class MenuItems {
24
24
  logPrefix?: string;
25
25
  }): boolean;
26
26
  }
27
+ export declare class MenuConfig {
28
+ showNotification?: boolean;
29
+ }
@@ -5,5 +5,5 @@ export declare class MatBadgeIconTestPage {
5
5
  $icon: BehaviorSubject<string>;
6
6
  $size: BehaviorSubject<MatBadgeSize>;
7
7
  $fill: BehaviorSubject<MatBadgeFill>;
8
- $color: BehaviorSubject<"primary" | "accent" | "warn" | "light" | "tertiary" | "secondary" | "success" | "warning" | "danger" | "medium" | "dark">;
8
+ $color: BehaviorSubject<"primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | "light" | "medium" | "dark" | "accent" | "warn">;
9
9
  }
@@ -10,6 +10,10 @@ export declare class DateDiffDurationPipe implements PipeTransform {
10
10
  transform(value: {
11
11
  startValue: string | Moment;
12
12
  endValue: string | Moment;
13
- }, args?: any): string | Promise<string>;
14
- format(startDate: Moment, endDate: Moment): string;
13
+ }, args?: {
14
+ seconds?: boolean;
15
+ }): string | Promise<string>;
16
+ format(startDate: Moment, endDate: Moment, args: {
17
+ seconds?: boolean;
18
+ }): string;
15
19
  }
@@ -1,3 +1,5 @@
1
+ import { ThemePalette } from '@angular/material/core';
2
+ import { PredefinedColors } from '@ionic/core';
1
3
  export declare type KeyType = string | number;
2
4
  export declare type KeyValueType<T> = {
3
5
  [key in KeyType]: T;
@@ -15,8 +17,10 @@ export declare interface ObjectMapEntry<O = any> {
15
17
  export declare type PropertiesMap = ObjectMap<string>;
16
18
  export declare type Property = ObjectMapEntry<string>;
17
19
  export declare type PropertiesArray = Property[];
20
+ export declare type AppColors = PredefinedColors | ThemePalette | string;
18
21
  export declare interface IconRef {
19
22
  icon?: string;
20
23
  matIcon?: string;
21
24
  matSvgIcon?: string;
25
+ color?: AppColors;
22
26
  }
@@ -0,0 +1,33 @@
1
+ import { Moment } from 'moment';
2
+ import { Entity } from '../../core/services/model/entity.model';
3
+ export declare type JobStatus = 'PENDING' | 'RUNNING' | 'SUCCESS' | 'ERROR' | 'FAILED' | 'WARNING' | 'CANCELLED';
4
+ export interface IJob {
5
+ id: number;
6
+ name: string;
7
+ type: string;
8
+ status: JobStatus;
9
+ startDate: Moment;
10
+ endDate: Moment;
11
+ configuration: string;
12
+ report: string;
13
+ }
14
+ export declare class Job implements IJob {
15
+ id: number;
16
+ name: string;
17
+ type: string;
18
+ status: JobStatus;
19
+ startDate: Moment;
20
+ endDate: Moment;
21
+ configuration: string;
22
+ report: string;
23
+ }
24
+ export declare class JobProgression extends Entity<JobProgression> {
25
+ static fromObject: (source: any, opts?: any) => JobProgression;
26
+ id: number;
27
+ name: string;
28
+ message: string;
29
+ current: number;
30
+ total: number;
31
+ constructor(id?: number);
32
+ fromObject(source: any): void;
33
+ }
@@ -0,0 +1,2 @@
1
+ export declare class JobModule {
2
+ }
@@ -0,0 +1,23 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { JobProgression } from './job.model';
3
+ import { BaseGraphqlService } from '../../core/services/base-graphql-service.class';
4
+ import { GraphqlService } from '../../core/graphql/graphql.service';
5
+ import { Environment } from '../../../environments/environment.class';
6
+ import { Observable } from 'rxjs';
7
+ import { FetchPolicy } from '@apollo/client/core';
8
+ export declare const JobProgressionServiceToken: InjectionToken<JobProgressionService>;
9
+ export interface IJobProgressionService {
10
+ listenChanges(id: number, options?: {
11
+ interval?: number;
12
+ fetchPolicy?: FetchPolicy;
13
+ }): Observable<JobProgression>;
14
+ }
15
+ export declare class JobProgressionService extends BaseGraphqlService<JobProgression> implements IJobProgressionService {
16
+ protected graphql: GraphqlService;
17
+ protected environment: Environment;
18
+ constructor(graphql: GraphqlService, environment: Environment);
19
+ listenChanges(id: number, options?: {
20
+ interval?: number;
21
+ fetchPolicy?: FetchPolicy;
22
+ }): Observable<JobProgression>;
23
+ }
@@ -0,0 +1,44 @@
1
+ import { ChangeDetectorRef, EventEmitter, OnDestroy, OnInit } from '@angular/core';
2
+ import { ThemePalette } from '@angular/material/core';
3
+ import { ProgressSpinnerMode } from '@angular/material/progress-spinner';
4
+ import { IJobProgressionService } from '../job.service';
5
+ import { JobProgression } from '../job.model';
6
+ import { PopoverController } from '@ionic/angular';
7
+ export interface JobProgressionOptions {
8
+ autoHide: boolean;
9
+ autoHideDelay: number;
10
+ autoRemove: boolean;
11
+ autoRemoveDelay: number;
12
+ }
13
+ export declare class JobProgressionComponent implements OnInit, OnDestroy {
14
+ protected jobProgressionService: IJobProgressionService;
15
+ protected popoverController: PopoverController;
16
+ protected cd: ChangeDetectorRef;
17
+ debug: boolean;
18
+ titleI18n: string;
19
+ options: JobProgressionOptions;
20
+ jobFinished: EventEmitter<number>;
21
+ visible: boolean;
22
+ disabled: boolean;
23
+ color: ThemePalette;
24
+ mode: ProgressSpinnerMode;
25
+ value: number;
26
+ jobProgressions: JobProgression[];
27
+ protected autoHide: boolean;
28
+ protected autoHideDelay: number;
29
+ protected autoRemove: boolean;
30
+ protected autoRemoveDelay: number;
31
+ private _listPopover;
32
+ private _subscriptions;
33
+ private _subscriptionsById;
34
+ private _logPrefix;
35
+ constructor(jobProgressionService: IJobProgressionService, popoverController: PopoverController, cd: ChangeDetectorRef);
36
+ ngOnInit(): void;
37
+ addJob(id: number): void;
38
+ removeJob(id: number): void;
39
+ getProgression(id: number): JobProgression | undefined;
40
+ updateValue(): void;
41
+ showList(event: UIEvent): Promise<void>;
42
+ protected markForCheck(): void;
43
+ ngOnDestroy(): void;
44
+ }
@@ -0,0 +1,12 @@
1
+ import { OnInit } from '@angular/core';
2
+ import { JobProgression } from '../job.model';
3
+ export interface JobProgressionListOptions {
4
+ titleI18n?: string;
5
+ jobProgressions?: JobProgression[];
6
+ }
7
+ export declare class JobProgressionList implements OnInit, JobProgressionListOptions {
8
+ titleI18n: string;
9
+ jobProgressions: JobProgression[];
10
+ constructor();
11
+ ngOnInit(): void;
12
+ }
@@ -0,0 +1,2 @@
1
+ export declare class MessageModule {
2
+ }
@@ -1,5 +1,8 @@
1
1
  export declare const SocialErrorCodes: {
2
2
  LOAD_USER_EVENTS_ERROR: number;
3
3
  SAVE_USER_EVENT_ERROR: number;
4
+ COUNT_USER_EVENT_ERROR: number;
4
5
  SEND_MESSAGE_ERROR: number;
6
+ SUBSCRIBE_USER_EVENTS_ERROR: number;
7
+ SUBSCRIBE_JOB_PROGRESSION_ERROR: number;
5
8
  };
@@ -1,2 +1,10 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { JobProgressionOptions } from './job/progression/job-progression.component';
3
+ export interface SocialModuleOptions {
4
+ showUserEventNotification: boolean;
5
+ showJobProgression: boolean;
6
+ jobProgressionOptions: JobProgressionOptions;
7
+ }
8
+ export declare const SocialModuleOptionsToken: InjectionToken<SocialModuleOptions>;
1
9
  export declare class SocialModule {
2
10
  }
@@ -0,0 +1,22 @@
1
+ import { OnDestroy, OnInit } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ import { PopoverController } from '@ionic/angular';
4
+ import { IUserEventService } from '../user-event.service';
5
+ import { IUserEvent, IUserEventFilter } from '../user-event.model';
6
+ import { AccountService } from '../../../core/services/account.service';
7
+ export declare class UserEventNotificationComponent implements OnInit, OnDestroy {
8
+ userEventService: IUserEventService<IUserEvent<any>, IUserEventFilter<any>>;
9
+ protected accountService: AccountService;
10
+ protected popoverController: PopoverController;
11
+ debug: boolean;
12
+ titleI18n: string;
13
+ disabled: boolean;
14
+ get count(): Observable<number>;
15
+ private _logPrefix;
16
+ private _readEvent;
17
+ private _readEvents;
18
+ constructor(userEventService: IUserEventService<IUserEvent<any>, IUserEventFilter<any>>, accountService: AccountService, popoverController: PopoverController);
19
+ ngOnInit(): Promise<void>;
20
+ showList(event: UIEvent): Promise<void>;
21
+ ngOnDestroy(): void;
22
+ }
@@ -0,0 +1,30 @@
1
+ import { ChangeDetectorRef, EventEmitter, OnDestroy, OnInit } from '@angular/core';
2
+ import { IUserEvent, IUserEventFilter, UserEventAction } from '../user-event.model';
3
+ import { BehaviorSubject, Subscription } from 'rxjs';
4
+ import { PopoverController } from '@ionic/angular';
5
+ import { IUserEventService } from '../user-event.service';
6
+ export interface UserEventNotificationListOptions {
7
+ debug?: boolean;
8
+ titleI18n?: string;
9
+ readEvent?: EventEmitter<IUserEvent<any>>;
10
+ readEvents?: EventEmitter<IUserEvent<any>[]>;
11
+ }
12
+ export declare class UserEventNotificationList implements OnInit, OnDestroy, UserEventNotificationListOptions {
13
+ protected cd: ChangeDetectorRef;
14
+ protected popoverController: PopoverController;
15
+ userEventService: IUserEventService<IUserEvent<any>, IUserEventFilter<any>>;
16
+ debug: boolean;
17
+ titleI18n: string;
18
+ readEvent: EventEmitter<IUserEvent<any>>;
19
+ readEvents: EventEmitter<IUserEvent<any>[]>;
20
+ userEvents: BehaviorSubject<IUserEvent<any, string, import("../user-event.model").EventLevel>[]>;
21
+ protected subscriptions: Subscription;
22
+ constructor(cd: ChangeDetectorRef, popoverController: PopoverController, userEventService: IUserEventService<IUserEvent<any>, IUserEventFilter<any>>);
23
+ ngOnInit(): void;
24
+ ngOnDestroy(): void;
25
+ read(event: UIEvent, userEvent: IUserEvent<any>): void;
26
+ readAll(event: UIEvent): void;
27
+ executeAction(action: UserEventAction, userEvent: IUserEvent<any>): void;
28
+ dismiss(): void;
29
+ protected markForCheck(): void;
30
+ }
@@ -0,0 +1,35 @@
1
+ import { AbstractUserEventService, UserEventWatchOptions } from '../user-event.service';
2
+ import { IUserEvent, UserEvent, UserEventFilter } from '../user-event.model';
3
+ import { Observable } from 'rxjs';
4
+ import { GraphqlService } from '../../../core/graphql/graphql.service';
5
+ import { AccountService } from '../../../core/services/account.service';
6
+ import { NetworkService } from '../../../core/services/network.service';
7
+ import { TranslateService } from '@ngx-translate/core';
8
+ import { Environment } from '../../../../environments/environment.class';
9
+ import { FetchPolicy } from '@apollo/client/core';
10
+ import { EntityServiceLoadOptions, LoadResult } from '../../../shared/services/entity-service.class';
11
+ import { SortDirection } from '@angular/material/sort';
12
+ export declare class UserEventTestService extends AbstractUserEventService<UserEvent, UserEventFilter> {
13
+ protected graphql: GraphqlService;
14
+ protected accountService: AccountService;
15
+ protected network: NetworkService;
16
+ protected translate: TranslateService;
17
+ protected environment: Environment;
18
+ private userEvents;
19
+ constructor(graphql: GraphqlService, accountService: AccountService, network: NetworkService, translate: TranslateService, environment: Environment);
20
+ fromObject(source: any): UserEvent;
21
+ add(entity: IUserEvent<any>): void;
22
+ asFilter(filter: Partial<any>): any;
23
+ count(filter: any, options?: {
24
+ fetchPolicy?: FetchPolicy;
25
+ }): Promise<number>;
26
+ delete(entity: any): Promise<any>;
27
+ deleteAll(data: any[], opts?: any): Promise<any>;
28
+ listenChanges(filter: any, options?: UserEventWatchOptions & {
29
+ interval?: number;
30
+ fetchPolicy?: FetchPolicy;
31
+ }): Observable<any[]>;
32
+ save(entity: any, options?: EntityServiceLoadOptions): Promise<any>;
33
+ saveAll(data: any[], opts?: any): Promise<any[]>;
34
+ watchAll(offset: number, size: number, sortBy?: string, sortDirection?: SortDirection, filter?: Partial<any>, options?: UserEventWatchOptions): Observable<LoadResult<any>>;
35
+ }
@@ -1,29 +1,73 @@
1
1
  import { Moment } from 'moment';
2
2
  import { Entity, EntityAsObjectOptions, IEntity } from '../../core/services/model/entity.model';
3
- import { PredefinedColors } from '@ionic/core';
3
+ import { EntityFilter, IEntityFilter } from '../../core/services/model/filter.model';
4
+ import { FilterFn } from '../../shared/services/entity-service.class';
5
+ import { AppColors, IconRef } from '../../shared/types';
4
6
  export declare const UserEventTypes: {
5
7
  DEBUG_DATA: string;
6
8
  INBOX_MESSAGE: string;
7
9
  };
8
- export declare class UserEvent extends Entity<UserEvent> {
10
+ export declare type EventLevel = 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
11
+ export interface IUserEvent<E extends Entity<E>, U = string, L = EventLevel> extends IEntity<E> {
12
+ issuer: U;
13
+ recipient: U;
14
+ type: string;
15
+ level: L;
16
+ updateDate: Moment;
17
+ creationDate: Moment;
18
+ readDate?: Moment;
19
+ message?: string;
20
+ content?: string | any;
21
+ avatar?: string;
22
+ avatarIcon?: IconRef;
23
+ icon?: IconRef;
24
+ actions?: UserEventAction[];
25
+ }
26
+ export declare class UserEvent extends Entity<UserEvent> implements IUserEvent<UserEvent> {
9
27
  static fromObject: (source: any, opts?: any) => UserEvent;
10
- eventType: string;
28
+ type: string;
29
+ level: EventLevel;
11
30
  issuer: string;
12
31
  recipient: string;
13
32
  updateDate: Moment;
14
33
  creationDate: Moment;
34
+ readDate: Moment;
35
+ message: string | undefined;
15
36
  content: string | any;
37
+ hash: string;
16
38
  signature: string;
17
39
  readSignature: string;
40
+ avatar?: string;
41
+ avatarIcon?: IconRef;
42
+ icon?: IconRef;
43
+ actions?: UserEventAction[];
18
44
  constructor();
19
45
  asObject(opts?: EntityAsObjectOptions): any;
20
46
  fromObject(source: any): void;
21
47
  }
22
- export interface UserEventAction<T extends IEntity<T>> {
48
+ export interface IUserEventFilter<E extends IUserEvent<E, U, L>, U = string, L = EventLevel> extends IEntityFilter<any, E> {
49
+ types: string[];
50
+ levels: L[];
51
+ issuers: U[];
52
+ recipients: U[];
53
+ startDate: Moment;
54
+ excludeRead: boolean;
55
+ }
56
+ export declare class UserEventFilter extends EntityFilter<UserEventFilter, UserEvent> implements IUserEventFilter<UserEvent> {
57
+ static fromObject: (source: any, opts?: any) => UserEventFilter;
58
+ types: string[];
59
+ levels: EventLevel[];
60
+ issuers: string[];
61
+ recipients: string[];
62
+ startDate: Moment;
63
+ excludeRead: boolean;
64
+ fromObject(source: any, opts?: any): void;
65
+ protected buildFilter(): FilterFn<UserEvent>[];
66
+ }
67
+ export interface UserEventAction {
23
68
  name: string | any;
24
69
  title?: string;
25
- icon?: string;
26
- matIcon?: string;
27
- color?: PredefinedColors;
28
- executeAction: (event: UserEvent, context?: T) => any | Promise<any>;
70
+ color?: AppColors;
71
+ iconRef?: IconRef;
72
+ executeAction: (event: IUserEvent<any>) => any | Promise<any>;
29
73
  }
@@ -0,0 +1,2 @@
1
+ export declare class UserEventModule {
2
+ }
@@ -1,9 +1,11 @@
1
+ import { InjectionToken, OnDestroy } from '@angular/core';
2
+ import { FetchPolicy } from '@apollo/client/core';
1
3
  import { AccountService } from '../../core/services/account.service';
2
4
  import { GraphqlService } from '../../core/graphql/graphql.service';
3
- import { Observable } from 'rxjs';
4
- import { UserEvent, UserEventAction } from './user-event.model';
5
+ import { BehaviorSubject, Observable } from 'rxjs';
6
+ import { IUserEvent, IUserEventFilter, UserEvent, UserEventFilter } from './user-event.model';
5
7
  import { SortDirection } from '@angular/material/sort';
6
- import { EntitiesServiceWatchOptions, EntityServiceLoadOptions, FilterFn, IEntitiesService, LoadResult, Page } from '../../shared/services/entity-service.class';
8
+ import { EntitiesServiceWatchOptions, EntityServiceLoadOptions, IEntitiesService, LoadResult, Page } from '../../shared/services/entity-service.class';
7
9
  import { ShowToastOptions } from '../../shared/toast/toasts';
8
10
  import { OverlayEventDetail } from '@ionic/core';
9
11
  import { ToastController } from '@ionic/angular';
@@ -11,64 +13,112 @@ import { TranslateService } from '@ngx-translate/core';
11
13
  import { NetworkService } from '../../core/services/network.service';
12
14
  import { BaseGraphqlService } from '../../core/services/base-graphql-service.class';
13
15
  import { Environment } from '../../../environments/environment.class';
14
- import { EntityFilter } from '../../core/services/model/filter.model';
15
- export declare class UserEventFilter extends EntityFilter<UserEventFilter, UserEvent> {
16
- static fromObject: (source: any, opts?: any) => UserEventFilter;
17
- issuer: string;
18
- recipient: string;
19
- fromObject(source: any, opts?: any): void;
20
- protected buildFilter(): FilterFn<UserEvent>[];
21
- }
16
+ import { Moment } from 'moment';
17
+ import { IStartableService } from '../../shared/services/startable-service.class';
18
+ export declare const UserEventServiceToken: InjectionToken<IUserEventService<any, any, UserEventWatchOptions>>;
22
19
  export declare interface UserEventWatchOptions extends EntitiesServiceWatchOptions {
23
20
  withContent?: boolean;
24
21
  }
25
- export interface UserEventActionDefinition extends UserEventAction<any> {
26
- __typename: string;
22
+ export interface IUserEventQueries {
23
+ loadAll: any;
24
+ loadAllWithContent: any;
25
+ count?: any;
26
+ }
27
+ export interface IUserEventMutations {
28
+ save: any;
29
+ markAsRead?: any;
30
+ deleteByIds: any;
31
+ }
32
+ export interface IUserEventSubscriptions {
33
+ listenChanges: any;
34
+ listenCountChanges?: any;
35
+ }
36
+ export interface IUserEventListener<E extends IUserEvent<E>> {
37
+ accept: (E: any) => boolean;
38
+ onReceived?: (E: any) => E | undefined;
39
+ onRead?: (E: any) => Promise<void> | void;
40
+ }
41
+ export interface IUserEventService<E extends IUserEvent<E>, F extends IUserEventFilter<E>, WO extends UserEventWatchOptions = UserEventWatchOptions> extends IEntitiesService<E, F, WO>, IStartableService {
42
+ userEventCount: Observable<number>;
43
+ add(entity: E): any;
44
+ count(filter: Partial<F>, options?: {
45
+ fetchPolicy?: FetchPolicy;
46
+ }): Promise<number>;
47
+ listenCountChanges(filter: Partial<F>, options?: WO & {
48
+ interval?: number;
49
+ fetchPolicy?: FetchPolicy;
50
+ }): Observable<number>;
51
+ listenChanges(filter: Partial<F>, options?: WO & {
52
+ interval?: number;
53
+ fetchPolicy?: FetchPolicy;
54
+ }): Observable<E[]>;
55
+ save(entity: E, options?: EntityServiceLoadOptions): Promise<E>;
56
+ delete(entity: E): Promise<any>;
57
+ markAsRead(entities: E[]): any;
58
+ registerListener(listener: IUserEventListener<E>): any;
59
+ resetCount(): any;
60
+ }
61
+ export declare abstract class AbstractUserEventService<E extends IUserEvent<E, any>, F extends IUserEventFilter<E, any>, WO extends UserEventWatchOptions = UserEventWatchOptions> extends BaseGraphqlService<E, F> implements IUserEventService<E, F, WO>, OnDestroy {
62
+ protected graphql: GraphqlService;
63
+ protected accountService: AccountService;
64
+ protected network: NetworkService;
65
+ protected translate: TranslateService;
66
+ protected queries: IUserEventQueries;
67
+ protected mutations: IUserEventMutations;
68
+ protected subscriptions: IUserEventSubscriptions;
69
+ protected environment: Environment;
70
+ protected count$: BehaviorSubject<number>;
71
+ protected resetCountDate: Moment;
72
+ protected listeners: IUserEventListener<E>[];
73
+ private _subscriptions;
74
+ private _listenSubscription;
75
+ get userEventCount(): Observable<number>;
76
+ protected constructor(graphql: GraphqlService, accountService: AccountService, network: NetworkService, translate: TranslateService, queries: IUserEventQueries, mutations: IUserEventMutations, subscriptions: IUserEventSubscriptions, environment: Environment);
77
+ protected ngOnStart(): Promise<void>;
78
+ ngOnDestroy(): void;
79
+ abstract asFilter(filter: Partial<F>): F;
80
+ abstract fromObject(source: any): E;
81
+ watchAll(offset: number, size: number, sortBy?: string, sortDirection?: SortDirection, filter?: Partial<F>, options?: WO): Observable<LoadResult<E>>;
82
+ watchPage(page: Page, filter?: Partial<F>, options?: WO): Observable<LoadResult<E>>;
83
+ add(entity: E): void;
84
+ count(filter: Partial<F>, options?: {
85
+ fetchPolicy?: FetchPolicy;
86
+ }): Promise<number>;
87
+ listenCountChanges(filter: Partial<F>, options?: WO & {
88
+ interval?: number;
89
+ fetchPolicy?: FetchPolicy;
90
+ }): Observable<number>;
91
+ listenChanges(filter: Partial<F>, options?: WO & {
92
+ interval?: number;
93
+ fetchPolicy?: FetchPolicy;
94
+ }): Observable<E[]>;
95
+ delete(entity: E): Promise<any>;
96
+ deleteAll(entities: E[], opts?: any): Promise<any>;
97
+ save(entity: E, options?: EntityServiceLoadOptions): Promise<E>;
98
+ saveAll(entities: E[], opts?: any): Promise<E[]>;
99
+ markAsRead(entities: E[]): Promise<void>;
100
+ registerListener(listener: IUserEventListener<E>): void;
101
+ resetCount(): void;
102
+ protected onLogin(): Promise<void>;
103
+ protected onLogout(): void;
104
+ protected startListenCountChanges(): void;
105
+ protected stopListenCountChanges(): void;
106
+ protected processUserEvent(source: any, that?: AbstractUserEventService<E, F>): E;
107
+ protected defaultMarkAsRead(userEvents: E[]): Promise<void>;
108
+ protected defaultFilter(): F;
109
+ protected defaultRecipient(): any;
110
+ protected fillDefaultProperties(entity: E): void;
111
+ protected unreadEvents(events: E[]): number;
112
+ protected copyIdAndUpdateDate(source: E, target: E): void;
27
113
  }
28
- export declare class UserEventService extends BaseGraphqlService<UserEvent, UserEventFilter> implements IEntitiesService<UserEvent, UserEventFilter, UserEventWatchOptions> {
114
+ export declare class UserEventService extends AbstractUserEventService<UserEvent, UserEventFilter> {
29
115
  protected graphql: GraphqlService;
30
116
  protected accountService: AccountService;
31
117
  protected network: NetworkService;
32
118
  protected translate: TranslateService;
33
119
  protected toastController: ToastController;
34
120
  protected environment: Environment;
35
- private _userEventActions;
36
121
  constructor(graphql: GraphqlService, accountService: AccountService, network: NetworkService, translate: TranslateService, toastController: ToastController, environment: Environment);
37
- /**
38
- *
39
- * @param offset
40
- * @param size
41
- * @param sortBy
42
- * @param sortDirection
43
- * @param filter
44
- * @param options
45
- * @deprecated use watchPage() instead
46
- */
47
- watchAll(offset: number, size: number, sortBy?: string, sortDirection?: SortDirection, filter?: UserEventFilter, options?: UserEventWatchOptions): Observable<LoadResult<UserEvent>>;
48
- watchPage(page: Page, filter?: Partial<UserEventFilter>, options?: UserEventWatchOptions): Observable<LoadResult<UserEvent>>;
49
- saveAll(data: UserEvent[], options?: any): Promise<UserEvent[]>;
50
- /**
51
- * Save a userEvent entity
52
- *
53
- * @param entity
54
- */
55
- save(entity: UserEvent, options?: EntityServiceLoadOptions): Promise<UserEvent>;
56
- /**
57
- * Save many trips
58
- *
59
- * @param entities
60
- * @param opts
61
- */
62
- deleteAll(entities: UserEvent[], opts?: {
63
- trash?: boolean;
64
- }): Promise<any>;
65
- /**
66
- * Delete userEvent entities
67
- */
68
- delete(data: UserEvent): Promise<any>;
69
- listenChanges(id: number, options?: any): Observable<UserEvent | undefined>;
70
- registerAction(definition: UserEventActionDefinition): void;
71
- getActionsByTypename(typename: string): UserEventAction<any>[];
72
122
  showToastErrorWithContext(opts: {
73
123
  error?: any;
74
124
  message?: string;
@@ -76,8 +126,8 @@ export declare class UserEventService extends BaseGraphqlService<UserEvent, User
76
126
  }): Promise<void>;
77
127
  sendDataForDebug(data: any): Promise<UserEvent>;
78
128
  asFilter(filter: Partial<UserEventFilter>): UserEventFilter;
129
+ fromObject(source: any): UserEvent;
79
130
  protected convertObjectToString(data: any): string;
80
131
  protected showToast<T = any>(opts: ShowToastOptions): Promise<OverlayEventDetail<T>>;
81
132
  protected fillDefaultProperties(entity: UserEvent): void;
82
- protected copyIdAndUpdateDate(source: UserEvent, target: UserEvent): void;
83
133
  }