diff --git a/package-lock.json b/package-lock.json index ae1c902d1bdc543e877aa2ee3e4be6dec27ac44a..f877643c77e34f6eaea86b77ffa924f65306d0c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4035,11 +4035,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4052,15 +4054,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4163,7 +4168,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4173,6 +4179,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4185,17 +4192,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4212,6 +4222,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4284,7 +4295,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4294,6 +4306,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4399,6 +4412,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a2789ff7d0d0769af3d65704c90a47576513bb23..18e753b560adc31a3791d77a85d01c057cdb2ae5 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,6 +1,12 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { Title } from '@angular/platform-browser'; -import { Router, ActivatedRoute, NavigationStart, NavigationEnd } from '@angular/router'; +import { Router, + Event as RouterEvent, + NavigationStart, + NavigationEnd, + NavigationCancel, + NavigationError , + ActivatedRoute, } from '@angular/router'; import { Observable, Subscription } from 'rxjs'; import { filter, map, mergeMap } from 'rxjs/operators'; import { LoaderService } from './core'; @@ -11,7 +17,8 @@ import { LoaderService } from './core'; styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit, OnDestroy { - + + loading = true; active = false; sub = new Subscription(); @@ -22,6 +29,24 @@ export class AppComponent implements OnInit, OnDestroy { private loaderService: LoaderService, ) { } + // Shows and hides the loading spinner during RouterEvent changes + navigationInterceptor(event: RouterEvent): void { + if (event instanceof NavigationStart) { + this.loading = true + } + if (event instanceof NavigationEnd) { + this.loading = false + } + + // Set loading state to false in both of the below events to hide the spinner in case a request fails + if (event instanceof NavigationCancel) { + this.loading = false + } + if (event instanceof NavigationError) { + this.loading = false + } + } + ngOnInit() { this.sub.add( this.title$().subscribe(title => this.titleService.setTitle(title)) diff --git a/src/app/core/api.ts b/src/app/core/api.ts index 0721be230d3a98be74945cb0f67d4698f512fdaa..792acf9b518cc71868afd67c5940b98b1202b8b0 100644 --- a/src/app/core/api.ts +++ b/src/app/core/api.ts @@ -4,17 +4,14 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { environment } from 'environments/environment'; - export class ShowcaseApiService { apiUrl = environment.showcaseApiUrl; } - export class ApiService { apiUrl = environment.apiUrl; } - export abstract class ModelApiService<T> extends ApiService { abstract baseUrl: string; diff --git a/src/app/core/document.service.ts b/src/app/core/document.service.ts index df836032f68c52e688c8785bae4f3584a602a08f..463c31e3684712b6480e7756a1698f2e64fc869b 100644 --- a/src/app/core/document.service.ts +++ b/src/app/core/document.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, of } from 'rxjs'; -import { map, tap, catchError } from 'rxjs/operators'; +import { map, catchError } from 'rxjs/operators'; import { environment } from 'environments/environment'; import { ActivatedRouteSnapshot, RouterStateSnapshot, Resolve } from '@angular/router'; diff --git a/src/app/core/geocoding.service.ts b/src/app/core/geocoding.service.ts index e215afd123aa192219c8bfe5be882030cedd68ed..ed6bcb866ed2a51e1b961f4090f55f06000b4b93 100644 --- a/src/app/core/geocoding.service.ts +++ b/src/app/core/geocoding.service.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core'; import { MapsAPILoader } from '@agm/core'; import { Resolve } from '@angular/router'; -import { Observable, BehaviorSubject, from } from 'rxjs'; -import { filter, map, mergeMap } from 'rxjs/operators'; +import { Observable, from } from 'rxjs'; +import { map } from 'rxjs/operators'; declare const google: any; diff --git a/src/app/core/loader.interceptor.ts b/src/app/core/loader.interceptor.ts index 45556413d290be94ee0290ba61b0b4b7d12a41f9..cb4693cf3031b4c277b32bc28e13013d4ef512e6 100644 --- a/src/app/core/loader.interceptor.ts +++ b/src/app/core/loader.interceptor.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http'; -import { Observable, timer } from 'rxjs'; +import { Observable } from 'rxjs'; import { tap } from 'rxjs/operators'; import { LoaderService } from './loader.service'; diff --git a/src/app/core/loader.service.ts b/src/app/core/loader.service.ts index 013b0d2c75b0081fc837d20f6dd58b0fc8fe6206..356d88b112f2871779c3ef716ba5b7c49e643b36 100644 --- a/src/app/core/loader.service.ts +++ b/src/app/core/loader.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { Observable, BehaviorSubject } from 'rxjs'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; +import { distinctUntilChanged } from 'rxjs/operators'; @Injectable() diff --git a/src/app/core/resolvers/generic.ts b/src/app/core/resolvers/generic.ts index 9a63221deed88501ee4e88031d5835e87c8e519c..a506e79c4aaf9b9b2b31fdb4a52c9a67aabe381e 100644 --- a/src/app/core/resolvers/generic.ts +++ b/src/app/core/resolvers/generic.ts @@ -11,7 +11,6 @@ interface Retrievable<T> { retrieve: (id: any) => Observable<T>; } - export abstract class ObjectListResolver<T> implements Resolve<T[]> { public service: Listable<T>; @@ -23,7 +22,6 @@ export abstract class ObjectListResolver<T> implements Resolve<T[]> { } } - export abstract class ObjectResolver<T> implements Resolve<T> { public service: Retrievable<T>; diff --git a/src/app/core/resolvers/simple.resolver.ts b/src/app/core/resolvers/simple.resolver.ts index 401ec5676c5a6eb84d0d7faafa43a1de37d69660..30dc9ca6a3ce632c7d52ad75e52ff9b7636e05e3 100644 --- a/src/app/core/resolvers/simple.resolver.ts +++ b/src/app/core/resolvers/simple.resolver.ts @@ -3,8 +3,6 @@ import { Observable, of } from 'rxjs'; import { map, tap, catchError } from 'rxjs/operators'; import { HttpClient } from '@angular/common/http'; import { Resolve } from '@angular/router'; -import { environment } from 'environments/environment'; - @Injectable() export abstract class SimpleListResolver<T> implements Resolve<T[]> { diff --git a/src/app/showcase-site/shared/action.service.ts b/src/app/showcase-site/shared/action.service.ts index 545c69c3ab02d9b8c7ff1e60f2b8c4ba6257ca51..e185a6301586bf3d150e01470c3def439dfde088 100644 --- a/src/app/showcase-site/shared/action.service.ts +++ b/src/app/showcase-site/shared/action.service.ts @@ -1,8 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { map, tap, filter } from 'rxjs/operators'; +import { map } from 'rxjs/operators'; import { Action } from './action.model'; import { environment } from 'environments/environment'; import { ObjectListResolver } from 'app/core'; diff --git a/src/app/showcase-site/shared/article.service.ts b/src/app/showcase-site/shared/article.service.ts index d29d8d102966b1f216ccaf68e023f5173d226dd1..796e221b2a6a3b374f3a2f8138b9fd6c5c719efc 100644 --- a/src/app/showcase-site/shared/article.service.ts +++ b/src/app/showcase-site/shared/article.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { map, tap } from 'rxjs/operators'; +import { map } from 'rxjs/operators'; import { Article } from './article.model'; import { environment } from 'environments/environment'; import { ObjectListResolver, ObjectResolver } from 'app/core'; diff --git a/src/app/showcase-site/showcase-site-routing.module.ts b/src/app/showcase-site/showcase-site-routing.module.ts index 5f49db97e16685aac7d79031672f5616d426f3b1..df7ddaf805dc88c977134d885bdafbe0b9cfdf09 100644 --- a/src/app/showcase-site/showcase-site-routing.module.ts +++ b/src/app/showcase-site/showcase-site-routing.module.ts @@ -32,7 +32,7 @@ const routes: Routes = [ resolve: { 'actions': ActionsResolver, 'partners': PartnersResolver, - }, + }, data: { title: 'Accueil' }, }, {