Commit 18dd06a9 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Reorganize modules

parent 5139f590
Pipeline #1777 passed with stages
in 2 minutes and 55 seconds
......@@ -17,7 +17,7 @@ build_development:
- build
only:
- development
- fusion-table-map-universe
- refacto
script:
- export TAG=dev
- export NGINX_PORT=8081
......@@ -46,7 +46,7 @@ deploy_development:
stage: deploy
only:
- development
- fusion-table-map-universe
- refacto
script:
- export TAG=dev
- export NGINX_PORT=8081
......
import { NgModule } from '@angular/core';
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { AppRoutes } from './routes';
export const routes: Routes = [
// {
// path: AppRoutes.research.uri,
// loadChildren: './geosource/geosource.module#GeosourceModule',
// },
{
path: '**',
redirectTo: AppRoutes.page404.uri,
......
// import { TestBed, async } from '@angular/core/testing';
// import { Router, Routes } from '@angular/router';
// import { RouterTestingModule } from '@angular/router/testing';
// import { AppComponent } from './app.component';
// import { FormsModule } from '@angular/forms';
// // importing routes from the different routing files
// import { routes as AppRoutes } from './app-routing.module';
// import { routes as GeosourceRoutes } from './geosource/geosource-routing.module';
// import { routes as CoreRoutes } from './core/core-routing.module';
// import { routes as EditorialisationRoutes } from './editorialisation/editorialisation-routing.module';
// import { AppRoutes as RouteNames } from './routes';
// // importing components
// import { CoreComponents } from './core/components';
// import { GeosourceComponents } from './geosource/components';
// import { EditorialisationComponents } from './editorialisation/components';
// import { SharedModule } from './shared/shared.module';
// import { EditorialisationService, EditorialisationServices } from './editorialisation/services';
// import { HttpClientModule } from '@angular/common/http';
// import { GeosourceServices } from './geosource/services';
// import { PostDetailResolver, PostsListResolver, PostVideoResolver } from './editorialisation/resolvers';
// import { EditorialisationServiceMock } from './editorialisation/services/editorialisation.service.mock';
// import { PageResolver } from './editorialisation/resolvers/page.resolver';
// describe('App routing', () => {
// const routeNames = RouteNames;
// let router: Router;
// const routes: Routes = [
// ...AppRoutes,
// ...GeosourceRoutes,
// ...CoreRoutes,
// ...EditorialisationRoutes,
// ];
// beforeEach(async(() => {
// TestBed.configureTestingModule({
// imports: [
// FormsModule,
// SharedModule,
// HttpClientModule,
// RouterTestingModule.withRoutes(routes),
// ],
// declarations: [
// AppComponent,
// ...CoreComponents,
// ...GeosourceComponents,
// ...EditorialisationComponents,
// ],
// providers: [
// {
// provide: EditorialisationService,
// useValue: EditorialisationServiceMock,
// },
// {
// provide: PageResolver,
// useValue: { resolve() { } },
// },
// {
// provide: PostDetailResolver,
// useValue: { resolve() { } },
// },
// {
// provide: PostsListResolver,
// useValue: { resolve() { } },
// },
// {
// provide: PostVideoResolver,
// useValue: { resolve() { } },
// },
// ...GeosourceServices,
// ],
// }).compileComponents();
// }));
// beforeEach(() => {
// router = TestBed.get(Router);
// router.initialNavigation();
// });
// // ********* From geosource module ********* //
// it('navigate to "/recherche" redirects you to /recherche/datasets', (done) => {
// router.navigateByUrl('/' + routeNames.research).then(() => {
// expect(router.routerState.snapshot.url).toBe('/' + routeNames.research + '/' + routeNames.datasets);
// done();
// });
// });
// it('navigate to "/recherche/datasets" takes you to /datasets', (done) => {
// router.navigateByUrl('/' + routeNames.research + '/' + routeNames.datasets).then(() => {
// expect(router.routerState.snapshot.url).toBe('/' + routeNames.research + '/' + routeNames.datasets);
// done();
// });
// });
// it('navigate to "/recherche/datasets/abcdef" takes you to /recherche/datasets/abcdef', (done) => {
// router.navigateByUrl('/' + routeNames.research + '/' + routeNames.datasets + '/abcdef').then(() => {
// expect(router.routerState.snapshot.url).toBe(
// '/' + routeNames.research + '/' + routeNames.datasets + '/abcdef/' + routeNames.info);
// done();
// });
// });
// // ********* From core module ********* //
// it('navigate to "" redirects you to /accueil', (done) => {
// router.navigateByUrl('/').then(() => {
// expect(router.routerState.snapshot.url).toBe('/' + routeNames.home);
// done();
// });
// });
// // ********* From editorialisation module ********* //
// it('navigate to "/accueil" takes you to /accueil', (done) => {
// router.navigateByUrl('/' + routeNames.home).then(() => {
// expect(router.routerState.snapshot.url).toBe('/' + routeNames.home);
// done();
// });
// });
// it('navigate to "/demarche" takes you to /demarche', (done) => {
// router.navigateByUrl('/' + routeNames.approach).then(() => {
// expect(router.routerState.snapshot.url).toBe('/' + routeNames.approach);
// done();
// });
// });
// it('navigate to "/accessibilite" takes you to /accessibilite', (done) => {
// router.navigateByUrl('/' + routeNames.accessibility).then(() => {
// expect(router.routerState.snapshot.url).toBe('/' + routeNames.accessibility);
// done();
// });
// });
// it('navigate to "/plan-du-site" takes you to /plan-du-site', (done) => {
// router.navigateByUrl('/' + routeNames.siteMap).then(() => {
// expect(router.routerState.snapshot.url).toBe('/' + routeNames.siteMap);
// done();
// });
// });
// it('navigate to "/mentions-legales" takes you to /mentions-legales', (done) => {
// router.navigateByUrl('/' + routeNames.legalNotices).then(() => {
// expect(router.routerState.snapshot.url).toBe('/' + routeNames.legalNotices);
// done();
// });
// });
// });
import { Component, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Angulartics2Piwik } from 'angulartics2/piwik';
import { AppRoutes } from '../../../../routes';
import { DatasetResearchService } from '../../../../geosource/services';
import { Router, NavigationEnd } from '@angular/router';
import { UserService } from '../../../../user/services';
import { AppStateService } from '../../../services';
import { Angulartics2Piwik } from 'angulartics2/piwik';
@Component({
selector: 'app-header',
......@@ -20,7 +19,6 @@ export class HeaderComponent implements OnInit {
AppRoutes = AppRoutes;
constructor(
private _datasetResearchService: DatasetResearchService,
private _router: Router,
private _userService: UserService,
private _appStateService: AppStateService,
......@@ -28,13 +26,6 @@ export class HeaderComponent implements OnInit {
) { }
ngOnInit() {
this._datasetResearchService.searchChange$.subscribe(() => {
// Redirect to results page if this is not the current page
if (this._router.url.split('/').pop() !== AppRoutes.research.uri) {
this._router.navigate(['/', AppRoutes.research.uri]);
}
});
this._router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
......
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { AppRoutes } from '../../../routes';
import { EmailService, AppStateService } from '../../services';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { AppRoutes } from '../../../routes';
import { AppStateService } from '../../services';
@Component({
selector: 'app-main',
......
......@@ -20,7 +20,7 @@
</a>
</li>
<li>
<a [routerLink]="['/', AppRoutes.research.uri]" routerLinkActive="active-link" [tabIndex]="isOpened ? 0 : -1">
<a [routerLink]="['/', AppRoutes.datasets.uri]" routerLinkActive="active-link" [tabIndex]="isOpened ? 0 : -1">
<div class="icon-item">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23">
<path class="main" fill-rule="evenodd"
......@@ -31,8 +31,7 @@
</a>
</li>
<li *ngIf="APP_CONFIG.theFunctionalitiesInterruptor.partners">
<a [routerLink]="['/', AppRoutes.partners.uri]" routerLinkActive="active-link"
[tabIndex]="isOpened ? 0 : -1">
<a [routerLink]="['/', AppRoutes.partners.uri]" routerLinkActive="active-link" [tabIndex]="isOpened ? 0 : -1">
<div class="icon-item">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23">
<g id="picto_x5F_acteur">
......
import { Component, OnInit, Input, EventEmitter, Output, OnDestroy } from '@angular/core';
import { AppRoutes } from '../../../../routes';
import { Router, NavigationEnd, ActivatedRoute, NavigationStart } from '@angular/router';
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { environment } from '../../../../../environments/environment';
import { ElasticsearchService } from '../../../../elasticsearch/services/elasticsearch.service';
import { AppRoutes } from '../../../../routes';
import { UserService } from '../../../../user/services';
import { ElasticsearchService } from '../../../../geosource/services';
import { AppStateService } from '../../../services';
import { Subscription } from 'rxjs';
import { APP_CONFIG } from '../../../services/app-config.service';
@Component({
......
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { RouterModule, Routes } from '@angular/router';
import { AppRoutes } from '../routes';
import { ContactComponent } from './components';
import { PageNotFoundComponent } from './components/page-not-found/page-not-found.component';
......@@ -28,6 +28,6 @@ export const routes: Routes = [
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
exports: [RouterModule],
})
export class CoreRoutingModule { }
import { NgModule, ErrorHandler } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CoreRoutingModule } from './core-routing.module';
import { CoreComponents, MainComponent, FeedbackComponent } from './components';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { ErrorHandler, NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { CookieService } from 'ngx-cookie-service';
import { DatasetsModule } from '../datasets/datasets.module';
import { SharedModule } from '../shared/shared.module';
import { CoreComponents, MainComponent } from './components';
import { CloseMenuDirective } from './components/main/close-menu-directive';
import { CoreRoutingModule } from './core-routing.module';
import { ErrorsHandler } from './handlers/errors-handler';
import { HttpErrorResponseInterceptor } from './interceptors/http-error-response-interceptor';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { CoreServices } from './services';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { GeosourceModule } from '../geosource/geosource.module';
import { CookieService } from 'ngx-cookie-service';
import { CloseMenuDirective } from './components/main/close-menu-directive';
@NgModule({
imports: [
......@@ -20,7 +20,7 @@ import { CloseMenuDirective } from './components/main/close-menu-directive';
SharedModule,
ReactiveFormsModule,
FormsModule,
GeosourceModule.forRoot(),
DatasetsModule,
],
declarations: [...CoreComponents, CloseMenuDirective],
providers: [
......
// http-service-interceptor.ts
// tslint:disable-next-line: max-line-length
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import {
HttpInterceptor, HttpRequest, HttpHandler,
HttpEvent, HttpResponse, HttpErrorResponse,
} from '@angular/common/http';
import { tap } from 'rxjs/operators';
import { Router } from '@angular/router';
import { AppRoutes } from '../../routes';
import { UserService } from '../../user/services';
@Injectable()
......
import { HttpErrorResponse } from '@angular/common/http';
import { ErrorService, NotificationService } from '../../core/services';
import { BehaviorSubject } from 'rxjs';
import { Notification } from '../models';
describe('ErrorService', () => {
let errorService: ErrorService;
let notificationServiceMock: NotificationService;
beforeEach(() => {
const subject = new BehaviorSubject(null);
notificationServiceMock = {
get notification$(): BehaviorSubject<Notification> {
return subject;
},
notify(notification: Notification) {
subject.next(notification);
},
} as NotificationService;
errorService = new ErrorService(notificationServiceMock);
});
describe('handleError(err, opt)', () => {
// it('should return the same HTTPERROR', () => {
// // given
// const error = new HttpErrorResponse({
// error: 'User unauthenticated',
// status: 401,
// url: 'https://data.reloaded-dev.alpha.grandlyon.com/fr',
// });
// // when
// const result = errorService.handleError(error, { message: 'Custom message' });
// // then
// expect(result).toBe(error);
// expect(result instanceof HttpErrorResponse).toBeTruthy();
// });
it('should transform the error with an friendly error message', () => {
// given
const friendlyMessage = 'Friendly message';
const stack = 'ugly stack';
const error = new Error('ugly error message');
error.stack = stack;
// when
const result = errorService.handleError(error, { message: friendlyMessage });
// then
expect(result.message).toBe(friendlyMessage);
expect(result['stack']).toBe(stack);
});
});
});
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import { catchError } from 'rxjs/operators';
import { notificationMessages } from '../../../i18n/traductions';
import { ErrorService } from './error.service';
......
import { AppConfigService } from './app-config.service';
import { AppStateService } from './app-state.service';
import { EmailService } from './email.service';
import { ErrorService } from './error.service';
import { NotificationService } from './notification.service';
import { FileService } from './file.service';
import { MatomoService } from './matomo.service';
import { NavigationHistoryService } from './navigation-history.service';
import { NotificationService } from './notification.service';
import { StorageService } from './storage.service';
import { EmailService } from './email.service';
import { FileService } from './file-service';
import { AppConfigService } from './app-config.service';
import { AppStateService } from './app-state.service';
export {
ErrorService, NotificationService, MatomoService, NavigationHistoryService, EmailService, FileService,
AppConfigService, AppStateService,
};
// tslint:disable-next-line: max-line-length
export { ErrorService, NotificationService, MatomoService, NavigationHistoryService, EmailService, FileService, AppConfigService, AppStateService, };
// tslint:disable-next-line:variable-name
export const CoreServices = [
......
import { NotificationService } from '../../core/services';
import { BehaviorSubject } from 'rxjs';
import { Notification } from '../models';
describe('NotificationService', () => {
let notificationService: NotificationService;
beforeEach(() => {
notificationService = new NotificationService();
});
describe('get notification$()', () => {
it('should return a behaviorSubject<Notification>', () => {
// given
// when
const result = notificationService.notification$;
// then
expect(result instanceof BehaviorSubject).toBeTruthy();
});
it('should call next function of the _notification BehaviorSubject', () => {
// Given
const nextSpy = spyOn(notificationService.notification$, 'next').and.callThrough();
const notification = new Notification({ message: 'Error', type: 'error' });
// When
notificationService.notify(notification);
// Then
expect(nextSpy).toHaveBeenCalledWith(notification);
});
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { DatasetDetailService } from '../../../services';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { DatasetDetailService } from '../../services';
@Component({
selector: 'app-dataset-data-details',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment