Skip to content

Commit

Permalink
feat: create source parameter to coordinateurs http (#308)
Browse files Browse the repository at this point in the history
* feat: create source parameter to coordinateurs http

* fix: replace production url

* fix: url coordinateurs test by default
  • Loading branch information
abelkhay committed Jun 14, 2023
1 parent 661a33d commit f003667
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type DataCoordinateursConfiguration = {
conseillers: string;
coordinateurs: string;
};

export const DATA_COORDINATEURS_CONFIGURATION: DataCoordinateursConfiguration = {
conseillers: 'https://cdn.jsdelivr.net/npm/@gouvfr-anct/cartographie-nationale@5.10.1/assets/data/conseillers.json',
coordinateurs: 'https://cdn.jsdelivr.net/npm/@gouvfr-anct/cartographie-nationale@5.10.1/assets/data/coordinateurs.json'
};
1 change: 1 addition & 0 deletions src/features/coordinateurs/data/configuration/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './data.configuration';
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Conseiller } from '../../../models';
import { ConseillersRepository } from '../../../reporitories';
import { DATA_COORDINATEURS_CONFIGURATION } from '../../configuration';

export class ConseillersHttp extends ConseillersRepository {
public constructor(private readonly httpClient: HttpClient) {
super();
}

public getAll$ = (): Observable<Conseiller[]> =>
this.httpClient.get<Conseiller[]>(
'https://cdn.jsdelivr.net/npm/@gouvfr-anct/cartographie-nationale@5.10.1/assets/data/conseillers.json'
);
this.httpClient.get<Conseiller[]>(DATA_COORDINATEURS_CONFIGURATION.conseillers);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Coordinateur } from '../../../models';
import { CoordinateursRepository } from '../../../reporitories';
import { DATA_COORDINATEURS_CONFIGURATION } from '../../configuration';

export class CoordinateursHttp extends CoordinateursRepository {
public constructor(private readonly httpClient: HttpClient) {
super();
}

public getAll$ = (): Observable<Coordinateur[]> =>
this.httpClient.get<Coordinateur[]>(
'https://cdn.jsdelivr.net/npm/@gouvfr-anct/cartographie-nationale@5.10.1/assets/data/coordinateurs.json'
);
this.httpClient.get<Coordinateur[]>(DATA_COORDINATEURS_CONFIGURATION.coordinateurs);
}
1 change: 1 addition & 0 deletions src/features/coordinateurs/data/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './http';
export * from './configuration';
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { CoordinateursWebComponentLayout } from './coordinateurs-web-component.layout';

describe('CoordinateursWebComponentLayout', (): void => {
beforeEach(async (): Promise<void> => {
await TestBed.configureTestingModule({
declarations: [CoordinateursWebComponentLayout],
imports: [RouterTestingModule],
providers: [
{
useValue: new Map()
}
]
})
.compileComponents()
.catch((): void => {
throw new Error('CoordinateursWebComponentLayout');
});
});

it('should create the component', (): void => {
const fixture: ComponentFixture<CoordinateursWebComponentLayout> = TestBed.createComponent(CoordinateursWebComponentLayout);
const coordinateursWebComponentLayout: CoordinateursWebComponentLayout = fixture.componentInstance;
expect(coordinateursWebComponentLayout).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { POSITION_CONFIGURATION, ZOOM_LEVEL_CONFIGURATION } from '../../../../root';
import { DATA_COORDINATEURS_CONFIGURATION } from '../../data/configuration';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -19,6 +20,14 @@ export class CoordinateursWebComponentLayout implements OnInit {
ZOOM_LEVEL_CONFIGURATION.regular = parseInt(zoom);
}

@Input() set conseillersSource(conseillersSource: string) {
DATA_COORDINATEURS_CONFIGURATION.conseillers = conseillersSource;
}

@Input() set coordinateursSource(coordinateursSource: string) {
DATA_COORDINATEURS_CONFIGURATION.coordinateurs = coordinateursSource;
}

public constructor(private readonly router: Router) {}

public ngOnInit(): void {
Expand Down

0 comments on commit f003667

Please sign in to comment.