From 7da6e00e02845d7851f98fbfeb3d7bfecc355bd1 Mon Sep 17 00:00:00 2001 From: AurianeStrasser2 <auriane.strasser@student.ecp.fr> Date: Sun, 16 Sep 2018 15:46:43 +0200 Subject: [PATCH] to be tested --- package-lock.json | 28 +++++++++++++----- src/app/app.component.ts | 29 +++++++++++++++++-- src/app/core/api.ts | 3 -- src/app/core/document.service.ts | 2 +- src/app/core/geocoding.service.ts | 4 +-- src/app/core/loader.interceptor.ts | 2 +- src/app/core/loader.service.ts | 2 +- src/app/core/resolvers/generic.ts | 2 -- src/app/core/resolvers/simple.resolver.ts | 2 -- .../showcase-site/shared/action.service.ts | 3 +- .../showcase-site/shared/article.service.ts | 2 +- .../showcase-site-routing.module.ts | 2 +- 12 files changed, 56 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index ae1c902..f877643 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 a2789ff..18e753b 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 0721be2..792acf9 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 df83603..463c31e 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 e215afd..ed6bcb8 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 4555641..cb4693c 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 013b0d2..356d88b 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 9a63221..a506e79 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 401ec56..30dc9ca 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 545c69c..e185a63 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 d29d8d1..796e221 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 5f49db9..df7ddaf 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' }, }, { -- GitLab