@sumaris-net/ngx-components 0.28.2 → 1.0.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 (42) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +369 -337
  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 +4 -0
  6. package/esm2015/src/app/core/account/account.js +4 -5
  7. package/esm2015/src/app/core/auth/form/form-auth.js +3 -4
  8. package/esm2015/src/app/core/form/form.class.js +24 -12
  9. package/esm2015/src/app/core/form/list.form.js +2 -3
  10. package/esm2015/src/app/core/form/properties.form.js +2 -3
  11. package/esm2015/src/app/core/graphql/graphql.service.js +5 -8
  12. package/esm2015/src/app/core/services/account.service.js +177 -188
  13. package/esm2015/src/app/core/services/base-entity-service.class.js +9 -7
  14. package/esm2015/src/app/core/services/base-graphql-service.class.js +7 -2
  15. package/esm2015/src/app/core/services/config.service.js +9 -54
  16. package/esm2015/src/app/core/services/model/account.model.js +1 -1
  17. package/esm2015/src/app/core/services/model/settings.model.js +29 -2
  18. package/esm2015/src/app/core/services/network.service.js +5 -7
  19. package/esm2015/src/app/core/services/storage/entities-storage.service.js +3 -6
  20. package/esm2015/src/app/core/settings/settings.page.js +3 -4
  21. package/esm2015/src/app/shared/services/startable-service.class.js +13 -2
  22. package/esm2015/src/app/shared/services/translate-context.service.js +38 -13
  23. package/fesm2015/sumaris-net.ngx-components.js +308 -296
  24. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/app/core/account/account.d.ts +0 -1
  27. package/src/app/core/auth/form/form-auth.d.ts +0 -1
  28. package/src/app/core/form/form.class.d.ts +10 -2
  29. package/src/app/core/form/list.form.d.ts +0 -1
  30. package/src/app/core/form/properties.form.d.ts +0 -1
  31. package/src/app/core/graphql/graphql.service.d.ts +0 -1
  32. package/src/app/core/services/account.service.d.ts +8 -21
  33. package/src/app/core/services/base-entity-service.class.d.ts +1 -0
  34. package/src/app/core/services/base-graphql-service.class.d.ts +3 -2
  35. package/src/app/core/services/config.service.d.ts +2 -9
  36. package/src/app/core/services/model/settings.model.d.ts +2 -0
  37. package/src/app/core/services/network.service.d.ts +2 -2
  38. package/src/app/core/services/storage/entities-storage.service.d.ts +0 -1
  39. package/src/app/core/settings/settings.page.d.ts +0 -1
  40. package/src/app/shared/services/startable-service.class.d.ts +3 -1
  41. package/src/app/shared/services/translate-context.service.d.ts +10 -0
  42. 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": "0.28.2",
4
+ "version": "1.0.0",
5
5
  "author": "contact@e-is.pro",
6
6
  "license": "AGPL-3.0",
7
7
  "readmeFilename": "README.md",
@@ -20,7 +20,6 @@ export declare class AccountPage extends AppForm<Account> implements OnDestroy {
20
20
  protected translate: TranslateService;
21
21
  protected settings: LocalSettingsService;
22
22
  protected cd: ChangeDetectorRef;
23
- loading: boolean;
24
23
  isLogin: boolean;
25
24
  changesSubscription: Subscription;
26
25
  account: Account;
@@ -13,7 +13,6 @@ export declare class AuthForm extends AppForm<AuthData> implements OnInit {
13
13
  network: NetworkService;
14
14
  private cd;
15
15
  protected environment: any;
16
- loading: boolean;
17
16
  readonly mobile: boolean;
18
17
  canWorkOffline: boolean;
19
18
  showPwd: boolean;
@@ -18,14 +18,22 @@ export declare abstract class AppForm<T> implements IAppForm, OnInit, OnDestroy,
18
18
  protected errorTranslator: FormErrorTranslator;
19
19
  protected _enable: boolean;
20
20
  protected _$ready: BehaviorSubject<boolean>;
21
- protected _loading: boolean;
21
+ protected _$loading: BehaviorSubject<boolean>;
22
22
  protected i18nFieldPrefix: string;
23
+ /**
24
+ * @deprecated
25
+ */
26
+ protected set _loading(value: boolean);
27
+ /**
28
+ * @deprecated
29
+ */
30
+ protected get _loading(): boolean;
23
31
  private _subscription;
24
32
  private _form;
25
33
  debug: boolean;
26
34
  tabindex: number;
27
35
  errorTranslatorOptions: FormErrorTranslatorOptions;
28
- protected get _ready(): boolean;
36
+ get loading(): boolean;
29
37
  get value(): any;
30
38
  set value(data: any);
31
39
  get dirty(): boolean;
@@ -26,7 +26,6 @@ export declare class AppListForm<T = any> extends AppForm<T[]> implements OnInit
26
26
  protected settings: LocalSettingsService;
27
27
  protected cd: ChangeDetectorRef;
28
28
  private formGroupDir;
29
- loading: boolean;
30
29
  helper: FormArrayHelper<T>;
31
30
  selection: SelectionModel<T>;
32
31
  formArrayName: string;
@@ -13,7 +13,6 @@ export declare class AppPropertiesForm<T = Property> extends AppForm<T[]> implem
13
13
  protected settings: LocalSettingsService;
14
14
  protected cd: ChangeDetectorRef;
15
15
  private formGroupDir;
16
- loading: boolean;
17
16
  definitionsMapByKey: FormFieldDefinitionMap;
18
17
  definitionsByIndex: {
19
18
  [index: number]: FormFieldDefinition;
@@ -45,7 +45,6 @@ export declare class GraphqlService extends StartableService<ApolloClient<any>>
45
45
  private cryptoService;
46
46
  protected environment: any;
47
47
  private typePolicies;
48
- private _subscription;
49
48
  private readonly _networkStatusChanged$;
50
49
  private httpParams;
51
50
  private wsParams;
@@ -2,7 +2,7 @@ import { CryptoService, KeyPair } from './crypto.service';
2
2
  import { Department } from './model/department.model';
3
3
  import { Account } from './model/account.model';
4
4
  import { Person, UserProfileLabel } from './model/person.model';
5
- import { UsageMode } from './model/settings.model';
5
+ import { LocalSettings, UsageMode } from './model/settings.model';
6
6
  import { Observable, Subject, Subscription } from 'rxjs';
7
7
  import { FetchPolicy } from '@apollo/client/core';
8
8
  import { Storage } from '@ionic/storage';
@@ -13,14 +13,12 @@ import { FormFieldDefinition } from '../../shared/form/field.model';
13
13
  import { AuthTokenType, NetworkService } from './network.service';
14
14
  import { FileService } from '../../shared/file/file.service';
15
15
  import { Referential } from './model/referential.model';
16
- import { IStartableService } from '../../shared/services/startable-service.class';
17
- export declare interface AccountHolder {
16
+ export declare interface AccountDetails {
18
17
  loaded: boolean;
19
18
  keypair: KeyPair;
20
19
  authToken: string;
21
20
  authBasic?: string;
22
21
  pubkey: string;
23
- account: Account;
24
22
  person: Person;
25
23
  department: Department;
26
24
  mainProfile: String;
@@ -37,7 +35,7 @@ export declare interface IsEmailExistsVariables {
37
35
  email: string;
38
36
  hash: string;
39
37
  }
40
- export declare class AccountService extends BaseGraphqlService implements IStartableService<Account> {
38
+ export declare class AccountService extends BaseGraphqlService<Account, any, number, Account> {
41
39
  private cryptoService;
42
40
  protected network: NetworkService;
43
41
  protected graphql: GraphqlService;
@@ -50,9 +48,7 @@ export declare class AccountService extends BaseGraphqlService implements IStart
50
48
  onChange: Subject<Account>;
51
49
  onAuthTokenChange: Subject<string>;
52
50
  onAuthBasicChange: Subject<string>;
53
- private _data;
54
- private _startPromise;
55
- private _started;
51
+ private _cache;
56
52
  private _$additionalFields;
57
53
  private _tokenType$;
58
54
  get account(): Account;
@@ -61,11 +57,8 @@ export declare class AccountService extends BaseGraphqlService implements IStart
61
57
  get tokenType(): AuthTokenType;
62
58
  set tokenType(value: AuthTokenType);
63
59
  constructor(cryptoService: CryptoService, network: NetworkService, graphql: GraphqlService, settings: LocalSettingsService, storage: Storage, file: FileService, environment: any);
64
- start(): Promise<Account>;
65
- get started(): boolean;
66
- stop(): Promise<void>;
67
- restart(): Promise<Account>;
68
- ready(): Promise<Account>;
60
+ ngOnStart(): Promise<Account>;
61
+ protected ngOnStop(): Promise<void>;
69
62
  isLogin(): boolean;
70
63
  isAuth(): boolean;
71
64
  hasMinProfile(userProfile: UserProfileLabel): boolean;
@@ -117,14 +110,6 @@ export declare class AccountService extends BaseGraphqlService implements IStart
117
110
  sendConfirmationEmail(email: string, locale?: string): Promise<boolean>;
118
111
  confirmEmail(email: String, code: String): Promise<boolean>;
119
112
  listenChanges(): Subscription;
120
- /**
121
- * @deprecated
122
- */
123
- getPageSettings(pageId: string, propertyName?: string): string[];
124
- /**
125
- * @deprecated
126
- */
127
- savePageSetting(pageId: string, value: any, propertyName?: string): Promise<void>;
128
113
  get additionalFields(): FormFieldDefinition[];
129
114
  get $additionalFields(): Observable<FormFieldDefinition[]>;
130
115
  getAdditionalField(key: string): FormFieldDefinition | undefined;
@@ -134,11 +119,13 @@ export declare class AccountService extends BaseGraphqlService implements IStart
134
119
  offline?: boolean;
135
120
  fetchPolicy?: FetchPolicy;
136
121
  }): Promise<Account>;
122
+ protected listenSettings(): Promise<void>;
137
123
  protected restoreLocally(): Promise<Account | undefined>;
138
124
  /**
139
125
  * Save account into the local storage
140
126
  */
141
127
  protected saveLocally(): Promise<void>;
128
+ saveLocalSettingsRemotely(source: LocalSettings): Promise<void>;
142
129
  /**
143
130
  * Create or update an user account
144
131
  *
@@ -102,6 +102,7 @@ export declare abstract class BaseEntityService<T extends Entity<T, ID>, F exten
102
102
  copyIdAndUpdateDate(source: T, target: T): void;
103
103
  fromObject(source: any): T;
104
104
  asFilter(source: any): F;
105
+ protected ngOnStart(): Promise<void>;
105
106
  protected fillDefaultProperties(source: T): void;
106
107
  protected asObject(entity: T, opts?: EntityAsObjectOptions): any;
107
108
  protected getRefetchQueriesForMutation(opts?: EntitySaveOptions): ((result: FetchResult<{
@@ -7,6 +7,7 @@ import { ApolloCache, InternalRefetchQueriesInclude } from '@apollo/client/core'
7
7
  import { QueryRef } from 'apollo-angular';
8
8
  import { PureQueryOptions } from '@apollo/client/core/types';
9
9
  import { DocumentNode } from 'graphql';
10
+ import { StartableService } from '../../shared/services/startable-service.class';
10
11
  export interface QueryVariables<F = any> extends Partial<Page> {
11
12
  filter?: F;
12
13
  [key: string]: any;
@@ -48,9 +49,8 @@ export interface FindMutableWatchQueriesOptions {
48
49
  export declare class BaseGraphqlServiceOptions {
49
50
  production?: boolean;
50
51
  }
51
- export declare abstract class BaseGraphqlService<T = any, F = any, ID = any> {
52
+ export declare abstract class BaseGraphqlService<T = any, F = any, ID = any, S = void> extends StartableService<S> {
52
53
  protected graphql: GraphqlService;
53
- protected _debug: boolean;
54
54
  protected _logPrefix: string;
55
55
  protected _mutableWatchQueries: MutableWatchQueryDescription<any>[];
56
56
  protected _mutableWatchQueriesMaxCount: number;
@@ -69,4 +69,5 @@ export declare abstract class BaseGraphqlService<T = any, F = any, ID = any> {
69
69
  protected findMutableWatchQueries(opts: FindMutableWatchQueriesOptions): MutableWatchQueryDescription<any>[];
70
70
  protected registerNewMutableWatchQuery(mutableQuery: MutableWatchQueryDescription<any>): void;
71
71
  protected findRefetchQueries(opts: FindMutableWatchQueriesOptions): InternalRefetchQueriesInclude;
72
+ protected ngOnStart(): Promise<S>;
72
73
  }
@@ -16,7 +16,7 @@ export declare const Fragments: {
16
16
  config: import("graphql/language/ast").DocumentNode;
17
17
  };
18
18
  export declare const APP_CONFIG_OPTIONS: InjectionToken<FormFieldDefinitionMap>;
19
- export declare class ConfigService extends BaseGraphqlService<Configuration, any, number> implements IEntityService<Configuration>, IStartableService<Configuration> {
19
+ export declare class ConfigService extends BaseGraphqlService<Configuration, any, number, Configuration> implements IEntityService<Configuration>, IStartableService<Configuration> {
20
20
  protected platform: Platform;
21
21
  protected graphql: GraphqlService;
22
22
  protected storage: Storage;
@@ -25,18 +25,11 @@ export declare class ConfigService extends BaseGraphqlService<Configuration, any
25
25
  protected toastController: ToastController;
26
26
  protected translate: TranslateService;
27
27
  protected environment: any;
28
- private _started;
29
- private _startPromise;
30
- private _subscription;
31
28
  private _optionDefs;
32
29
  private $data;
33
- get started(): boolean;
34
30
  get config(): Observable<Configuration>;
35
31
  constructor(platform: Platform, graphql: GraphqlService, storage: Storage, network: NetworkService, file: FileService, toastController: ToastController, translate: TranslateService, environment: any, defaultOptionsMap: FormFieldDefinitionMap);
36
- start(): Promise<Configuration>;
37
- stop(): Promise<void>;
38
- restart(): Promise<Configuration>;
39
- ready(): Promise<Configuration>;
32
+ protected ngOnStart(): Promise<Configuration>;
40
33
  loadDefault(opts?: EntityServiceLoadOptions): Promise<Configuration>;
41
34
  load(id: number, opts?: EntityServiceLoadOptions & {
42
35
  query?: any;
@@ -28,6 +28,7 @@ export declare interface LocalSettings {
28
28
  pageHistoryMaxSize: number;
29
29
  }
30
30
  export declare class UserSettings extends Entity<UserSettings> {
31
+ static SETTINGS_PROPERTIES: string[];
31
32
  static fromObject: (source: any, opts?: any) => UserSettings;
32
33
  locale: string;
33
34
  latLongFormat: LatLongPattern;
@@ -36,4 +37,5 @@ export declare class UserSettings extends Entity<UserSettings> {
36
37
  constructor();
37
38
  asObject(opts?: EntityAsObjectOptions): any;
38
39
  fromObject(source: any, opts?: any): void;
40
+ merge<S = LocalSettings>(source: S, includesProperties: (keyof S)[]): boolean;
39
41
  }
@@ -36,7 +36,6 @@ export declare class NetworkService extends StartableService<Peer> {
36
36
  onNetworkStatusChanges: BehaviorSubject<ConnectionType>;
37
37
  onResetNetworkCache: EventEmitter<any>;
38
38
  private readonly _mobile;
39
- private _subscription;
40
39
  private _timerSubscription;
41
40
  private readonly _timerRefreshPeriod;
42
41
  private readonly _timerRefreshCondition;
@@ -75,7 +74,8 @@ export declare class NetworkService extends StartableService<Peer> {
75
74
  /**
76
75
  * Check if the peer is alive
77
76
  *
78
- * @param email
77
+ * @param peer
78
+ * @param opts
79
79
  */
80
80
  checkPeerAlive(peer?: string | Peer, opts?: {
81
81
  checkCompatible?: boolean;
@@ -23,7 +23,6 @@ export declare class EntitiesStorage extends StartableService<EntityStorageMap>
23
23
  static TRASH_PREFIX: string;
24
24
  static REMOTE_PREFIX: string;
25
25
  private readonly _typePolicies;
26
- private _subscription;
27
26
  private readonly _saveTimerPeriod;
28
27
  private _$save;
29
28
  private _dirty;
@@ -28,7 +28,6 @@ export declare class SettingsPage extends AppForm<LocalSettings> implements OnIn
28
28
  locales: LocaleConfig[];
29
29
  private data;
30
30
  mobile: boolean;
31
- loading: boolean;
32
31
  saving: boolean;
33
32
  usageModes: UsageMode[];
34
33
  propertyDefinitions: FormFieldDefinition[];
@@ -1,4 +1,4 @@
1
- import { Subject } from 'rxjs';
1
+ import { Subject, Subscription } from 'rxjs';
2
2
  export interface IStartableService<T = any> {
3
3
  started: boolean;
4
4
  start(): Promise<T>;
@@ -13,6 +13,7 @@ export declare abstract class StartableService<T = any> implements IStartableSer
13
13
  private _started;
14
14
  private _startPromise;
15
15
  private _startPrerequisite;
16
+ private _subscription;
16
17
  protected constructor(prerequisiteService: {
17
18
  ready: () => Promise<any>;
18
19
  });
@@ -22,6 +23,7 @@ export declare abstract class StartableService<T = any> implements IStartableSer
22
23
  get started(): boolean;
23
24
  get starting(): boolean;
24
25
  ready(): Promise<T>;
26
+ protected registerSubscription(sub: Subscription): Subscription;
25
27
  protected ngOnStop(): Promise<void>;
26
28
  protected abstract ngOnStart(): Promise<T>;
27
29
  }
@@ -5,6 +5,15 @@ export declare class TranslateContextService {
5
5
  constructor(translate: TranslateService);
6
6
  get(key: string, context?: string, interpolateParams?: Object): Observable<any>;
7
7
  instant(key: string, context?: string, interpolateParams?: Object): any;
8
+ /**
9
+ * Compute contextual i18n keys, using the context as suffix.<br>
10
+ * Suffix can be simple name (like 'aaa' - will return ['<key>.aaa']) or complexe (like 'aaa.bbb' - will return ['<key>.aaa.bbb', '<key>.aaa']
11
+ *
12
+ * @param key
13
+ * @param context
14
+ * @private
15
+ */
16
+ contextualKeys(key: string, context: string): string[];
8
17
  /**
9
18
  * Compute a contextual i18n key, using the context as suffix
10
19
  *
@@ -13,4 +22,5 @@ export declare class TranslateContextService {
13
22
  * @private
14
23
  */
15
24
  contextualKey(key: string, context: string): string;
25
+ private findFirstValid;
16
26
  }