@sumaris-net/ngx-components 18.13.0 → 18.14.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 (38) hide show
  1. package/doc/changelog.md +4 -0
  2. package/doc/feed/feed-en.json +26 -0
  3. package/doc/feed/feed-fr.json +26 -0
  4. package/esm2022/public_api.mjs +9 -1
  5. package/esm2022/src/app/core/home/home.mjs +13 -12
  6. package/esm2022/src/app/core/home/home.module.mjs +7 -3
  7. package/esm2022/src/app/core/services/local-settings.service.mjs +3 -2
  8. package/esm2022/src/app/core/services/network.service.mjs +12 -1
  9. package/esm2022/src/app/social/feed/discourse/discourse-feed.service.mjs +179 -0
  10. package/esm2022/src/app/social/feed/discourse/discourse.model.mjs +2 -0
  11. package/esm2022/src/app/social/feed/discourse/discourse.utils.mjs +168 -0
  12. package/esm2022/src/app/social/feed/feed.component.mjs +121 -0
  13. package/esm2022/src/app/social/feed/feed.directive.mjs +151 -0
  14. package/esm2022/src/app/social/feed/feed.model.mjs +68 -0
  15. package/esm2022/src/app/social/feed/feed.module.mjs +22 -0
  16. package/esm2022/src/app/social/feed/feed.service.mjs +3 -0
  17. package/esm2022/src/environments/environment.class.mjs +2 -1
  18. package/esm2022/src/environments/environment.mjs +10 -1
  19. package/fesm2022/sumaris-net.ngx-components.mjs +681 -8
  20. package/fesm2022/sumaris-net.ngx-components.mjs.map +1 -1
  21. package/package.json +1 -1
  22. package/public_api.d.ts +8 -0
  23. package/src/app/core/home/home.d.ts +1 -1
  24. package/src/app/core/home/home.module.d.ts +2 -1
  25. package/src/app/core/services/local-settings.service.d.ts +1 -0
  26. package/src/app/core/services/network.service.d.ts +1 -0
  27. package/src/app/social/feed/discourse/discourse-feed.service.d.ts +55 -0
  28. package/src/app/social/feed/discourse/discourse.model.d.ts +7 -0
  29. package/src/app/social/feed/discourse/discourse.utils.d.ts +44 -0
  30. package/src/app/social/feed/feed.component.d.ts +39 -0
  31. package/src/app/social/feed/feed.directive.d.ts +32 -0
  32. package/src/app/social/feed/feed.model.d.ts +69 -0
  33. package/src/app/social/feed/feed.module.d.ts +11 -0
  34. package/src/app/social/feed/feed.service.d.ts +13 -0
  35. package/src/assets/i18n/en-US.json +5 -1
  36. package/src/assets/i18n/en.json +5 -0
  37. package/src/assets/i18n/fr.json +5 -0
  38. package/src/environments/environment.class.d.ts +8 -0
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": "18.13.0",
4
+ "version": "18.14.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
@@ -282,6 +282,14 @@ export * from './src/app/social/message/message.model';
282
282
  export * from './src/app/social/message/message.service';
283
283
  export * from './src/app/social/message/message.form';
284
284
  export * from './src/app/social/message/message.modal';
285
+ export * from './src/app/social/feed/feed.component';
286
+ export * from './src/app/social/feed/feed.service';
287
+ export * from './src/app/social/feed/feed.model';
288
+ export * from './src/app/social/feed/feed.directive';
289
+ export * from './src/app/social/feed/feed.module';
290
+ export * from './src/app/social/feed/discourse/discourse-feed.service';
291
+ export * from './src/app/social/feed/discourse/discourse.utils';
292
+ export * from './src/app/social/feed/discourse/discourse.model';
285
293
  export * from './src/app/admin/admin.module';
286
294
  export { AdminRoutingModule } from './src/app/admin/admin-routing.module';
287
295
  export * from './src/app/admin/services/filter/person.filter';
@@ -91,7 +91,7 @@ export declare class HomePage extends RxState<HomePageState> implements OnDestro
91
91
  get showInstallLinks(): boolean;
92
92
  set darkMode(value: boolean);
93
93
  get darkMode(): boolean;
94
- get currentLocaleCode(): string;
94
+ get currentLocale(): string;
95
95
  get partnerBannerSize(): number;
96
96
  constructor(accountService: AccountService, modalCtrl: ModalController, translate: TranslateService, toastController: ToastController, configService: ConfigService, platform: PlatformService, cd: ChangeDetectorRef, network: NetworkService, settings: LocalSettingsService, environment: Environment, locales: LocaleConfig[], buttons: IMenuItem[], config: IHomePageConfig);
97
97
  ngOnDestroy(): void;
@@ -8,8 +8,9 @@ import * as i6 from "../auth/auth.module";
8
8
  import * as i7 from "../install/install-upgrade-card.module";
9
9
  import * as i8 from "../../shared/markdown/markdown.module";
10
10
  import * as i9 from "../../social/user-event/user-event.module";
11
+ import * as i10 from "../../social/feed/feed.module";
11
12
  export declare class AppHomePageModule {
12
13
  static ɵfac: i0.ɵɵFactoryDeclaration<AppHomePageModule, never>;
13
- static ɵmod: i0.ɵɵNgModuleDeclaration<AppHomePageModule, [typeof i1.HomePage], [typeof i2.SharedModule, typeof i3.RouterModule, typeof i4.TranslateModule, typeof i5.RxStateModule, typeof i6.AppAuthModule, typeof i7.AppInstallUpgradeCardModule, typeof i8.SharedMarkdownModule, typeof i9.UserEventModule], [typeof i3.RouterModule, typeof i4.TranslateModule, typeof i1.HomePage]>;
14
+ static ɵmod: i0.ɵɵNgModuleDeclaration<AppHomePageModule, [typeof i1.HomePage], [typeof i2.SharedModule, typeof i3.RouterModule, typeof i4.TranslateModule, typeof i5.RxStateModule, typeof i6.AppAuthModule, typeof i7.AppInstallUpgradeCardModule, typeof i8.SharedMarkdownModule, typeof i9.UserEventModule, typeof i10.FeedModule], [typeof i3.RouterModule, typeof i4.TranslateModule, typeof i1.HomePage]>;
14
15
  static ɵinj: i0.ɵɵInjectorDeclaration<AppHomePageModule>;
15
16
  }
@@ -31,6 +31,7 @@ export declare class LocalSettingsService extends StartableService<LocalSettings
31
31
  private readonly defaultSettings;
32
32
  onChange: Subject<LocalSettings>;
33
33
  darkMode$: import("rxjs").Observable<boolean>;
34
+ locale$: import("rxjs").Observable<string>;
34
35
  private readonly _optionDefs;
35
36
  private readonly _serializeAsString;
36
37
  private _$persist;
@@ -111,6 +111,7 @@ export declare class NetworkService extends StartableObservableService<Peer, Pee
111
111
  clearCache(opts?: {
112
112
  emitEvent?: boolean;
113
113
  }): Promise<void>;
114
+ fetch<T>(url: string): Promise<T>;
114
115
  protected ngOnStart(peer?: Peer): Promise<Peer>;
115
116
  protected ngOnAfterStart(peer: Peer): Promise<void>;
116
117
  protected ngOnStop(): void;
@@ -0,0 +1,55 @@
1
+ import DiscourseAPI from 'discourse2';
2
+ import { JsonFeed } from '../feed.model';
3
+ import { Observable } from 'rxjs';
4
+ import { StartableService } from '../../../shared/services/startable-service.class';
5
+ import { LocalSettingsService } from '../../../core/services/local-settings.service';
6
+ import { Environment } from '../../../../environments/environment.class';
7
+ import { LoadResult } from '../../../shared/services/entity-service.class';
8
+ import { IFeedService } from '../feed.service';
9
+ import * as i0 from "@angular/core";
10
+ export interface DiscourseFeedServiceState {
11
+ locale: string;
12
+ feedUrls?: string[];
13
+ }
14
+ export declare class DiscourseFeedService extends StartableService<DiscourseFeedServiceState> implements IFeedService {
15
+ private settings;
16
+ protected environment: Environment;
17
+ private discourseApis;
18
+ private _logPrefix;
19
+ private _state;
20
+ private network;
21
+ locale$: Observable<string>;
22
+ feedUrls$: Observable<string[]>;
23
+ locale: string;
24
+ feedUrls: string[];
25
+ constructor(settings: LocalSettingsService, environment: Environment);
26
+ protected ngOnStart(): Promise<DiscourseFeedServiceState>;
27
+ watchAll(opts?: {
28
+ maxAgeInMonths?: number;
29
+ maxContentLength?: number;
30
+ }): Observable<LoadResult<JsonFeed>>;
31
+ getHomeUrl(feed?: JsonFeed): string;
32
+ getTagUrl(feed: JsonFeed, tag: string): string;
33
+ load(url: string, opts?: {
34
+ locale?: string;
35
+ maxAgeInMonths?: number;
36
+ maxContentLength?: number;
37
+ closeApis?: boolean;
38
+ depth?: number;
39
+ }): Promise<JsonFeed>;
40
+ loadAll(urls?: string[], opts?: {
41
+ locale?: string;
42
+ maxAgeInMonths?: number;
43
+ maxContentLength?: number;
44
+ closeApis?: boolean;
45
+ depth?: number;
46
+ }): Promise<LoadResult<JsonFeed>>;
47
+ protected getOrCreateDiscourseApi(url: string): DiscourseAPI;
48
+ protected closeApis(): void;
49
+ protected resolveFeedItems(json: JsonFeed, opts?: {
50
+ maxContentLength?: number;
51
+ depth?: number;
52
+ }): Promise<JsonFeed>;
53
+ static ɵfac: i0.ɵɵFactoryDeclaration<DiscourseFeedService, [null, { optional: true; }]>;
54
+ static ɵprov: i0.ɵɵInjectableDeclaration<DiscourseFeedService>;
55
+ }
@@ -0,0 +1,7 @@
1
+ import type { operations } from 'discourse2/esm/schema';
2
+ export type DiscourseCategory = operations['listCategoryTopics']['responses']['200']['content']['application/json'];
3
+ export type DiscourseCategoryTopic = DiscourseCategory['topic_list']['topics'][0];
4
+ export type DiscourseTopic = operations['getTopic']['responses']['200']['content']['application/json'];
5
+ export type DiscoursePost = operations['getTopic']['responses']['200']['content']['application/json']['post_stream']['posts'][0] & {
6
+ post_url?: string;
7
+ };
@@ -0,0 +1,44 @@
1
+ import DiscourseAPI from 'discourse2';
2
+ import { JsonFeed, JsonFeedItem, JsonFeedUtils } from '../feed.model';
3
+ import { DiscourseCategory, DiscoursePost, DiscourseTopic } from './discourse.model';
4
+ export declare abstract class DiscourseUtils {
5
+ static _logPrefix: string;
6
+ static removeJsonExtension: typeof JsonFeedUtils.removeJsonExtension;
7
+ static isDiscourseObject(json: any): json is DiscourseTopic | DiscourseCategory;
8
+ static isDiscourseTopic(json: any | Partial<DiscourseTopic>): json is DiscourseTopic;
9
+ static isDiscourseCategory(json: any | Partial<DiscourseCategory>): json is DiscourseCategory;
10
+ static getDiscourseBaseUrl(url: string): string;
11
+ static isDiscourseCategoryUrl(url: string): RegExpMatchArray;
12
+ static extractCategoryIdFromUrl(url: string): number;
13
+ static extractCategorySlugFromUrl(url: string): string;
14
+ static extractTopicIdFromUrl(url: string): number;
15
+ static getLanguageFromTitle(title: string): string;
16
+ static getFeedsByUrl(url: string, opts?: {
17
+ api?: DiscourseAPI;
18
+ locale?: string;
19
+ maxAgeInMonths?: number;
20
+ maxContentLength?: number;
21
+ }): Promise<JsonFeed[]>;
22
+ static getFeedsByCategoryUrl(url: string, opts?: {
23
+ api?: DiscourseAPI;
24
+ locale?: string;
25
+ maxAgeInMonths?: number;
26
+ maxContentLength?: number;
27
+ }): Promise<JsonFeed[]>;
28
+ static getFeedByTopicUrl(url: string, opts?: {
29
+ locale?: string;
30
+ maxAgeInMonths?: number;
31
+ maxContentLength?: number;
32
+ api?: DiscourseAPI;
33
+ }): Promise<JsonFeed>;
34
+ static filterRecentPosts(posts: DiscoursePost[], opts?: {
35
+ maxAgeInMonths?: number;
36
+ }): DiscoursePost[];
37
+ static toFeed(posts: DiscoursePost[], topic: DiscourseTopic, url: string, opts?: {
38
+ maxContentLength?: number;
39
+ }): JsonFeed;
40
+ static toFeedItem(post: DiscoursePost, topic: DiscourseTopic, url: string, opts?: {
41
+ maxContentLength?: number;
42
+ }): JsonFeedItem;
43
+ static cleanTitle(title: string): string;
44
+ }
@@ -0,0 +1,39 @@
1
+ import { RxState } from '@rx-angular/state';
2
+ import { TranslateService } from '@ngx-translate/core';
3
+ import { Router } from '@angular/router';
4
+ import { JsonFeed } from './feed.model';
5
+ import { Observable } from 'rxjs';
6
+ import { PlatformService } from '../../core/services/platform.service';
7
+ import { Environment } from '../../../environments/environment.class';
8
+ import { AppColors } from '../../shared/types';
9
+ import { IFeedService } from './feed.service';
10
+ import * as i0 from "@angular/core";
11
+ export interface FeedState {
12
+ maxAgeInMonths: number;
13
+ maxContentLength: number;
14
+ feeds: JsonFeed[];
15
+ hasFeeds: boolean;
16
+ }
17
+ export declare class FeedsComponent<T extends JsonFeed = JsonFeed> {
18
+ protected environment: Environment;
19
+ feedService: IFeedService<T>;
20
+ protected _debug: boolean;
21
+ protected _state: RxState<FeedState>;
22
+ protected translate: TranslateService;
23
+ protected platform: PlatformService;
24
+ protected router: Router;
25
+ protected version: string;
26
+ feeds$: Observable<T[]>;
27
+ hasFeeds$: Observable<boolean>;
28
+ feeds: T[];
29
+ hasFeeds: boolean;
30
+ showHeader: boolean;
31
+ headerTextColor: AppColors;
32
+ constructor(environment: Environment, feedService: IFeedService<T>);
33
+ openFeedHome(feed?: T): Promise<void>;
34
+ openUrl(url: string): Promise<void>;
35
+ openTag(feed: T, tag: string): Promise<void>;
36
+ getTags(feedOrItem?: T | T['items'][0]): string[];
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<FeedsComponent<any>, [null, { optional: true; }]>;
38
+ static ɵcmp: i0.ɵɵComponentDeclaration<FeedsComponent<any>, "app-feeds", never, { "feeds": { "alias": "feeds"; "required": false; }; "showHeader": { "alias": "showHeader"; "required": false; }; "headerTextColor": { "alias": "headerTextColor"; "required": false; }; }, {}, never, never, false, never>;
39
+ }
@@ -0,0 +1,32 @@
1
+ import { AfterViewInit, ElementRef, OnDestroy } from '@angular/core';
2
+ import { Subscription } from 'rxjs';
3
+ import { UrlTree } from '@angular/router';
4
+ import * as i0 from "@angular/core";
5
+ export declare class FeedDirective implements AfterViewInit, OnDestroy {
6
+ private element;
7
+ private _subscription;
8
+ private platform;
9
+ private locationStrategy;
10
+ private navController;
11
+ private router;
12
+ private route;
13
+ private _feedUrl;
14
+ private _baseUrl;
15
+ set feedUrl(value: string);
16
+ get feedUrl(): string;
17
+ constructor(element: ElementRef<HTMLElement>);
18
+ ngAfterViewInit(): void;
19
+ ngOnDestroy(): void;
20
+ protected listenClickEvents(nativeElement: HTMLElement): Subscription;
21
+ protected click(event: Event, containerElement: HTMLElement): Promise<boolean>;
22
+ scrollToAnchor(containerElement: HTMLElement, anchorId: string): void;
23
+ /**
24
+ * Transform a relative URL to its absolute representation according to current router state.
25
+ * @param url Relative URL path.
26
+ * @return Absolute URL based on the current route.
27
+ */
28
+ normalizeUrl(url: string): string;
29
+ getUrlTree(url: string): UrlTree;
30
+ static ɵfac: i0.ɵɵFactoryDeclaration<FeedDirective, never>;
31
+ static ɵdir: i0.ɵɵDirectiveDeclaration<FeedDirective, "feed,[feed]", never, { "feedUrl": { "alias": "feed"; "required": false; }; }, {}, never, never, false, never>;
32
+ }
@@ -0,0 +1,69 @@
1
+ export interface JsonFeed {
2
+ version: string;
3
+ title: string;
4
+ home_page_url?: string;
5
+ feed_url?: string;
6
+ description?: string;
7
+ user_comment?: string;
8
+ next_url?: string;
9
+ icon?: string;
10
+ favicon?: string;
11
+ authors: JsonFeedAuthor[];
12
+ language?: string;
13
+ expired?: boolean;
14
+ items: JsonFeedItem[];
15
+ hubs?: {
16
+ type?: string;
17
+ url: string;
18
+ }[];
19
+ tag_template?: string;
20
+ /**
21
+ * @deprecated since version 1.1
22
+ */
23
+ author: JsonFeedAuthor;
24
+ }
25
+ export interface JsonFeedItem {
26
+ id: string;
27
+ url?: string;
28
+ external_url?: string;
29
+ title?: string;
30
+ content_html?: string;
31
+ content_text?: string;
32
+ summary?: string;
33
+ banner_image?: string;
34
+ date_published?: string;
35
+ date_modified?: string;
36
+ authors: JsonFeedAuthor[];
37
+ tags: string[];
38
+ language: string;
39
+ /**
40
+ * @deprecated since version 1.1
41
+ */
42
+ author: JsonFeedAuthor;
43
+ truncated: boolean;
44
+ }
45
+ export interface JsonFeedAuthor {
46
+ name?: string;
47
+ url?: string;
48
+ avatar?: string;
49
+ }
50
+ export declare class JsonFeedUtils {
51
+ static DEFAULT_MAX_POST_AGE_IN_MONTHS: number;
52
+ static VERSION_1: string;
53
+ static VERSION_1_1: string;
54
+ static ACCEPTED_VERSIONS: string[];
55
+ static removeJsonExtension(url: string): string;
56
+ static isJsonFeed(json: any): json is JsonFeed;
57
+ static isJsonFeedItem(json: any): json is JsonFeedItem;
58
+ static truncateFeedItemsHtml(feed: JsonFeed, opts?: {
59
+ maxContentLength?: number;
60
+ }): JsonFeed;
61
+ static truncateHtml(html: string, opts?: {
62
+ maxContentLength?: number;
63
+ }): string;
64
+ /**
65
+ * Migrate from old version 1.0 to 1.1
66
+ * @param feed
67
+ */
68
+ static migrateFeed(feed: JsonFeed): JsonFeed;
69
+ }
@@ -0,0 +1,11 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./feed.component";
3
+ import * as i2 from "./feed.directive";
4
+ import * as i3 from "../../shared/shared.module";
5
+ import * as i4 from "@ngx-translate/core";
6
+ import * as i5 from "@angular/common";
7
+ export declare class FeedModule {
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<FeedModule, never>;
9
+ static ɵmod: i0.ɵɵNgModuleDeclaration<FeedModule, [typeof i1.FeedsComponent, typeof i2.FeedDirective], [typeof i3.SharedModule, typeof i4.TranslateModule, typeof i5.NgOptimizedImage], [typeof i4.TranslateModule, typeof i1.FeedsComponent, typeof i2.FeedDirective]>;
10
+ static ɵinj: i0.ɵɵInjectorDeclaration<FeedModule>;
11
+ }
@@ -0,0 +1,13 @@
1
+ import { Observable } from 'rxjs';
2
+ import { LoadResult } from '../../shared/services/entity-service.class';
3
+ import { JsonFeed } from './feed.model';
4
+ import { InjectionToken } from '@angular/core';
5
+ export declare const APP_FEED_SERVICE: InjectionToken<IFeedService<any>>;
6
+ export interface IFeedService<T extends JsonFeed = JsonFeed> {
7
+ watchAll(opts?: {
8
+ maxAgeInMonths?: number;
9
+ maxContentLength?: number;
10
+ }): Observable<LoadResult<T>>;
11
+ getHomeUrl(feed?: T): string;
12
+ getTagUrl(feed: T, tag: string): string;
13
+ }
@@ -551,7 +551,7 @@
551
551
  },
552
552
  "MESSAGE": {
553
553
  "TYPE": "Message type",
554
- "RECIPIENTS": "Recipients"
554
+ "RECIPIENTS": "Recipients",
555
555
  "RECIPIENT_FILTER_COUNT": "{{count}} filtered users",
556
556
  "SUBJECT": "Object",
557
557
  "BODY_HELP": "Your message...",
@@ -564,6 +564,10 @@
564
564
  "FEED": "Feed"
565
565
  }
566
566
  },
567
+ "FEED": {
568
+ "NEWS": "News",
569
+ "SHOW_ALL_FEED": "Show all"
570
+ },
567
571
  "ERROR": {
568
572
  "LOAD_USER_EVENTS_ERROR": "Error while loading notifications",
569
573
  "COUNT_USER_EVENT_ERROR": "Error while counting notifications",
@@ -564,6 +564,11 @@
564
564
  "FEED": "Feed"
565
565
  }
566
566
  },
567
+ "FEED": {
568
+ "NEWS": "News",
569
+ "READ_MORE": "Read more",
570
+ "SHOW_ALL_FEED": "Show all"
571
+ },
567
572
  "ERROR": {
568
573
  "LOAD_USER_EVENTS_ERROR": "Error while loading notifications",
569
574
  "COUNT_USER_EVENT_ERROR": "Error while counting notifications",
@@ -564,6 +564,11 @@
564
564
  "FEED": "Actualité"
565
565
  }
566
566
  },
567
+ "FEED": {
568
+ "NEWS": "Actualités",
569
+ "READ_MORE": "Lire la suite",
570
+ "SHOW_ALL_FEED": "Voir tout"
571
+ },
567
572
  "ERROR": {
568
573
  "LOAD_USER_EVENTS_ERROR": "Erreur de chargement des notifications",
569
574
  "COUNT_USER_EVENT_ERROR": "Erreur de comptage des notifications",
@@ -72,4 +72,12 @@ export declare class Environment {
72
72
  enableListenChanges?: boolean;
73
73
  listenIntervalInSeconds?: number;
74
74
  };
75
+ feed?: {
76
+ jsonFeed: {
77
+ [key: string]: string[];
78
+ };
79
+ maxContentLength: number;
80
+ maxAgeInMonths: number;
81
+ maxCount: number;
82
+ };
75
83
  }