@sumaris-net/ngx-components 1.20.35 → 1.21.0-beta2

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 (71) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +1100 -319
  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 +0 -9
  6. package/esm2015/public_api.js +8 -3
  7. package/esm2015/src/app/core/icon/icon.component.js +5 -2
  8. package/esm2015/src/app/core/menu/menu.component.js +9 -2
  9. package/esm2015/src/app/core/table/table.class.js +11 -11
  10. package/esm2015/src/app/shared/functions.js +60 -1
  11. package/esm2015/src/app/shared/material/autocomplete/material.autocomplete.js +4 -5
  12. package/esm2015/src/app/shared/material/autocomplete/testing/autocomplete.test.js +7 -10
  13. package/esm2015/src/app/shared/material/chips/material.chips.js +2 -3
  14. package/esm2015/src/app/shared/material/chips/testing/chips.test.js +2 -3
  15. package/esm2015/src/app/shared/material/datetime/material.date.js +2 -3
  16. package/esm2015/src/app/shared/material/datetime/material.datetime.js +2 -3
  17. package/esm2015/src/app/shared/pipes/arrays.pipe.js +1 -1
  18. package/esm2015/src/app/shared/pipes/form.pipes.js +4 -2
  19. package/esm2015/src/app/shared/pipes/highlight.pipe.js +4 -4
  20. package/esm2015/src/app/shared/pipes/string.pipes.js +18 -7
  21. package/esm2015/src/app/shared/services/memory-entity-service.class.js +1 -13
  22. package/esm2015/src/app/shared/types.js +1 -1
  23. package/esm2015/src/app/social/job/job.model.js +24 -0
  24. package/esm2015/src/app/social/job/job.module.js +25 -0
  25. package/esm2015/src/app/social/job/job.service.js +54 -0
  26. package/esm2015/src/app/social/job/progression/job-progression.component.js +192 -0
  27. package/esm2015/src/app/social/job/progression/job-progression.list.js +20 -0
  28. package/esm2015/src/app/social/message/message.module.js +25 -0
  29. package/esm2015/src/app/social/social.errors.js +5 -2
  30. package/esm2015/src/app/social/social.module.js +10 -15
  31. package/esm2015/src/app/social/user-event/notification/user-event-notification.component.js +95 -0
  32. package/esm2015/src/app/social/user-event/notification/user-event-notification.list.js +39 -0
  33. package/esm2015/src/app/social/user-event/user-event.model.js +58 -2
  34. package/esm2015/src/app/social/user-event/user-event.module.js +28 -0
  35. package/esm2015/src/app/social/user-event/user-event.service.js +294 -166
  36. package/esm2015/src/app/social/user-event/user-events.table.js +17 -12
  37. package/esm2015/sumaris-net.ngx-components.js +8 -6
  38. package/fesm2015/sumaris-net.ngx-components.js +931 -284
  39. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  40. package/package.json +2 -3
  41. package/public_api.d.ts +7 -2
  42. package/src/app/core/icon/icon.component.d.ts +4 -4
  43. package/src/app/core/table/table.class.d.ts +6 -8
  44. package/src/app/shared/functions.d.ts +9 -0
  45. package/src/app/shared/material/autocomplete/testing/autocomplete.test.d.ts +2 -1
  46. package/src/app/shared/material/badge/badge-icon.test.d.ts +1 -1
  47. package/src/app/shared/pipes/form.pipes.d.ts +2 -1
  48. package/src/app/shared/services/memory-entity-service.class.d.ts +0 -6
  49. package/src/app/shared/types.d.ts +4 -0
  50. package/src/app/social/job/job.model.d.ts +32 -0
  51. package/src/app/social/job/job.module.d.ts +2 -0
  52. package/src/app/social/job/job.service.d.ts +23 -0
  53. package/src/app/social/job/progression/job-progression.component.d.ts +43 -0
  54. package/src/app/social/job/progression/job-progression.list.d.ts +12 -0
  55. package/src/app/social/message/message.module.d.ts +2 -0
  56. package/src/app/social/social.errors.d.ts +3 -0
  57. package/src/app/social/social.module.d.ts +8 -0
  58. package/src/app/social/user-event/notification/user-event-notification.component.d.ts +25 -0
  59. package/src/app/social/user-event/notification/user-event-notification.list.d.ts +20 -0
  60. package/src/app/social/user-event/user-event.model.d.ts +51 -6
  61. package/src/app/social/user-event/user-event.module.d.ts +2 -0
  62. package/src/app/social/user-event/user-event.service.d.ts +80 -51
  63. package/src/app/social/user-event/user-events.table.d.ts +6 -6
  64. package/src/assets/i18n/en-US.json +15 -2
  65. package/src/assets/i18n/en.json +15 -2
  66. package/src/assets/i18n/fr.json +14 -1
  67. package/src/theme/_ngx-components.scss +7 -0
  68. package/sumaris-net.ngx-components.d.ts +7 -5
  69. package/sumaris-net.ngx-components.metadata.json +1 -1
  70. package/esm2015/src/app/shared/services.js +0 -61
  71. package/src/app/shared/services.d.ts +0 -9
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.20.35",
4
+ "version": "1.21.0-beta2",
5
5
  "author": "contact@e-is.pro",
6
6
  "license": "AGPL-3.0",
7
7
  "readmeFilename": "README.md",
@@ -15,8 +15,7 @@
15
15
  "tslib": "^2.2.0"
16
16
  },
17
17
  "peerDependencies": {
18
- "@apollo/client": "~3.5.10",
19
- "localforage": "1.7.4"
18
+ "@apollo/client": "~3.5.10"
20
19
  },
21
20
  "repository": {
22
21
  "type": "git",
package/public_api.d.ts CHANGED
@@ -82,7 +82,6 @@ export * from './src/app/shared/validator/form-error-adapter.class';
82
82
  export * from './src/app/shared/types';
83
83
  export * from './src/app/shared/dates';
84
84
  export * from './src/app/shared/functions';
85
- export * from './src/app/shared/services';
86
85
  export * from './src/app/shared/forms';
87
86
  export * from './src/app/shared/observables';
88
87
  export * from './src/app/shared/events';
@@ -165,10 +164,17 @@ export * from './src/app/core/menu/menu.service';
165
164
  export { EntityClass, EntityClasses } from './src/app/core/services/model/entity.decorators';
166
165
  export * from './src/app/social/social.module';
167
166
  export * from './src/app/social/social.errors';
167
+ export * from './src/app/social/user-event/user-event.module';
168
168
  export * from './src/app/social/user-event/user-event.model';
169
169
  export * from './src/app/social/user-event/user-event.fragments';
170
170
  export * from './src/app/social/user-event/user-event.service';
171
171
  export * from './src/app/social/user-event/user-events.table';
172
+ export * from './src/app/social/user-event/notification/user-event-notification.component';
173
+ export * from './src/app/social/job/job.module';
174
+ export * from './src/app/social/job/job.model';
175
+ export * from './src/app/social/job/job.service';
176
+ export * from './src/app/social/job/progression/job-progression.component';
177
+ export * from './src/app/social/message/message.module';
172
178
  export * from './src/app/social/message/message.model';
173
179
  export * from './src/app/social/message/message.service';
174
180
  export * from './src/app/social/message/message.form';
@@ -197,4 +203,3 @@ export * from './src/app/core/table/testing/table.testing.module';
197
203
  export * from './src/app/core/table/testing/table.testing';
198
204
  export * from './src/app/core/text-popover/testing/text-popover.testing.module';
199
205
  export * from './src/app/core/text-popover/testing/text-popover.testing';
200
- export { suggestFromArray } from "./src/app/shared/services";
@@ -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
  }
@@ -244,9 +244,7 @@ export declare abstract class AppTable<T extends IEntity<T, ID>, F = any, ID = n
244
244
  interactive?: boolean;
245
245
  keepEditing?: boolean;
246
246
  }): void;
247
- addRow(event?: Event, insertAt?: number, opts?: {
248
- focusColumn?: string;
249
- }): boolean;
247
+ addRow(event?: Event, insertAt?: number): boolean;
250
248
  save(opts?: {
251
249
  keepEditing?: boolean;
252
250
  }): Promise<boolean>;
@@ -266,20 +264,22 @@ export declare abstract class AppTable<T extends IEntity<T, ID>, F = any, ID = n
266
264
  * @param event
267
265
  * @param row
268
266
  * @param opts Use interactive=false to avoid user interaction (e.g. user confirmation)
269
- * And to force deletion even if table is busy
267
+ * Use skipIfLoading=false to force deletion even if table is busy
270
268
  */
271
269
  deleteRow(event: UIEvent | null, row: TableElement<T>, opts?: {
272
270
  interactive?: boolean;
271
+ skipIfLoading?: boolean;
273
272
  }): Promise<boolean>;
274
273
  /**
275
274
  *
276
275
  * @param event
277
276
  * @param rows
278
277
  * @param opts Use interactive=false to avoid user interaction (e.g. user confirmation)
279
- * And to force deletion even if table is busy
278
+ * Use skipIfLoading=false to force deletion even if table is busy
280
279
  */
281
280
  deleteRows(event: UIEvent | null, rows: TableElement<T>[], opts?: {
282
281
  interactive?: boolean;
282
+ skipIfLoading?: boolean;
283
283
  }): Promise<number>;
284
284
  selectRowById(id: number): Promise<boolean>;
285
285
  /**
@@ -343,9 +343,7 @@ export declare abstract class AppTable<T extends IEntity<T, ID>, F = any, ID = n
343
343
  protected registerAutocompleteField<E = any, EF = any>(fieldName: string, options?: MatAutocompleteFieldAddOptions<E, EF>): MatAutocompleteFieldConfig<E, EF>;
344
344
  protected getI18nColumnName(columnName: string): string;
345
345
  protected generateTableId(): string;
346
- protected addRowToTable(insertAt?: number, opts?: {
347
- focusColumn?: string;
348
- }): Promise<TableElement<T>>;
346
+ protected addRowToTable(insertAt?: number): Promise<TableElement<T>>;
349
347
  protected registerCellValueChanges(name: string, formPath?: string, emitInitialValue?: boolean): Observable<any>;
350
348
  protected setShowColumn(columnName: string, show: boolean, opts?: {
351
349
  emitEvent?: boolean;
@@ -1,3 +1,4 @@
1
+ import { LoadResult } from './services/entity-service.class';
1
2
  import { KeysEnum, KeyValueType } from './types';
2
3
  export declare function isNil<T>(obj: T | null | undefined): boolean;
3
4
  export declare function isNilOrBlank<T>(obj: T | null | undefined): boolean;
@@ -45,6 +46,14 @@ export declare function removeEnd(value: string, end: string): string;
45
46
  */
46
47
  export declare function changeCaseToUnderscore(value: string): string;
47
48
  export declare function removeDiacritics(text: string): string;
49
+ export declare function suggestFromArray<T = any>(items: T[], value: any, opts?: {
50
+ offset?: number;
51
+ size?: number;
52
+ searchAttribute?: string;
53
+ searchAttributes?: string[];
54
+ excludedIds?: number[];
55
+ skipSort?: boolean;
56
+ }): LoadResult<T>;
48
57
  export declare function suggestFromStringArray(values: string[], value: any, options?: {
49
58
  searchAttribute?: string;
50
59
  searchAttributes?: string[];
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { AfterViewInit, OnInit } from '@angular/core';
3
- import { FormBuilder, FormGroup } from '@angular/forms';
3
+ import { FormArray, FormBuilder, FormGroup } from '@angular/forms';
4
4
  import { MatAutocompleteConfigHolder, MatAutocompleteField } from '../material.autocomplete';
5
5
  import { LoadResult } from '../../../services/entity-service.class';
6
6
  import Timer = NodeJS.Timer;
@@ -20,6 +20,7 @@ export declare class AutocompleteTestPage implements OnInit, AfterViewInit {
20
20
  memoryAutocompleteFieldName: string;
21
21
  memoryTimer: Timer;
22
22
  mode: 'mobile' | 'desktop' | 'memory' | 'temp';
23
+ entitiesArray: FormArray;
23
24
  farEntityField: MatAutocompleteField;
24
25
  constructor(formBuilder: FormBuilder);
25
26
  ngOnInit(): void;
@@ -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
  }
@@ -30,13 +30,14 @@ export declare class FormGetGroupPipe implements PipeTransform {
30
30
  transform(form: AbstractControl, path?: Array<string | number> | string): FormGroup;
31
31
  }
32
32
  export declare class FormGetValuePipe implements PipeTransform, OnDestroy {
33
+ private adapter;
33
34
  private _ref;
34
35
  value: any;
35
36
  private _lastControl;
36
37
  private _lastPath;
37
38
  private _onControlValueChanges;
38
39
  private _onControlStatusChanges;
39
- constructor(_ref: ChangeDetectorRef);
40
+ constructor(adapter: FormErrorTranslator, _ref: ChangeDetectorRef);
40
41
  transform(form: AbstractControl, path?: Array<string | number> | string, listenStatusChanges?: boolean): any;
41
42
  ngOnDestroy(): void;
42
43
  /**
@@ -43,12 +43,6 @@ export declare class InMemoryEntitiesService<T extends IEntity<T, ID>, F = any,
43
43
  asFilter(source: Partial<F>): F;
44
44
  addSortByReplacement(source: string, target: string): void;
45
45
  equals(d1: T, d2: T): boolean;
46
- /**
47
- * Count data stored by the service (without hidden data).
48
- * @param opts
49
- */
50
- get count(): number;
51
- get hiddenCount(): number;
52
46
  protected filter(data: T[], _filter: F, hiddenData: T[]): T[];
53
47
  protected connect(): Observable<LoadResult<T>>;
54
48
  protected markAsSaving(): void;
@@ -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,32 @@
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
+ message: string;
28
+ current: number;
29
+ total: number;
30
+ constructor();
31
+ fromObject(source: any): void;
32
+ }
@@ -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,43 @@
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 _subscriptions;
32
+ private _subscriptionsById;
33
+ private _logPrefix;
34
+ constructor(jobProgressionService: IJobProgressionService, popoverController: PopoverController, cd: ChangeDetectorRef);
35
+ ngOnInit(): void;
36
+ addJob(id: number): void;
37
+ removeJob(id: number): void;
38
+ getProgression(id: number): JobProgression | undefined;
39
+ updateValue(): void;
40
+ showList(event: UIEvent): Promise<void>;
41
+ protected markForCheck(): void;
42
+ ngOnDestroy(): void;
43
+ }
@@ -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,25 @@
1
+ import { ChangeDetectorRef, OnDestroy, OnInit } from '@angular/core';
2
+ import { BehaviorSubject, 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
+ protected cd: ChangeDetectorRef;
12
+ debug: boolean;
13
+ titleI18n: string;
14
+ disabled: boolean;
15
+ userEventsSubject: BehaviorSubject<IUserEvent<any, string, import("../user-event.model").EventLevel>[]>;
16
+ get count(): Observable<number>;
17
+ private _subscriptions;
18
+ private _logPrefix;
19
+ private _readEvent;
20
+ constructor(userEventService: IUserEventService<IUserEvent<any>, IUserEventFilter<any>>, accountService: AccountService, popoverController: PopoverController, cd: ChangeDetectorRef);
21
+ ngOnInit(): void;
22
+ showList(event: UIEvent): Promise<void>;
23
+ protected markForCheck(): void;
24
+ ngOnDestroy(): void;
25
+ }
@@ -0,0 +1,20 @@
1
+ import { EventEmitter, OnInit } from '@angular/core';
2
+ import { IUserEvent, UserEventAction } from '../user-event.model';
3
+ import { Observable, Subject } from 'rxjs';
4
+ import { PopoverController } from '@ionic/angular';
5
+ export interface UserEventNotificationListOptions {
6
+ titleI18n?: string;
7
+ userEvents?: Observable<IUserEvent<any>[]>;
8
+ readEvent?: EventEmitter<IUserEvent<any>>;
9
+ }
10
+ export declare class UserEventNotificationList implements OnInit, UserEventNotificationListOptions {
11
+ protected popoverController: PopoverController;
12
+ titleI18n: string;
13
+ userEvents: Subject<IUserEvent<any>[]>;
14
+ readEvent: EventEmitter<IUserEvent<any>>;
15
+ constructor(popoverController: PopoverController);
16
+ ngOnInit(): void;
17
+ read($event: UIEvent, userEvent: IUserEvent<any>): void;
18
+ executeAction(action: UserEventAction, userEvent: IUserEvent<any>): void;
19
+ dismiss(): void;
20
+ }
@@ -1,29 +1,74 @@
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 = 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
70
  icon?: string;
26
71
  matIcon?: string;
27
- color?: PredefinedColors;
28
- executeAction: (event: UserEvent, context?: T) => any | Promise<any>;
72
+ color?: AppColors;
73
+ executeAction: (event: IUserEvent<any>) => any | Promise<any>;
29
74
  }
@@ -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 { Observable, Subscription } 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,91 @@ 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
+ export declare const UserEventServiceToken: InjectionToken<IUserEventService<any, any, UserEventWatchOptions>>;
22
17
  export declare interface UserEventWatchOptions extends EntitiesServiceWatchOptions {
23
18
  withContent?: boolean;
24
19
  }
25
- export interface UserEventActionDefinition extends UserEventAction<any> {
26
- __typename: string;
20
+ export interface IUserEventQueries {
21
+ loadAll: any;
22
+ loadAllWithContent: any;
23
+ count?: any;
24
+ }
25
+ export interface IUserEventMutations {
26
+ save: any;
27
+ deleteByIds: any;
28
+ }
29
+ export interface IUserEventSubscriptions {
30
+ listenChanges: any;
31
+ }
32
+ export interface IUserEventListener<E extends IUserEvent<E>> {
33
+ accept: (E: any) => boolean;
34
+ onReceived?: (E: any) => E | undefined;
35
+ onRead?: (E: any) => Promise<void> | void;
36
+ }
37
+ export interface IUserEventService<E extends IUserEvent<E>, F extends IUserEventFilter<E>, WO extends UserEventWatchOptions = UserEventWatchOptions> extends IEntitiesService<E, F, WO> {
38
+ userEventCount: Observable<number>;
39
+ add(entity: E): any;
40
+ count(filter: Partial<F>, options?: {
41
+ fetchPolicy?: FetchPolicy;
42
+ }): Promise<number>;
43
+ listenChanges(filter: Partial<F>, options?: WO & {
44
+ interval?: number;
45
+ fetchPolicy?: FetchPolicy;
46
+ }): Observable<E[]>;
47
+ save(entity: E, options?: EntityServiceLoadOptions): Promise<E>;
48
+ delete(entity: E): Promise<any>;
49
+ markAsRead(entity: E): any;
50
+ }
51
+ export declare abstract class AbstractUserEventService<E extends IUserEvent<E>, F extends IUserEventFilter<E>, WO extends UserEventWatchOptions = UserEventWatchOptions> extends BaseGraphqlService<E, F> implements IUserEventService<E, F, WO>, OnDestroy {
52
+ protected graphql: GraphqlService;
53
+ protected accountService: AccountService;
54
+ protected network: NetworkService;
55
+ protected translate: TranslateService;
56
+ protected toastController: ToastController;
57
+ protected queries: IUserEventQueries;
58
+ protected mutations: IUserEventMutations;
59
+ protected subscriptions: IUserEventSubscriptions;
60
+ protected environment: Environment;
61
+ private _count$;
62
+ protected _subscriptions: Subscription;
63
+ protected listeners: IUserEventListener<E>[];
64
+ get userEventCount(): Observable<number>;
65
+ protected constructor(graphql: GraphqlService, accountService: AccountService, network: NetworkService, translate: TranslateService, toastController: ToastController, queries: IUserEventQueries, mutations: IUserEventMutations, subscriptions: IUserEventSubscriptions, environment: Environment);
66
+ ngOnDestroy(): void;
67
+ abstract asFilter(filter: Partial<F>): F;
68
+ abstract fromObject(source: any): E;
69
+ watchAll(offset: number, size: number, sortBy?: string, sortDirection?: SortDirection, filter?: Partial<F>, options?: WO): Observable<LoadResult<E>>;
70
+ watchPage(page: Page, filter?: Partial<F>, options?: WO): Observable<LoadResult<E>>;
71
+ add(entity: E): void;
72
+ count(filter: Partial<F>, options?: {
73
+ fetchPolicy?: FetchPolicy;
74
+ }): Promise<number>;
75
+ listenChanges(filter: Partial<F>, options?: WO & {
76
+ interval?: number;
77
+ fetchPolicy?: FetchPolicy;
78
+ }): Observable<E[]>;
79
+ delete(entity: E): Promise<any>;
80
+ deleteAll(entities: E[], opts?: any): Promise<any>;
81
+ save(entity: E, options?: EntityServiceLoadOptions): Promise<E>;
82
+ saveAll(data: E[], opts?: any): Promise<E[]>;
83
+ markAsRead(entity: E): Promise<void>;
84
+ registerListener(listener: IUserEventListener<E>): void;
85
+ protected processUserEvent(source: any): E;
86
+ protected defaultMarkAsRead(userEvent: E): Promise<void>;
87
+ protected defaultFilter(): F;
88
+ protected defaultRecipient(): any;
89
+ protected fillDefaultProperties(entity: E): void;
90
+ protected unreadEvents(events: E[]): number;
91
+ protected copyIdAndUpdateDate(source: E, target: E): void;
27
92
  }
28
- export declare class UserEventService extends BaseGraphqlService<UserEvent, UserEventFilter> implements IEntitiesService<UserEvent, UserEventFilter, UserEventWatchOptions> {
93
+ export declare class UserEventService extends AbstractUserEventService<UserEvent, UserEventFilter> {
29
94
  protected graphql: GraphqlService;
30
95
  protected accountService: AccountService;
31
96
  protected network: NetworkService;
32
97
  protected translate: TranslateService;
33
98
  protected toastController: ToastController;
34
99
  protected environment: Environment;
35
- private _userEventActions;
36
100
  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
101
  showToastErrorWithContext(opts: {
73
102
  error?: any;
74
103
  message?: string;
@@ -76,8 +105,8 @@ export declare class UserEventService extends BaseGraphqlService<UserEvent, User
76
105
  }): Promise<void>;
77
106
  sendDataForDebug(data: any): Promise<UserEvent>;
78
107
  asFilter(filter: Partial<UserEventFilter>): UserEventFilter;
108
+ fromObject(source: any): UserEvent;
79
109
  protected convertObjectToString(data: any): string;
80
110
  protected showToast<T = any>(opts: ShowToastOptions): Promise<OverlayEventDetail<T>>;
81
111
  protected fillDefaultProperties(entity: UserEvent): void;
82
- protected copyIdAndUpdateDate(source: UserEvent, target: UserEvent): void;
83
112
  }