Skip to content

Commit

Permalink
chore(*): major cleanup
Browse files Browse the repository at this point in the history
* refactor(*): delete pointersummary mentions

* wip environnement refactor

* chore(*): setup code formatting (add script + suggested extensions + autoFomatting in IDE)

* chore(*): apply code formatting

* wip

* wip

* wip

* feat(SplashScreen): add a splashscreen

* refactor(*): config handling

* wip

* chore(*): delete workspaces mentions (some remaining in portal module)

* delete various unused var and methods

* review comment

* refactor(*): now sharing the same searchstate from lib

* fix(portal): set valid breakpoint
  • Loading branch information
pelord authored Mar 18, 2024
1 parent a523e7c commit 46bb652
Show file tree
Hide file tree
Showing 21 changed files with 303 additions and 864 deletions.
88 changes: 62 additions & 26 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { Component, ElementRef, Renderer2, ViewChild } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import {
Component,
ElementRef,
Inject,
OnInit,
Renderer2,
ViewChild
} from '@angular/core';
import { MatIconRegistry } from '@angular/material/icon';
import { Meta, Title } from '@angular/platform-browser';
import { NavigationEnd, Router } from '@angular/router';

import { AuthOptions } from '@igo2/auth';
import { ConfigService, LanguageService, MessageService } from '@igo2/core';
import { userAgent } from '@igo2/utils';
import { AnalyticsListenerService, AppOptions } from '@igo2/integration';
import { DomUtils, userAgent } from '@igo2/utils';

import { delay, first } from 'rxjs';

import { PwaService } from './services/pwa.service';

Expand All @@ -13,54 +24,78 @@ import { PwaService } from './services/pwa.service';
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
public authConfig: AuthOptions;
export class AppComponent implements OnInit {
private themeClass = 'qcca-theme';
public hasHeader: boolean = true;
public hasFooter: boolean = true;
public hasHeader: boolean;
public hasFooter: boolean;
private promptEvent: any;
public hasMenu: boolean = false;

@ViewChild('searchBar', { read: ElementRef, static: true })
searchBar: ElementRef;

constructor(
@Inject(DOCUMENT) private document: Document,
protected languageService: LanguageService,
private configService: ConfigService,
private analyticsListenerService: AnalyticsListenerService,
private renderer: Renderer2,
private titleService: Title,
private metaService: Meta,
private messageService: MessageService,
private pwaService: PwaService,
private router: Router,
iconRegistry: MatIconRegistry
) {
iconRegistry.registerFontClassAlias('Linearicons-Free', 'lnr');
this.readTitleConfig();
this.readThemeConfig();
this.readDescriptionConfig();

this.detectOldBrowser();

this.hasHeader =
this.configService.getConfig('header.hasHeader') === undefined
? false
: this.configService.getConfig('header.hasHeader');
this.analyticsListenerService.listen();

this.hasFooter =
this.configService.getConfig('hasFooter') === undefined
? false
: this.configService.getConfig('hasFooter');
this.detectOldBrowser();

this.hasMenu =
this.configService.getConfig('hasMenu') === undefined
? false
: this.configService.getConfig('hasMenu');
this.hasHeader = this.configService.getConfig('header.hasHeader', false);
this.hasFooter = this.configService.getConfig('hasFooter', false);
this.hasMenu = this.configService.getConfig('hasMenu', false);

this.setManifest();
this.installPrompt();
this.pwaService.checkForUpdates();
}

ngOnInit(): void {
this.handleSplashScreen();
}

private handleSplashScreen(): void {
this.router.events
.pipe(
first((events) => events instanceof NavigationEnd),
delay(500)
)
.subscribe(() => {
this._removeSplashScreen();
});
}

private _removeSplashScreen(): void {
const intro = this.document.getElementById('splash-screen');
if (!intro) {
return;
}
intro.classList.add('is-destroying');

const destroyingAnimationTime = 300;
const stylesheet = this.document.getElementById('splash-screen-stylesheet');

setTimeout(() => {
DomUtils.remove(intro);
DomUtils.remove(stylesheet);
}, destroyingAnimationTime);
}

private readTitleConfig() {
this.languageService.translate
.get(this.configService.getConfig('title'))
Expand All @@ -73,18 +108,19 @@ export class AppComponent {
}

private setManifest() {
const appConfig = this.configService.getConfig('app');
if (appConfig?.install?.enabled) {
const manifestPath =
appConfig.install.manifestPath || 'manifest.webmanifest';
if (this.configService.getConfig('app.install.enabled')) {
const manifestPath = this.configService.getConfig(
'app.install.manifestPath',
'manifest.webmanifest'
);
document
.querySelector('#igoManifestByConfig')
.setAttribute('href', manifestPath);
}
}

private installPrompt() {
const appConfig = this.configService.getConfig('app');
const appConfig: AppOptions = this.configService.getConfig('app');
if (appConfig?.install?.enabled && appConfig?.install?.promote) {
if (userAgent.getOSName() !== 'iOS') {
window.addEventListener(
Expand Down
48 changes: 12 additions & 36 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,28 @@ import {
Injector,
NgModule
} from '@angular/core';
import {
MAT_TOOLTIP_DEFAULT_OPTIONS,
MatTooltipDefaultOptions
} from '@angular/material/tooltip';
import { BrowserModule, HammerModule } from '@angular/platform-browser';
import { 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 { IgoSpinnerModule, IgoStopPropagationModule } from '@igo2/common';
import {
IgoGestureModule,
IgoMessageModule,
LanguageService,
RouteService,
provideConfigOptions
} from '@igo2/core';
import {
CoordinatesSearchResultFormatter,
IChercheSearchSource,
SearchService,
provideCadastreSearchSource,
provideCoordinatesReverseSearchSource,
provideDefaultCoordinatesSearchResultFormatter,
provideDefaultIChercheSearchResultFormatter,
provideIChercheReverseSearchSource,
provideIChercheSearchSource,
provideILayerSearchSource,
provideNominatimSearchSource,
provideOptionsApi,
provideOsrmDirectionsSource,
provideSearchSourceService,
provideStyleListOptions,
provideWorkspaceSearchSource
provideStoredQueriesSearchSource,
provideStyleListOptions
} from '@igo2/geo';

import { concatMap, first } from 'rxjs';
Expand All @@ -61,12 +50,10 @@ export const defaultTooltipOptions: MatTooltipDefaultOptions = {
BrowserModule,
BrowserAnimationsModule,
RouterModule.forRoot([]),
IgoGestureModule.forRoot(),
IgoMessageModule,
IgoSpinnerModule,
IgoStopPropagationModule,
PortalModule,
HammerModule,
HeaderModule,
FooterModule,
MenuModule,
Expand All @@ -80,24 +67,14 @@ export const defaultTooltipOptions: MatTooltipDefaultOptions = {
default: environment.igo,
path: './config/config.json'
}),
provideCoordinatesReverseSearchSource(),
provideIChercheSearchSource(),
RouteService,
provideNominatimSearchSource(),
provideIChercheSearchSource(),
provideIChercheReverseSearchSource(),
provideILayerSearchSource(),
provideOsrmDirectionsSource(),
provideCoordinatesReverseSearchSource(),
provideStoredQueriesSearchSource(),
provideOptionsApi(),
CoordinatesSearchResultFormatter,
provideDefaultCoordinatesSearchResultFormatter(),
provideDefaultIChercheSearchResultFormatter(),
provideSearchSourceService(),
SearchService,
IChercheSearchSource,
provideStyleListOptions({
path: './assets/list-style.json'
}),
RouteService,
provideWorkspaceSearchSource(),
provideCadastreSearchSource(),
{
provide: APP_INITIALIZER,
useFactory: appInitializerFactory,
Expand All @@ -106,8 +83,7 @@ export const defaultTooltipOptions: MatTooltipDefaultOptions = {
},
provideStyleListOptions({
path: './assets/list-style.json'
}),
{ provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: defaultTooltipOptions }
})
],
bootstrap: [AppComponent]
})
Expand All @@ -117,7 +93,7 @@ function appInitializerFactory(
injector: Injector,
applicationRef: ApplicationRef
) {
// ensure to have the proper translations loaded once, whe the app is stable.
// ensure to have the proper translations loaded once, when the app is stable.
return () =>
new Promise<any>((resolve: any) => {
applicationRef.isStable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
[termSplitter]="termSplitter"
[forceNA]="forceCoordsNA"
[store]="searchStore"
[pointerSummaryEnabled]="igoSearchPointerSummaryEnabled"
(pointerSummaryStatus)="onPointerSummaryStatusChange($event)"
[searchResultsGeometryEnabled]="searchResultsGeometryEnabled"
(searchResultsGeometryStatus)="
onSearchResultsGeometryStatusChange($event)
Expand Down Expand Up @@ -82,6 +80,7 @@ <h6>{{ 'igo.integration.searchResultsTool.doSearch' | translate }}</h6>
<div *ngIf="mapQueryClick" #getInfo>
<app-feature-info
[map]="map"
[searchState]="searchState"
[store]="queryStore"
[mobile]="mobile"
(closeQuery)="closePanelOnCloseQuery()"
Expand Down
27 changes: 13 additions & 14 deletions src/app/pages/portal/panels/bottompanel/bottompanel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ import {
getCommonVectorSelectedStyle,
getCommonVectorStyle
} from '@igo2/geo';
import { MapState, QueryState, StorageState } from '@igo2/integration';
import {
MapState,
QueryState,
SearchState,
StorageState
} from '@igo2/integration';

import olFeature from 'ol/Feature';
import type { default as OlGeometry } from 'ol/geom/Geometry';
import olPoint from 'ol/geom/Point';

import { BehaviorSubject, Subscription, combineLatest, tap } from 'rxjs';

import { SearchState } from '../search-results-tool/search.state';

@Component({
selector: 'app-bottompanel',
templateUrl: './bottompanel.component.html',
Expand Down Expand Up @@ -70,6 +73,8 @@ export class BottomPanelComponent implements OnInit, OnDestroy {

@Input() mapQueryClick: boolean;

@Input() searchState: SearchState;

@Output() mapQuery = new EventEmitter<boolean>();

get queryStore(): EntityStore<SearchResult> {
Expand Down Expand Up @@ -119,7 +124,6 @@ export class BottomPanelComponent implements OnInit, OnDestroy {

public store = new ActionStore([]);
public showSearchBar: boolean;
public igoSearchPointerSummaryEnabled: boolean = false;
get termSplitter(): string {
return this.searchState.searchTermSplitter$.value;
}
Expand Down Expand Up @@ -182,7 +186,6 @@ export class BottomPanelComponent implements OnInit, OnDestroy {
constructor(
private configService: ConfigService,
private mapService: MapService,
private searchState: SearchState,
private searchService: SearchService,
private queryState: QueryState,
private cdRef: ChangeDetectorRef,
Expand All @@ -191,10 +194,10 @@ export class BottomPanelComponent implements OnInit, OnDestroy {
private elRef: ElementRef
) {
this.mapService.setMap(this.map);
this.showSearchBar =
this.configService.getConfig('showSearchBar') === undefined
? true
: this.configService.getConfig('showSearchBar');
this.showSearchBar = this.configService.getConfig(
'searchBar.showSearchBar',
true
);
this.zoomAuto = this.storageService.get('zoomAuto') as boolean;
}

Expand Down Expand Up @@ -253,15 +256,11 @@ export class BottomPanelComponent implements OnInit, OnDestroy {
this.clearSearch();
}

onPointerSummaryStatusChange(value) {
this.igoSearchPointerSummaryEnabled = value;
}

onSearchTermChange(term = '') {
this.term = term;
this.clearedSearchbar = false;
const termWithoutHashtag = term.replace(/(#[^\s]*)/g, '').trim();

this.searchState.setSearchTerm(term);
if (termWithoutHashtag.length < 2) {
this.searchStore.clear();
this.selectedFeature = undefined;
Expand Down
Loading

0 comments on commit 46bb652

Please sign in to comment.