From 765cb4aac1c1b1f448e607a71c1adfc45609a478 Mon Sep 17 00:00:00 2001 From: Alexandre Caron Date: Wed, 20 Dec 2023 16:59:52 -0500 Subject: [PATCH 1/7] feat: Convert all components, directives and pipes to standalone --- src/app/app.component.html | 4 +- src/app/pages/footer/footer.component.ts | 9 ++- src/app/pages/footer/footer.module.ts | 5 +- src/app/pages/header/header.component.ts | 10 ++- src/app/pages/header/header.module.ts | 5 +- .../expansion-panel-header.component.ts | 11 ++- .../expansion-panel.component.ts | 7 +- .../expansion-panel/expansion-panel.module.ts | 28 +++---- .../map-overlay/map-overlay.component.ts | 9 ++- .../portal/map-overlay/map-overlay.module.ts | 5 +- src/app/pages/portal/portal.component.ts | 63 +++++++++++++++- src/app/pages/portal/portal.module.ts | 74 +++++++++---------- .../pages/portal/sidenav/sidenav.component.ts | 32 +++++++- .../pages/portal/sidenav/sidenav.module.ts | 34 ++++----- .../toast-panel-for-expansion.component.ts | 6 +- .../toast-panel-for-expansion.module.ts | 20 ++--- .../toast-panel/toast-panel.component.ts | 30 +++++++- .../portal/toast-panel/toast-panel.module.ts | 32 ++++---- .../welcome-window.component.ts | 32 +++++++- .../welcome-window/welcome-window.module.ts | 28 +++---- .../welcome-window/welcome-window.service.ts | 1 + src/contexts/variousStyles.json | 13 +--- src/environments/environnement.interface.ts | 1 + 23 files changed, 305 insertions(+), 154 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index aedffd49b..494e6b0e5 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -11,8 +11,8 @@ ? 'portal-with-header-footer' : 'portal-with-header' : hasFooter - ? 'portal-with-footer' - : 'portal' + ? 'portal-with-footer' + : 'portal' " igoStopDropPropagation > diff --git a/src/app/pages/footer/footer.component.ts b/src/app/pages/footer/footer.component.ts index 8f1d73064..8c29890ff 100644 --- a/src/app/pages/footer/footer.component.ts +++ b/src/app/pages/footer/footer.component.ts @@ -1,11 +1,14 @@ import { Component } from '@angular/core'; import { LanguageService } from '@igo2/core'; +import { TranslateModule } from '@ngx-translate/core'; @Component({ - selector: 'app-footer', - templateUrl: './footer.component.html', - styleUrls: ['./footer.component.scss'] + selector: 'app-footer', + templateUrl: './footer.component.html', + styleUrls: ['./footer.component.scss'], + standalone: true, + imports: [TranslateModule] }) export class FooterComponent { constructor(protected languageService: LanguageService) {} diff --git a/src/app/pages/footer/footer.module.ts b/src/app/pages/footer/footer.module.ts index 7f1f6991a..84441a3a4 100644 --- a/src/app/pages/footer/footer.module.ts +++ b/src/app/pages/footer/footer.module.ts @@ -6,8 +6,7 @@ import { IgoLanguageModule } from '@igo2/core'; import { FooterComponent } from './footer.component'; @NgModule({ - declarations: [FooterComponent], - imports: [CommonModule, IgoLanguageModule], - exports: [FooterComponent] + imports: [CommonModule, IgoLanguageModule, FooterComponent], + exports: [FooterComponent] }) export class FooterModule {} diff --git a/src/app/pages/header/header.component.ts b/src/app/pages/header/header.component.ts index c525410bb..741435287 100644 --- a/src/app/pages/header/header.component.ts +++ b/src/app/pages/header/header.component.ts @@ -1,11 +1,15 @@ import { Component } from '@angular/core'; import { ConfigService, LanguageService } from '@igo2/core'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatToolbarModule } from '@angular/material/toolbar'; @Component({ - selector: 'app-header', - templateUrl: './header.component.html', - styleUrls: ['./header.component.scss'] + selector: 'app-header', + templateUrl: './header.component.html', + styleUrls: ['./header.component.scss'], + standalone: true, + imports: [MatToolbarModule, TranslateModule] }) export class HeaderComponent { public headerLogo: string; diff --git a/src/app/pages/header/header.module.ts b/src/app/pages/header/header.module.ts index cd82c724d..36165a530 100644 --- a/src/app/pages/header/header.module.ts +++ b/src/app/pages/header/header.module.ts @@ -7,8 +7,7 @@ import { IgoLanguageModule } from '@igo2/core'; import { HeaderComponent } from './header.component'; @NgModule({ - declarations: [HeaderComponent], - imports: [CommonModule, IgoLanguageModule, MatToolbarModule], - exports: [HeaderComponent] + imports: [CommonModule, IgoLanguageModule, MatToolbarModule, HeaderComponent], + exports: [HeaderComponent] }) export class HeaderModule {} diff --git a/src/app/pages/portal/expansion-panel/expansion-panel-header.component.ts b/src/app/pages/portal/expansion-panel/expansion-panel-header.component.ts index f852b4cd1..445c3cdab 100644 --- a/src/app/pages/portal/expansion-panel/expansion-panel-header.component.ts +++ b/src/app/pages/portal/expansion-panel/expansion-panel-header.component.ts @@ -6,12 +6,15 @@ import { Input, Output } from '@angular/core'; +import { ExpansionPanelButtonComponent } from './expansion-panel-button/expansion-panel-button.component'; @Component({ - selector: 'app-expansion-panel-header', - templateUrl: './expansion-panel-header.component.html', - styleUrls: ['./expansion-panel-header.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush + selector: 'app-expansion-panel-header', + templateUrl: './expansion-panel-header.component.html', + styleUrls: ['./expansion-panel-header.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [ExpansionPanelButtonComponent] }) export class ExpansionPanelHeaderComponent { @Input() expanded: boolean; diff --git a/src/app/pages/portal/expansion-panel/expansion-panel.component.ts b/src/app/pages/portal/expansion-panel/expansion-panel.component.ts index 99018f7e3..502879d1b 100644 --- a/src/app/pages/portal/expansion-panel/expansion-panel.component.ts +++ b/src/app/pages/portal/expansion-panel/expansion-panel.component.ts @@ -7,6 +7,9 @@ import { Output } from '@angular/core'; +import { BackdropComponent } from '@igo2/common'; + +import { ExpansionPanelHeaderComponent } from './expansion-panel-header.component'; import { showContent } from './expansion-panel.animations'; @Component({ @@ -14,7 +17,9 @@ import { showContent } from './expansion-panel.animations'; templateUrl: './expansion-panel.component.html', styleUrls: ['./expansion-panel.component.scss'], animations: [showContent()], - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [BackdropComponent, ExpansionPanelHeaderComponent] }) export class ExpansionPanelComponent { @Input() diff --git a/src/app/pages/portal/expansion-panel/expansion-panel.module.ts b/src/app/pages/portal/expansion-panel/expansion-panel.module.ts index dd604322d..c38717f6f 100644 --- a/src/app/pages/portal/expansion-panel/expansion-panel.module.ts +++ b/src/app/pages/portal/expansion-panel/expansion-panel.module.ts @@ -15,19 +15,19 @@ import { ExpansionPanelHeaderComponent } from './expansion-panel-header.componen import { ExpansionPanelComponent } from './expansion-panel.component'; @NgModule({ - imports: [ - CommonModule, - MatButtonModule, - MatIconModule, - MatMenuModule, - MatListModule, - MatSelectModule, - MatTooltipModule, - IgoLanguageModule, - IgoBackdropModule, - ExpansionPanelButtonComponent - ], - exports: [ExpansionPanelComponent, ExpansionPanelButtonComponent], - declarations: [ExpansionPanelComponent, ExpansionPanelHeaderComponent] + imports: [ + CommonModule, + MatButtonModule, + MatIconModule, + MatMenuModule, + MatListModule, + MatSelectModule, + MatTooltipModule, + IgoLanguageModule, + IgoBackdropModule, + ExpansionPanelButtonComponent, + ExpansionPanelComponent, ExpansionPanelHeaderComponent + ], + exports: [ExpansionPanelComponent, ExpansionPanelButtonComponent] }) export class AppExpansionPanelModule {} diff --git a/src/app/pages/portal/map-overlay/map-overlay.component.ts b/src/app/pages/portal/map-overlay/map-overlay.component.ts index dac5da9aa..ebb0273e8 100644 --- a/src/app/pages/portal/map-overlay/map-overlay.component.ts +++ b/src/app/pages/portal/map-overlay/map-overlay.component.ts @@ -6,11 +6,14 @@ import { ConfigService, MediaService } from '@igo2/core'; import { Subscription } from 'rxjs'; import { MapOverlay } from './map-overlay.interface'; +import { NgFor, NgClass, NgIf, NgStyle } from '@angular/common'; @Component({ - selector: 'app-map-overlay', - templateUrl: './map-overlay.component.html', - styleUrls: ['./map-overlay.component.scss'] + selector: 'app-map-overlay', + templateUrl: './map-overlay.component.html', + styleUrls: ['./map-overlay.component.scss'], + standalone: true, + imports: [NgFor, NgClass, NgIf, NgStyle] }) export class MapOverlayComponent implements AfterViewInit, OnDestroy { public mapOverlay: MapOverlay[] = []; diff --git a/src/app/pages/portal/map-overlay/map-overlay.module.ts b/src/app/pages/portal/map-overlay/map-overlay.module.ts index ed3c0d5b8..9317c84a6 100644 --- a/src/app/pages/portal/map-overlay/map-overlay.module.ts +++ b/src/app/pages/portal/map-overlay/map-overlay.module.ts @@ -4,8 +4,7 @@ import { NgModule } from '@angular/core'; import { MapOverlayComponent } from './map-overlay.component'; @NgModule({ - imports: [CommonModule], - exports: [MapOverlayComponent], - declarations: [MapOverlayComponent] + imports: [CommonModule, MapOverlayComponent], + exports: [MapOverlayComponent] }) export class MapOverlayModule {} diff --git a/src/app/pages/portal/portal.component.ts b/src/app/pages/portal/portal.component.ts index 8076d2bf6..7eeecd869 100644 --- a/src/app/pages/portal/portal.component.ts +++ b/src/app/pages/portal/portal.component.ts @@ -1,3 +1,4 @@ +import { AsyncPipe, NgClass, NgIf } from '@angular/common'; import { HttpClient, HttpParams } from '@angular/common/http'; import { ChangeDetectorRef, @@ -7,28 +8,43 @@ import { OnInit, ViewChild } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; import { MatDialog, MatDialogConfig, MatDialogRef } from '@angular/material/dialog'; +import { MatIconModule } from '@angular/material/icon'; import { MatPaginator } from '@angular/material/paginator'; +import { MatSidenavModule } from '@angular/material/sidenav'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { ActivatedRoute, Params } from '@angular/router'; import { AuthService } from '@igo2/auth'; import { ActionStore, + ActionbarComponent, ActionbarMode, + BackdropComponent, + ContextMenuDirective, + ENTITY_DIRECTIVES, EntityRecord, EntityStore, EntityTablePaginatorOptions, + LongPressDirective, Tool, Toolbox, Widget, Workspace, - WorkspaceStore + WorkspaceStore, + WorkspaceWidgetOutletComponent } from '@igo2/common'; -import { DetailedContext } from '@igo2/context'; +import { + DetailedContext, + LayerContextDirective, + MapContextDirective, + UserButtonComponent +} from '@igo2/context'; import { ConfigService, LanguageService, @@ -42,6 +58,7 @@ import { CapabilitiesService, ConfigFileToGeoDBService, DataSourceService, + DropGeoFileDirective, EditionWorkspace, EditionWorkspaceService, FEATURE, @@ -53,10 +70,14 @@ import { ImageLayer, ImportService, LayerService, + MAP_DIRECTIVES, MapExtent, + QueryDirective, QuerySearchSource, QueryService, Research, + SearchBarComponent, + SearchPointerSummaryDirective, SearchResult, SearchSource, SearchSourceService, @@ -90,11 +111,15 @@ import olFormatGeoJSON from 'ol/format/GeoJSON'; import type { default as OlGeometry } from 'ol/geom/Geometry'; import * as olProj from 'ol/proj'; +import { TranslateModule } from '@ngx-translate/core'; import { BehaviorSubject, Subscription, combineLatest, of } from 'rxjs'; import { debounceTime, first, pairwise, skipWhile, take } from 'rxjs/operators'; import { getAppVersion } from 'src/app/app.utils'; import { EnvironmentOptions } from 'src/environments/environnement.interface'; +import { ExpansionPanelButtonComponent } from './expansion-panel/expansion-panel-button/expansion-panel-button.component'; +import { ExpansionPanelComponent } from './expansion-panel/expansion-panel.component'; +import { MapOverlayComponent } from './map-overlay/map-overlay.component'; import { controlSlideX, controlSlideY, @@ -104,6 +129,9 @@ import { mapSlideY, toastPanelAnimation } from './portal.animation'; +import { SidenavComponent } from './sidenav/sidenav.component'; +import { ToastPanelForExpansionComponent } from './toast-panel-for-expansion/toast-panel-for-expansion.component'; +import { ToastPanelComponent } from './toast-panel/toast-panel.component'; import { WelcomeWindowComponent } from './welcome-window/welcome-window.component'; import { WelcomeWindowService } from './welcome-window/welcome-window.service'; @@ -119,6 +147,37 @@ import { WelcomeWindowService } from './welcome-window/welcome-window.service'; controlSlideY(), mapSlideX(), mapSlideY() + ], + standalone: true, + imports: [ + ActionbarComponent, + AsyncPipe, + BackdropComponent, + ContextMenuDirective, + DropGeoFileDirective, + ENTITY_DIRECTIVES, + ExpansionPanelButtonComponent, + ExpansionPanelComponent, + LayerContextDirective, + LongPressDirective, + MAP_DIRECTIVES, + MapContextDirective, + MapOverlayComponent, + MatButtonModule, + MatIconModule, + MatSidenavModule, + MatTooltipModule, + NgClass, + NgIf, + QueryDirective, + SearchBarComponent, + SearchPointerSummaryDirective, + SidenavComponent, + ToastPanelComponent, + ToastPanelForExpansionComponent, + TranslateModule, + UserButtonComponent, + WorkspaceWidgetOutletComponent ] }) export class PortalComponent implements OnInit, OnDestroy { diff --git a/src/app/pages/portal/portal.module.ts b/src/app/pages/portal/portal.module.ts index 8867ceb06..8ad0ee98d 100644 --- a/src/app/pages/portal/portal.module.ts +++ b/src/app/pages/portal/portal.module.ts @@ -43,42 +43,42 @@ import { AppToastPanelModule } from './toast-panel/toast-panel.module'; import { IgoWelcomeWindowModule } from './welcome-window/welcome-window.module'; @NgModule({ - imports: [ - CommonModule, - MatTooltipModule, - MatButtonModule, - MatIconModule, - MatSidenavModule, - MatDialogModule, - IgoCoreModule, - IgoFeatureModule, - IgoImportExportModule, - IgoMapModule, - IgoQueryModule.forRoot(), - IgoSearchModule.forRoot(), - IgoActionModule, - IgoWorkspaceModule, - IgoEntityModule, - IgoGeoWorkspaceModule, - IgoPanelModule, - IgoToolModule, - IgoContextMenuModule, - IgoBackdropModule, - IgoFlexibleModule, - IgoIntegrationModule, - AppExpansionPanelModule, - AppToastPanelModule, - AppToastPanelForExpansionModule, - AppSidenavModule, - MapOverlayModule, - IgoContextManagerModule, - IgoContextMapButtonModule, - IgoEntityTableModule, - IgoEntityTablePaginatorModule, - IgoInteractiveTourModule, - IgoWelcomeWindowModule - ], - exports: [PortalComponent], - declarations: [PortalComponent] + imports: [ + CommonModule, + MatTooltipModule, + MatButtonModule, + MatIconModule, + MatSidenavModule, + MatDialogModule, + IgoCoreModule, + IgoFeatureModule, + IgoImportExportModule, + IgoMapModule, + IgoQueryModule.forRoot(), + IgoSearchModule.forRoot(), + IgoActionModule, + IgoWorkspaceModule, + IgoEntityModule, + IgoGeoWorkspaceModule, + IgoPanelModule, + IgoToolModule, + IgoContextMenuModule, + IgoBackdropModule, + IgoFlexibleModule, + IgoIntegrationModule, + AppExpansionPanelModule, + AppToastPanelModule, + AppToastPanelForExpansionModule, + AppSidenavModule, + MapOverlayModule, + IgoContextManagerModule, + IgoContextMapButtonModule, + IgoEntityTableModule, + IgoEntityTablePaginatorModule, + IgoInteractiveTourModule, + IgoWelcomeWindowModule, + PortalComponent + ], + exports: [PortalComponent] }) export class PortalModule {} diff --git a/src/app/pages/portal/sidenav/sidenav.component.ts b/src/app/pages/portal/sidenav/sidenav.component.ts index d6e33a28b..921a9373b 100644 --- a/src/app/pages/portal/sidenav/sidenav.component.ts +++ b/src/app/pages/portal/sidenav/sidenav.component.ts @@ -1,3 +1,4 @@ +import { AsyncPipe, NgClass, NgIf } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -7,19 +8,46 @@ import { OnInit, Output } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; +import { MatIconModule } from '@angular/material/icon'; +import { MatSidenavModule } from '@angular/material/sidenav'; +import { MatTooltipModule } from '@angular/material/tooltip'; -import { Tool, Toolbox } from '@igo2/common'; +import { + HomeButtonComponent, + InteractiveTourComponent, + PanelComponent, + Tool, + Toolbox, + ToolboxComponent +} from '@igo2/common'; import { ConfigService } from '@igo2/core'; import { IgoMap } from '@igo2/geo'; import { CatalogState, ToolState } from '@igo2/integration'; +import { TranslateModule } from '@ngx-translate/core'; import { BehaviorSubject, Subscription } from 'rxjs'; @Component({ selector: 'app-sidenav', templateUrl: './sidenav.component.html', styleUrls: ['./sidenav.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [ + MatSidenavModule, + NgClass, + NgIf, + HomeButtonComponent, + PanelComponent, + MatButtonModule, + MatTooltipModule, + MatIconModule, + InteractiveTourComponent, + ToolboxComponent, + AsyncPipe, + TranslateModule + ] }) export class SidenavComponent implements OnInit, OnDestroy { title$: BehaviorSubject = new BehaviorSubject(undefined); diff --git a/src/app/pages/portal/sidenav/sidenav.module.ts b/src/app/pages/portal/sidenav/sidenav.module.ts index df651e259..f354538f5 100644 --- a/src/app/pages/portal/sidenav/sidenav.module.ts +++ b/src/app/pages/portal/sidenav/sidenav.module.ts @@ -19,22 +19,22 @@ import { IgoFeatureModule } from '@igo2/geo'; import { SidenavComponent } from './sidenav.component'; @NgModule({ - imports: [ - CommonModule, - MatIconModule, - MatButtonModule, - MatSidenavModule, - MatTooltipModule, - IgoLanguageModule, - IgoPanelModule, - IgoFlexibleModule, - IgoContextManagerModule, - IgoToolModule, - IgoFeatureModule, - IgoInteractiveTourModule, - IgoHomeButtonModule - ], - exports: [SidenavComponent], - declarations: [SidenavComponent] + imports: [ + CommonModule, + MatIconModule, + MatButtonModule, + MatSidenavModule, + MatTooltipModule, + IgoLanguageModule, + IgoPanelModule, + IgoFlexibleModule, + IgoContextManagerModule, + IgoToolModule, + IgoFeatureModule, + IgoInteractiveTourModule, + IgoHomeButtonModule, + SidenavComponent + ], + exports: [SidenavComponent] }) export class AppSidenavModule {} diff --git a/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.component.ts b/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.component.ts index 09bf8e3f5..ffac7ff56 100644 --- a/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.component.ts +++ b/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.component.ts @@ -7,6 +7,8 @@ import { Output } from '@angular/core'; +import { PanelComponent } from '@igo2/common'; + import { showContent } from './toast-panel-for-expansion.animations'; @Component({ @@ -14,7 +16,9 @@ import { showContent } from './toast-panel-for-expansion.animations'; templateUrl: './toast-panel-for-expansion.component.html', styleUrls: ['./toast-panel-for-expansion.component.scss'], animations: [showContent()], - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [PanelComponent] }) export class ToastPanelForExpansionComponent { @Input() diff --git a/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.module.ts b/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.module.ts index fc60ac262..8b8e9d601 100644 --- a/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.module.ts +++ b/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.module.ts @@ -9,15 +9,15 @@ import { IgoLanguageModule } from '@igo2/core'; import { ToastPanelForExpansionComponent } from './toast-panel-for-expansion.component'; @NgModule({ - imports: [ - CommonModule, - MatIconModule, - MatButtonModule, - IgoLanguageModule, - IgoPanelModule, - IgoStopPropagationModule - ], - exports: [ToastPanelForExpansionComponent], - declarations: [ToastPanelForExpansionComponent] + imports: [ + CommonModule, + MatIconModule, + MatButtonModule, + IgoLanguageModule, + IgoPanelModule, + IgoStopPropagationModule, + ToastPanelForExpansionComponent + ], + exports: [ToastPanelForExpansionComponent] }) export class AppToastPanelForExpansionModule {} diff --git a/src/app/pages/portal/toast-panel/toast-panel.component.ts b/src/app/pages/portal/toast-panel/toast-panel.component.ts index b35a47ec3..47e5a6f46 100644 --- a/src/app/pages/portal/toast-panel/toast-panel.component.ts +++ b/src/app/pages/portal/toast-panel/toast-panel.component.ts @@ -1,3 +1,4 @@ +import { AsyncPipe, NgClass, NgIf, NgTemplateOutlet } from '@angular/common'; import { ChangeDetectionStrategy, Component, @@ -9,12 +10,19 @@ import { OnInit, Output } from '@angular/core'; +import { MatBadgeModule } from '@angular/material/badge'; +import { MatButtonModule } from '@angular/material/button'; +import { MatIconModule } from '@angular/material/icon'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { Action, ActionStore, + ActionbarComponent, ActionbarMode, EntityStore, + PanelComponent, + StopPropagationDirective, getEntityTitle } from '@igo2/common'; import { @@ -28,6 +36,7 @@ import { } from '@igo2/core'; import { Feature, + FeatureDetailsComponent, FeatureMotion, GeoServiceDefinition, IgoMap, @@ -35,6 +44,7 @@ import { LayerService, PropertyTypeDetectorService, SearchResult, + SearchResultsComponent, computeOlFeaturesExtent, featureFromOl, featureToOl, @@ -52,6 +62,7 @@ import olFeature from 'ol/Feature'; import olFormatGeoJSON from 'ol/format/GeoJSON'; import olPoint from 'ol/geom/Point'; +import { TranslateModule } from '@ngx-translate/core'; import { BehaviorSubject, Observable, Subscription, combineLatest } from 'rxjs'; import { debounceTime, map, skipWhile, tap } from 'rxjs/operators'; @@ -63,7 +74,24 @@ interface ExtendedGeoServiceDefinition extends GeoServiceDefinition { selector: 'app-toast-panel', templateUrl: './toast-panel.component.html', styleUrls: ['./toast-panel.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [ + NgIf, + PanelComponent, + NgClass, + ActionbarComponent, + MatButtonModule, + StopPropagationDirective, + MatTooltipModule, + MatIconModule, + MatBadgeModule, + FeatureDetailsComponent, + SearchResultsComponent, + NgTemplateOutlet, + AsyncPipe, + TranslateModule + ] }) export class ToastPanelComponent implements OnInit, OnDestroy { static SWIPE_ACTION = { diff --git a/src/app/pages/portal/toast-panel/toast-panel.module.ts b/src/app/pages/portal/toast-panel/toast-panel.module.ts index 11bdbce22..8f10c5a5b 100644 --- a/src/app/pages/portal/toast-panel/toast-panel.module.ts +++ b/src/app/pages/portal/toast-panel/toast-panel.module.ts @@ -17,21 +17,21 @@ import { IgoFeatureModule, IgoSearchResultsModule } from '@igo2/geo'; import { ToastPanelComponent } from './toast-panel.component'; @NgModule({ - imports: [ - CommonModule, - MatBadgeModule, - MatIconModule, - MatButtonModule, - MatTooltipModule, - MatMenuModule, - IgoLanguageModule, - IgoPanelModule, - IgoStopPropagationModule, - IgoActionModule, - IgoFeatureModule, - IgoSearchResultsModule - ], - exports: [ToastPanelComponent], - declarations: [ToastPanelComponent] + imports: [ + CommonModule, + MatBadgeModule, + MatIconModule, + MatButtonModule, + MatTooltipModule, + MatMenuModule, + IgoLanguageModule, + IgoPanelModule, + IgoStopPropagationModule, + IgoActionModule, + IgoFeatureModule, + IgoSearchResultsModule, + ToastPanelComponent + ], + exports: [ToastPanelComponent] }) export class AppToastPanelModule {} diff --git a/src/app/pages/portal/welcome-window/welcome-window.component.ts b/src/app/pages/portal/welcome-window/welcome-window.component.ts index 69a8376d7..04a66d1c7 100644 --- a/src/app/pages/portal/welcome-window/welcome-window.component.ts +++ b/src/app/pages/portal/welcome-window/welcome-window.component.ts @@ -1,18 +1,42 @@ +import { AsyncPipe, NgIf } from '@angular/common'; import { Component, OnDestroy, OnInit } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; - +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { MatButtonModule } from '@angular/material/button'; +import { + MatDialog, + MatDialogClose, + MatDialogContent +} from '@angular/material/dialog'; +import { MatToolbarModule } from '@angular/material/toolbar'; + +import { CustomHtmlComponent, InteractiveTourComponent } from '@igo2/common'; import { ConfigService, LanguageService } from '@igo2/core'; +import { TranslateModule } from '@ngx-translate/core'; import { BehaviorSubject, Observable, Subscription, of } from 'rxjs'; import { map } from 'rxjs/operators'; +import { getAppVersion } from 'src/app/app.utils'; import { WelcomeWindowService } from './welcome-window.service'; -import { getAppVersion } from 'src/app/app.utils'; @Component({ selector: 'app-welcome-window', templateUrl: './welcome-window.component.html', - styleUrls: ['./welcome-window.component.scss'] + styleUrls: ['./welcome-window.component.scss'], + standalone: true, + imports: [ + NgIf, + MatToolbarModule, + ReactiveFormsModule, + FormsModule, + MatDialogContent, + CustomHtmlComponent, + InteractiveTourComponent, + MatButtonModule, + MatDialogClose, + TranslateModule, + AsyncPipe + ] }) export class WelcomeWindowComponent implements OnInit, OnDestroy { // isVisible = true; diff --git a/src/app/pages/portal/welcome-window/welcome-window.module.ts b/src/app/pages/portal/welcome-window/welcome-window.module.ts index 31da887c0..d691be289 100644 --- a/src/app/pages/portal/welcome-window/welcome-window.module.ts +++ b/src/app/pages/portal/welcome-window/welcome-window.module.ts @@ -13,19 +13,19 @@ import { IgoLanguageModule } from '@igo2/core'; import { WelcomeWindowComponent } from './welcome-window.component'; @NgModule({ - imports: [ - IgoLanguageModule, - CommonModule, - FormsModule, - MatDialogModule, - IgoInteractiveTourModule, - IgoCustomHtmlModule, - MatButtonModule, - MatTooltipModule, - MatIconModule, - MatToolbarModule - ], - declarations: [WelcomeWindowComponent], - exports: [WelcomeWindowComponent] + imports: [ + IgoLanguageModule, + CommonModule, + FormsModule, + MatDialogModule, + IgoInteractiveTourModule, + IgoCustomHtmlModule, + MatButtonModule, + MatTooltipModule, + MatIconModule, + MatToolbarModule, + WelcomeWindowComponent + ], + exports: [WelcomeWindowComponent] }) export class IgoWelcomeWindowModule {} diff --git a/src/app/pages/portal/welcome-window/welcome-window.service.ts b/src/app/pages/portal/welcome-window/welcome-window.service.ts index ccc4f0166..01d635c57 100644 --- a/src/app/pages/portal/welcome-window/welcome-window.service.ts +++ b/src/app/pages/portal/welcome-window/welcome-window.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { MatDialogConfig } from '@angular/material/dialog'; import { ConfigService, StorageService } from '@igo2/core'; + import { getAppVersion } from 'src/app/app.utils'; @Injectable({ diff --git a/src/contexts/variousStyles.json b/src/contexts/variousStyles.json index 9f9e9fdf4..a0688206b 100644 --- a/src/contexts/variousStyles.json +++ b/src/contexts/variousStyles.json @@ -93,12 +93,7 @@ "styleByAttribute": { "type": "circle", "attribute": "MODÈLE", - "data": [ - "^90 porte 4\"$", - "^100$", - "^400$", - null - ], + "data": ["^90 porte 4\"$", "^100$", "^400$", null], "color": ["orange", "red", "green", "blue"], "fill": ["orange", "red", "green", "blue"], "hstroke": ["orange", "red", "green", "blue"], @@ -144,11 +139,7 @@ "styleByAttribute": { "type": "circle", "attribute": "MODÈLE", - "data": [ - "^90 porte 4\"$", - "^100$", - "^400$" - ], + "data": ["^90 porte 4\"$", "^100$", "^400$"], "fill": ["orange", "red", "green"], "icon": [ "./assets/images/styles/fire-hydrant.svg", diff --git a/src/environments/environnement.interface.ts b/src/environments/environnement.interface.ts index db297decb..3750b9368 100644 --- a/src/environments/environnement.interface.ts +++ b/src/environments/environnement.interface.ts @@ -1,5 +1,6 @@ import { AllEnvironmentOptions } from '@igo2/integration'; import { EnvironmentOptions as IntegrationEnvironmentOptions } from '@igo2/integration'; + import { MapOverlay } from 'src/app/pages/portal/map-overlay/map-overlay.interface'; export interface AppEnvironmentOptions extends IntegrationEnvironmentOptions { From fd9f1812325869f95c510ccc98efd5c402ef4ba9 Mon Sep 17 00:00:00 2001 From: Alexandre Caron Date: Wed, 20 Dec 2023 17:05:03 -0500 Subject: [PATCH 2/7] feat: Remove unnecessary NgModule classes --- src/app/app.module.ts | 10 +-- src/app/pages/footer/footer.module.ts | 12 ---- src/app/pages/header/header.module.ts | 13 ---- .../portal/map-overlay/map-overlay.module.ts | 10 --- src/app/pages/portal/portal.module.ts | 71 +++++++++---------- 5 files changed, 38 insertions(+), 78 deletions(-) delete mode 100644 src/app/pages/footer/footer.module.ts delete mode 100644 src/app/pages/header/header.module.ts delete mode 100644 src/app/pages/portal/map-overlay/map-overlay.module.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 816b661dc..63d38a653 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -16,7 +16,7 @@ import { RouterModule } from '@angular/router'; import { ServiceWorkerModule } from '@angular/service-worker'; import { IgoAuthModule } from '@igo2/auth'; -import { IgoSpinnerModule, IgoStopPropagationModule } from '@igo2/common'; +import { SpinnerComponent, StopPropagationDirective } from '@igo2/common'; import { ConfigService, IgoGestureModule, @@ -45,8 +45,6 @@ import { concatMap, first } from 'rxjs'; import { environment } from '../environments/environment'; import { AppComponent } from './app.component'; import { PortalModule } from './pages'; -import { FooterModule } from './pages/footer/footer.module'; -import { HeaderModule } from './pages/header/header.module'; const DEFAULT_THEME: string = 'blue-theme'; @@ -66,11 +64,9 @@ export const defaultTooltipOptions: MatTooltipDefaultOptions = { IgoAuthModule.forRoot(), IgoGestureModule.forRoot(), IgoMessageModule, - IgoSpinnerModule, - IgoStopPropagationModule, + SpinnerComponent, + StopPropagationDirective, PortalModule, - HeaderModule, - FooterModule, ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.igo.app.pwa.enabled, registrationStrategy: 'registerWithDelay:5000' diff --git a/src/app/pages/footer/footer.module.ts b/src/app/pages/footer/footer.module.ts deleted file mode 100644 index 84441a3a4..000000000 --- a/src/app/pages/footer/footer.module.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; - -import { IgoLanguageModule } from '@igo2/core'; - -import { FooterComponent } from './footer.component'; - -@NgModule({ - imports: [CommonModule, IgoLanguageModule, FooterComponent], - exports: [FooterComponent] -}) -export class FooterModule {} diff --git a/src/app/pages/header/header.module.ts b/src/app/pages/header/header.module.ts deleted file mode 100644 index 36165a530..000000000 --- a/src/app/pages/header/header.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { MatToolbarModule } from '@angular/material/toolbar'; - -import { IgoLanguageModule } from '@igo2/core'; - -import { HeaderComponent } from './header.component'; - -@NgModule({ - imports: [CommonModule, IgoLanguageModule, MatToolbarModule, HeaderComponent], - exports: [HeaderComponent] -}) -export class HeaderModule {} diff --git a/src/app/pages/portal/map-overlay/map-overlay.module.ts b/src/app/pages/portal/map-overlay/map-overlay.module.ts deleted file mode 100644 index 9317c84a6..000000000 --- a/src/app/pages/portal/map-overlay/map-overlay.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; - -import { MapOverlayComponent } from './map-overlay.component'; - -@NgModule({ - imports: [CommonModule, MapOverlayComponent], - exports: [MapOverlayComponent] -}) -export class MapOverlayModule {} diff --git a/src/app/pages/portal/portal.module.ts b/src/app/pages/portal/portal.module.ts index 8ad0ee98d..4948e9df7 100644 --- a/src/app/pages/portal/portal.module.ts +++ b/src/app/pages/portal/portal.module.ts @@ -35,7 +35,7 @@ import { import { IgoIntegrationModule } from '@igo2/integration'; import { AppExpansionPanelModule } from './expansion-panel/expansion-panel.module'; -import { MapOverlayModule } from './map-overlay/map-overlay.module'; + import { PortalComponent } from './portal.component'; import { AppSidenavModule } from './sidenav/sidenav.module'; import { AppToastPanelForExpansionModule } from './toast-panel-for-expansion/toast-panel-for-expansion.module'; @@ -44,41 +44,40 @@ import { IgoWelcomeWindowModule } from './welcome-window/welcome-window.module'; @NgModule({ imports: [ - CommonModule, - MatTooltipModule, - MatButtonModule, - MatIconModule, - MatSidenavModule, - MatDialogModule, - IgoCoreModule, - IgoFeatureModule, - IgoImportExportModule, - IgoMapModule, - IgoQueryModule.forRoot(), - IgoSearchModule.forRoot(), - IgoActionModule, - IgoWorkspaceModule, - IgoEntityModule, - IgoGeoWorkspaceModule, - IgoPanelModule, - IgoToolModule, - IgoContextMenuModule, - IgoBackdropModule, - IgoFlexibleModule, - IgoIntegrationModule, - AppExpansionPanelModule, - AppToastPanelModule, - AppToastPanelForExpansionModule, - AppSidenavModule, - MapOverlayModule, - IgoContextManagerModule, - IgoContextMapButtonModule, - IgoEntityTableModule, - IgoEntityTablePaginatorModule, - IgoInteractiveTourModule, - IgoWelcomeWindowModule, - PortalComponent - ], + CommonModule, + MatTooltipModule, + MatButtonModule, + MatIconModule, + MatSidenavModule, + MatDialogModule, + IgoCoreModule, + IgoFeatureModule, + IgoImportExportModule, + IgoMapModule, + IgoQueryModule.forRoot(), + IgoSearchModule.forRoot(), + IgoActionModule, + IgoWorkspaceModule, + IgoEntityModule, + IgoGeoWorkspaceModule, + IgoPanelModule, + IgoToolModule, + IgoContextMenuModule, + IgoBackdropModule, + IgoFlexibleModule, + IgoIntegrationModule, + AppExpansionPanelModule, + AppToastPanelModule, + AppToastPanelForExpansionModule, + AppSidenavModule, + IgoContextManagerModule, + IgoContextMapButtonModule, + IgoEntityTableModule, + IgoEntityTablePaginatorModule, + IgoInteractiveTourModule, + IgoWelcomeWindowModule, + PortalComponent +], exports: [PortalComponent] }) export class PortalModule {} From d720f5e70ea8469b48c7ec778feb77abd1532594 Mon Sep 17 00:00:00 2001 From: Alexandre Caron Date: Thu, 21 Dec 2023 08:54:32 -0500 Subject: [PATCH 3/7] feat: Bootstrap the project using standalone APIs --- .eslintrc.json | 2 +- src/app/app.component.ts | 22 ++- src/app/app.module.ts | 138 ------------------ .../expansion-panel/expansion-panel.module.ts | 33 ----- src/app/pages/portal/portal.component.ts | 17 ++- src/app/pages/portal/portal.module.ts | 105 +++++-------- .../pages/portal/sidenav/sidenav.component.ts | 14 +- .../pages/portal/sidenav/sidenav.module.ts | 40 ----- .../toast-panel-for-expansion.module.ts | 23 --- .../toast-panel/toast-panel.component.ts | 18 +-- .../portal/toast-panel/toast-panel.module.ts | 37 ----- .../welcome-window.component.ts | 4 +- .../welcome-window/welcome-window.module.ts | 31 ---- src/main.ts | 113 +++++++++++++- 14 files changed, 190 insertions(+), 407 deletions(-) delete mode 100644 src/app/app.module.ts delete mode 100644 src/app/pages/portal/expansion-panel/expansion-panel.module.ts delete mode 100644 src/app/pages/portal/sidenav/sidenav.module.ts delete mode 100644 src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.module.ts delete mode 100644 src/app/pages/portal/toast-panel/toast-panel.module.ts delete mode 100644 src/app/pages/portal/welcome-window/welcome-window.module.ts diff --git a/.eslintrc.json b/.eslintrc.json index b68141ff3..1e7766167 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,9 +1,9 @@ { "root": true, - "plugins": ["unused-imports"], "overrides": [ { "files": ["*.ts"], + "plugins": ["unused-imports"], "extends": [ "plugin:@angular-eslint/recommended", "plugin:@angular-eslint/template/process-inline-templates" diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2c5163018..dea232f33 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,21 +1,32 @@ -import { DOCUMENT } from '@angular/common'; +import { DOCUMENT, NgClass, NgIf } from '@angular/common'; import { Component, Inject, OnInit } from '@angular/core'; import { Meta, Title } from '@angular/platform-browser'; import { NavigationEnd, Router } from '@angular/router'; -import { AuthOptions } from '@igo2/auth'; +import { AuthFormComponent, AuthOptions } from '@igo2/auth'; +import { SpinnerComponent, StopPropagationDirective } from '@igo2/common'; import { ConfigService, LanguageService, MessageService } from '@igo2/core'; -import { AnalyticsListenerService, AppOptions } from '@igo2/integration'; +import { AppOptions } from '@igo2/integration'; import { DomUtils, userAgent } from '@igo2/utils'; import { delay, first } from 'rxjs'; +import { PortalComponent } from './pages/portal/portal.component'; import { PwaService } from './services/pwa.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', - styleUrls: ['./app.component.scss'] + styleUrls: ['./app.component.scss'], + standalone: true, + imports: [ + SpinnerComponent, + StopPropagationDirective, + NgIf, + AuthFormComponent, + PortalComponent, + NgClass + ] }) export class AppComponent implements OnInit { public authConfig: AuthOptions; @@ -27,7 +38,6 @@ export class AppComponent implements OnInit { @Inject(DOCUMENT) private document: Document, protected languageService: LanguageService, private configService: ConfigService, - private analyticsListenerService: AnalyticsListenerService, private titleService: Title, private metaService: Meta, private messageService: MessageService, @@ -39,8 +49,6 @@ export class AppComponent implements OnInit { this.readTitleConfig(); this.readDescriptionConfig(); - this.analyticsListenerService.listen(); - this.detectOldBrowser(); this.hasHeader = this.configService.getConfig('header.hasHeader', false); diff --git a/src/app/app.module.ts b/src/app/app.module.ts deleted file mode 100644 index 63d38a653..000000000 --- a/src/app/app.module.ts +++ /dev/null @@ -1,138 +0,0 @@ -import { DOCUMENT } from '@angular/common'; -import { - APP_INITIALIZER, - ApplicationRef, - Injector, - NgModule -} from '@angular/core'; -import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field'; -import { - MAT_TOOLTIP_DEFAULT_OPTIONS, - MatTooltipDefaultOptions -} from '@angular/material/tooltip'; -import { BrowserModule } from '@angular/platform-browser'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { RouterModule } from '@angular/router'; -import { ServiceWorkerModule } from '@angular/service-worker'; - -import { IgoAuthModule } from '@igo2/auth'; -import { SpinnerComponent, StopPropagationDirective } from '@igo2/common'; -import { - ConfigService, - IgoGestureModule, - IgoMessageModule, - LanguageService, - RouteService, - provideConfigOptions -} from '@igo2/core'; -import { - provideCadastreSearchSource, - provideCoordinatesReverseSearchSource, - provideIChercheReverseSearchSource, - provideIChercheSearchSource, - provideILayerSearchSource, - provideNominatimSearchSource, - provideOptionsApi, - provideOsrmDirectionsSource, - provideStoredQueriesSearchSource, - provideStyleListOptions, - provideWorkspaceSearchSource -} from '@igo2/geo'; -import { loadTheme } from '@igo2/utils'; - -import { concatMap, first } from 'rxjs'; - -import { environment } from '../environments/environment'; -import { AppComponent } from './app.component'; -import { PortalModule } from './pages'; - -const DEFAULT_THEME: string = 'blue-theme'; - -export const defaultTooltipOptions: MatTooltipDefaultOptions = { - showDelay: 500, - hideDelay: 0, - touchendHideDelay: 0, - disableTooltipInteractivity: true -}; - -@NgModule({ - declarations: [AppComponent], - imports: [ - BrowserModule, - BrowserAnimationsModule, - RouterModule.forRoot([]), - IgoAuthModule.forRoot(), - IgoGestureModule.forRoot(), - IgoMessageModule, - SpinnerComponent, - StopPropagationDirective, - PortalModule, - ServiceWorkerModule.register('ngsw-worker.js', { - enabled: environment.igo.app.pwa.enabled, - registrationStrategy: 'registerWithDelay:5000' - }) - ], - providers: [ - provideConfigOptions({ - default: environment.igo, - path: './config/config.json' - }), - RouteService, - provideNominatimSearchSource(), - provideIChercheSearchSource(), - provideWorkspaceSearchSource(), - provideIChercheReverseSearchSource(), - provideCoordinatesReverseSearchSource(), - provideILayerSearchSource(), - provideStoredQueriesSearchSource(), - provideOsrmDirectionsSource(), - provideOptionsApi(), - provideCadastreSearchSource(), - { - provide: APP_INITIALIZER, - useFactory: appInitializerFactory, - deps: [Injector, ApplicationRef, DOCUMENT], - multi: true - }, - provideStyleListOptions({ - path: './assets/list-style.json' - }), - { provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: defaultTooltipOptions }, - { - provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, - useValue: { appearance: 'fill' } - } - ], - bootstrap: [AppComponent] -}) -export class AppModule {} - -function appInitializerFactory( - injector: Injector, - applicationRef: ApplicationRef, - document: Document -) { - // ensure to have the proper translations loaded once, when the app is stable. - return () => - new Promise((resolve: any) => { - applicationRef.isStable - .pipe( - first((isStable) => isStable === true), - concatMap(() => { - const languageService = injector.get(LanguageService); - const lang = languageService.getLanguage(); - return languageService.translate.getTranslation(lang); - }) - ) - .subscribe((translations) => { - const languageService = injector.get(LanguageService); - const lang = languageService.getLanguage(); - languageService.translate.setTranslation(lang, translations); - - const configService = injector.get(ConfigService); - const theme = configService.getConfig('theme', DEFAULT_THEME); - loadTheme(document, theme); - resolve(); - }); - }); -} diff --git a/src/app/pages/portal/expansion-panel/expansion-panel.module.ts b/src/app/pages/portal/expansion-panel/expansion-panel.module.ts deleted file mode 100644 index c38717f6f..000000000 --- a/src/app/pages/portal/expansion-panel/expansion-panel.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; -import { MatIconModule } from '@angular/material/icon'; -import { MatListModule } from '@angular/material/list'; -import { MatMenuModule } from '@angular/material/menu'; -import { MatSelectModule } from '@angular/material/select'; -import { MatTooltipModule } from '@angular/material/tooltip'; - -import { IgoBackdropModule } from '@igo2/common'; -import { IgoLanguageModule } from '@igo2/core'; - -import { ExpansionPanelButtonComponent } from './expansion-panel-button/expansion-panel-button.component'; -import { ExpansionPanelHeaderComponent } from './expansion-panel-header.component'; -import { ExpansionPanelComponent } from './expansion-panel.component'; - -@NgModule({ - imports: [ - CommonModule, - MatButtonModule, - MatIconModule, - MatMenuModule, - MatListModule, - MatSelectModule, - MatTooltipModule, - IgoLanguageModule, - IgoBackdropModule, - ExpansionPanelButtonComponent, - ExpansionPanelComponent, ExpansionPanelHeaderComponent - ], - exports: [ExpansionPanelComponent, ExpansionPanelButtonComponent] -}) -export class AppExpansionPanelModule {} diff --git a/src/app/pages/portal/portal.component.ts b/src/app/pages/portal/portal.component.ts index 7eeecd869..fb5369ab9 100644 --- a/src/app/pages/portal/portal.component.ts +++ b/src/app/pages/portal/portal.component.ts @@ -12,6 +12,7 @@ import { MatButtonModule } from '@angular/material/button'; import { MatDialog, MatDialogConfig, + MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { MatIconModule } from '@angular/material/icon'; @@ -34,10 +35,10 @@ import { LongPressDirective, Tool, Toolbox, + WORKSPACE_DIRECTIVES, Widget, Workspace, - WorkspaceStore, - WorkspaceWidgetOutletComponent + WorkspaceStore } from '@igo2/common'; import { DetailedContext, @@ -66,6 +67,7 @@ import { FeatureMotion, FeatureWorkspace, GoogleLinks, + IgoGeoWorkspaceModule, IgoMap, ImageLayer, ImportService, @@ -83,6 +85,7 @@ import { SearchSourceService, VectorLayer, WfsWorkspace, + WorkspaceUpdatorDirective, addStopToStore, computeOlFeaturesExtent, featureFromOl, @@ -95,6 +98,7 @@ import { sourceCanSearch } from '@igo2/geo'; import { + AnalyticsListenerService, ContextState, DirectionState, MapState, @@ -151,6 +155,7 @@ import { WelcomeWindowService } from './welcome-window/welcome-window.service'; standalone: true, imports: [ ActionbarComponent, + SidenavComponent, AsyncPipe, BackdropComponent, ContextMenuDirective, @@ -160,6 +165,8 @@ import { WelcomeWindowService } from './welcome-window/welcome-window.service'; ExpansionPanelComponent, LayerContextDirective, LongPressDirective, + MatDialogModule, + IgoGeoWorkspaceModule, MAP_DIRECTIVES, MapContextDirective, MapOverlayComponent, @@ -172,12 +179,12 @@ import { WelcomeWindowService } from './welcome-window/welcome-window.service'; QueryDirective, SearchBarComponent, SearchPointerSummaryDirective, - SidenavComponent, ToastPanelComponent, ToastPanelForExpansionComponent, TranslateModule, UserButtonComponent, - WorkspaceWidgetOutletComponent + WORKSPACE_DIRECTIVES, + WorkspaceUpdatorDirective ] }) export class PortalComponent implements OnInit, OnDestroy { @@ -366,6 +373,7 @@ export class PortalComponent implements OnInit, OnDestroy { } constructor( + private analyticsListenerService: AnalyticsListenerService, private route: ActivatedRoute, public workspaceState: WorkspaceState, public authService: AuthService, @@ -393,6 +401,7 @@ export class PortalComponent implements OnInit, OnDestroy { private directionState: DirectionState, private configFileToGeoDBService: ConfigFileToGeoDBService ) { + this.analyticsListenerService.listen(); this.handleAppConfigs(); this.storageService.set('version', getAppVersion(this.configService)); this.fullExtent = this.storageService.get('fullExtent') as boolean; diff --git a/src/app/pages/portal/portal.module.ts b/src/app/pages/portal/portal.module.ts index 4948e9df7..8e919044d 100644 --- a/src/app/pages/portal/portal.module.ts +++ b/src/app/pages/portal/portal.module.ts @@ -1,83 +1,50 @@ -import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; -import { MatDialogModule } from '@angular/material/dialog'; -import { MatIconModule } from '@angular/material/icon'; -import { MatSidenavModule } from '@angular/material/sidenav'; -import { MatTooltipModule } from '@angular/material/tooltip'; +import { IgoGestureModule } from '@igo2/core'; import { - IgoActionModule, - IgoBackdropModule, - IgoContextMenuModule, - IgoEntityModule, - IgoEntityTableModule, - IgoEntityTablePaginatorModule, - IgoFlexibleModule, - IgoInteractiveTourModule, - IgoPanelModule, - IgoToolModule, - IgoWorkspaceModule -} from '@igo2/common'; -import { - IgoContextManagerModule, - IgoContextMapButtonModule -} from '@igo2/context'; -import { IgoCoreModule } from '@igo2/core'; -import { - IgoFeatureModule, - IgoGeoWorkspaceModule, - IgoImportExportModule, - IgoMapModule, + IgoDirectionsModule, IgoQueryModule, - IgoSearchModule + IgoSearchModule, + provideCadastreSearchSource, + provideCoordinatesReverseSearchSource, + provideIChercheReverseSearchSource, + provideIChercheSearchSource, + provideILayerSearchSource, + provideNominatimSearchSource, + provideOptionsApi, + provideOsrmDirectionsSource, + provideStoredQueriesSearchSource, + provideStyleListOptions, + provideWorkspaceSearchSource } from '@igo2/geo'; -import { IgoIntegrationModule } from '@igo2/integration'; - -import { AppExpansionPanelModule } from './expansion-panel/expansion-panel.module'; +import { AnalyticsListenerService } from '@igo2/integration'; import { PortalComponent } from './portal.component'; -import { AppSidenavModule } from './sidenav/sidenav.module'; -import { AppToastPanelForExpansionModule } from './toast-panel-for-expansion/toast-panel-for-expansion.module'; -import { AppToastPanelModule } from './toast-panel/toast-panel.module'; -import { IgoWelcomeWindowModule } from './welcome-window/welcome-window.module'; @NgModule({ - imports: [ - CommonModule, - MatTooltipModule, - MatButtonModule, - MatIconModule, - MatSidenavModule, - MatDialogModule, - IgoCoreModule, - IgoFeatureModule, - IgoImportExportModule, - IgoMapModule, + imports: [ + IgoGestureModule.forRoot(), IgoQueryModule.forRoot(), IgoSearchModule.forRoot(), - IgoActionModule, - IgoWorkspaceModule, - IgoEntityModule, - IgoGeoWorkspaceModule, - IgoPanelModule, - IgoToolModule, - IgoContextMenuModule, - IgoBackdropModule, - IgoFlexibleModule, - IgoIntegrationModule, - AppExpansionPanelModule, - AppToastPanelModule, - AppToastPanelForExpansionModule, - AppSidenavModule, - IgoContextManagerModule, - IgoContextMapButtonModule, - IgoEntityTableModule, - IgoEntityTablePaginatorModule, - IgoInteractiveTourModule, - IgoWelcomeWindowModule, + IgoDirectionsModule, PortalComponent -], - exports: [PortalComponent] + ], + exports: [PortalComponent], + providers: [ + AnalyticsListenerService, + provideNominatimSearchSource(), + provideIChercheSearchSource(), + provideWorkspaceSearchSource(), + provideIChercheReverseSearchSource(), + provideCoordinatesReverseSearchSource(), + provideILayerSearchSource(), + provideStoredQueriesSearchSource(), + provideOsrmDirectionsSource(), + provideOptionsApi(), + provideCadastreSearchSource(), + provideStyleListOptions({ + path: './assets/list-style.json' + }) + ] }) export class PortalModule {} diff --git a/src/app/pages/portal/sidenav/sidenav.component.ts b/src/app/pages/portal/sidenav/sidenav.component.ts index 921a9373b..be7d38e10 100644 --- a/src/app/pages/portal/sidenav/sidenav.component.ts +++ b/src/app/pages/portal/sidenav/sidenav.component.ts @@ -15,7 +15,7 @@ import { MatTooltipModule } from '@angular/material/tooltip'; import { HomeButtonComponent, - InteractiveTourComponent, + IgoInteractiveTourModule, PanelComponent, Tool, Toolbox, @@ -35,17 +35,17 @@ import { BehaviorSubject, Subscription } from 'rxjs'; changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [ + AsyncPipe, + HomeButtonComponent, + IgoInteractiveTourModule, + MatButtonModule, + MatIconModule, MatSidenavModule, + MatTooltipModule, NgClass, NgIf, - HomeButtonComponent, PanelComponent, - MatButtonModule, - MatTooltipModule, - MatIconModule, - InteractiveTourComponent, ToolboxComponent, - AsyncPipe, TranslateModule ] }) diff --git a/src/app/pages/portal/sidenav/sidenav.module.ts b/src/app/pages/portal/sidenav/sidenav.module.ts deleted file mode 100644 index f354538f5..000000000 --- a/src/app/pages/portal/sidenav/sidenav.module.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; -import { MatIconModule } from '@angular/material/icon'; -import { MatSidenavModule } from '@angular/material/sidenav'; -import { MatTooltipModule } from '@angular/material/tooltip'; - -import { - IgoFlexibleModule, - IgoHomeButtonModule, - IgoInteractiveTourModule, - IgoPanelModule, - IgoToolModule -} from '@igo2/common'; -import { IgoContextManagerModule } from '@igo2/context'; -import { IgoLanguageModule } from '@igo2/core'; -import { IgoFeatureModule } from '@igo2/geo'; - -import { SidenavComponent } from './sidenav.component'; - -@NgModule({ - imports: [ - CommonModule, - MatIconModule, - MatButtonModule, - MatSidenavModule, - MatTooltipModule, - IgoLanguageModule, - IgoPanelModule, - IgoFlexibleModule, - IgoContextManagerModule, - IgoToolModule, - IgoFeatureModule, - IgoInteractiveTourModule, - IgoHomeButtonModule, - SidenavComponent - ], - exports: [SidenavComponent] -}) -export class AppSidenavModule {} diff --git a/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.module.ts b/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.module.ts deleted file mode 100644 index 8b8e9d601..000000000 --- a/src/app/pages/portal/toast-panel-for-expansion/toast-panel-for-expansion.module.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; -import { MatIconModule } from '@angular/material/icon'; - -import { IgoPanelModule, IgoStopPropagationModule } from '@igo2/common'; -import { IgoLanguageModule } from '@igo2/core'; - -import { ToastPanelForExpansionComponent } from './toast-panel-for-expansion.component'; - -@NgModule({ - imports: [ - CommonModule, - MatIconModule, - MatButtonModule, - IgoLanguageModule, - IgoPanelModule, - IgoStopPropagationModule, - ToastPanelForExpansionComponent - ], - exports: [ToastPanelForExpansionComponent] -}) -export class AppToastPanelForExpansionModule {} diff --git a/src/app/pages/portal/toast-panel/toast-panel.component.ts b/src/app/pages/portal/toast-panel/toast-panel.component.ts index 47e5a6f46..6e82d2711 100644 --- a/src/app/pages/portal/toast-panel/toast-panel.component.ts +++ b/src/app/pages/portal/toast-panel/toast-panel.component.ts @@ -77,19 +77,19 @@ interface ExtendedGeoServiceDefinition extends GeoServiceDefinition { changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [ - NgIf, - PanelComponent, - NgClass, ActionbarComponent, + AsyncPipe, + FeatureDetailsComponent, + MatBadgeModule, MatButtonModule, - StopPropagationDirective, - MatTooltipModule, MatIconModule, - MatBadgeModule, - FeatureDetailsComponent, - SearchResultsComponent, + MatTooltipModule, + NgClass, + NgIf, NgTemplateOutlet, - AsyncPipe, + PanelComponent, + SearchResultsComponent, + StopPropagationDirective, TranslateModule ] }) diff --git a/src/app/pages/portal/toast-panel/toast-panel.module.ts b/src/app/pages/portal/toast-panel/toast-panel.module.ts deleted file mode 100644 index 8f10c5a5b..000000000 --- a/src/app/pages/portal/toast-panel/toast-panel.module.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { MatBadgeModule } from '@angular/material/badge'; -import { MatButtonModule } from '@angular/material/button'; -import { MatIconModule } from '@angular/material/icon'; -import { MatMenuModule } from '@angular/material/menu'; -import { MatTooltipModule } from '@angular/material/tooltip'; - -import { - IgoActionModule, - IgoPanelModule, - IgoStopPropagationModule -} from '@igo2/common'; -import { IgoLanguageModule } from '@igo2/core'; -import { IgoFeatureModule, IgoSearchResultsModule } from '@igo2/geo'; - -import { ToastPanelComponent } from './toast-panel.component'; - -@NgModule({ - imports: [ - CommonModule, - MatBadgeModule, - MatIconModule, - MatButtonModule, - MatTooltipModule, - MatMenuModule, - IgoLanguageModule, - IgoPanelModule, - IgoStopPropagationModule, - IgoActionModule, - IgoFeatureModule, - IgoSearchResultsModule, - ToastPanelComponent - ], - exports: [ToastPanelComponent] -}) -export class AppToastPanelModule {} diff --git a/src/app/pages/portal/welcome-window/welcome-window.component.ts b/src/app/pages/portal/welcome-window/welcome-window.component.ts index 04a66d1c7..63f998314 100644 --- a/src/app/pages/portal/welcome-window/welcome-window.component.ts +++ b/src/app/pages/portal/welcome-window/welcome-window.component.ts @@ -9,7 +9,7 @@ import { } from '@angular/material/dialog'; import { MatToolbarModule } from '@angular/material/toolbar'; -import { CustomHtmlComponent, InteractiveTourComponent } from '@igo2/common'; +import { CustomHtmlComponent, IgoInteractiveTourModule } from '@igo2/common'; import { ConfigService, LanguageService } from '@igo2/core'; import { TranslateModule } from '@ngx-translate/core'; @@ -31,7 +31,7 @@ import { WelcomeWindowService } from './welcome-window.service'; FormsModule, MatDialogContent, CustomHtmlComponent, - InteractiveTourComponent, + IgoInteractiveTourModule, MatButtonModule, MatDialogClose, TranslateModule, diff --git a/src/app/pages/portal/welcome-window/welcome-window.module.ts b/src/app/pages/portal/welcome-window/welcome-window.module.ts deleted file mode 100644 index d691be289..000000000 --- a/src/app/pages/portal/welcome-window/welcome-window.module.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatDialogModule } from '@angular/material/dialog'; -import { MatIconModule } from '@angular/material/icon'; -import { MatToolbarModule } from '@angular/material/toolbar'; -import { MatTooltipModule } from '@angular/material/tooltip'; - -import { IgoCustomHtmlModule, IgoInteractiveTourModule } from '@igo2/common'; -import { IgoLanguageModule } from '@igo2/core'; - -import { WelcomeWindowComponent } from './welcome-window.component'; - -@NgModule({ - imports: [ - IgoLanguageModule, - CommonModule, - FormsModule, - MatDialogModule, - IgoInteractiveTourModule, - IgoCustomHtmlModule, - MatButtonModule, - MatTooltipModule, - MatIconModule, - MatToolbarModule, - WelcomeWindowComponent - ], - exports: [WelcomeWindowComponent] -}) -export class IgoWelcomeWindowModule {} diff --git a/src/main.ts b/src/main.ts index 0fa4f834b..8c54d94e0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,15 +1,116 @@ -import { enableProdMode } from '@angular/core'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { DOCUMENT } from '@angular/common'; +import { provideHttpClient } from '@angular/common/http'; +import { + APP_INITIALIZER, + ApplicationRef, + Injector, + enableProdMode, + importProvidersFrom +} from '@angular/core'; +import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field'; +import { + MAT_TOOLTIP_DEFAULT_OPTIONS, + MatTooltipDefaultOptions +} from '@angular/material/tooltip'; +import { BrowserModule, bootstrapApplication } from '@angular/platform-browser'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideRouter } from '@angular/router'; +import { ServiceWorkerModule } from '@angular/service-worker'; + +import { IgoAuthModule } from '@igo2/auth'; +import { + ConfigService, + IgoCoreModule, + IgoMessageModule, + LanguageService, + RouteService, + provideConfigOptions, + provideRootTranslation +} from '@igo2/core'; +import { loadTheme } from '@igo2/utils'; import 'hammerjs'; +import { concatMap, first } from 'rxjs'; -import { AppModule } from './app/app.module'; +import { AppComponent } from './app/app.component'; +import { PortalModule } from './app/pages'; import { environment } from './environments/environment'; +const TOOLTIP_OPTIONS: MatTooltipDefaultOptions = { + showDelay: 500, + hideDelay: 0, + touchendHideDelay: 0, + disableTooltipInteractivity: true +}; + +const DEFAULT_THEME: string = 'blue-theme'; + if (environment.production) { enableProdMode(); } -platformBrowserDynamic() - .bootstrapModule(AppModule) - .catch((err) => console.log(err)); +bootstrapApplication(AppComponent, { + providers: [ + importProvidersFrom( + BrowserModule, + IgoCoreModule.forRoot(), + IgoAuthModule.forRoot(), + provideRootTranslation(), + IgoMessageModule, + PortalModule, + ServiceWorkerModule.register('ngsw-worker.js', { + enabled: environment.igo.app.pwa.enabled, + registrationStrategy: 'registerWithDelay:5000' + }) + ), + provideHttpClient(), + provideAnimations(), + provideRouter([]), + provideConfigOptions({ + default: environment.igo, + path: './config/config.json' + }), + RouteService, + { + provide: APP_INITIALIZER, + useFactory: appInitializerFactory, + deps: [Injector, ApplicationRef, DOCUMENT], + multi: true + }, + { provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: TOOLTIP_OPTIONS }, + { + provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, + useValue: { appearance: 'fill' } + } + ] +}).catch((err) => console.log(err)); + +function appInitializerFactory( + injector: Injector, + applicationRef: ApplicationRef, + document: Document +) { + // ensure to have the proper translations loaded once, when the app is stable. + return () => + new Promise((resolve: any) => { + applicationRef.isStable + .pipe( + first((isStable) => isStable === true), + concatMap(() => { + const languageService = injector.get(LanguageService); + const lang = languageService.getLanguage(); + return languageService.translate.getTranslation(lang); + }) + ) + .subscribe((translations) => { + const languageService = injector.get(LanguageService); + const lang = languageService.getLanguage(); + languageService.translate.setTranslation(lang, translations); + + const configService = injector.get(ConfigService); + const theme = configService.getConfig('theme', DEFAULT_THEME); + loadTheme(document, theme); + resolve(); + }); + }); +} From 9299c377b198510065ef78ae2fb960ee8d32ad04 Mon Sep 17 00:00:00 2001 From: Alexandre Caron Date: Thu, 21 Dec 2023 09:05:20 -0500 Subject: [PATCH 4/7] fix: format --- src/app/pages/footer/footer.component.ts | 11 ++++++----- src/app/pages/header/header.component.ts | 13 +++++++------ .../expansion-panel-header.component.ts | 13 +++++++------ .../portal/map-overlay/map-overlay.component.ts | 12 ++++++------ 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/app/pages/footer/footer.component.ts b/src/app/pages/footer/footer.component.ts index 8c29890ff..6ff219a65 100644 --- a/src/app/pages/footer/footer.component.ts +++ b/src/app/pages/footer/footer.component.ts @@ -1,14 +1,15 @@ import { Component } from '@angular/core'; import { LanguageService } from '@igo2/core'; + import { TranslateModule } from '@ngx-translate/core'; @Component({ - selector: 'app-footer', - templateUrl: './footer.component.html', - styleUrls: ['./footer.component.scss'], - standalone: true, - imports: [TranslateModule] + selector: 'app-footer', + templateUrl: './footer.component.html', + styleUrls: ['./footer.component.scss'], + standalone: true, + imports: [TranslateModule] }) export class FooterComponent { constructor(protected languageService: LanguageService) {} diff --git a/src/app/pages/header/header.component.ts b/src/app/pages/header/header.component.ts index 741435287..c4c694683 100644 --- a/src/app/pages/header/header.component.ts +++ b/src/app/pages/header/header.component.ts @@ -1,15 +1,16 @@ import { Component } from '@angular/core'; +import { MatToolbarModule } from '@angular/material/toolbar'; import { ConfigService, LanguageService } from '@igo2/core'; + import { TranslateModule } from '@ngx-translate/core'; -import { MatToolbarModule } from '@angular/material/toolbar'; @Component({ - selector: 'app-header', - templateUrl: './header.component.html', - styleUrls: ['./header.component.scss'], - standalone: true, - imports: [MatToolbarModule, TranslateModule] + selector: 'app-header', + templateUrl: './header.component.html', + styleUrls: ['./header.component.scss'], + standalone: true, + imports: [MatToolbarModule, TranslateModule] }) export class HeaderComponent { public headerLogo: string; diff --git a/src/app/pages/portal/expansion-panel/expansion-panel-header.component.ts b/src/app/pages/portal/expansion-panel/expansion-panel-header.component.ts index 445c3cdab..f2a13fd4e 100644 --- a/src/app/pages/portal/expansion-panel/expansion-panel-header.component.ts +++ b/src/app/pages/portal/expansion-panel/expansion-panel-header.component.ts @@ -6,15 +6,16 @@ import { Input, Output } from '@angular/core'; + import { ExpansionPanelButtonComponent } from './expansion-panel-button/expansion-panel-button.component'; @Component({ - selector: 'app-expansion-panel-header', - templateUrl: './expansion-panel-header.component.html', - styleUrls: ['./expansion-panel-header.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [ExpansionPanelButtonComponent] + selector: 'app-expansion-panel-header', + templateUrl: './expansion-panel-header.component.html', + styleUrls: ['./expansion-panel-header.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [ExpansionPanelButtonComponent] }) export class ExpansionPanelHeaderComponent { @Input() expanded: boolean; diff --git a/src/app/pages/portal/map-overlay/map-overlay.component.ts b/src/app/pages/portal/map-overlay/map-overlay.component.ts index ebb0273e8..464b80d83 100644 --- a/src/app/pages/portal/map-overlay/map-overlay.component.ts +++ b/src/app/pages/portal/map-overlay/map-overlay.component.ts @@ -1,3 +1,4 @@ +import { NgClass, NgFor, NgIf, NgStyle } from '@angular/common'; import { AfterViewInit, Component, OnDestroy } from '@angular/core'; import { Context, ContextService } from '@igo2/context'; @@ -6,14 +7,13 @@ import { ConfigService, MediaService } from '@igo2/core'; import { Subscription } from 'rxjs'; import { MapOverlay } from './map-overlay.interface'; -import { NgFor, NgClass, NgIf, NgStyle } from '@angular/common'; @Component({ - selector: 'app-map-overlay', - templateUrl: './map-overlay.component.html', - styleUrls: ['./map-overlay.component.scss'], - standalone: true, - imports: [NgFor, NgClass, NgIf, NgStyle] + selector: 'app-map-overlay', + templateUrl: './map-overlay.component.html', + styleUrls: ['./map-overlay.component.scss'], + standalone: true, + imports: [NgFor, NgClass, NgIf, NgStyle] }) export class MapOverlayComponent implements AfterViewInit, OnDestroy { public mapOverlay: MapOverlay[] = []; From a971afe166b5ddce5cb3e745e3f0aa52b75de30e Mon Sep 17 00:00:00 2001 From: Alexandre Caron Date: Mon, 8 Jan 2024 09:18:48 -0500 Subject: [PATCH 5/7] fix(Translation): make provideRootTranslation more robust and provide LanguageService with ngx-translate --- src/main.ts | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8c54d94e0..1c8e182e3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,6 @@ import { DOCUMENT } from '@angular/common'; import { provideHttpClient } from '@angular/common/http'; import { APP_INITIALIZER, - ApplicationRef, Injector, enableProdMode, importProvidersFrom @@ -22,7 +21,6 @@ import { ConfigService, IgoCoreModule, IgoMessageModule, - LanguageService, RouteService, provideConfigOptions, provideRootTranslation @@ -30,7 +28,6 @@ import { import { loadTheme } from '@igo2/utils'; import 'hammerjs'; -import { concatMap, first } from 'rxjs'; import { AppComponent } from './app/app.component'; import { PortalModule } from './app/pages'; @@ -55,7 +52,6 @@ bootstrapApplication(AppComponent, { BrowserModule, IgoCoreModule.forRoot(), IgoAuthModule.forRoot(), - provideRootTranslation(), IgoMessageModule, PortalModule, ServiceWorkerModule.register('ngsw-worker.js', { @@ -63,6 +59,7 @@ bootstrapApplication(AppComponent, { registrationStrategy: 'registerWithDelay:5000' }) ), + provideRootTranslation(), provideHttpClient(), provideAnimations(), provideRouter([]), @@ -73,8 +70,8 @@ bootstrapApplication(AppComponent, { RouteService, { provide: APP_INITIALIZER, - useFactory: appInitializerFactory, - deps: [Injector, ApplicationRef, DOCUMENT], + useFactory: provideTheme, + deps: [Injector, DOCUMENT], multi: true }, { provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: TOOLTIP_OPTIONS }, @@ -85,32 +82,10 @@ bootstrapApplication(AppComponent, { ] }).catch((err) => console.log(err)); -function appInitializerFactory( - injector: Injector, - applicationRef: ApplicationRef, - document: Document -) { - // ensure to have the proper translations loaded once, when the app is stable. - return () => - new Promise((resolve: any) => { - applicationRef.isStable - .pipe( - first((isStable) => isStable === true), - concatMap(() => { - const languageService = injector.get(LanguageService); - const lang = languageService.getLanguage(); - return languageService.translate.getTranslation(lang); - }) - ) - .subscribe((translations) => { - const languageService = injector.get(LanguageService); - const lang = languageService.getLanguage(); - languageService.translate.setTranslation(lang, translations); - - const configService = injector.get(ConfigService); - const theme = configService.getConfig('theme', DEFAULT_THEME); - loadTheme(document, theme); - resolve(); - }); - }); +function provideTheme(injector: Injector, document: Document) { + return () => { + const configService = injector.get(ConfigService); + const theme = configService.getConfig('theme', DEFAULT_THEME); + loadTheme(document, theme); + }; } From e155f3c8ea7f3d80152a7543924944f78384e002 Mon Sep 17 00:00:00 2001 From: Alexandre Caron Date: Wed, 10 Jan 2024 08:47:58 -0500 Subject: [PATCH 6/7] Revert "fix(Translation): make provideRootTranslation more robust and provide LanguageService with ngx-translate" This reverts commit a971afe166b5ddce5cb3e745e3f0aa52b75de30e. --- src/main.ts | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/main.ts b/src/main.ts index 1c8e182e3..8c54d94e0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import { DOCUMENT } from '@angular/common'; import { provideHttpClient } from '@angular/common/http'; import { APP_INITIALIZER, + ApplicationRef, Injector, enableProdMode, importProvidersFrom @@ -21,6 +22,7 @@ import { ConfigService, IgoCoreModule, IgoMessageModule, + LanguageService, RouteService, provideConfigOptions, provideRootTranslation @@ -28,6 +30,7 @@ import { import { loadTheme } from '@igo2/utils'; import 'hammerjs'; +import { concatMap, first } from 'rxjs'; import { AppComponent } from './app/app.component'; import { PortalModule } from './app/pages'; @@ -52,6 +55,7 @@ bootstrapApplication(AppComponent, { BrowserModule, IgoCoreModule.forRoot(), IgoAuthModule.forRoot(), + provideRootTranslation(), IgoMessageModule, PortalModule, ServiceWorkerModule.register('ngsw-worker.js', { @@ -59,7 +63,6 @@ bootstrapApplication(AppComponent, { registrationStrategy: 'registerWithDelay:5000' }) ), - provideRootTranslation(), provideHttpClient(), provideAnimations(), provideRouter([]), @@ -70,8 +73,8 @@ bootstrapApplication(AppComponent, { RouteService, { provide: APP_INITIALIZER, - useFactory: provideTheme, - deps: [Injector, DOCUMENT], + useFactory: appInitializerFactory, + deps: [Injector, ApplicationRef, DOCUMENT], multi: true }, { provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: TOOLTIP_OPTIONS }, @@ -82,10 +85,32 @@ bootstrapApplication(AppComponent, { ] }).catch((err) => console.log(err)); -function provideTheme(injector: Injector, document: Document) { - return () => { - const configService = injector.get(ConfigService); - const theme = configService.getConfig('theme', DEFAULT_THEME); - loadTheme(document, theme); - }; +function appInitializerFactory( + injector: Injector, + applicationRef: ApplicationRef, + document: Document +) { + // ensure to have the proper translations loaded once, when the app is stable. + return () => + new Promise((resolve: any) => { + applicationRef.isStable + .pipe( + first((isStable) => isStable === true), + concatMap(() => { + const languageService = injector.get(LanguageService); + const lang = languageService.getLanguage(); + return languageService.translate.getTranslation(lang); + }) + ) + .subscribe((translations) => { + const languageService = injector.get(LanguageService); + const lang = languageService.getLanguage(); + languageService.translate.setTranslation(lang, translations); + + const configService = injector.get(ConfigService); + const theme = configService.getConfig('theme', DEFAULT_THEME); + loadTheme(document, theme); + resolve(); + }); + }); } From e7daf47a928aa983911efb727830768bdf7ee06e Mon Sep 17 00:00:00 2001 From: Alexandre Caron Date: Wed, 10 Jan 2024 09:02:33 -0500 Subject: [PATCH 7/7] fix(translation): move in providers --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 8c54d94e0..2951e1648 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,7 +55,6 @@ bootstrapApplication(AppComponent, { BrowserModule, IgoCoreModule.forRoot(), IgoAuthModule.forRoot(), - provideRootTranslation(), IgoMessageModule, PortalModule, ServiceWorkerModule.register('ngsw-worker.js', { @@ -63,6 +62,7 @@ bootstrapApplication(AppComponent, { registrationStrategy: 'registerWithDelay:5000' }) ), + provideRootTranslation(), provideHttpClient(), provideAnimations(), provideRouter([]),