diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 01fe96729c27077740037e81f7750cf41e311307..5c12447eb35cec7c707b32df52e42edbf7d63e5c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 7c4461b1d1d94550fd78f733077af6285bd72bb9..d818dfc9494e09f608ec2fff6f57a64167c1b34a 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,12 +1,8 @@ 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, diff --git a/src/app/app.routing.spec.ts b/src/app/app.routing.spec.ts deleted file mode 100644 index af5765e1ac58aa6e00486bb722de4c86394a4c45..0000000000000000000000000000000000000000 --- a/src/app/app.routing.spec.ts +++ /dev/null @@ -1,151 +0,0 @@ -// 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(); -// }); -// }); -// }); diff --git a/src/app/core/components/main/header/header.component.ts b/src/app/core/components/main/header/header.component.ts index aadc9987a2771645fa0f2c5c9ea0a841d410d515..8793e17ac7f7025abe810503c266fad2a4133d70 100644 --- a/src/app/core/components/main/header/header.component.ts +++ b/src/app/core/components/main/header/header.component.ts @@ -1,10 +1,9 @@ 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) { diff --git a/src/app/core/components/main/main.component.ts b/src/app/core/components/main/main.component.ts index 4b4281a025ee4be63aeedf3e00e1c5909dc86017..5a0371556e702a5df1b79e8412810674c70438a9 100644 --- a/src/app/core/components/main/main.component.ts +++ b/src/app/core/components/main/main.component.ts @@ -1,8 +1,8 @@ -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', diff --git a/src/app/core/components/main/side-menu/side-menu.component.html b/src/app/core/components/main/side-menu/side-menu.component.html index a6758b4053bbabd7ed35f5924e5c089e228f027a..b1ae62e1c79c96fa250f10fc0f2a2d6b39779d3c 100644 --- a/src/app/core/components/main/side-menu/side-menu.component.html +++ b/src/app/core/components/main/side-menu/side-menu.component.html @@ -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"> diff --git a/src/app/core/components/main/side-menu/side-menu.component.ts b/src/app/core/components/main/side-menu/side-menu.component.ts index 5e95051f8c11c10585d60ad1d659c55669219d29..2a5c28c66f701c2e0a676106118668919e361e50 100644 --- a/src/app/core/components/main/side-menu/side-menu.component.ts +++ b/src/app/core/components/main/side-menu/side-menu.component.ts @@ -1,11 +1,11 @@ -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({ diff --git a/src/app/core/core-routing.module.ts b/src/app/core/core-routing.module.ts index 8d7648c4b16178335980c085a81cd7b8ca26e031..7374399aad47ecc2211aae684f55a4be7b146e89 100644 --- a/src/app/core/core-routing.module.ts +++ b/src/app/core/core-routing.module.ts @@ -1,5 +1,5 @@ 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 { } diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 5fd7cc818ed17db1769051e3794c5ca093d9faa5..a717641cf6623edd9dda1348e5b839b6b8c324d6 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -1,17 +1,17 @@ -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: [ diff --git a/src/app/core/interceptors/http-error-response-interceptor.ts b/src/app/core/interceptors/http-error-response-interceptor.ts index 184be7141118ee30ef724dd5be7b0f3815215c93..e97d4dad4a028f14163cf78d75edf63ba403b9fc 100644 --- a/src/app/core/interceptors/http-error-response-interceptor.ts +++ b/src/app/core/interceptors/http-error-response-interceptor.ts @@ -1,13 +1,10 @@ // 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() diff --git a/src/app/core/services/error.service.spec.ts b/src/app/core/services/error.service.spec.ts deleted file mode 100644 index 49c1840efe280a0c6a5a31dcd41b15d94a065341..0000000000000000000000000000000000000000 --- a/src/app/core/services/error.service.spec.ts +++ /dev/null @@ -1,55 +0,0 @@ -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); - }); - }); -}); diff --git a/src/app/core/services/file-service.ts b/src/app/core/services/file.service.ts similarity index 93% rename from src/app/core/services/file-service.ts rename to src/app/core/services/file.service.ts index cd4ff1e38e36f233bd9de460dcdfbb05e4d7132c..e76b10ff45dd7274c2b6a17f47a41e81d750a18e 100644 --- a/src/app/core/services/file-service.ts +++ b/src/app/core/services/file.service.ts @@ -1,7 +1,7 @@ -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'; diff --git a/src/app/core/services/index.ts b/src/app/core/services/index.ts index 020738bf13d0695577233d6f9900ef835a8db6d4..eef3ec75ac6d54cca21ef98c2912183d9a1a27a8 100644 --- a/src/app/core/services/index.ts +++ b/src/app/core/services/index.ts @@ -1,17 +1,15 @@ +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 = [ diff --git a/src/app/core/services/notification.service.spec.ts b/src/app/core/services/notification.service.spec.ts deleted file mode 100644 index 8161d8622ca4a7575b42035c1910ae4c81f9376b..0000000000000000000000000000000000000000 --- a/src/app/core/services/notification.service.spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -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); - }); - }); -}); diff --git a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.html b/src/app/dataset-detail/components/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.html rename to src/app/dataset-detail/components/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.scss b/src/app/dataset-detail/components/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.scss similarity index 95% rename from src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.scss rename to src/app/dataset-detail/components/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.scss index 04acad21813401a2c0d43a8b09bb32e99145f874..e8589c4ba405f517705fb8d5580ce103e6986de8 100644 --- a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.scss +++ b/src/app/dataset-detail/components/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.scss @@ -1,4 +1,4 @@ -@import "../../../../../../scss/variables"; +@import "../../../../../scss/variables"; .property-value { font-size: 0.875rem; diff --git a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.ts b/src/app/dataset-detail/components/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.ts similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.ts rename to src/app/dataset-detail/components/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component.ts diff --git a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-details.component.html b/src/app/dataset-detail/components/dataset-data-details/dataset-data-details.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-details.component.html rename to src/app/dataset-detail/components/dataset-data-details/dataset-data-details.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-details.component.scss b/src/app/dataset-detail/components/dataset-data-details/dataset-data-details.component.scss similarity index 93% rename from src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-details.component.scss rename to src/app/dataset-detail/components/dataset-data-details/dataset-data-details.component.scss index 619e851af9defe58dbe742bb13aace5de0fc0261..4840767e2ee0b0b71669789ffcbfa473ac07b981 100644 --- a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-details.component.scss +++ b/src/app/dataset-detail/components/dataset-data-details/dataset-data-details.component.scss @@ -1,4 +1,4 @@ -@import "../../../../../scss/variables"; +@import "../../../../scss/variables"; $details-header-height: 36px; diff --git a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-details.component.ts b/src/app/dataset-detail/components/dataset-data-details/dataset-data-details.component.ts similarity index 90% rename from src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-details.component.ts rename to src/app/dataset-detail/components/dataset-data-details/dataset-data-details.component.ts index d12bf86d81a3904ca008133733f62108b514ae9b..9420f99b0d0c7103eb69ceca620540e582f7ac81 100644 --- a/src/app/geosource/components/dataset-detail/dataset-data-details/dataset-data-details.component.ts +++ b/src/app/dataset-detail/components/dataset-data-details/dataset-data-details.component.ts @@ -1,5 +1,5 @@ -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', diff --git a/src/app/geosource/components/dataset-detail/dataset-detail.component.html b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-detail.component.html rename to src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-detail.component.scss b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.scss similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-detail.component.scss rename to src/app/dataset-detail/components/dataset-detail/dataset-detail.component.scss diff --git a/src/app/geosource/components/dataset-detail/dataset-detail.component.ts b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts similarity index 91% rename from src/app/geosource/components/dataset-detail/dataset-detail.component.ts rename to src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts index c40666377e8e484ee500b6c1892e4642d7c158cf..313d9dab55d0555755455dafaa137e18eaf09e88 100644 --- a/src/app/geosource/components/dataset-detail/dataset-detail.component.ts +++ b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts @@ -1,15 +1,13 @@ -import { filter } from 'rxjs/operators'; -import { Component, OnInit, OnDestroy } from '@angular/core'; -import { Metadata } from '../../models'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute, Router, Scroll } from '@angular/router'; -import { DatasetDetailService } from '../../services'; -import { typesMetadata } from '../../models/metadata.model'; -import { AppRoutes } from '../../../routes'; -import { NotificationService, NavigationHistoryService } from '../../../core/services'; -import { ViewportScroller } from '../../../../../node_modules/@angular/common'; import { Subscription } from 'rxjs'; -import { IPageHeaderInfo } from '../../../shared/models'; +import { filter } from 'rxjs/operators'; +import { ViewportScroller } from '../../../../../node_modules/@angular/common'; import { datatsetDataRepresentationType, geosource } from '../../../../i18n/traductions'; +import { NavigationHistoryService } from '../../../core/services'; +import { AppRoutes } from '../../../routes'; +import { IPageHeaderInfo, Metadata, typesMetadata } from '../../../shared/models'; +import { DatasetDetailService } from '../../services'; @Component({ selector: 'app-dataset-detail', @@ -31,7 +29,6 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { private _route: ActivatedRoute, private _datasetDetailService: DatasetDetailService, private _router: Router, - private _notificationService: NotificationService, private _scroller: ViewportScroller, private _navigationHistoryService: NavigationHistoryService, ) { } @@ -125,7 +122,7 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { if (this.hasTable || this.hasMap) { this._router.navigate([ `/${AppRoutes.datasets.uri}/${this._datasetDetailService.dataset.slug}/${AppRoutes.data.uri}`, - // tslint:disable-next-line: align + // tslint:disable-next-line: align ], { queryParamsHandling: 'preserve' }); } else { this._router.navigate([ @@ -153,7 +150,7 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { goToPreviousPage() { let index = 1; // Start to retrieve the previous element let url = this._navigationHistoryService.getFromLast(index); - // While the previous element still has /datasets or is not null (no previous element) + // While the previous element still has /jeux-de-donnees or is not null (no previous element) // get the previous element of the previous element... while (url !== null && url.search(`${AppRoutes.datasets.uri}/`) !== -1) { // the method getFromLast deletes every history after the index required therefor as we already entered diff --git a/src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.html b/src/app/dataset-detail/components/dataset-info/dataset-info.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.html rename to src/app/dataset-detail/components/dataset-info/dataset-info.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.scss b/src/app/dataset-detail/components/dataset-info/dataset-info.component.scss similarity index 94% rename from src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.scss rename to src/app/dataset-detail/components/dataset-info/dataset-info.component.scss index 1a66f88ea07693f27c000ce391d39046f75cedba..2845766f635735dacfc1e768133e304f4b6f80a2 100644 --- a/src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.scss +++ b/src/app/dataset-detail/components/dataset-info/dataset-info.component.scss @@ -1,5 +1,5 @@ -@import "../../../../../scss/variables"; -@import "../../../../../../node_modules/bulma/sass/utilities/_all"; +@import "../../../../scss/variables"; +@import "../../../../../node_modules/bulma/sass/utilities/_all"; span, p { diff --git a/src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.spec.ts b/src/app/dataset-detail/components/dataset-info/dataset-info.component.spec.ts similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.spec.ts rename to src/app/dataset-detail/components/dataset-info/dataset-info.component.spec.ts diff --git a/src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.ts b/src/app/dataset-detail/components/dataset-info/dataset-info.component.ts similarity index 87% rename from src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.ts rename to src/app/dataset-detail/components/dataset-info/dataset-info.component.ts index cb6cce629293dfd5f110f4d06b944463d56996d1..09504bc2e778a01ad151824b05c691f530957382 100644 --- a/src/app/geosource/components/dataset-detail/dataset-info/dataset-info.component.ts +++ b/src/app/dataset-detail/components/dataset-info/dataset-info.component.ts @@ -1,13 +1,9 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; -import { geosource, datatsetDataRepresentationType, notificationMessages } from '../../../../../i18n/traductions'; -import { Metadata, IMetadataLink } from '../../../models'; -import { typesMetadata, IResponsibleParty } from '../../../models/metadata.model'; - -import { DatasetDetailService } from '../../../services'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; -import { AppRoutes } from '../../../../routes'; -import { CMSContent } from '../../../../editorialisation/models'; -import { EditorialisationService } from '../../../../editorialisation/services'; +import { datatsetDataRepresentationType, geosource } from '../../../../i18n/traductions'; +import { AppRoutes } from '../../../routes'; +import { IResponsibleParty, Metadata, typesMetadata } from '../../../shared/models'; +import { DatasetDetailService } from '../../services'; @Component({ selector: 'app-dataset-info', @@ -66,7 +62,7 @@ export class DatasetInfoComponent implements OnInit, OnDestroy { maxNorth: `${this.metadata.max_north} nord,`, maxWest: `${this.metadata.max_west} ouest`, }, - coordinatesSystem: this.metadata.crs , + coordinatesSystem: this.metadata.crs, }; } diff --git a/src/app/geosource/components/dataset-detail/dataset-map/dataset-map.component.html b/src/app/dataset-detail/components/dataset-map/dataset-map.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-map/dataset-map.component.html rename to src/app/dataset-detail/components/dataset-map/dataset-map.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-map/dataset-map.component.scss b/src/app/dataset-detail/components/dataset-map/dataset-map.component.scss similarity index 95% rename from src/app/geosource/components/dataset-detail/dataset-map/dataset-map.component.scss rename to src/app/dataset-detail/components/dataset-map/dataset-map.component.scss index 6390d536d8f08bbf471701f6b97d2bd8d7685312..c488234dd64fa0ceae64a7fe145269190423e661 100644 --- a/src/app/geosource/components/dataset-detail/dataset-map/dataset-map.component.scss +++ b/src/app/dataset-detail/components/dataset-map/dataset-map.component.scss @@ -1,4 +1,4 @@ -@import "../../../../../scss/variables"; +@import "../../../../scss/variables"; div { height: 100%; diff --git a/src/app/geosource/components/dataset-detail/dataset-map/dataset-map.component.ts b/src/app/dataset-detail/components/dataset-map/dataset-map.component.ts similarity index 91% rename from src/app/geosource/components/dataset-detail/dataset-map/dataset-map.component.ts rename to src/app/dataset-detail/components/dataset-map/dataset-map.component.ts index e7270a1b361b19f084a5ebd5b9a9d63a6d93463e..48ecc6c99b97d940ed90798d329b914d04cd4010 100644 --- a/src/app/geosource/components/dataset-detail/dataset-map/dataset-map.component.ts +++ b/src/app/dataset-detail/components/dataset-map/dataset-map.component.ts @@ -1,12 +1,11 @@ -import { Component, OnInit, ViewChild, Input, Output, EventEmitter, OnDestroy, ElementRef } from '@angular/core'; -import { MapService } from '../../../../map/services/map.service'; -import { DatasetDetailService } from '../../../services'; +import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; import { Subscription } from 'rxjs'; -import { Metadata, Data } from '../../../models'; -import { MapComponent } from '../../../../map/components'; -import { MapOptions } from '../../../../map/models/map-options'; -import { linkFormats } from '../../../models/metadata.model'; -import { APP_CONFIG } from '../../../../core/services/app-config.service'; +import { APP_CONFIG } from '../../../core/services/app-config.service'; +import { MapComponent } from '../../../map/components'; +import { MapOptions } from '../../../map/models/map-options'; +import { MapService } from '../../../map/services/map.service'; +import { Data, linkFormats, Metadata } from '../../../shared/models'; +import { DatasetDetailService } from '../../services'; @Component({ selector: 'app-dataset-map', diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.html b/src/app/dataset-detail/components/dataset-resources/dataset-resources.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.html rename to src/app/dataset-detail/components/dataset-resources/dataset-resources.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.scss b/src/app/dataset-detail/components/dataset-resources/dataset-resources.component.scss similarity index 94% rename from src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.scss rename to src/app/dataset-detail/components/dataset-resources/dataset-resources.component.scss index eaaab04646db6dc40f43fc60f09938c9ceeeaaec..4b6f3de38bddeef4afb4aa910e7e4ac860fffd40 100644 --- a/src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.scss +++ b/src/app/dataset-detail/components/dataset-resources/dataset-resources.component.scss @@ -1,5 +1,5 @@ -@import "../../../../../scss/variables"; -@import "../../../../../../node_modules/bulma/sass/utilities/_all"; +@import "../../../../scss/variables"; +@import "../../../../../node_modules/bulma/sass/utilities/_all"; .resource-container { padding: 2rem 1.25rem 1.25rem 1.25rem; diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.spec.ts b/src/app/dataset-detail/components/dataset-resources/dataset-resources.component.spec.ts similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.spec.ts rename to src/app/dataset-detail/components/dataset-resources/dataset-resources.component.spec.ts diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.ts b/src/app/dataset-detail/components/dataset-resources/dataset-resources.component.ts similarity index 88% rename from src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.ts rename to src/app/dataset-detail/components/dataset-resources/dataset-resources.component.ts index 9dda24eae07911fe394b554cbe3db338c90154bc..b5823387cf7744afd34cf7178c310f243cd1d705 100644 --- a/src/app/geosource/components/dataset-detail/dataset-resources/dataset-resources.component.ts +++ b/src/app/dataset-detail/components/dataset-resources/dataset-resources.component.ts @@ -1,11 +1,11 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; -import { DatasetDetailService, ResourcesService } from '../../../services'; -import { Metadata, Resource } from '../../../models'; -import { Subscription, forkJoin } from 'rxjs'; -import { IMetadataLink } from '../../../models/metadata.model'; -import { NotificationService } from '../../../../core/services'; -import { notificationMessages } from '../../../../../i18n/traductions'; -import { Notification } from '../../../../core/models'; +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Subscription } from 'rxjs'; +import { notificationMessages } from '../../../../i18n/traductions'; +import { Notification } from '../../../core/models'; +import { NotificationService } from '../../../core/services'; +import { IMetadataLink, Metadata } from '../../../shared/models'; +import { Resource } from '../../models'; +import { DatasetDetailService, ResourcesService } from '../../services'; @Component({ selector: 'app-dataset-resources', diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/icon-format/icon-format.component.html b/src/app/dataset-detail/components/dataset-resources/icon-format/icon-format.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-resources/icon-format/icon-format.component.html rename to src/app/dataset-detail/components/dataset-resources/icon-format/icon-format.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/icon-format/icon-format.component.scss b/src/app/dataset-detail/components/dataset-resources/icon-format/icon-format.component.scss similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-resources/icon-format/icon-format.component.scss rename to src/app/dataset-detail/components/dataset-resources/icon-format/icon-format.component.scss diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/icon-format/icon-format.component.ts b/src/app/dataset-detail/components/dataset-resources/icon-format/icon-format.component.ts similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-resources/icon-format/icon-format.component.ts rename to src/app/dataset-detail/components/dataset-resources/icon-format/icon-format.component.ts diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component.html b/src/app/dataset-detail/components/dataset-resources/resource-downloadable/resource-downloadable.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component.html rename to src/app/dataset-detail/components/dataset-resources/resource-downloadable/resource-downloadable.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component.scss b/src/app/dataset-detail/components/dataset-resources/resource-downloadable/resource-downloadable.component.scss similarity index 95% rename from src/app/geosource/components/dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component.scss rename to src/app/dataset-detail/components/dataset-resources/resource-downloadable/resource-downloadable.component.scss index 0e2b726c42b81a1b0b70c0f274532c1ecb694455..60fc87929783c689c1f6eb9c5b5da7382bfbea2b 100644 --- a/src/app/geosource/components/dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component.scss +++ b/src/app/dataset-detail/components/dataset-resources/resource-downloadable/resource-downloadable.component.scss @@ -1,4 +1,4 @@ -@import '../../../../../../scss/variables.scss'; +@import '../../../../../scss/variables.scss'; .resource { background-color: white; diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component.ts b/src/app/dataset-detail/components/dataset-resources/resource-downloadable/resource-downloadable.component.ts similarity index 90% rename from src/app/geosource/components/dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component.ts rename to src/app/dataset-detail/components/dataset-resources/resource-downloadable/resource-downloadable.component.ts index fa58db23c78f9c1606f84813c1be7841b1e95ee6..afd1ae5ac27906b2fa441279574e51620ca80286 100644 --- a/src/app/geosource/components/dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component.ts +++ b/src/app/dataset-detail/components/dataset-resources/resource-downloadable/resource-downloadable.component.ts @@ -1,6 +1,6 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { IMetadataLink } from '../../../../models'; -import { NotificationService, FileService } from '../../../../../core/services'; +import { Component, Input, OnInit } from '@angular/core'; +import { FileService, NotificationService } from '../../../../core/services'; +import { IMetadataLink } from '../../../../shared/models'; @Component({ selector: 'app-resource-downloadable', diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.html b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.html rename to src/app/dataset-detail/components/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.scss b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.scss similarity index 98% rename from src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.scss rename to src/app/dataset-detail/components/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.scss index 1c9d6847d596df202e6a9f0017db436a9fcf3553..c721abd3068313da14f6b65c871974baada5f82e 100644 --- a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.scss +++ b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.scss @@ -1,4 +1,4 @@ -@import '../../../../../../../scss/variables.scss'; +@import '../../../../../../scss/variables.scss'; .resource-item { display: grid; diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.ts b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.ts similarity index 96% rename from src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.ts rename to src/app/dataset-detail/components/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.ts index 75d3923cffc1ed8fa6fe64a9c4d75b2eee8bea86..8d434a0effb6e1be8b24f242ff15528297b3f45b 100644 --- a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.ts +++ b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component.ts @@ -1,14 +1,12 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { SafeHtml, DomSanitizer } from '@angular/platform-browser'; -import { Resource, Metadata } from '../../../../../models'; -import { Format } from '../../../../../models/resource.model'; -import { communeInsee } from '../../../../../../../assets/resources/commune-insee'; -import { DatasetDetailService } from '../../../../../services'; -import { linkFormats } from '../../../../../models/metadata.model'; -import { geosource, notificationMessages } from '../../../../../../../i18n/traductions'; +import { Component, Input, OnInit } from '@angular/core'; +import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { saveAs } from 'file-saver'; -import { NotificationService } from '../../../../../../core/services'; -import { Projection } from '../../../../../models/projection.model'; +import { communeInsee } from '../../../../../../assets/resources/commune-insee'; +import { geosource, notificationMessages } from '../../../../../../i18n/traductions'; +import { NotificationService } from '../../../../../core/services'; +import { linkFormats, Metadata } from '../../../../../shared/models'; +import { Format, Projection, Resource } from '../../../../models'; +import { DatasetDetailService } from '../../../../services'; @Component({ selector: 'app-resource-queryable', diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resources-queryable.component.html b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resources-queryable.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resources-queryable.component.html rename to src/app/dataset-detail/components/dataset-resources/resources-queryable/resources-queryable.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resources-queryable.component.scss b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resources-queryable.component.scss similarity index 93% rename from src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resources-queryable.component.scss rename to src/app/dataset-detail/components/dataset-resources/resources-queryable/resources-queryable.component.scss index b6e32fcc6e1f017b601eb6fe3f6c7c4d50f56f7a..c10f4a94e3f26256f714e8f114266b847152f332 100644 --- a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resources-queryable.component.scss +++ b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resources-queryable.component.scss @@ -1,4 +1,4 @@ -@import '../../../../../../scss/variables.scss'; +@import '../../../../../scss/variables.scss'; .resources { margin: 0; diff --git a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resources-queryable.component.ts b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resources-queryable.component.ts similarity index 74% rename from src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resources-queryable.component.ts rename to src/app/dataset-detail/components/dataset-resources/resources-queryable/resources-queryable.component.ts index cf82a39ba296686fbddc0719186433dc0bc28fed..e7715af9aa25f8789a3c4c49f39485324f5101bf 100644 --- a/src/app/geosource/components/dataset-detail/dataset-resources/resources-queryable/resources-queryable.component.ts +++ b/src/app/dataset-detail/components/dataset-resources/resources-queryable/resources-queryable.component.ts @@ -1,8 +1,8 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { Resource, Metadata } from '../../../../models'; -import { ResourcesService } from '../../../../services'; -import { Projection } from '../../../../models/projection.model'; -import { environment } from '../../../../../../environments/environment'; +import { Component, Input, OnInit } from '@angular/core'; +import { environment } from '../../../../../environments/environment'; +import { Metadata } from '../../../../shared/models'; +import { Projection, Resource } from '../../../models'; +import { ResourcesService } from '../../../services'; @Component({ selector: 'app-resources-queryable', diff --git a/src/app/geosource/components/dataset-detail/dataset-table-map/dataset-table-map.component.html b/src/app/dataset-detail/components/dataset-table-map/dataset-table-map.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-table-map/dataset-table-map.component.html rename to src/app/dataset-detail/components/dataset-table-map/dataset-table-map.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-table-map/dataset-table-map.component.scss b/src/app/dataset-detail/components/dataset-table-map/dataset-table-map.component.scss similarity index 96% rename from src/app/geosource/components/dataset-detail/dataset-table-map/dataset-table-map.component.scss rename to src/app/dataset-detail/components/dataset-table-map/dataset-table-map.component.scss index 784feda7b84f273c0d22ca099f23fd3ed1f9ed6f..2193eabd37b33f056e7c2fffc93d73df3b2d0598 100644 --- a/src/app/geosource/components/dataset-detail/dataset-table-map/dataset-table-map.component.scss +++ b/src/app/dataset-detail/components/dataset-table-map/dataset-table-map.component.scss @@ -1,5 +1,5 @@ -@import "../../../../../scss/variables"; -@import "../../../../../../node_modules/bulma/sass/utilities/_all"; +@import "../../../../scss/variables.scss"; +@import "../../../../../node_modules/bulma/sass/utilities/_all"; .component-wrapper { max-width: 100vw; @@ -76,7 +76,7 @@ } .properties-dropdown button { - background-image: url('../../../../../assets/img/picto_colonnes.svg'); + background-image: url('../../../../assets/img/picto_colonnes.svg'); background-size: 36px 36px; background-repeat: no-repeat; background-position: center; @@ -294,14 +294,14 @@ } .btn-exit-fullscreen { - background-image: url('../../../../../assets/img/picto_fullscreen_off.svg'); + background-image: url('../../../../assets/img/picto_fullscreen_off.svg'); background-size: 36px 36px; background-repeat: no-repeat; background-position: center; } .btn-fullscreen { - background-image: url('../../../../../assets/img/picto_fullscreen_on.svg'); + background-image: url('../../../../assets/img/picto_fullscreen_on.svg'); background-size: 36px 36px; background-repeat: no-repeat; background-position: center; diff --git a/src/app/geosource/components/dataset-detail/dataset-table-map/dataset-table-map.component.ts b/src/app/dataset-detail/components/dataset-table-map/dataset-table-map.component.ts similarity index 97% rename from src/app/geosource/components/dataset-detail/dataset-table-map/dataset-table-map.component.ts rename to src/app/dataset-detail/components/dataset-table-map/dataset-table-map.component.ts index 0b91d5b531028153d0035845803e9a9a34d46534..d33a0de145d3bc00460b04a0d9b1b6bf625ebafe 100644 --- a/src/app/geosource/components/dataset-detail/dataset-table-map/dataset-table-map.component.ts +++ b/src/app/dataset-detail/components/dataset-table-map/dataset-table-map.component.ts @@ -1,9 +1,9 @@ -import { Component, OnInit, ViewChild, OnDestroy, ElementRef, AfterViewInit } from '@angular/core'; -import { DatasetDetailService } from '../../../services'; -import { DatasetMapComponent } from '../dataset-map/dataset-map.component'; +import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { FormControl } from '@angular/forms'; -import { Data } from '../../../models'; import { Subscription } from 'rxjs'; +import { Data } from '../../../elasticsearch/models'; +import { DatasetDetailService } from '../../services'; +import { DatasetMapComponent } from '../dataset-map/dataset-map.component'; @Component({ selector: 'app-dataset-table-map', diff --git a/src/app/geosource/components/dataset-detail/dataset-table/dataset-table.component.html b/src/app/dataset-detail/components/dataset-table/dataset-table.component.html similarity index 100% rename from src/app/geosource/components/dataset-detail/dataset-table/dataset-table.component.html rename to src/app/dataset-detail/components/dataset-table/dataset-table.component.html diff --git a/src/app/geosource/components/dataset-detail/dataset-table/dataset-table.component.scss b/src/app/dataset-detail/components/dataset-table/dataset-table.component.scss similarity index 95% rename from src/app/geosource/components/dataset-detail/dataset-table/dataset-table.component.scss rename to src/app/dataset-detail/components/dataset-table/dataset-table.component.scss index e72c230cf59e0f5f4a89645297b8f5fe9340710e..e4d11fe3a510c710df18e7932e5233e0f7ae7699 100644 --- a/src/app/geosource/components/dataset-detail/dataset-table/dataset-table.component.scss +++ b/src/app/dataset-detail/components/dataset-table/dataset-table.component.scss @@ -1,5 +1,5 @@ -@import "../../../../../scss/variables"; -@import "../../../../../../node_modules/bulma/sass/utilities/_all"; +@import "../../../../scss/variables"; +@import "../../../../../node_modules/bulma/sass/utilities/_all"; .data-table { display: grid; diff --git a/src/app/geosource/components/dataset-detail/dataset-table/dataset-table.component.ts b/src/app/dataset-detail/components/dataset-table/dataset-table.component.ts similarity index 92% rename from src/app/geosource/components/dataset-detail/dataset-table/dataset-table.component.ts rename to src/app/dataset-detail/components/dataset-table/dataset-table.component.ts index a59f4ea300cbda14f13b85ece2f001854fa69a53..9fb3bd1c2b81656db665885270d9cd5bf8713cf9 100644 --- a/src/app/geosource/components/dataset-detail/dataset-table/dataset-table.component.ts +++ b/src/app/dataset-detail/components/dataset-table/dataset-table.component.ts @@ -1,12 +1,10 @@ -import { - Component, OnInit, ElementRef, QueryList, ViewChildren, - OnDestroy, Input, Output, EventEmitter -} from '@angular/core'; -import { DatasetDetailService } from '../../../services'; -import { Data } from '../../../models'; -import { Subscription } from '../../../../../../node_modules/rxjs'; -import { geosource } from '../../../../../i18n/traductions'; -import { AppRoutes } from '../../../../routes'; +// tslint:disable-next-line: max-line-length +import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, QueryList, ViewChildren } from '@angular/core'; +import { Subscription } from 'rxjs'; +import { geosource } from '../../../../i18n/traductions'; +import { Data } from '../../../elasticsearch/models'; +import { AppRoutes } from '../../../routes'; +import { DatasetDetailService } from '../../services'; @Component({ selector: 'app-dataset-table', diff --git a/src/app/dataset-detail/components/index.ts b/src/app/dataset-detail/components/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f4b4a10c58570833c6c2a299d7370388cae19eb5 --- /dev/null +++ b/src/app/dataset-detail/components/index.ts @@ -0,0 +1,33 @@ +// tslint:disable-next-line: max-line-length +import { DatasetDataDetailPropertiesComponent } from './dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component'; +import { DatasetDataDetailsComponent } from './dataset-data-details/dataset-data-details.component'; +import { DatasetDetailComponent } from './dataset-detail/dataset-detail.component'; +import { DatasetInfoComponent } from './dataset-info/dataset-info.component'; +import { DatasetMapComponent } from './dataset-map/dataset-map.component'; +import { DatasetResourcesComponent } from './dataset-resources/dataset-resources.component'; +import { IconFormatComponent } from './dataset-resources/icon-format/icon-format.component'; +// tslint:disable-next-line:max-line-length +import { ResourceDownloadableComponent } from './dataset-resources/resource-downloadable/resource-downloadable.component'; +// tslint:disable-next-line:max-line-length +import { ResourceQueryableComponent } from './dataset-resources/resources-queryable/resource-queryable/resource-queryable.component'; +import { ResourcesQueryableComponent } from './dataset-resources/resources-queryable/resources-queryable.component'; +import { DatasetTableMapComponent } from './dataset-table-map/dataset-table-map.component'; +import { DatasetTableComponent } from './dataset-table/dataset-table.component'; + +export { DatasetDetailComponent, DatasetResourcesComponent, ResourceQueryableComponent, ResourceDownloadableComponent, DatasetMapComponent, DatasetInfoComponent, DatasetTableMapComponent, DatasetTableComponent, ResourcesQueryableComponent, IconFormatComponent, DatasetDataDetailsComponent, DatasetDataDetailPropertiesComponent }; + +// tslint:disable-next-line:variable-name +export const DatasetDetailComponents = [ + DatasetDetailComponent, + DatasetResourcesComponent, + ResourceQueryableComponent, + ResourceDownloadableComponent, + DatasetMapComponent, + DatasetInfoComponent, + DatasetTableMapComponent, + DatasetTableComponent, + ResourcesQueryableComponent, + IconFormatComponent, + DatasetDataDetailsComponent, + DatasetDataDetailPropertiesComponent, +]; diff --git a/src/app/geosource/geosource-routing.module.ts b/src/app/dataset-detail/dataset-detail-routing.module.ts similarity index 59% rename from src/app/geosource/geosource-routing.module.ts rename to src/app/dataset-detail/dataset-detail-routing.module.ts index b195df07b746f66df14cb486b5c09e2059d54fe9..0485df6dfe8d76b018b63dfd488dbde4d5fbc43e 100644 --- a/src/app/geosource/geosource-routing.module.ts +++ b/src/app/dataset-detail/dataset-detail-routing.module.ts @@ -1,39 +1,15 @@ import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; -import { - ResultsComponent, DatasetDetailComponent, ResearchComponent, DatasetInfoComponent, - DatasetResourcesComponent, - DatasetTableMapComponent, -} from './components'; +import { RouterModule, Routes } from '@angular/router'; import { AppRoutes } from '../routes'; +// tslint:disable-next-line: max-line-length +import { DatasetDetailComponent, DatasetInfoComponent, DatasetResourcesComponent, DatasetTableMapComponent } from './components'; import { DatasetDetailResolver } from './resolvers'; export const routes: Routes = [ - { - path: AppRoutes.research.uri, - component: ResearchComponent, - data: { - title: AppRoutes.research.title, - }, - children: [ - { - path: '', - component: ResultsComponent, - data: { - title: AppRoutes.datasets.title, - }, - pathMatch: 'full', - }, - ], - }, // Some of the parteners already used the english version of this routing so in order to not break again there link // we implemented a fallback routes that redirects to the new routing { - path: 'datasets/:id', - redirectTo: `${AppRoutes.datasets.uri}/:id`, - }, - { - path: `${AppRoutes.datasets.uri}/:id`, + path: '', component: DatasetDetailComponent, resolve: { dataset: DatasetDetailResolver, @@ -68,4 +44,4 @@ export const routes: Routes = [ exports: [RouterModule], imports: [RouterModule.forChild(routes)], }) -export class GeosourceRoutingModule { } +export class DatasetDetailRoutingModule { } diff --git a/src/app/dataset-detail/dataset-detail.module.ts b/src/app/dataset-detail/dataset-detail.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..d635bbeecc3d46e403e92942ca5f68611bbf3d22 --- /dev/null +++ b/src/app/dataset-detail/dataset-detail.module.ts @@ -0,0 +1,29 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { InlineSVGModule } from 'ng-inline-svg'; +import { InfiniteScrollModule } from 'ngx-infinite-scroll'; +import { ElasticsearchModule } from '../elasticsearch/elasticsearch.module'; +import { MapModule } from '../map/map.module'; +import { SharedModule } from '../shared/shared.module'; +import { DatasetDetailComponents } from './components'; +import { DatasetDetailRoutingModule } from './dataset-detail-routing.module'; +import { DatasetDetailResolvers } from './resolvers'; +import { DatasetDetailServices } from './services'; + +@NgModule({ + declarations: [...DatasetDetailComponents], + imports: [ + CommonModule, + DatasetDetailRoutingModule, + ElasticsearchModule, + FormsModule, + ReactiveFormsModule, + MapModule, + SharedModule, + InlineSVGModule.forRoot(), + InfiniteScrollModule, + ], + providers: [...DatasetDetailServices, ...DatasetDetailResolvers], +}) +export class DatasetDetailModule { } diff --git a/src/app/geosource/models/dataset-child.model.ts b/src/app/dataset-detail/models/dataset-child.model.ts similarity index 100% rename from src/app/geosource/models/dataset-child.model.ts rename to src/app/dataset-detail/models/dataset-child.model.ts diff --git a/src/app/dataset-detail/models/index.ts b/src/app/dataset-detail/models/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..60f209105b826f4898ec4825207d09c1ce860459 --- /dev/null +++ b/src/app/dataset-detail/models/index.ts @@ -0,0 +1,4 @@ +export { DatasetChild, IDatasetRawChild } from './dataset-child.model'; +export { IProjection, Projection } from './projection.model'; +export { Format, IFormat, IResource, IResourceFormat, Resource } from './resource.model'; + diff --git a/src/app/geosource/models/projection.model.ts b/src/app/dataset-detail/models/projection.model.ts similarity index 100% rename from src/app/geosource/models/projection.model.ts rename to src/app/dataset-detail/models/projection.model.ts diff --git a/src/app/geosource/models/resource.model.ts b/src/app/dataset-detail/models/resource.model.ts similarity index 97% rename from src/app/geosource/models/resource.model.ts rename to src/app/dataset-detail/models/resource.model.ts index 644ca166c23323eb3e5964162b7a0d2bf7ac67b4..d0a736ca35e0e6bafefa76cd5ed8e34241eb0ab5 100644 --- a/src/app/geosource/models/resource.model.ts +++ b/src/app/dataset-detail/models/resource.model.ts @@ -1,4 +1,4 @@ -import { IMetadataLink } from '.'; +import { IMetadataLink } from "../../shared/models"; export interface IFormat { id: number; diff --git a/src/app/geosource/resolvers/dataset-detail.resolver.ts b/src/app/dataset-detail/resolvers/dataset-detail.resolver.ts similarity index 80% rename from src/app/geosource/resolvers/dataset-detail.resolver.ts rename to src/app/dataset-detail/resolvers/dataset-detail.resolver.ts index f372e944aa83683e734407c8ed0eb480140a46f2..b6aa5d86ba9b6328dcf4d2c185f916f7e1a6dd32 100644 --- a/src/app/geosource/resolvers/dataset-detail.resolver.ts +++ b/src/app/dataset-detail/resolvers/dataset-detail.resolver.ts @@ -1,9 +1,9 @@ -import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; import { Injectable } from '@angular/core'; -import { catchError, map } from 'rxjs/operators'; +import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; import { of } from 'rxjs'; +import { catchError } from 'rxjs/operators'; +import { Dataset } from '../../shared/models'; import { DatasetDetailService } from '../services'; -import { Dataset, Metadata, IMetadata } from '../models'; @Injectable() export class DatasetDetailResolver implements Resolve<Dataset> { diff --git a/src/app/geosource/resolvers/index.ts b/src/app/dataset-detail/resolvers/index.ts similarity index 65% rename from src/app/geosource/resolvers/index.ts rename to src/app/dataset-detail/resolvers/index.ts index af5791ad0a5fd7bdd91eebf12c18b09cac1d0792..c60a08bbd00334bd532317d11b569a6d0f23d542 100644 --- a/src/app/geosource/resolvers/index.ts +++ b/src/app/dataset-detail/resolvers/index.ts @@ -1,10 +1,8 @@ import { DatasetDetailResolver } from './dataset-detail.resolver'; -export { - DatasetDetailResolver, -}; +export { DatasetDetailResolver }; // tslint:disable-next-line:variable-name -export const GeosourceResolvers = [ +export const DatasetDetailResolvers = [ DatasetDetailResolver, ]; diff --git a/src/app/geosource/services/dataset-detail.service.ts b/src/app/dataset-detail/services/dataset-detail.service.ts similarity index 96% rename from src/app/geosource/services/dataset-detail.service.ts rename to src/app/dataset-detail/services/dataset-detail.service.ts index ba06147f5f5ba90773ee505fefc698e98a81f5ad..36f511833e4f6ee914b8f067734690aaadecff66 100644 --- a/src/app/geosource/services/dataset-detail.service.ts +++ b/src/app/dataset-detail/services/dataset-detail.service.ts @@ -1,14 +1,13 @@ import { Injectable } from '@angular/core'; -import { ElasticsearchService } from './elasticsearch.service'; -import { - Metadata, Dataset, DatasetChild, Data, IElasticsearchResponse, ElasticsearchOptions, - EditorialMetadata, -} from '../models'; -import { Observable, Subject, of, forkJoin } from 'rxjs'; -import { map, catchError, flatMap, tap, finalize } from 'rxjs/operators'; -import { ErrorService, MatomoService } from '../../core/services'; +import { Observable, of, Subject } from 'rxjs'; +import { catchError, finalize, flatMap, map, tap } from 'rxjs/operators'; import { notificationMessages } from '../../../i18n/traductions'; -import { IDatasetRawChild } from '../models/dataset-child.model'; +import { ErrorService, MatomoService } from '../../core/services'; +import { ElasticsearchOptions, IElasticsearchResponse } from '../../elasticsearch/models'; +import { ElasticsearchService } from '../../elasticsearch/services/elasticsearch.service'; +// tslint:disable-next-line: max-line-length +import { Data, Dataset, EditorialMetadata, Metadata } from '../../shared/models'; +import { DatasetChild, IDatasetRawChild } from '../models'; @Injectable() export class DatasetDetailService { diff --git a/src/app/dataset-detail/services/index.ts b/src/app/dataset-detail/services/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..d72f59e5bb2f52aa61fad2f85abacf37051229de --- /dev/null +++ b/src/app/dataset-detail/services/index.ts @@ -0,0 +1,10 @@ +import { DatasetDetailService } from './dataset-detail.service'; +import { ResourcesService } from './resources.service'; + +export { DatasetDetailService, ResourcesService }; + +// tslint:disable-next-line:variable-name +export const DatasetDetailServices = [ + DatasetDetailService, + ResourcesService, +]; diff --git a/src/app/geosource/services/resources.service.ts b/src/app/dataset-detail/services/resources.service.ts similarity index 100% rename from src/app/geosource/services/resources.service.ts rename to src/app/dataset-detail/services/resources.service.ts diff --git a/src/app/geosource/components/filter-list/filter-detail/filter-detail.component.html b/src/app/datasets/components/filter-list/filter-detail/filter-detail.component.html similarity index 100% rename from src/app/geosource/components/filter-list/filter-detail/filter-detail.component.html rename to src/app/datasets/components/filter-list/filter-detail/filter-detail.component.html diff --git a/src/app/geosource/components/filter-list/filter-detail/filter-detail.component.scss b/src/app/datasets/components/filter-list/filter-detail/filter-detail.component.scss similarity index 100% rename from src/app/geosource/components/filter-list/filter-detail/filter-detail.component.scss rename to src/app/datasets/components/filter-list/filter-detail/filter-detail.component.scss diff --git a/src/app/geosource/components/filter-list/filter-detail/filter-detail.component.spec.ts b/src/app/datasets/components/filter-list/filter-detail/filter-detail.component.spec.ts similarity index 100% rename from src/app/geosource/components/filter-list/filter-detail/filter-detail.component.spec.ts rename to src/app/datasets/components/filter-list/filter-detail/filter-detail.component.spec.ts diff --git a/src/app/geosource/components/filter-list/filter-detail/filter-detail.component.ts b/src/app/datasets/components/filter-list/filter-detail/filter-detail.component.ts similarity index 93% rename from src/app/geosource/components/filter-list/filter-detail/filter-detail.component.ts rename to src/app/datasets/components/filter-list/filter-detail/filter-detail.component.ts index a714cddb3a9de7170192bdc00a3570ccc77d5176..5005ff01bc60295dc53c907538f3825d1fa9ade8 100644 --- a/src/app/geosource/components/filter-list/filter-detail/filter-detail.component.ts +++ b/src/app/datasets/components/filter-list/filter-detail/filter-detail.component.ts @@ -1,7 +1,6 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Aggregation, Filter } from '../../../../elasticsearch/models'; import { DatasetResearchService } from '../../../services'; -import { Component, OnInit, Input } from '@angular/core'; -import { Filter } from '../../../models'; -import { Aggregation } from '../../../models/filter.model'; @Component({ selector: 'app-filter-detail', diff --git a/src/app/geosource/components/filter-list/filter-list.component.html b/src/app/datasets/components/filter-list/filter-list.component.html similarity index 100% rename from src/app/geosource/components/filter-list/filter-list.component.html rename to src/app/datasets/components/filter-list/filter-list.component.html diff --git a/src/app/geosource/components/filter-list/filter-list.component.scss b/src/app/datasets/components/filter-list/filter-list.component.scss similarity index 100% rename from src/app/geosource/components/filter-list/filter-list.component.scss rename to src/app/datasets/components/filter-list/filter-list.component.scss diff --git a/src/app/geosource/components/filter-list/filter-list.component.spec.ts b/src/app/datasets/components/filter-list/filter-list.component.spec.ts similarity index 100% rename from src/app/geosource/components/filter-list/filter-list.component.spec.ts rename to src/app/datasets/components/filter-list/filter-list.component.spec.ts diff --git a/src/app/geosource/components/filter-list/filter-list.component.ts b/src/app/datasets/components/filter-list/filter-list.component.ts similarity index 88% rename from src/app/geosource/components/filter-list/filter-list.component.ts rename to src/app/datasets/components/filter-list/filter-list.component.ts index c40913b587f4743a5d7ded782d71e1c0b904a7fe..21795417ec554660ade11af0b9e13fc2f03b7200 100644 --- a/src/app/geosource/components/filter-list/filter-list.component.ts +++ b/src/app/datasets/components/filter-list/filter-list.component.ts @@ -1,10 +1,9 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; -import { DatasetResearchService } from '../../services'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; -import { Filter } from '../../models'; -import { Aggregation, IActiveFiltersTemplate } from '../../models/filter.model'; -import { scopesResearch } from '../../models/scopes-research'; import { geosource } from '../../../../i18n/traductions'; +import { Aggregation, Filter, IActiveFiltersTemplate } from '../../../elasticsearch/models'; +import { scopesResearch } from '../../../shared/variables'; +import { DatasetResearchService } from '../../services'; @Component({ selector: 'app-filter-list', @@ -91,8 +90,8 @@ export class FilterListComponent implements OnInit, OnDestroy { const parentKey = (aggregationToRemove.aggregation.parentAggregation) ? aggregationToRemove.aggregation.parentAggregation.key : ''; this._datasetResearchService.updateAggregation(aggregationToRemove.filter.field, - aggregationToRemove.aggregation.key, false, - parentKey); + aggregationToRemove.aggregation.key, false, + parentKey); this._datasetResearchService.triggerSearchChange(); } diff --git a/src/app/datasets/components/index.ts b/src/app/datasets/components/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c4188fe63396f1a54648e3bbc49f51816aebb7c --- /dev/null +++ b/src/app/datasets/components/index.ts @@ -0,0 +1,23 @@ +import { FilterDetailComponent } from './filter-list/filter-detail/filter-detail.component'; +import { FilterListComponent } from './filter-list/filter-list.component'; +import { ResultDatasetComponent } from './results/result-dataset/result-dataset.component'; +import { ResultPostComponent } from './results/result-post/result-post.component'; +import { ResultsTabScopeComponent } from './results/results-tab-scope/results-tab-scope.component'; +import { ResultsComponent } from './results/results.component'; +// tslint:disable-next-line:max-line-length +import { SearchBarComponent } from './search-bar/search-bar.component'; +import { SortComponent } from './sort/sort.component'; + +export { ResultsComponent, SearchBarComponent, SortComponent, FilterListComponent, FilterDetailComponent, ResultDatasetComponent, ResultsTabScopeComponent, ResultPostComponent }; + +// tslint:disable-next-line:variable-name +export const DatasetsComponents = [ + ResultsComponent, + SearchBarComponent, + SortComponent, + FilterListComponent, + FilterDetailComponent, + ResultDatasetComponent, + ResultsTabScopeComponent, + ResultPostComponent, +]; diff --git a/src/app/geosource/components/results/result-dataset/result-dataset.component.html b/src/app/datasets/components/results/result-dataset/result-dataset.component.html similarity index 100% rename from src/app/geosource/components/results/result-dataset/result-dataset.component.html rename to src/app/datasets/components/results/result-dataset/result-dataset.component.html diff --git a/src/app/geosource/components/results/result-dataset/result-dataset.component.scss b/src/app/datasets/components/results/result-dataset/result-dataset.component.scss similarity index 100% rename from src/app/geosource/components/results/result-dataset/result-dataset.component.scss rename to src/app/datasets/components/results/result-dataset/result-dataset.component.scss diff --git a/src/app/geosource/components/results/result-dataset/result-dataset.component.spec.ts b/src/app/datasets/components/results/result-dataset/result-dataset.component.spec.ts similarity index 100% rename from src/app/geosource/components/results/result-dataset/result-dataset.component.spec.ts rename to src/app/datasets/components/results/result-dataset/result-dataset.component.spec.ts diff --git a/src/app/geosource/components/results/result-dataset/result-dataset.component.ts b/src/app/datasets/components/results/result-dataset/result-dataset.component.ts similarity index 90% rename from src/app/geosource/components/results/result-dataset/result-dataset.component.ts rename to src/app/datasets/components/results/result-dataset/result-dataset.component.ts index 14f9cb607ab71de60ec6eb5647b2f975dc64d564..5fa41dd5eb77e7f400ea72d4553320a4dcea2c5e 100644 --- a/src/app/geosource/components/results/result-dataset/result-dataset.component.ts +++ b/src/app/datasets/components/results/result-dataset/result-dataset.component.ts @@ -1,8 +1,7 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { Dataset } from '../../../models'; -import { AppRoutes } from '../../../../routes'; +import { Component, Input, OnInit } from '@angular/core'; import { geosource } from '../../../../../i18n/traductions'; -import { typesMetadata } from '../../../models/metadata.model'; +import { AppRoutes } from '../../../../routes'; +import { Dataset, typesMetadata } from '../../../../shared/models'; @Component({ selector: 'app-result-dataset', diff --git a/src/app/geosource/components/results/result-post/result-post.component.html b/src/app/datasets/components/results/result-post/result-post.component.html similarity index 100% rename from src/app/geosource/components/results/result-post/result-post.component.html rename to src/app/datasets/components/results/result-post/result-post.component.html diff --git a/src/app/geosource/components/results/result-post/result-post.component.scss b/src/app/datasets/components/results/result-post/result-post.component.scss similarity index 100% rename from src/app/geosource/components/results/result-post/result-post.component.scss rename to src/app/datasets/components/results/result-post/result-post.component.scss diff --git a/src/app/geosource/components/results/result-post/result-post.component.ts b/src/app/datasets/components/results/result-post/result-post.component.ts similarity index 100% rename from src/app/geosource/components/results/result-post/result-post.component.ts rename to src/app/datasets/components/results/result-post/result-post.component.ts diff --git a/src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.html b/src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.html similarity index 100% rename from src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.html rename to src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.html diff --git a/src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.scss b/src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.scss similarity index 100% rename from src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.scss rename to src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.scss diff --git a/src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.spec.ts b/src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.spec.ts similarity index 100% rename from src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.spec.ts rename to src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.spec.ts diff --git a/src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.ts b/src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.ts similarity index 71% rename from src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.ts rename to src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.ts index a5582a5663c9ac398edd5bddfdaf7f07d3cf84ab..a3d33cb2bbb60881fb6de0d92d0a057cb848024d 100644 --- a/src/app/geosource/components/results/results-tab-scope/results-tab-scope.component.ts +++ b/src/app/datasets/components/results/results-tab-scope/results-tab-scope.component.ts @@ -1,6 +1,6 @@ -import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core'; -import { scopesResearch } from '../../../models/scopes-research'; -import { IScope } from '../../../models/elasticsearch-options.model'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { IScope } from '../../../../elasticsearch/models'; +import { scopesResearch } from '../../../../shared/variables'; @Component({ selector: 'app-results-tab-scope', diff --git a/src/app/geosource/components/results/results.component.html b/src/app/datasets/components/results/results.component.html similarity index 100% rename from src/app/geosource/components/results/results.component.html rename to src/app/datasets/components/results/results.component.html diff --git a/src/app/geosource/components/results/results.component.scss b/src/app/datasets/components/results/results.component.scss similarity index 100% rename from src/app/geosource/components/results/results.component.scss rename to src/app/datasets/components/results/results.component.scss diff --git a/src/app/geosource/components/results/results.component.ts b/src/app/datasets/components/results/results.component.ts similarity index 93% rename from src/app/geosource/components/results/results.component.ts rename to src/app/datasets/components/results/results.component.ts index bf783d22f9f54f65ebcaffbae782a0d7fbe5b730..8024a2aa4f9adfa90fc505ebe1f5518e7126359c 100644 --- a/src/app/geosource/components/results/results.component.ts +++ b/src/app/datasets/components/results/results.component.ts @@ -1,16 +1,15 @@ -import { Component, OnInit, OnDestroy } from '@angular/core'; -import { DatasetResearchService } from '../../services'; -import { Dataset, IMetadataLink, SearchSuggestion } from '../../models'; +import { DatePipe, ViewportScroller } from '@angular/common'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { Subscription } from 'rxjs'; -import { PaginatorOptions } from '../../../shared/models'; -import { AppRoutes } from '../../../routes'; -import { NotificationService } from '../../../core/services'; import { Notification } from '../../../core/models'; -import { DatePipe, ViewportScroller } from '@angular/common'; +import { NotificationService } from '../../../core/services'; import { MatomoService } from '../../../core/services/matomo.service'; import { CMSContent } from '../../../editorialisation/models'; -import { scopesResearch } from '../../models/scopes-research'; -import { IScope, ICountScope } from '../../models/elasticsearch-options.model'; +import { IScope } from '../../../elasticsearch/models'; +import { AppRoutes } from '../../../routes'; +import { Dataset, IMetadataLink, PaginatorOptions } from '../../../shared/models'; +import { SearchSuggestion } from '../../models'; +import { DatasetResearchService } from '../../services'; @Component({ selector: 'app-results', diff --git a/src/app/geosource/components/search-bar/search-bar.component.html b/src/app/datasets/components/search-bar/search-bar.component.html similarity index 100% rename from src/app/geosource/components/search-bar/search-bar.component.html rename to src/app/datasets/components/search-bar/search-bar.component.html diff --git a/src/app/geosource/components/search-bar/search-bar.component.scss b/src/app/datasets/components/search-bar/search-bar.component.scss similarity index 100% rename from src/app/geosource/components/search-bar/search-bar.component.scss rename to src/app/datasets/components/search-bar/search-bar.component.scss diff --git a/src/app/geosource/components/search-bar/search-bar.component.spec.ts b/src/app/datasets/components/search-bar/search-bar.component.spec.ts similarity index 91% rename from src/app/geosource/components/search-bar/search-bar.component.spec.ts rename to src/app/datasets/components/search-bar/search-bar.component.spec.ts index 57189c13197f95a2ada32d3d3c686ee6e473df6c..d0cd5e281f8c7668e0b2047f443073517c9f8af2 100644 --- a/src/app/geosource/components/search-bar/search-bar.component.spec.ts +++ b/src/app/datasets/components/search-bar/search-bar.component.spec.ts @@ -1,4 +1,4 @@ -import { ElasticsearchService } from '../../services/elasticsearch.service'; + import { DatasetResearchService } from '../../services'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; @@ -8,6 +8,7 @@ import { FormsModule } from '@angular/forms'; import { HttpClientModule } from '@angular/common/http'; import { ErrorService, NotificationService } from '../../../core/services'; import { StorageService } from '../../../core/services/storage.service'; +import { ElasticsearchService } from '../../../elasticsearch/services/elasticsearch.service'; describe('SearchBarComponent', () => { let component: SearchBarComponent; @@ -31,7 +32,7 @@ describe('SearchBarComponent', () => { NotificationService, ], }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { diff --git a/src/app/geosource/components/search-bar/search-bar.component.ts b/src/app/datasets/components/search-bar/search-bar.component.ts similarity index 95% rename from src/app/geosource/components/search-bar/search-bar.component.ts rename to src/app/datasets/components/search-bar/search-bar.component.ts index d6e6348da49080b7b62446ddcf5aa366e198f094..5a72df483fab8c0b2daa873b7702e1f090cd98ec 100644 --- a/src/app/geosource/components/search-bar/search-bar.component.ts +++ b/src/app/datasets/components/search-bar/search-bar.component.ts @@ -1,11 +1,11 @@ -import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core'; -import { DatasetResearchService } from '../../services'; -import { SearchCompletion } from '../../models'; -import { debounceTime } from 'rxjs/operators'; -import { Subject } from 'rxjs'; import { ViewportScroller } from '@angular/common'; -import { IScope } from '../../models/elasticsearch-options.model'; +import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; +import { Subject } from 'rxjs'; +import { debounceTime } from 'rxjs/operators'; import { geosource } from '../../../../i18n/traductions'; +import { IScope } from '../../../elasticsearch/models'; +import { SearchCompletion } from '../../models'; +import { DatasetResearchService } from '../../services'; @Component({ selector: 'app-search-bar', @@ -124,7 +124,7 @@ export class SearchBarComponent implements OnInit { requestAutocomplete() { // tslint:disable-next-line:max-line-length - this._datasetResearchService.getAutoComplete(this.searchValue, this._datasetResearchService.scopeReasearch).subscribe( + this._datasetResearchService.getAutoComplete(this.searchValue).subscribe( (res) => { this.optionsAutocomplete = res; }, diff --git a/src/app/geosource/components/sort/sort.component.html b/src/app/datasets/components/sort/sort.component.html similarity index 100% rename from src/app/geosource/components/sort/sort.component.html rename to src/app/datasets/components/sort/sort.component.html diff --git a/src/app/geosource/components/sort/sort.component.scss b/src/app/datasets/components/sort/sort.component.scss similarity index 100% rename from src/app/geosource/components/sort/sort.component.scss rename to src/app/datasets/components/sort/sort.component.scss diff --git a/src/app/geosource/components/sort/sort.component.spec.ts b/src/app/datasets/components/sort/sort.component.spec.ts similarity index 100% rename from src/app/geosource/components/sort/sort.component.spec.ts rename to src/app/datasets/components/sort/sort.component.spec.ts diff --git a/src/app/geosource/components/sort/sort.component.ts b/src/app/datasets/components/sort/sort.component.ts similarity index 100% rename from src/app/geosource/components/sort/sort.component.ts rename to src/app/datasets/components/sort/sort.component.ts diff --git a/src/app/datasets/datasets-routing.module.ts b/src/app/datasets/datasets-routing.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..05924ac3fdadfe22a400b0339a535b6c476e106e --- /dev/null +++ b/src/app/datasets/datasets-routing.module.ts @@ -0,0 +1,28 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { AppRoutes } from '../routes'; +import { ResultsComponent } from './components'; + +export const routes: Routes = [ + { + path: AppRoutes.research.uri, + component: ResultsComponent, + data: { + title: AppRoutes.research.title, + }, + }, + { + path: 'datasets/:id', + redirectTo: `${AppRoutes.datasets.uri}/:id`, + }, + { + path: `${AppRoutes.datasets.uri}/:id`, + loadChildren: '../dataset-detail/dataset-detail.module#DatasetDetailModule', + }, +]; + +@NgModule({ + exports: [RouterModule], + imports: [RouterModule.forChild(routes)], +}) +export class DatasetsRoutingModule { } diff --git a/src/app/datasets/datasets.module.ts b/src/app/datasets/datasets.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..bbfa95e0aa0f65170f8c18bb8fcf608bf41db675 --- /dev/null +++ b/src/app/datasets/datasets.module.ts @@ -0,0 +1,24 @@ +import { CommonModule, DatePipe } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { ElasticsearchModule } from '../elasticsearch/elasticsearch.module'; +import { SharedModule } from '../shared/shared.module'; +import { DatasetsComponents, SearchBarComponent } from './components'; +import { DatasetsRoutingModule } from './datasets-routing.module'; +import { DatasetsServices } from './services'; + +@NgModule({ + declarations: [...DatasetsComponents], + exports: [ + SearchBarComponent, + ], + imports: [ + CommonModule, + DatasetsRoutingModule, + ElasticsearchModule, + SharedModule, + FormsModule, + ], + providers: [...DatasetsServices, DatePipe], +}) +export class DatasetsModule { } diff --git a/src/app/datasets/models/index.ts b/src/app/datasets/models/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..6963e979a70bfc1097b0f85e853bf56969dc85ee --- /dev/null +++ b/src/app/datasets/models/index.ts @@ -0,0 +1,3 @@ +export { SearchCompletion } from './search-completion.model'; +export { SearchSuggestion } from './suggestion.model'; + diff --git a/src/app/geosource/models/search-completion.model.ts b/src/app/datasets/models/search-completion.model.ts similarity index 100% rename from src/app/geosource/models/search-completion.model.ts rename to src/app/datasets/models/search-completion.model.ts diff --git a/src/app/geosource/models/suggestion.model.ts b/src/app/datasets/models/suggestion.model.ts similarity index 100% rename from src/app/geosource/models/suggestion.model.ts rename to src/app/datasets/models/suggestion.model.ts diff --git a/src/app/geosource/services/dataset-research.service.ts b/src/app/datasets/services/dataset-research.service.ts similarity index 88% rename from src/app/geosource/services/dataset-research.service.ts rename to src/app/datasets/services/dataset-research.service.ts index 31b8e93459344150384f660dff4064226ca5f1eb..635a1ddcb9c9b8dd41ffce0094d179a63eabdb7e 100644 --- a/src/app/geosource/services/dataset-research.service.ts +++ b/src/app/datasets/services/dataset-research.service.ts @@ -1,21 +1,19 @@ import { Injectable } from '@angular/core'; - +import { Router } from '@angular/router'; +import { Angulartics2Piwik } from 'angulartics2/piwik'; import { Observable, Subject } from 'rxjs'; - -import { - ISortOption, ElasticsearchOptions, IElasticsearchHit, Dataset, Highlights, - SearchCompletion, SearchSuggestion, -} from '../models'; -import { ElasticsearchService } from './elasticsearch.service'; -import { map, catchError, tap } from 'rxjs/operators'; -import { notificationMessages, geosource } from '../../../i18n/traductions'; +import { catchError, map, tap } from 'rxjs/operators'; +import { geosource, notificationMessages } from '../../../i18n/traductions'; import { ErrorService } from '../../core/services'; -import { Aggregation, Filter } from '../models/filter.model'; import { CMSContent } from '../../editorialisation/models'; -import { IScope, ICountScope } from '../models/elasticsearch-options.model'; -import { scopesResearch } from '../models/scopes-research'; import { IESCMSResponse } from '../../editorialisation/models/cms-content.model'; -import { Angulartics2Piwik } from 'angulartics2/piwik'; +// tslint:disable-next-line: max-line-length +import { Aggregation, ElasticsearchOptions, Filter, ICountScope, IElasticsearchHit, IScope, ISortOption } from '../../elasticsearch/models'; +import { ElasticsearchService } from '../../elasticsearch/services/elasticsearch.service'; +import { AppRoutes } from '../../routes'; +import { Dataset, Highlights } from '../../shared/models'; +import { scopesResearch } from '../../shared/variables'; +import { SearchCompletion, SearchSuggestion } from '../models'; @Injectable() export class DatasetResearchService { @@ -32,6 +30,7 @@ export class DatasetResearchService { private _errorService: ErrorService, private _elasticsearchService: ElasticsearchService, private angulartics2Piwik: Angulartics2Piwik, + private _router: Router, ) { this._searchChangeSubject = new Subject<any>(); this._datasetsReloadedSubject = new Subject<any>(); @@ -412,13 +411,53 @@ export class DatasetResearchService { this._elasticsearchOptions.shouldAggregateResultCount = true; } - getAutoComplete(text: string, scope?: IScope): Observable<SearchCompletion[]> { - return this._elasticsearchService.getAutoComplete(text); + getAutoComplete(text: string): Observable<SearchCompletion[]> { + const options: SearchCompletion[] = []; + return this._elasticsearchService.getAutoComplete(text).pipe( + map((e) => { + // We will loop over all the hits, look if an highlight have been found, + // and if yes, we add the first one to our autocompletion options list. + const searchOption = {}; + if (e['hits']['hits']) { + e['hits']['hits'].forEach((hit) => { + searchOption['id'] = hit._id; + searchOption['_index'] = hit._index; + searchOption['_score'] = hit._score; + const highlight = hit['highlight']; + if (highlight) { + Object.keys(highlight).forEach((key, index) => { + // We check if this text highlight already exists in the options array + // We want a unique text in the list, no duplicata. + const found = options.some((el) => { + return el.text === highlight[key][0]; + }); + if (!found && options.length < 5) { + searchOption['text'] = highlight[key][0]; + options.push(new SearchCompletion(searchOption)); + } + }); + } + + }); + } + return options; + }), + ); } getSuggestion(query: string): Observable<SearchSuggestion> { this._pendingRequests += 1; return this._elasticsearchService.getSuggestion(query).pipe( + map((res) => { + const suggestions = res.suggest['suggestion'][0].options; + let suggestion: SearchSuggestion; + if (suggestions && suggestions.length > 0) { + suggestion = new SearchSuggestion(suggestions[0]); + } else { + suggestion = new SearchSuggestion(); + } + return suggestion; + }), tap(() => { this._pendingRequests -= 1; }), @@ -430,6 +469,9 @@ export class DatasetResearchService { this._elasticsearchOptions.searchString = value; this._elasticsearchOptions.pageIndex = 0; this._elasticsearchOptions.shouldAggregateResultCount = true; + if (this._router.url.split('/').pop() !== AppRoutes.research.uri) { + this._router.navigate(['/', AppRoutes.research.uri]); + } this._searchChangeSubject.next(); } diff --git a/src/app/datasets/services/index.ts b/src/app/datasets/services/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..181021dcf02a8f9a01c724706e826b94bbae624d --- /dev/null +++ b/src/app/datasets/services/index.ts @@ -0,0 +1,8 @@ +import { DatasetResearchService } from './dataset-research.service'; + +export { DatasetResearchService }; + +// tslint:disable-next-line:variable-name +export const DatasetsServices = [ + DatasetResearchService, +]; diff --git a/src/app/editorialisation/components/cms-post-detail/cms-post-detail.component.ts b/src/app/editorialisation/components/cms-post-detail/cms-post-detail.component.ts index c04ec94d7b611a984a33ab7aad5785762927df71..d0be587cbc8d124e0bebea450695c676197fe18b 100644 --- a/src/app/editorialisation/components/cms-post-detail/cms-post-detail.component.ts +++ b/src/app/editorialisation/components/cms-post-detail/cms-post-detail.component.ts @@ -1,14 +1,12 @@ +import { DatePipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; +import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; -import { SafeHtml, DomSanitizer } from '@angular/platform-browser'; -import { CMSContent } from '../../models/cms-content.model'; -import { IPageHeaderInfo } from '../../../shared/models'; -import { DatePipe } from '@angular/common'; import { notificationMessages } from '../../../../i18n/traductions'; +import { ElasticsearchService } from '../../../elasticsearch/services/elasticsearch.service'; import { AppRoutes } from '../../../routes'; -import { ElasticsearchService } from '../../../geosource/services'; -import { Metadata } from '../../../geosource/models'; -import { typesMetadata } from '../../../geosource/models/metadata.model'; +import { IPageHeaderInfo, Metadata, typesMetadata } from '../../../shared/models'; +import { CMSContent } from '../../models/cms-content.model'; @Component({ selector: 'app-cms-post-detail', diff --git a/src/app/editorialisation/components/cms-posts-list/cms-drafts-list.component.ts b/src/app/editorialisation/components/cms-posts-list/cms-drafts-list.component.ts index 9ebb6703b8dedacc071869d551e45caedc3280e2..d18fc6a30077b32a4d7501094c3607623e941d0a 100644 --- a/src/app/editorialisation/components/cms-posts-list/cms-drafts-list.component.ts +++ b/src/app/editorialisation/components/cms-posts-list/cms-drafts-list.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; -import { ElasticsearchService } from '../../../geosource/services'; import { AppRoutes } from '../../../routes'; import { CMSContent, IESCMSResponse } from '../../models/cms-content.model'; +import { ElasticsearchService } from '../../../elasticsearch/services/elasticsearch.service'; @Component({ selector: 'app-cms-drafts-list', diff --git a/src/app/editorialisation/components/home/home.component.spec.ts b/src/app/editorialisation/components/home/home.component.spec.ts deleted file mode 100644 index a7267f4eb625f456b347b9b948719f21ff9e3d81..0000000000000000000000000000000000000000 --- a/src/app/editorialisation/components/home/home.component.spec.ts +++ /dev/null @@ -1,188 +0,0 @@ -// import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing'; - -// import { HomeComponent } from './home.component'; -// import { ActivatedRoute, Router } from '@angular/router'; -// import { DebugElement } from '@angular/core'; -// import { MockComponent } from 'ng2-mock-component'; -// import { EscapeHtmlPipe } from '../../../shared/pipes/keep-html.pipe'; -// import { CMSPost, IGhostPostResponse } from '../../models'; -// import { of } from 'rxjs'; -// import { ElasticsearchService, DatasetResearchService } from '../../../geosource/services'; -// import { IElasticsearchResponse } from '../../../geosource/models'; -// import { IPostsESOptions } from '../../../geosource/models/elasticsearch-options.model'; -// import { RouterTestingModule } from '@angular/router/testing'; -// import { ErrorService, NotificationService } from '../../../core/services'; -// import { StorageService } from '../../../core/services/storage.service'; -// import { HttpClient, HttpClientModule } from '@angular/common/http'; - -// describe('HomeComponent', () => { -// describe('Template', () => { -// let component: HomeComponent; -// let fixture: ComponentFixture<HomeComponent>; -// let debugElement: DebugElement; - -// beforeEach(async(() => { -// TestBed.configureTestingModule({ -// declarations: [ -// HomeComponent, -// MockComponent({ selector: 'app-search-bar', inputs: ['searchOnChangeScope'] }), -// EscapeHtmlPipe, -// ], -// imports: [ -// RouterTestingModule, -// HttpClientModule, -// ], -// providers: [ -// { -// provide: ActivatedRoute, -// useValue: { -// snapshot: { -// data: { -// posts: null, -// videoPost: {}, -// }, -// }, -// }, -// }, -// ElasticsearchService, -// ErrorService, -// NotificationService, -// DatasetResearchService, -// StorageService, -// ], -// }).compileComponents(); -// })); - -// beforeEach(() => { -// fixture = TestBed.createComponent(HomeComponent); -// component = fixture.componentInstance; -// debugElement = fixture.debugElement; -// fixture.detectChanges(); -// }); - -// it('should create', () => { -// expect(component).toBeTruthy(); -// }); - -// }); - -// describe('Component.ts', () => { -// let component: HomeComponent; -// let activatedRouteMock: ActivatedRoute; -// let elasticSearchServiceMock: ElasticsearchService; -// let datasetResearchServiceMock: DatasetResearchService; -// const routerMock = { - -// } as Router; - -// const elasticResponseMock = { -// hits: { -// hits: [{ -// _source: {}, -// }], -// }, -// }; - -// const post = new CMSPost( -// { -// uuid: '1', -// title: 'test post', -// status: 'published', -// categories: [], -// tags: [], -// publicationDate: '2018-05-02T08:58:09', -// modificationDate: '2018-05-02T08:58:09', -// content: 'Post content', -// featuredMedia: 'url', -// excerpt: '', -// author: '', -// }); - -// const iESPost = { -// uuid: '1', -// title: 'test post', -// status: 'published', -// categories: [], -// tags: [], -// modificationDate: '2018-05-02T08:58:09', -// publicationDate: '2018-05-02T08:58:09', -// content: 'Post content', -// featuredMedia: 'url', -// excerpt: '', -// author: '', -// } as IGhostPostResponse; - -// beforeEach(() => { -// elasticSearchServiceMock = { -// getLatestDatasets: (size?: number) => { -// return of(elasticResponseMock as IElasticsearchResponse); -// }, -// getPosts: (options?: IPostsESOptions) => { -// return of(elasticResponseMock as IElasticsearchResponse); -// }, -// } as ElasticsearchService; - -// datasetResearchServiceMock = { -// resetResearch: (trigger?: boolean) => { -// const value = trigger; -// }, -// } as DatasetResearchService; - -// activatedRouteMock = { -// pathFromRoot: null, -// children: [], -// firstChild: null, -// parent: null, -// root: null, -// routeConfig: {}, -// component: '', -// outlet: '', -// data: of([]), -// fragment: of(null), -// queryParams: of(null), -// queryParamMap: of(null), -// params: of(null), -// paramMap: null, -// url: of(null), -// snapshot: { -// data: { -// posts: [post], -// videoPost: post, -// }, -// pathFromRoot: null, -// children: [], -// firstChild: null, -// parent: null, -// root: null, -// routeConfig: {}, -// component: '', -// outlet: '', -// fragment: '', -// queryParams: of(null), -// queryParamMap: null, -// params: of(null), -// paramMap: null, -// url: [], -// }, -// }; -// }); - -// describe('ngOnInit()', () => { -// it('should initialize component\'s variables', () => { -// // Given -// // Given -// elasticResponseMock.hits.hits[0]._source = iESPost; -// component = new HomeComponent( -// activatedRouteMock, elasticSearchServiceMock, -// datasetResearchServiceMock, routerMock); - -// // When -// component.ngOnInit(); - -// // Then -// expect(component.latestPosts.length).toBe(1); -// expect(component.latestPosts[0]).toEqual(post); -// }); -// }); -// }); -// }); diff --git a/src/app/editorialisation/components/home/home.component.ts b/src/app/editorialisation/components/home/home.component.ts index 8991a5659666e2003c8541f4c5ccbb567681b777..ad49495174ca9ac422e15a37911e572fcaaf89de 100644 --- a/src/app/editorialisation/components/home/home.component.ts +++ b/src/app/editorialisation/components/home/home.component.ts @@ -1,15 +1,16 @@ import { Component, OnInit } from '@angular/core'; -import { CMSContent, IESCMSResponse } from '../../models/cms-content.model'; import { Router } from '@angular/router'; -import { ElasticsearchService, DatasetResearchService } from '../../../geosource/services'; -import { AppRoutes } from '../../../routes'; -import { scopesResearch } from '../../../geosource/models/scopes-research'; -import { environment } from '../../../../environments/environment'; +import { Angulartics2Piwik } from 'angulartics2/piwik'; import { forkJoin } from 'rxjs/internal/observable/forkJoin'; -import { NotificationService } from '../../../core/services'; -import { Notification } from '../../../core/models'; +import { environment } from '../../../../environments/environment'; import { notificationMessages } from '../../../../i18n/traductions'; -import { Angulartics2Piwik } from 'angulartics2/piwik'; +import { Notification } from '../../../core/models'; +import { NotificationService } from '../../../core/services'; +import { DatasetResearchService } from '../../../datasets/services'; +import { ElasticsearchService } from '../../../elasticsearch/services/elasticsearch.service'; +import { AppRoutes } from '../../../routes'; +import { scopesResearch } from '../../../shared/variables'; +import { CMSContent, IESCMSResponse } from '../../models/cms-content.model'; @Component({ selector: 'app-home', diff --git a/src/app/editorialisation/components/organizations/organizations.component.ts b/src/app/editorialisation/components/organizations/organizations.component.ts index 793a8fe2fd1600267f71dc4641483fd38c69ff1d..ed2860174d8b8b4bf5df1fe87d5d48941749c248 100644 --- a/src/app/editorialisation/components/organizations/organizations.component.ts +++ b/src/app/editorialisation/components/organizations/organizations.component.ts @@ -1,14 +1,16 @@ import { Component, OnInit } from '@angular/core'; -import { OrganizationsService } from '../../services/organizations.service'; -import { Organization } from '../../models'; -import { ElasticsearchService, DatasetResearchService } from '../../../geosource/services'; import { Router } from '@angular/router'; +import { map, mergeMap, tap } from 'rxjs/operators'; +import { notificationMessages, pageTitles } from '../../../../i18n/traductions'; +import { NotificationService } from '../../../core/services'; +import { DatasetResearchService } from '../../../datasets/services'; +import { Aggregation } from '../../../elasticsearch/models'; +import { ElasticsearchService } from '../../../elasticsearch/services/elasticsearch.service'; import { AppRoutes } from '../../../routes'; -import { Aggregation } from '../../../geosource/models/filter.model'; -import { scopesResearch } from '../../../geosource/models/scopes-research'; import { IPageHeaderInfo } from '../../../shared/models'; -import { pageTitles, notificationMessages } from '../../../../i18n/traductions'; -import { NotificationService } from '../../../core/services'; +import { scopesResearch } from '../../../shared/variables'; +import { Organization } from '../../models'; +import { OrganizationsService } from '../../services/organizations.service'; @Component({ selector: 'app-organizations', @@ -31,27 +33,34 @@ export class OrganizationsComponent implements OnInit { ) { } ngOnInit() { - this._organizationsService.getOrganizations().subscribe( - (organizations) => { + this._organizationsService.getOrganizations().pipe( + tap((organizations) => { this.organizations = organizations; + }), + mergeMap(() => { + return this._elasticSearchService.getNumberDatasetsByOrganization().pipe( + map((e) => { + const aggregations = e.aggregations['nested_agg']['organisationName'].buckets; + return aggregations; + }), + ); + }), + ).subscribe( + (aggregations) => { + aggregations.forEach((aggregation: Aggregation) => { + this.organizations.forEach((organization) => { + if (aggregation.key === organization.elasticSearchName) { + const aggregationsType = aggregation['scope']['type_agg'].buckets; - this._elasticSearchService.getNumberDatasetsByOrganization().subscribe((aggregations) => { - aggregations.forEach((aggregation: Aggregation) => { - this.organizations.forEach((organization) => { - if (aggregation.key === organization.elasticSearchName) { - const aggregationsType = aggregation['scope']['type_agg'].buckets; - - aggregationsType.forEach((type) => { - if (type.key === scopesResearch.services.key) { - organization.servicesCount += type['count_per_metadata']['cid'].value; - - } else { - organization.datasetsCount += type['count_per_metadata']['cid'].value; + aggregationsType.forEach((type) => { + if (type.key === scopesResearch.services.key) { + organization.servicesCount += type['count_per_metadata']['cid'].value; - } - }); - } - }); + } else { + organization.datasetsCount += type['count_per_metadata']['cid'].value; + } + }); + } }); }); }, diff --git a/src/app/editorialisation/components/reuse-detail/reuse-detail.component.ts b/src/app/editorialisation/components/reuse-detail/reuse-detail.component.ts index e6da59e0d60893f564f364d9f02177add5fa6859..de0c98ecf878d084484d4e56477eb86c4f78e133 100644 --- a/src/app/editorialisation/components/reuse-detail/reuse-detail.component.ts +++ b/src/app/editorialisation/components/reuse-detail/reuse-detail.component.ts @@ -1,14 +1,12 @@ import { Component, OnInit } from '@angular/core'; -import { IPageHeaderInfo } from '../../../shared/models'; -import { ReusesService } from '../../services'; -import { filter, switchMap, map } from 'rxjs/operators'; -import { ParamMap, ActivatedRoute } from '@angular/router'; -import { IReuse, Reuse } from '../../models'; -import { ElasticsearchService } from '../../../geosource/services'; -import { Metadata, IElasticsearchResponse } from '../../../geosource/models'; -import { typesMetadata } from '../../../geosource/models/metadata.model'; +import { ActivatedRoute, ParamMap } from '@angular/router'; import { forkJoin } from 'rxjs'; +import { filter, map, switchMap } from 'rxjs/operators'; +import { ElasticsearchService } from '../../../elasticsearch/services/elasticsearch.service'; import { AppRoutes } from '../../../routes'; +import { IPageHeaderInfo, Metadata, typesMetadata } from '../../../shared/models'; +import { Reuse } from '../../models'; +import { ReusesService } from '../../services'; @Component({ selector: 'app-reuse-detail', diff --git a/src/app/editorialisation/editorialisation.module.ts b/src/app/editorialisation/editorialisation.module.ts index e8be70b5032b11442f4b69880cf3a99001f69cb9..08d16c1542ead29e39a9a89ae685d2b53d200af6 100644 --- a/src/app/editorialisation/editorialisation.module.ts +++ b/src/app/editorialisation/editorialisation.module.ts @@ -1,18 +1,20 @@ -import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { EditorialisationRoutingModule } from './editorialisation-routing.module'; +import { NgModule } from '@angular/core'; +import { intersectionObserverPreset, LazyLoadImageModule } from 'ng-lazyload-image'; +import { DatasetsModule } from '../datasets/datasets.module'; +import { ElasticsearchModule } from '../elasticsearch/elasticsearch.module'; +import { SharedModule } from '../shared/shared.module'; import { EditorialisationComponents } from './components'; -import { EditorialisationServices } from './services'; +import { EditorialisationRoutingModule } from './editorialisation-routing.module'; import { EditorialisationResolvers } from './resolvers'; -import { SharedModule } from '../shared/shared.module'; -import { GeosourceModule } from '../geosource/geosource.module'; -import { LazyLoadImageModule, intersectionObserverPreset } from 'ng-lazyload-image'; +import { EditorialisationServices } from './services'; @NgModule({ imports: [ CommonModule, + ElasticsearchModule, + DatasetsModule, EditorialisationRoutingModule, - GeosourceModule.forRoot(), SharedModule, LazyLoadImageModule.forRoot({ preset: intersectionObserverPreset, diff --git a/src/app/editorialisation/services/editorialisation.service.ts b/src/app/editorialisation/services/editorialisation.service.ts index 18397755647ef1ce10abde024dae509226e8ab2e..5892b6f2f14800f6b44eba878d60bdde36a05837 100644 --- a/src/app/editorialisation/services/editorialisation.service.ts +++ b/src/app/editorialisation/services/editorialisation.service.ts @@ -1,15 +1,12 @@ -import { Observable } from 'rxjs'; -import { map, catchError } from 'rxjs/operators'; import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { catchError, map } from 'rxjs/operators'; import { environment } from '../../../environments/environment'; -import { HttpClient } from '@angular/common/http'; -import { - CMSContent, IGhostContentResponse, IESCMSResponse, -} from '../models/cms-content.model'; -import { ErrorService } from '../../core/services'; import { notificationMessages } from '../../../i18n/traductions'; -import { ElasticsearchService } from '../../geosource/services'; +import { ErrorService } from '../../core/services'; +import { ElasticsearchService } from '../../elasticsearch/services/elasticsearch.service'; +import { CMSContent, IESCMSResponse } from '../models/cms-content.model'; @Injectable() export class EditorialisationService { @@ -38,26 +35,6 @@ export class EditorialisationService { ); } - /* - * Get the list of cms posts. - */ - getPostsList(): Observable<CMSContent[]> { - return this._elasticSearchService.getWPPosts().pipe( - map((res) => { - const postsList = []; - const resultHits = res.hits.hits; - resultHits.forEach((hit) => { - const wpResponse = hit._source as IESCMSResponse; - postsList.push(new CMSContent(wpResponse)); - }); - return postsList; - }), - catchError((error) => { - throw this._errorService.handleError(error, { message: notificationMessages.edito.getPosts }); - }), - ); - } - getPostBySlug(slug: string): Observable<CMSContent> { return this._elasticSearchService.getPosts({ slug }).pipe( map((res) => { diff --git a/src/app/elasticsearch/elasticsearch.module.ts b/src/app/elasticsearch/elasticsearch.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a0e63295c6ea6cc43bf1f0b937ab93025c27c03 --- /dev/null +++ b/src/app/elasticsearch/elasticsearch.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { ElasticsearchService } from './services/elasticsearch.service'; + +@NgModule({ + declarations: [], + imports: [ + CommonModule, + ], + providers: [ + ElasticsearchService, + ], +}) +export class ElasticsearchModule { } diff --git a/src/app/geosource/models/elasticsearch-options.model.ts b/src/app/elasticsearch/models/elasticsearch-options.model.ts similarity index 86% rename from src/app/geosource/models/elasticsearch-options.model.ts rename to src/app/elasticsearch/models/elasticsearch-options.model.ts index 6f39e433a44dbe5a2c01e8687c072316cd78fa22..3ccb0eb60f8a40c4637c407ac6c24b848d37d459 100644 --- a/src/app/geosource/models/elasticsearch-options.model.ts +++ b/src/app/elasticsearch/models/elasticsearch-options.model.ts @@ -1,7 +1,7 @@ import { geosource } from '../../../i18n/traductions'; -import { scopesResearch } from './scopes-research'; -import { ISortOption } from './sort-option.model'; +import { scopesResearch } from '../../shared/variables'; import { Filter } from './filter.model'; +import { ISortOption } from './sort-option.model'; export interface IPostsESOptions { type?: string; @@ -25,31 +25,31 @@ export interface IScope { } export interface IElasticsearchOptions { - 'pageIndex'?: number; - 'from'?: number; - 'pageSize'?: number; - 'sortOptions'?: ISortOption; - 'searchString'?: string; - 'filters'?: Filter[]; - 'shouldAggregateResultCount': boolean; - 'shouldAggregateFilters': boolean; - 'scope': IScope; - 'useCache': boolean; + pageIndex?: number; + from?: number; + pageSize?: number; + sortOptions?: ISortOption; + searchString?: string; + filters?: Filter[]; + shouldAggregateResultCount: boolean; + shouldAggregateFilters: boolean; + scope: IScope; + useCache: boolean; } export class ElasticsearchOptions { - '_pageIndex': number; - 'from'?: number; - '_pageSize': number; - '_sortOptions': ISortOption; - '_searchString': string; - '_filters': Filter[]; - 'shouldAggregateResultCount': boolean; - 'shouldAggregateFilters': boolean; - 'fromAutocompletion': boolean; - 'scope': IScope; - 'useCache': boolean; - 'otherLicenceAggregations': string[]; + _pageIndex: number; + from?: number; + _pageSize: number; + _sortOptions: ISortOption; + _searchString: string; + _filters: Filter[]; + shouldAggregateResultCount: boolean; + shouldAggregateFilters: boolean; + fromAutocompletion: boolean; + scope: IScope; + useCache: boolean; + otherLicenceAggregations: string[]; constructor(data?) { this.from = (data && data.from != null) ? data.from : 0; diff --git a/src/app/geosource/models/elasticsearch-hit.model.ts b/src/app/elasticsearch/models/elasticsearch-response.model.ts similarity index 51% rename from src/app/geosource/models/elasticsearch-hit.model.ts rename to src/app/elasticsearch/models/elasticsearch-response.model.ts index 43863044e93ff93a2efa6909e1c5540568007d92..52411101458da4120ae164e3799eae0f7d96cd8b 100644 --- a/src/app/geosource/models/elasticsearch-hit.model.ts +++ b/src/app/elasticsearch/models/elasticsearch-response.model.ts @@ -1,15 +1,8 @@ -import { IMetadata } from '.'; -import { IData } from './data.model'; -import { IESCMSResponse } from '../../editorialisation/models/cms-content.model'; - export interface IElasticsearchHit { '_id': string; '_index': string; '_score': number; - '_source': { - 'metadata-fr': IMetadata; - 'data-fr': IData; - } | IESCMSResponse; + '_source': any; 'uuid': string; 'slug': string; 'inner_hits': { @@ -21,3 +14,14 @@ export interface IElasticsearchHit { }, }; } + +export interface IElasticsearchResponse { + 'took': number; + 'hits': { + 'total': number, + 'max_score': number, + 'hits': IElasticsearchHit[], + }; + 'suggest': any; + 'aggregations': any; +} diff --git a/src/app/geosource/models/filter.model.ts b/src/app/elasticsearch/models/filter.model.ts similarity index 100% rename from src/app/geosource/models/filter.model.ts rename to src/app/elasticsearch/models/filter.model.ts diff --git a/src/app/elasticsearch/models/index.ts b/src/app/elasticsearch/models/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..14b3eeb0fae9c495e7555bb2f53dbe7a2f3d51e3 --- /dev/null +++ b/src/app/elasticsearch/models/index.ts @@ -0,0 +1,7 @@ +export { Data, IData } from '../../shared/models'; +// tslint:disable-next-line: max-line-length +export { ElasticsearchOptions, ICountScope, IElasticsearchOptions, IPostsESOptions, IScope } from './elasticsearch-options.model'; +export { IElasticsearchHit, IElasticsearchResponse } from './elasticsearch-response.model'; +export { Aggregation, Filter, IActiveFiltersTemplate, IFilter } from './filter.model'; +export { ISortOption } from './sort-option.model'; + diff --git a/src/app/geosource/models/sort-option.model.ts b/src/app/elasticsearch/models/sort-option.model.ts similarity index 100% rename from src/app/geosource/models/sort-option.model.ts rename to src/app/elasticsearch/models/sort-option.model.ts diff --git a/src/app/geosource/services/elasticsearch.service.ts b/src/app/elasticsearch/services/elasticsearch.service.ts similarity index 72% rename from src/app/geosource/services/elasticsearch.service.ts rename to src/app/elasticsearch/services/elasticsearch.service.ts index b373c63c937be0bcaca30cc32ec761e824aa7d1a..ac3d122b7ad431f6e5651ba21f5b30822a75ef68 100644 --- a/src/app/geosource/services/elasticsearch.service.ts +++ b/src/app/elasticsearch/services/elasticsearch.service.ts @@ -5,10 +5,9 @@ import { catchError, map } from 'rxjs/operators'; import { geosource, notificationMessages } from '../../../i18n/traductions'; import { ErrorService } from '../../core/services'; import { APP_CONFIG } from '../../core/services/app-config.service'; -import { ElasticsearchOptions, Filter, IElasticsearchResponse, SearchCompletion, SearchSuggestion } from '../models'; -import { IPostsESOptions } from '../models/elasticsearch-options.model'; -import { Aggregation } from '../models/filter.model'; -import { scopesResearch } from '../models/scopes-research'; +import { scopesResearch } from '../../shared/variables'; +// tslint:disable-next-line: max-line-length +import { Aggregation, ElasticsearchOptions, Filter, IElasticsearchResponse, IPostsESOptions } from '../models'; @Injectable() export class ElasticsearchService { @@ -78,7 +77,7 @@ export class ElasticsearchService { ); } - getSlugsFromUuid(slugs: string[]): Observable<any> { + getSlugsFromUuid(uuids: string[]): Observable<IElasticsearchResponse> { return this._http.request<IElasticsearchResponse>('POST', this.elasticSearchUrl, { body: { from: 0, @@ -86,31 +85,14 @@ export class ElasticsearchService { _source: ['slug', 'metadata-fr'], query: { terms: { - 'metadata-fr.geonet:info.uuid.keyword': slugs, + 'metadata-fr.geonet:info.uuid.keyword': uuids, }, }, collapse: { field: 'metadata-fr.geonet:info.uuid.keyword', - } + }, }, }).pipe( - map((response) => { - // { - // uuid: {'slug': xx, 'title': yy } - // - // } - const slugUuids = {}; - if (response.hits.hits && response.hits.hits.length > 0) { - response.hits.hits.forEach((element) => { - slugUuids[element._source['metadata-fr']['geonet:info']['uuid']] = { - slug: element._source['slug'], - title: element._source['metadata-fr']['title'], - }; - }); - } - - return slugUuids; - }), catchError( (err) => { throw this._errorService.handleError(err, { message: notificationMessages.geosource.getDatasetById }); @@ -178,8 +160,7 @@ export class ElasticsearchService { /** * This request will get the completion values based on highlight request from one query text */ - getAutoComplete(text: string): Observable<SearchCompletion[]> { - const options: SearchCompletion[] = []; + getAutoComplete(text: string): Observable<IElasticsearchResponse> { const regex = text.replace(/[\*\+\-=~><\"\?^\${}\(\)\:\!\/[\]\\\s]/g, '\\$&') .replace(/\|\|/g, '\\||') // replace || .replace(/\&\&/g, '\\&&'); // replace && @@ -234,128 +215,6 @@ export class ElasticsearchService { body: request, withCredentials: true, }).pipe( - map((e) => { - // We will loop over all the hits, look if an highlight have been found, - // and if yes, we add the first one to our autocompletion options list. - const searchOption = {}; - if (e['hits']['hits']) { - e['hits']['hits'].forEach((hit) => { - searchOption['id'] = hit._id; - searchOption['_index'] = hit._index; - searchOption['_score'] = hit._score; - const highlight = hit['highlight']; - if (highlight) { - Object.keys(highlight).forEach((key, index) => { - // We check if this text highlight already exists in the options array - // We want a unique text in the list, no duplicata. - const found = options.some((el) => { - return el.text === highlight[key][0]; - }); - if (!found && options.length < 5) { - searchOption['text'] = highlight[key][0]; - options.push(new SearchCompletion(searchOption)); - } - }); - } - - }); - } - return options; - }), - catchError( - (err) => { - throw this._errorService.handleError(err, { message: notificationMessages.geosource.getAutocomplete }); - }, - ), - ); - } - - /** - * This request will get the completion values based on highlight request from one query text - * The request is applied on data-fr properties - */ - getDataAutoComplete(text: string, datasetId: string): Observable<SearchCompletion[]> { - const options: SearchCompletion[] = []; - - const regex = text.replace(/[\*\+\-=~><\"\?^\${}\(\)\:\!\/[\]\\\s]/g, '\\$&') - .replace(/\|\|/g, '\\||') // replace || - .replace(/\&\&/g, '\\&&'); // replace && - - return this._http.request<IElasticsearchResponse>('POST', this.elasticSearchUrl, { - withCredentials: true, - body: { - _source: false, - query: { - bool: { - must: [{ - query_string: { - query: regex, - default_field: 'data_and_metadata', - analyzer: 'my_search_analyzer', - fuzziness: 'AUTO', - minimum_should_match: '90%', - }, - }], - filter: { - term: { - 'metadata-fr.geonet\:info.uuid.keyword': datasetId, - }, - }, - }, - }, - highlight: { - order: 'score', - pre_tags: ['<b>'], - post_tags: ['</b>'], - highlight_query: { - query_string: { - query: regex, - default_field: 'data_and_metadata', - analyzer: 'my_search_analyzer', - fuzziness: 'AUTO', - minimum_should_match: '90%', - }, - }, - fields: { - '*data-fr.*': { - number_of_fragments: 10, - fragment_size: 50, - fragmenter: 'span', - type: 'unified', - require_field_match: false, - }, - }, - }, - }, - }).pipe( - map((e) => { - // We will loop over all the hits, look if an highlight have been found, - // and if yes, we add the first one to our autocompletion options list. - const searchOption = {}; - if (e['hits']['hits']) { - e['hits']['hits'].forEach((hit) => { - searchOption['id'] = hit._id; - searchOption['_index'] = hit._index; - searchOption['_score'] = hit._score; - const highlight = hit['highlight']; - if (highlight) { - Object.keys(highlight).forEach((key, index) => { - // We check if this text highlight already exists in the options array - // We want a unique text in the list, no duplicata. - const found = options.some((el) => { - return el.text === highlight[key][0]; - }); - if (!found && options.length < 5) { - searchOption['text'] = highlight[key][0]; - options.push(new SearchCompletion(searchOption)); - } - }); - } - - }); - } - return options; - }), catchError( (err) => { throw this._errorService.handleError(err, { message: notificationMessages.geosource.getAutocomplete }); @@ -368,7 +227,7 @@ export class ElasticsearchService { * This request will get one phrase suggestion out of the query text * cf. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html */ - getSuggestion(query: string): Observable<SearchSuggestion> { + getSuggestion(query: string): Observable<IElasticsearchResponse> { return this._http.request<IElasticsearchResponse>('POST', this.elasticSearchUrl, { withCredentials: true, body: { @@ -397,16 +256,6 @@ export class ElasticsearchService { }, }, }).pipe( - map((res) => { - const suggestions = res.suggest['suggestion'][0].options; - let suggestion: SearchSuggestion; - if (suggestions && suggestions.length > 0) { - suggestion = new SearchSuggestion(suggestions[0]); - } else { - suggestion = new SearchSuggestion(); - } - return suggestion; - }), catchError( (err) => { throw this._errorService.handleError(err, { message: notificationMessages.geosource.getSuggestion }); @@ -803,7 +652,7 @@ export class ElasticsearchService { return escapedSearchString; } - getNumberDatasetsByOrganization() { + getNumberDatasetsByOrganization(): Observable<IElasticsearchResponse> { // Set query string options const requestOptions = { withCredentials: true, @@ -854,10 +703,6 @@ export class ElasticsearchService { }; return this._http.request<IElasticsearchResponse>('POST', this.elasticSearchUrl, requestOptions).pipe( - map((e) => { - const aggregations = e.aggregations['nested_agg']['organisationName'].buckets; - return aggregations; - }), catchError( (err) => { throw this._errorService.handleError(err, { message: notificationMessages.geosource.getResults }); @@ -962,119 +807,10 @@ export class ElasticsearchService { ); } - getDataFromCoordinates(filter, metadataId) { - // Set query string options - const requestOptions = { - withCredentials: true, - body: { - size: 1, - query: { - bool: { - filter: { - bool: { - must: [ - { - geo_shape: { - 'data-fr.geometry': filter, - }, - }, - { - term: { - 'metadata-fr.geonet:info.uuid.keyword': metadataId, - }, - }, - ], - }, - }, - }, - }, - }, - }; - - return this._http.request<IElasticsearchResponse>('POST', this.elasticSearchUrl, requestOptions).pipe( - map((e) => { - let result = null; - if (e.hits && e.hits.hits) { - result = e.hits.hits[0]._source['data-fr']; - } - return result; - }), - catchError( - (err) => { - throw this._errorService.handleError(err, { message: notificationMessages.geosource.getDataFromCoordinates }); - }, - ), - ); - - } - - /** - * Get articles with research and highlights options - */ - getWPPosts(options?: ElasticsearchOptions) { - - const requestOptions = { - withCredentials: true, - body: { - }, - }; - - if (options) { - const from = options.pageSize * options.pageIndex; - const searchString = this.escapeSpecialCharacters(options.searchString, options.fromAutocompletion); - const regex = (options.searchString !== '') ? searchString : '*'; - - requestOptions.body = { - from, - size: options.pageSize, - query: { - query_string: { - query: regex, - default_field: 'data_and_metadata', - analyzer: 'my_search_analyzer', - fuzziness: 'AUTO', - minimum_should_match: '90%', - }, - }, - highlight: { - pre_tags: ['<span class="highlighted">'], - post_tags: ['</span>'], - require_field_match: false, - type: 'unified', - fragmenter: 'span', - order: 'score', - highlight_query: { - query_string: { - query: regex, - default_field: 'data_and_metadata', - analyzer: 'my_search_analyzer', - fuzziness: 'AUTO', - minimum_should_match: '90%', - }, - }, - fields: { - '*': { - fragment_size: 100, - number_of_fragments: 3, - }, - }, - }, - }; - } - return this._http.request<IElasticsearchResponse>('POST', this.elasticSearchUrl, requestOptions).pipe( - map((e) => { - return e; - }), - catchError( - (err) => { - throw this._errorService.handleError(err, { message: notificationMessages.geosource.getResults }); - }, - ), - ); - } + // --------------------- CMS CONTENT -------------------------- // /** - * Get raw articles with filter options (id, slug and content) + * Get raw articles with filter options (id, slug and content) */ getPosts(options?: IPostsESOptions): Observable<IElasticsearchResponse> { const requestOptions = { @@ -1139,41 +875,10 @@ export class ElasticsearchService { } return this._http.request<IElasticsearchResponse>('POST', this.elasticSearchUrl, requestOptions).pipe( - map((res) => { - return res; - }), catchError( (error) => { throw this._errorService.handleError(error, { message: notificationMessages.edito.getPost }); }, - )); - } - - getLatestDatasets(size?: number) { - const requestOptions = { - withCredentials: true, - body: { - from: 0, - size: (size ? size : 5), - collapse: { - field: 'uuid.keyword', - }, - sort: [ - { - 'metadata-fr.publicationDate': 'desc', - }, - ], - }, - }; - - return this._http.request<IElasticsearchResponse>('POST', this.elasticSearchUrl, requestOptions).pipe( - map((e) => { - return e; - }), - catchError( - (err) => { - throw this._errorService.handleError(err, { message: notificationMessages.geosource.getResults }); - }, ), ); } diff --git a/src/app/geosource/components/index.ts b/src/app/geosource/components/index.ts deleted file mode 100644 index d4fb2370bbdac5a21782b33138f389424f85bdae..0000000000000000000000000000000000000000 --- a/src/app/geosource/components/index.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { ResultsComponent } from './results/results.component'; -import { DatasetDetailComponent } from './dataset-detail/dataset-detail.component'; - -import { DatasetResourcesComponent } from './dataset-detail/dataset-resources/dataset-resources.component'; -// tslint:disable-next-line:max-line-length -import { ResourceQueryableComponent } from './dataset-detail/dataset-resources/resources-queryable/resource-queryable/resource-queryable.component'; -// tslint:disable-next-line:max-line-length -import { ResourcesQueryableComponent } from './dataset-detail/dataset-resources/resources-queryable/resources-queryable.component'; -// tslint:disable-next-line:max-line-length -import { ResourceDownloadableComponent } from './dataset-detail/dataset-resources/resource-downloadable/resource-downloadable.component'; -import { DatasetMapComponent } from './dataset-detail/dataset-map/dataset-map.component'; -import { DatasetInfoComponent } from './dataset-detail/dataset-info/dataset-info.component'; -import { DatasetTableComponent } from './dataset-detail/dataset-table/dataset-table.component'; -import { IconFormatComponent } from './dataset-detail/dataset-resources/icon-format/icon-format.component'; -import { SearchBarComponent } from './search-bar/search-bar.component'; -import { ResearchComponent } from './research/research.component'; -import { SortComponent } from './sort/sort.component'; -import { FilterListComponent } from './filter-list/filter-list.component'; -import { FilterDetailComponent } from './filter-list/filter-detail/filter-detail.component'; -import { ResultDatasetComponent } from './results/result-dataset/result-dataset.component'; -import { ResultsTabScopeComponent } from './results/results-tab-scope/results-tab-scope.component'; -import { ResultPostComponent } from './results/result-post/result-post.component'; -import { DatasetTableMapComponent } from './dataset-detail/dataset-table-map/dataset-table-map.component'; -import { DatasetDataDetailsComponent } from './dataset-detail/dataset-data-details/dataset-data-details.component'; -import { DatasetDataDetailPropertiesComponent } from './dataset-detail/dataset-data-details/dataset-data-detail-properties/dataset-data-detail-properties.component'; - -export { - DatasetDetailComponent, - DatasetResourcesComponent, - ResourceQueryableComponent, - ResourceDownloadableComponent, - DatasetMapComponent, - DatasetInfoComponent, - DatasetTableMapComponent, - DatasetTableComponent, - ResultsComponent, - SearchBarComponent, - ResearchComponent, - SortComponent, - FilterListComponent, - FilterDetailComponent, - ResultDatasetComponent, - ResultsTabScopeComponent, - ResultPostComponent, - ResourcesQueryableComponent, - IconFormatComponent, - DatasetDataDetailsComponent, - DatasetDataDetailPropertiesComponent, -}; - -// tslint:disable-next-line:variable-name -export const GeosourceComponents = [ - DatasetDetailComponent, - DatasetResourcesComponent, - ResourceQueryableComponent, - ResourceDownloadableComponent, - DatasetMapComponent, - DatasetInfoComponent, - DatasetTableMapComponent, - DatasetTableComponent, - ResultsComponent, - SearchBarComponent, - ResearchComponent, - SortComponent, - FilterListComponent, - FilterDetailComponent, - ResultDatasetComponent, - ResultsTabScopeComponent, - ResultPostComponent, - ResourcesQueryableComponent, - IconFormatComponent, - DatasetDataDetailsComponent, - DatasetDataDetailPropertiesComponent, -]; diff --git a/src/app/geosource/components/research/research.component.html b/src/app/geosource/components/research/research.component.html deleted file mode 100644 index 0680b43f9c6ae05df91c576141f20ed411d07c7d..0000000000000000000000000000000000000000 --- a/src/app/geosource/components/research/research.component.html +++ /dev/null @@ -1 +0,0 @@ -<router-outlet></router-outlet> diff --git a/src/app/geosource/components/research/research.component.scss b/src/app/geosource/components/research/research.component.scss deleted file mode 100644 index 01e4ffbea964cafb8a918fb48d12f258620a3704..0000000000000000000000000000000000000000 --- a/src/app/geosource/components/research/research.component.scss +++ /dev/null @@ -1,9 +0,0 @@ - -@import "../../../../../node_modules/bulma/sass/utilities/_all"; - -@media screen and (max-width: $desktop - 1px) { - .research-container { - margin-left: 1.5rem; - margin-right: 1.5rem; - } -} diff --git a/src/app/geosource/components/research/research.component.spec.ts b/src/app/geosource/components/research/research.component.spec.ts deleted file mode 100644 index c4ea8abdcb15bd4608fe9939d1b9ae220a75d3ef..0000000000000000000000000000000000000000 --- a/src/app/geosource/components/research/research.component.spec.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ResearchComponent } from './research.component'; -import { MockComponent } from 'ng2-mock-component'; -import { RouterTestingModule } from '@angular/router/testing'; -import { DatasetResearchService, ElasticsearchService } from '../../services'; -import { HttpClientModule } from '@angular/common/http'; -import { ErrorService, NotificationService } from '../../../core/services'; -import { StorageService } from '../../../core/services/storage.service'; - -describe('ResearchComponent', () => { - let component: ResearchComponent; - let fixture: ComponentFixture<ResearchComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - RouterTestingModule.withRoutes([]), - HttpClientModule, - ], - declarations: [ - ResearchComponent, - MockComponent({ selector: 'app-results' }), - ], - providers: [ - DatasetResearchService, - ElasticsearchService, - ErrorService, - StorageService, - NotificationService, - ], - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ResearchComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/geosource/components/research/research.component.ts b/src/app/geosource/components/research/research.component.ts deleted file mode 100644 index f0da7a24a1db803c48b02b4576771dad2e77bd95..0000000000000000000000000000000000000000 --- a/src/app/geosource/components/research/research.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { DatasetResearchService } from '../../services'; -import { Router } from '@angular/router'; -import { AppRoutes } from '../../../routes'; - -@Component({ - selector: 'app-research', - templateUrl: './research.component.html', - styleUrls: ['./research.component.scss'], -}) -export class ResearchComponent implements OnInit { - - constructor( - private _datasetResearchService: DatasetResearchService, - private _router: Router, - ) { } - - ngOnInit() { - this._datasetResearchService.searchChange$.subscribe(() => { - // Redirect to Dataset list if this is not the current page - if (this._router.url.split('/').pop() !== AppRoutes.research.uri) { - this._router.navigate(['/', AppRoutes.research.uri]); - } - }); - } - -} diff --git a/src/app/geosource/components/results/results.component.spec.ts b/src/app/geosource/components/results/results.component.spec.ts deleted file mode 100644 index d72ab4e695bb906700ff1984177084bddb99a1bc..0000000000000000000000000000000000000000 --- a/src/app/geosource/components/results/results.component.spec.ts +++ /dev/null @@ -1,188 +0,0 @@ -// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -// import { DatasetListComponent } from './results.component'; -// import { DatasetResearchService, ElasticsearchService } from '../../services'; -// import { Observable, Subject, of } from 'rxjs'; -// import { Dataset, SearchSuggestion } from '../../models'; -// import { RouterTestingModule } from '@angular/router/testing'; -// import { HttpClientModule } from '@angular/common/http'; -// import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -// import { MockComponent } from 'ng2-mock-component'; -// import { FilterListComponent } from '..'; -// import { FilterDetailComponent } from '../filter-list/filter-detail/filter-detail.component'; -// import { PaginatorComponent } from '../../../shared/components/paginator/paginator.component'; -// import { FormsModule } from '@angular/forms'; -// import { ErrorService, NotificationService } from '../../../core/services'; - -// describe('DatasetListComponent', () => { -// const datasetList = [{ -// _index: 'abcesr', -// highlights: { -// highlightedAbstract: 'test', -// metadata: [{ -// label: 'metadata label', -// content: 'metadata content', -// }], -// data: [{ -// label: 'data label', -// content: 'data content', -// }], -// }, -// metadata: { -// title: 'Metadata Title', -// abstract: 'abstract', -// keyword: ['riri', 'fifi', 'loulou'], -// getCategories: () => { return ['space_exploration', 'tintin_sur_la_lune']; }, -// dataset_id: '1', -// link: [], -// contact: { -// role: '', -// organisationName: '', -// address: '', -// email: '', -// appliesTo: '', -// }, -// publicationDate: '', -// highlight: '', -// legalConstraints: [], -// rights: [], -// total_documents: 10, -// lineage: '', -// type: '', -// denominator: 2, -// resolution: '', -// topic_category: [], -// geonet: { -// notify: '', -// schema: '', -// createDate: '', -// view: '', -// id: '', -// featured: '', -// download: '', -// changeDate: '', -// dynamic: '', -// '@xmlns:geonet': '', -// source: '', -// uuid: '', -// selected: '', -// isPublishedToAll: '', -// }, -// categories: [], -// popularity: '', -// max_east: 4, -// max_south: 4, -// max_north: 4, -// updateFrequency: '', -// max_west: 4, -// crs: '', -// }, -// }] as Dataset[]; - -// let component: DatasetListComponent; -// let fixture: ComponentFixture<DatasetListComponent>; -// let service: DatasetResearchService; -// let elasticsearchService: ElasticsearchService; - -// const searchSubject = new Subject<string>(); - -// beforeEach(async(() => { -// TestBed.configureTestingModule({ -// declarations: [ -// DatasetListComponent, -// MockComponent({ selector: 'app-sort' }), -// FilterListComponent, -// FilterDetailComponent, -// PaginatorComponent, -// ], -// imports: [ -// RouterTestingModule.withRoutes([]), -// BrowserAnimationsModule, -// HttpClientModule, -// FormsModule, -// ], -// providers: [ -// DatasetResearchService, -// ElasticsearchService, -// ErrorService, -// NotificationService, -// ], -// }) -// .compileComponents(); -// })); - -// beforeEach(() => { -// fixture = TestBed.createComponent(DatasetListComponent); -// component = fixture.componentInstance; -// service = TestBed.get(DatasetResearchService); -// elasticsearchService = TestBed.get(ElasticsearchService); -// spyOn(elasticsearchService, 'getSuggestion').and.returnValue(of(new SearchSuggestion())); -// fixture.detectChanges(); -// }); - -// describe('Component creation', () => { -// it('should create', () => { -// expect(component).toBeTruthy(); -// }); -// }); - -// describe('ngOnInit()', () => { -// beforeEach(() => { - -// spyOnProperty(service, 'pageIndex', 'get').and.returnValue(5); -// spyOn(service, 'getResults').and.returnValue(of(datasetList)); -// spyOn(service, 'searchChange$').and.returnValue(searchSubject.asObservable()); -// spyOn(component, 'search').and.callThrough(); -// spyOn(component, 'getSuggestion').and.callThrough(); -// }); - -// it('should initialize the page index', () => { -// // When -// component.ngOnInit(); -// expect(component.paginator.pageIndex).toEqual(6); // Value of the service plus 1 -// }); - -// it('should call search function', () => { -// // When -// component.ngOnInit(); -// expect(component.search).toHaveBeenCalled(); -// }); - -// it('should call getSuggestion function', () => { -// // When -// component.ngOnInit(); -// expect(component.getSuggestion).toHaveBeenCalled(); -// }); -// }); - -// describe('search()', () => { -// beforeEach(() => { -// spyOn(service, 'getResults').and.returnValue(of(datasetList)); -// spyOnProperty(service, 'pageIndex', 'get').and.returnValue(2); -// spyOnProperty(service, 'pageSize', 'get').and.returnValue(5); -// spyOnProperty(service, 'resultsCount', 'get').and.returnValue(10); -// }); - -// it('should initialize the page index from service', () => { -// // When -// component.search(); -// expect(component.paginator.pageIndex).toEqual(3); // Value of the service plus 1 -// }); - -// it('should initialize the page size from service', () => { -// // When -// component.search(); -// expect(component.paginator.pageSize).toEqual(5); -// }); - -// it('should get count of dataset from service', () => { -// // When -// component.search(); -// expect(component.paginator.length).toBe(10); -// }); - -// it('should get the list of dataset from service', () => { -// component.search(); -// expect(component.datasetList).toBe(datasetList); -// }); -// }); -// }); diff --git a/src/app/geosource/geosource.module.ts b/src/app/geosource/geosource.module.ts deleted file mode 100644 index 569603110d88c38de6cfd9d607bb74060b77da42..0000000000000000000000000000000000000000 --- a/src/app/geosource/geosource.module.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { CommonModule, DatePipe } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { GeosourceRoutingModule } from './geosource-routing.module'; -import { GeosourceComponents, SearchBarComponent } from './components'; -import { GeosourceServices, DatasetResearchService } from './services'; -import { SharedModule } from '../shared/shared.module'; -import { MapModule } from '../map/map.module'; -import { InlineSVGModule } from 'ng-inline-svg'; -import { InfiniteScrollModule } from 'ngx-infinite-scroll'; -import { GeosourceResolvers } from './resolvers'; - -@NgModule({ - imports: [ - CommonModule, - GeosourceRoutingModule, - FormsModule, - SharedModule, - ReactiveFormsModule, - InfiniteScrollModule, - MapModule, - InlineSVGModule.forRoot(), - ], - declarations: [...GeosourceComponents], - providers: [ - ...GeosourceServices, - DatePipe, - ], - exports: [ - SearchBarComponent, - ], -}) -export class GeosourceModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: GeosourceModule, - providers: [DatasetResearchService, GeosourceResolvers], - }; - } -} diff --git a/src/app/geosource/models/dataset-service.model.ts b/src/app/geosource/models/dataset-service.model.ts deleted file mode 100644 index dcda6a32c7d7583678224591119e4b059bee4fef..0000000000000000000000000000000000000000 --- a/src/app/geosource/models/dataset-service.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface DatasetService { - key: string; - title: string; - subtitle: string; - description: string; - url: string; -} diff --git a/src/app/geosource/models/elasticsearch-response.model.ts b/src/app/geosource/models/elasticsearch-response.model.ts deleted file mode 100644 index b109cd099dbcd98aa50c0f591511eba2f9ea3084..0000000000000000000000000000000000000000 --- a/src/app/geosource/models/elasticsearch-response.model.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { IElasticsearchHit } from '.'; - -export interface IElasticsearchResponse { - 'took': number; - 'hits': { - 'total': number, - 'max_score': number, - 'hits': IElasticsearchHit[], - }; - 'suggest': any; - 'aggregations': any; -} diff --git a/src/app/geosource/models/index.ts b/src/app/geosource/models/index.ts deleted file mode 100644 index 82b7f9402e5641bc3d08b8bea6e3ba06f877b951..0000000000000000000000000000000000000000 --- a/src/app/geosource/models/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -export { IMetadata, IMetadataLink, Metadata, IResponsibleParty } from './metadata.model'; -export { IElasticsearchResponse } from './elasticsearch-response.model'; -export { IDataset, Dataset } from './dataset.model'; -export { IElasticsearchHit } from './elasticsearch-hit.model'; -export { ISortOption } from './sort-option.model'; -export { ElasticsearchOptions, IElasticsearchOptions } from './elasticsearch-options.model'; -export { Filter } from './filter.model'; -export { IHighlights, Highlights } from './highlights.model'; -export { SearchCompletion } from './search-completion.model'; -export { SearchSuggestion } from './suggestion.model'; -export { Data } from './data.model'; -export { DatasetChild } from './dataset-child.model'; -export { Resource, IResource } from './resource.model'; -export { IEditorialMetadata, EditorialMetadata } from './editorial-metadata.model'; diff --git a/src/app/geosource/services/dataset-detail.service.spec.ts b/src/app/geosource/services/dataset-detail.service.spec.ts deleted file mode 100644 index 7c59c1d53e9a37c2e2aeb4c37d9d77e382e6f3bb..0000000000000000000000000000000000000000 --- a/src/app/geosource/services/dataset-detail.service.spec.ts +++ /dev/null @@ -1,3 +0,0 @@ -describe('DatasetDetailService', () => { - -}); diff --git a/src/app/geosource/services/dataset-research.service.spec.ts b/src/app/geosource/services/dataset-research.service.spec.ts deleted file mode 100644 index b9e9930ea0c74dfd629e44ab197a7065ddd0de31..0000000000000000000000000000000000000000 --- a/src/app/geosource/services/dataset-research.service.spec.ts +++ /dev/null @@ -1,3 +0,0 @@ -describe('DatasetResearchService', () => { - -}); diff --git a/src/app/geosource/services/elasticsearch-response-mock.json b/src/app/geosource/services/elasticsearch-response-mock.json deleted file mode 100644 index 890ce0053f96e89932b6eb6bc68c7b7549b4eeb7..0000000000000000000000000000000000000000 --- a/src/app/geosource/services/elasticsearch-response-mock.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "took": 2, - "timed_out": false, - "_shards": { - "total": 12, - "successful": 12, - "skipped": 0, - "failed": 0 - }, - "hits": { - "total": 0, - "max_score": 0.0, - "hits": [] - }, - "suggest": { - "title": [ - { - "text": "a", - "offset": 0, - "length": 1, - "options": [ - { - "text": "Aire d'accueil des gens du voyage (Métropole de Ly", - "_index": "00d2adf.full.v3", - "_type": "_doc", - "id": "74243c0", - "_score": 1.0 - }, - { - "text": "Altitude d'une courbe de niveau maîtresse (Altimét", - "_index": "07504f8.full.v3", - "_type": "_doc", - "id": "113ca3b", - "_score": 1.0 - } - ] - } - ] - } -} \ No newline at end of file diff --git a/src/app/geosource/services/elasticsearch.service.spec.ts b/src/app/geosource/services/elasticsearch.service.spec.ts deleted file mode 100644 index ec818a417393985ee063279a509e87573f99d24d..0000000000000000000000000000000000000000 --- a/src/app/geosource/services/elasticsearch.service.spec.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { ElasticsearchService } from './elasticsearch.service'; -import { HttpClient } from '@angular/common/http'; -import { ErrorService } from '../../core/services'; -import { of, throwError } from 'rxjs'; -import * as json from './elasticsearch-response-mock.json'; -import { SearchCompletion } from '../models'; -import { StorageService } from '../../core/services/storage.service'; - -function buildAutoCompleteRequest(text) { - return { - body: { - _source: false, - suggest: { - title: { - prefix: text, - completion: { - field: 'metadata-fr.title.suggest', - size: 3, - fuzzy: { - fuzziness: 2, - }, - skip_: true, - }, - }, - }, - }, - }; -} - -const options: SearchCompletion[] = [ - { - text: 'Aire d\'accueil des gens du voyage (Métropole de Ly', - _index: '00d2adf.full.v3', - id: '74243c0', - _score: 1.0, - }, - { - text: 'Altitude d\'une courbe de niveau maîtresse (Altimét', - _index: '07504f8.full.v3', - id: '113ca3b', - _score: 1.0, - }, -]; - -describe('ElasticsearchService', () => { - - let service: ElasticsearchService; - let httpClientMock: HttpClient; - let errorServiceMock: ErrorService; - let storageServiceMock: StorageService; - - beforeEach(() => { - - httpClientMock = jasmine.createSpyObj('HttpClient', { - request: of(json), - }); - - storageServiceMock = jasmine.createSpyObj('StorageService', { - request: of(json), - }); - - errorServiceMock = jasmine.createSpyObj('ErrorService', { - handleError: (err, options) => { return new Error(options.message); }, - }); - - service = new ElasticsearchService(errorServiceMock, storageServiceMock, httpClientMock); - }); - - // describe('getAutoComplete(string)', () => { - - // it('should return an array of SearchCompletion', () => { - // // given - // const text = 'arbre'; - - // // when - // const observable = service.getAutoComplete(text); - - // // then - // expect(observable).toBeTruthy(); // not oundefined or null - // observable.subscribe((result) => { - // expect(result.length).toBe(2); - // expect(result).toContain(jasmine.objectContaining(options[0])); - // expect(result).toContain(jasmine.objectContaining(options[1])); - // }); - // expect(httpClientMock.request).toHaveBeenCalledWith( - // 'POST', - // jasmine.any(String), - // buildAutoCompleteRequest(text), - // ); - // }); - - // it('should return an error when httpClient return an error', () => { - // // given - // const text = 'arbre'; - // const expectedError = new Error('error'); - // httpClientMock.request = jasmine.createSpy('request').and.returnValue(throwError(expectedError)); - // // when - // const observable = service.getAutoComplete(text); - - // // then - // observable.subscribe( - // (result) => { - // fail('Should have returned an error'); - // }, - // (err) => { - // expect(err).toBeTruthy(); - // }, - // ); - // }); - // }); -}); diff --git a/src/app/geosource/services/index.ts b/src/app/geosource/services/index.ts deleted file mode 100644 index 83cf1b63254d9c8805e71908c973a25b66770985..0000000000000000000000000000000000000000 --- a/src/app/geosource/services/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { DatasetResearchService } from './dataset-research.service'; -import { DatasetDetailService } from './dataset-detail.service'; -import { ElasticsearchService } from './elasticsearch.service'; -import { ResourcesService } from './resources.service'; - -export { DatasetResearchService, DatasetDetailService, ElasticsearchService, ResourcesService }; - -// tslint:disable-next-line:variable-name -export const GeosourceServices = [ - // DatasetResearchService, - DatasetDetailService, - ElasticsearchService, - ResourcesService, -]; diff --git a/src/app/map/components/map.component.ts b/src/app/map/components/map.component.ts index 2d318b993e1bb553b5ac79e24547f0aecd51eddb..3ae47dcbc17242844936caf820ee332fb691fb78 100644 --- a/src/app/map/components/map.component.ts +++ b/src/app/map/components/map.component.ts @@ -1,12 +1,12 @@ -import { Component, OnInit, OnDestroy, Input } from '@angular/core'; +import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import * as mapboxgl from 'mapbox-gl'; import { Subscription } from 'rxjs'; -import { MapService } from '../services/map.service'; -import { settings } from '../settings'; import { geosource } from '../../../i18n/traductions'; -import { linkFormats } from '../../geosource/models/metadata.model'; -import { GeocoderService } from '../services/geocoder.service'; +import { linkFormats } from '../../shared/models'; import { MapOptions } from '../models/map-options'; +import { GeocoderService } from '../services/geocoder.service'; +import { MapService } from '../services/map.service'; +import { settings } from '../settings'; @Component({ selector: 'app-map', diff --git a/src/app/geosource/models/data.model.ts b/src/app/shared/models/data.model.ts similarity index 100% rename from src/app/geosource/models/data.model.ts rename to src/app/shared/models/data.model.ts diff --git a/src/app/geosource/models/dataset.model.ts b/src/app/shared/models/dataset.model.ts similarity index 93% rename from src/app/geosource/models/dataset.model.ts rename to src/app/shared/models/dataset.model.ts index 62ab5bee52228780c6d08f6bc15f3c13547ce51b..e5ca390baf025f4982fffd6d925391f7009f7831 100644 --- a/src/app/geosource/models/dataset.model.ts +++ b/src/app/shared/models/dataset.model.ts @@ -1,7 +1,7 @@ -import { IMetadata, Metadata, linkFormats } from './metadata.model'; +import { Data } from './data.model'; +import { EditorialMetadata, IEditorialMetadata } from './editorial-metadata.model'; import { Highlights } from './highlights.model'; -import { Data, IData } from './data.model'; -import { IEditorialMetadata, EditorialMetadata } from './editorial-metadata.model'; +import { IMetadata, linkFormats, Metadata } from './metadata.model'; export interface IDataset { _index?: string; diff --git a/src/app/geosource/models/editorial-metadata.model.ts b/src/app/shared/models/editorial-metadata.model.ts similarity index 100% rename from src/app/geosource/models/editorial-metadata.model.ts rename to src/app/shared/models/editorial-metadata.model.ts diff --git a/src/app/geosource/models/highlights.model.ts b/src/app/shared/models/highlights.model.ts similarity index 86% rename from src/app/geosource/models/highlights.model.ts rename to src/app/shared/models/highlights.model.ts index 2263a636cda04f4c1ff638a2a88376f63359f610..7dca35fc539265b2f322f3c77fb52934af9646a2 100644 --- a/src/app/geosource/models/highlights.model.ts +++ b/src/app/shared/models/highlights.model.ts @@ -1,4 +1,4 @@ -export interface IHighlights { +interface IHighlights { highlightedAbstract: string; highlightedTitle: string; highlightedDescription: string[]; @@ -16,8 +16,3 @@ export class Highlights implements IHighlights { this.highlightedDescription = (data && data.highlightedDescription != null) ? data.highlightedDescription : []; } } - -interface IHighlight { - 'label': string; - 'content': string; -} diff --git a/src/app/shared/models/index.ts b/src/app/shared/models/index.ts index 39ae3fab8eb04d07ee52c403505a3335a1bb1202..a8077c3fc086713fcce66d91fd9d0c253322ea5d 100644 --- a/src/app/shared/models/index.ts +++ b/src/app/shared/models/index.ts @@ -1,5 +1,10 @@ -export { PaginatorOptions } from './paginator-options.model'; - +export { IBasicTab } from './basic-tabs.model'; export { IPageHeaderInfo } from './cms-page.model'; +export { Data, IData } from './data.model'; +export { Dataset, IDataset, IDatasetFields } from './dataset.model'; +export { EditorialMetadata, IEditorialMetadata } from './editorial-metadata.model'; +export { Highlights } from './highlights.model'; +// tslint:disable-next-line: max-line-length +export { IMetadata, IMetadataLink, IParentDataset, IResponsibleParty, linkFormats, Metadata, typesMetadata } from './metadata.model'; +export { PaginatorOptions } from './paginator-options.model'; -export { IBasicTab } from './basic-tabs.model'; diff --git a/src/app/geosource/models/metadata.model.ts b/src/app/shared/models/metadata.model.ts similarity index 99% rename from src/app/geosource/models/metadata.model.ts rename to src/app/shared/models/metadata.model.ts index a8e68a1788eb29a21b3fb245e8283de3084ffa1b..908463a9fd93587c2aab52e9f7ca9209839d9169 100644 --- a/src/app/geosource/models/metadata.model.ts +++ b/src/app/shared/models/metadata.model.ts @@ -173,7 +173,7 @@ export class Metadata { } this.keyword = data.keyword; - const providersToAdd = new Set(); + const providersToAdd = new Set<string>(); this.contacts = []; if (data.responsibleParty) { data.responsibleParty.forEach((party) => { diff --git a/src/app/geosource/models/scopes-research.ts b/src/app/shared/variables.ts similarity index 93% rename from src/app/geosource/models/scopes-research.ts rename to src/app/shared/variables.ts index aaf9b7c606f186779365cad946cc907de0fe76fa..69a3e772872f097876596f02843676b353a576da 100644 --- a/src/app/geosource/models/scopes-research.ts +++ b/src/app/shared/variables.ts @@ -1,5 +1,4 @@ - -import { geosource } from '../../../i18n/traductions'; +import { geosource } from '../../i18n/traductions'; export const scopesResearch = { all: { @@ -36,4 +35,4 @@ export const scopesResearch = { elasticType: ['page'], errorItem: geosource.errorItem.pages, }, -}; +}; \ No newline at end of file diff --git a/src/app/user/components/access-management/available-data/available-data.component.ts b/src/app/user/components/access-management/available-data/available-data.component.ts index 6c0c1db3517b8725d93a40bbb14c1eb20e9ba9bb..7e13b646f8212e903289bc425399ded5bdee5d49 100644 --- a/src/app/user/components/access-management/available-data/available-data.component.ts +++ b/src/app/user/components/access-management/available-data/available-data.component.ts @@ -1,13 +1,13 @@ import { Component, OnInit } from '@angular/core'; -import { UserServicesService } from '../../../services'; -import { NotificationService } from '../../../../core/services'; -import { IService, IRestrictedAccessDataset, ServiceAccess, Resource, IResource } from '../../../models'; -import { Notification } from '../../../../core/models'; +import { Router } from '@angular/router'; import { forkJoin } from 'rxjs'; import { notificationMessages } from '../../../../../i18n/traductions'; -import { ElasticsearchService } from '../../../../geosource/services'; +import { Notification } from '../../../../core/models'; +import { NotificationService } from '../../../../core/services'; +import { ElasticsearchService } from '../../../../elasticsearch/services/elasticsearch.service'; import { AppRoutes } from '../../../../routes'; -import { Router } from '@angular/router'; +import { IResource, IRestrictedAccessDataset, IService, Resource, ServiceAccess } from '../../../models'; +import { UserServicesService } from '../../../services'; @Component({ selector: 'app-available-data', @@ -49,7 +49,7 @@ export class AvailableDataComponent implements OnInit { return (e.geonetUuid && e.geonetUuid !== ''); }); const uuids = this.restrictedAccessDatasets.map((e) => { return e.geonetUuid; }); - this._elasticSearchService.getSlugsFromUuid(uuids).subscribe( + this._userAccessService.getSlugsFromUuid(uuids).subscribe( (response) => { this.slugsUuids = response; this.initRequestableResources(); @@ -57,7 +57,7 @@ export class AvailableDataComponent implements OnInit { (err) => { }, () => { this._pendingRequests -= 1; - } + }, ); }, (err) => { @@ -296,7 +296,7 @@ export class AvailableDataComponent implements OnInit { // because only authenticated users are supposed to access this component handle401(err) { if (err && err.status === 401) { - this._router.navigate(['/', AppRoutes.signin.uri]); + this._router.navigate(['/', AppRoutes.signin.uri]); } } diff --git a/src/app/user/components/access-management/user-services/user-services.component.ts b/src/app/user/components/access-management/user-services/user-services.component.ts index 6f4574724fb79d8b68ca8a5a4f97aac221a9761e..469b641c748c775e5d035460aad6c678e1be567b 100644 --- a/src/app/user/components/access-management/user-services/user-services.component.ts +++ b/src/app/user/components/access-management/user-services/user-services.component.ts @@ -1,13 +1,14 @@ import { Component, OnInit } from '@angular/core'; -import { NotificationService } from '../../../../core/services'; -import { ServiceAccess, Resource, IService, IResource } from '../../../models'; +import { Router } from '@angular/router'; import { forkJoin } from 'rxjs'; -import { Notification } from '../../../../core/models'; +import { map, mergeMap } from 'rxjs/operators'; import { notificationMessages, userServicesStatuses } from '../../../../../i18n/traductions'; -import { UserServicesService } from '../../../services/user-services.service'; -import { ElasticsearchService } from '../../../../geosource/services'; +import { Notification } from '../../../../core/models'; +import { NotificationService } from '../../../../core/services'; +import { ElasticsearchService } from '../../../../elasticsearch/services/elasticsearch.service'; import { AppRoutes } from '../../../../routes'; -import { Router } from '@angular/router'; +import { IResource, IService, Resource, ServiceAccess } from '../../../models'; +import { UserServicesService } from '../../../services/user-services.service'; @Component({ selector: 'app-user-services', @@ -42,20 +43,25 @@ export class UserServicesComponent implements OnInit { this._userAccessService.getUserResources(), // Get the list of the different modes (wms, ws...) this._userAccessService.getServices(), - ]).subscribe( - (results) => { + ]).pipe( + mergeMap((results) => { this.services = results[1]; const resources = results[0].filter((e) => { return (e.geonetUuid && e.geonetUuid !== ''); }); + const uuids = resources.map((e) => { return e.geonetUuid; }); - this._elasticSearchService.getSlugsFromUuid(uuids).subscribe((response) => { - this.slugsUuids = response; - this.initUserResources(resources); - }); - }, + return this._userAccessService.getSlugsFromUuid(uuids).pipe( + map((response) => { + this.slugsUuids = response; + this.initUserResources(resources); + }), + ); + }), + ).subscribe( + () => { }, (err) => { this._notificationService.notify(new Notification({ type: 'error', @@ -327,7 +333,7 @@ export class UserServicesComponent implements OnInit { // because only authenticated users are supposed to access this component handle401(err) { if (err && err.status === 401) { - this._router.navigate(['/', AppRoutes.signin.uri]); + this._router.navigate(['/', AppRoutes.signin.uri]); } } } diff --git a/src/app/user/services/user-services.service.ts b/src/app/user/services/user-services.service.ts index 432e03fcedbc5b8e96b1c5b6649395deeb8a4bea..c54b25342a796a2a6bdeb620c482c78e66b845c4 100644 --- a/src/app/user/services/user-services.service.ts +++ b/src/app/user/services/user-services.service.ts @@ -1,17 +1,17 @@ -import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { - IService, IRestrictedAccessDataset, IResource, RenewAccessToResourceResponse, AccessRequestToResourceResponse, - DeleteAccessToRessourceResponse, -} from '../models'; +import { map } from 'rxjs/operators'; import { APP_CONFIG } from '../../core/services/app-config.service'; +import { ElasticsearchService } from '../../elasticsearch/services/elasticsearch.service'; +import { AccessRequestToResourceResponse, DeleteAccessToRessourceResponse, IResource, IRestrictedAccessDataset, IService, RenewAccessToResourceResponse } from '../models'; @Injectable() export class UserServicesService { constructor( private _http: HttpClient, + private _elasticsearchService: ElasticsearchService, ) { } getUserResources(): Observable<IResource[]> { @@ -21,6 +21,28 @@ export class UserServicesService { ); } + getSlugsFromUuid(uuids: string[]) { + return this._elasticsearchService.getSlugsFromUuid(uuids).pipe( + map((response) => { + // { + // uuid: {'slug': xx, 'title': yy } + // + // } + const slugUuids = {}; + if (response.hits.hits && response.hits.hits.length > 0) { + response.hits.hits.forEach((element) => { + slugUuids[element._source['metadata-fr']['geonet:info']['uuid']] = { + slug: element._source['slug'], + title: element._source['metadata-fr']['title'], + }; + }); + } + + return slugUuids; + }), + ); + } + getRestrictedAccessDatasets(): Observable<IRestrictedAccessDataset[]> { // tslint:disable-next-line:max-line-length return this._http.get<IRestrictedAccessDataset[]>(`${APP_CONFIG.backendUrls.middlewareLegacyAuth}restrictedAccessDatasets`); diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index 39ba8dbacbbe051fdd02481b07af43219296a075..213ce42a1b093feb2da1652105deed78c15a72e5 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -10,4 +10,4 @@ "test.ts", "**/*.spec.ts" ] -} +} \ No newline at end of file