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.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/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 816b661dc..000000000 --- a/src/app/app.module.ts +++ /dev/null @@ -1,142 +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 { IgoSpinnerModule, IgoStopPropagationModule } 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'; -import { FooterModule } from './pages/footer/footer.module'; -import { HeaderModule } from './pages/header/header.module'; - -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, - IgoSpinnerModule, - IgoStopPropagationModule, - PortalModule, - HeaderModule, - FooterModule, - 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/footer/footer.component.ts b/src/app/pages/footer/footer.component.ts index 8f1d73064..6ff219a65 100644 --- a/src/app/pages/footer/footer.component.ts +++ b/src/app/pages/footer/footer.component.ts @@ -2,10 +2,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'] + 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 deleted file mode 100644 index 7f1f6991a..000000000 --- a/src/app/pages/footer/footer.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; - -import { IgoLanguageModule } from '@igo2/core'; - -import { FooterComponent } from './footer.component'; - -@NgModule({ - declarations: [FooterComponent], - imports: [CommonModule, IgoLanguageModule], - 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..c4c694683 100644 --- a/src/app/pages/header/header.component.ts +++ b/src/app/pages/header/header.component.ts @@ -1,11 +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'; + @Component({ selector: 'app-header', templateUrl: './header.component.html', - styleUrls: ['./header.component.scss'] + 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 deleted file mode 100644 index cd82c724d..000000000 --- a/src/app/pages/header/header.module.ts +++ /dev/null @@ -1,14 +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({ - declarations: [HeaderComponent], - imports: [CommonModule, IgoLanguageModule, MatToolbarModule], - 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..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 @@ -7,11 +7,15 @@ import { 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 + 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 deleted file mode 100644 index dd604322d..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 - ], - exports: [ExpansionPanelComponent, ExpansionPanelButtonComponent], - declarations: [ExpansionPanelComponent, ExpansionPanelHeaderComponent] -}) -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..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'; @@ -10,7 +11,9 @@ import { MapOverlay } from './map-overlay.interface'; @Component({ selector: 'app-map-overlay', templateUrl: './map-overlay.component.html', - styleUrls: ['./map-overlay.component.scss'] + 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 deleted file mode 100644 index ed3c0d5b8..000000000 --- a/src/app/pages/portal/map-overlay/map-overlay.module.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; - -import { MapOverlayComponent } from './map-overlay.component'; - -@NgModule({ - imports: [CommonModule], - exports: [MapOverlayComponent], - declarations: [MapOverlayComponent] -}) -export class MapOverlayModule {} diff --git a/src/app/pages/portal/portal.component.ts b/src/app/pages/portal/portal.component.ts index 8076d2bf6..fb5369ab9 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,44 @@ import { OnInit, ViewChild } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; import { MatDialog, MatDialogConfig, + MatDialogModule, 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, + WORKSPACE_DIRECTIVES, Widget, Workspace, WorkspaceStore } from '@igo2/common'; -import { DetailedContext } from '@igo2/context'; +import { + DetailedContext, + LayerContextDirective, + MapContextDirective, + UserButtonComponent +} from '@igo2/context'; import { ConfigService, LanguageService, @@ -42,6 +59,7 @@ import { CapabilitiesService, ConfigFileToGeoDBService, DataSourceService, + DropGeoFileDirective, EditionWorkspace, EditionWorkspaceService, FEATURE, @@ -49,19 +67,25 @@ import { FeatureMotion, FeatureWorkspace, GoogleLinks, + IgoGeoWorkspaceModule, IgoMap, ImageLayer, ImportService, LayerService, + MAP_DIRECTIVES, MapExtent, + QueryDirective, QuerySearchSource, QueryService, Research, + SearchBarComponent, + SearchPointerSummaryDirective, SearchResult, SearchSource, SearchSourceService, VectorLayer, WfsWorkspace, + WorkspaceUpdatorDirective, addStopToStore, computeOlFeaturesExtent, featureFromOl, @@ -74,6 +98,7 @@ import { sourceCanSearch } from '@igo2/geo'; import { + AnalyticsListenerService, ContextState, DirectionState, MapState, @@ -90,11 +115,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 +133,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 +151,40 @@ import { WelcomeWindowService } from './welcome-window/welcome-window.service'; controlSlideY(), mapSlideX(), mapSlideY() + ], + standalone: true, + imports: [ + ActionbarComponent, + SidenavComponent, + AsyncPipe, + BackdropComponent, + ContextMenuDirective, + DropGeoFileDirective, + ENTITY_DIRECTIVES, + ExpansionPanelButtonComponent, + ExpansionPanelComponent, + LayerContextDirective, + LongPressDirective, + MatDialogModule, + IgoGeoWorkspaceModule, + MAP_DIRECTIVES, + MapContextDirective, + MapOverlayComponent, + MatButtonModule, + MatIconModule, + MatSidenavModule, + MatTooltipModule, + NgClass, + NgIf, + QueryDirective, + SearchBarComponent, + SearchPointerSummaryDirective, + ToastPanelComponent, + ToastPanelForExpansionComponent, + TranslateModule, + UserButtonComponent, + WORKSPACE_DIRECTIVES, + WorkspaceUpdatorDirective ] }) export class PortalComponent implements OnInit, OnDestroy { @@ -307,6 +373,7 @@ export class PortalComponent implements OnInit, OnDestroy { } constructor( + private analyticsListenerService: AnalyticsListenerService, private route: ActivatedRoute, public workspaceState: WorkspaceState, public authService: AuthService, @@ -334,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 8867ceb06..8e919044d 100644 --- a/src/app/pages/portal/portal.module.ts +++ b/src/app/pages/portal/portal.module.ts @@ -1,84 +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 { AnalyticsListenerService } 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'; -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, + IgoGestureModule.forRoot(), 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 + IgoDirectionsModule, + PortalComponent ], exports: [PortalComponent], - declarations: [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 d6e33a28b..be7d38e10 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, + IgoInteractiveTourModule, + 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: [ + AsyncPipe, + HomeButtonComponent, + IgoInteractiveTourModule, + MatButtonModule, + MatIconModule, + MatSidenavModule, + MatTooltipModule, + NgClass, + NgIf, + PanelComponent, + ToolboxComponent, + 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 deleted file mode 100644 index df651e259..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 - ], - exports: [SidenavComponent], - declarations: [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 deleted file mode 100644 index fc60ac262..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 - ], - exports: [ToastPanelForExpansionComponent], - declarations: [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..6e82d2711 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: [ + ActionbarComponent, + AsyncPipe, + FeatureDetailsComponent, + MatBadgeModule, + MatButtonModule, + MatIconModule, + MatTooltipModule, + NgClass, + NgIf, + NgTemplateOutlet, + PanelComponent, + SearchResultsComponent, + StopPropagationDirective, + 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 deleted file mode 100644 index 11bdbce22..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 - ], - exports: [ToastPanelComponent], - declarations: [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..63f998314 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, IgoInteractiveTourModule } 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, + IgoInteractiveTourModule, + 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 deleted file mode 100644 index 31da887c0..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 - ], - declarations: [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 { diff --git a/src/main.ts b/src/main.ts index 0fa4f834b..2951e1648 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(), + IgoMessageModule, + PortalModule, + ServiceWorkerModule.register('ngsw-worker.js', { + enabled: environment.igo.app.pwa.enabled, + registrationStrategy: 'registerWithDelay:5000' + }) + ), + provideRootTranslation(), + 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(); + }); + }); +}