From 6d594b0bee49787d3a42c10ccf5ba234cef8a265 Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com> Date: Mon, 12 Apr 2021 15:49:53 +0200 Subject: [PATCH] refacto: clean code --- karma.conf.js | 2 +- nginx/dev.conf | 4 ++-- proxy.conf.json | 2 +- src/app/admin/components/panel/panel.component.ts | 1 - src/app/app.module.ts | 4 ++-- src/app/map/components/map.component.ts | 13 +++++++++---- .../structure-list-search.component.html} | 0 .../structure-list-search.component.scss} | 0 .../structure-list-search.component.spec.ts} | 12 ++++++------ .../structure-list-search.component.ts} | 6 +++--- 10 files changed, 24 insertions(+), 20 deletions(-) rename src/app/structure-list/components/{search/search.component.html => structure-list-search/structure-list-search.component.html} (100%) rename src/app/structure-list/components/{search/search.component.scss => structure-list-search/structure-list-search.component.scss} (100%) rename src/app/structure-list/components/{search/search.component.spec.ts => structure-list-search/structure-list-search.component.spec.ts} (93%) rename src/app/structure-list/components/{search/search.component.ts => structure-list-search/structure-list-search.component.ts} (97%) diff --git a/karma.conf.js b/karma.conf.js index e0feaefc7..5cee0fd8e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -30,7 +30,7 @@ module.exports = function (config) { target: 'https://passerelle.formulaireextranet.grandlyon.com', changeOrigin: true, }, - '/geocoding/photon/api': { + '/geocoding/photon-bal/api': { target: 'https://download.data.grandlyon.com', changeOrigin: true, }, diff --git a/nginx/dev.conf b/nginx/dev.conf index 7609f90b7..38db77c59 100644 --- a/nginx/dev.conf +++ b/nginx/dev.conf @@ -52,8 +52,8 @@ server { proxy_pass https://passerelle.formulaireextranet.grandlyon.com/base-adresse/base-adresse-nationale/streets; } - location /geocoding/photon/api { - proxy_pass https://download.data.grandlyon.com/geocoding/photon/api; + location /geocoding/photon-bal/api { + proxy_pass https://download.data.grandlyon.com/geocoding/photon-bal/api; } location /reverse { diff --git a/proxy.conf.json b/proxy.conf.json index 0feeb012e..09812b4a5 100644 --- a/proxy.conf.json +++ b/proxy.conf.json @@ -27,7 +27,7 @@ "logLevel": "info" }, "/geocoding/photon-bal/api": { - "target": "https://download.data.grandlyon.com/geocoding/photon-bal/api", + "target": "https://download.data.grandlyon.com", "secure": false, "changeOrigin": true, "logLevel": "info" diff --git a/src/app/admin/components/panel/panel.component.ts b/src/app/admin/components/panel/panel.component.ts index 15052b621..8168d693f 100644 --- a/src/app/admin/components/panel/panel.component.ts +++ b/src/app/admin/components/panel/panel.component.ts @@ -15,7 +15,6 @@ export class PanelComponent implements OnInit { ngOnInit(): void { this.selectedFeature = this.features.pendingStructures; - console.log(this.ghostLink); } public changeActiveFeature(newFeature: AdminPannelEnum) { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 960ec8793..eaf45b743 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -13,7 +13,7 @@ import { SharedModule } from './shared/shared.module'; import { MapModule } from './map/map.module'; import { StructureListComponent } from './structure-list/structure-list.component'; import { CardComponent } from './structure-list/components/card/card.component'; -import { SearchComponent } from './structure-list/components/search/search.component'; +import { StructureListSearchComponent } from './structure-list/components/structure-list-search/structure-list-search.component'; import { StructureDetailsComponent } from './structure-list/components/structure-details/structure-details.component'; import { StructureOpeningStatusComponent } from './structure-list/components/structure-opening-status/structure-opening-status.component'; import { ModalFilterComponent } from './structure-list/components/modal-filter/modal-filter.component'; @@ -43,7 +43,7 @@ import { NewsletterSubscriptionComponent } from './newsletter-subscription/newsl CartoComponent, StructureListComponent, CardComponent, - SearchComponent, + StructureListSearchComponent, ModalFilterComponent, StructureDetailsComponent, StructureOpeningStatusComponent, diff --git a/src/app/map/components/map.component.ts b/src/app/map/components/map.component.ts index 1b80b2b56..61da5c52d 100644 --- a/src/app/map/components/map.component.ts +++ b/src/app/map/components/map.component.ts @@ -53,8 +53,11 @@ export class MapComponent implements OnChanges { ngOnChanges(changes: SimpleChanges): void { if (changes.searchedValue && !changes.searchedValue.firstChange) { - if (changes.searchedValue.currentValue) this.processTownCoordinate(changes.searchedValue.currentValue); - else this.map.setView(this.mapOptions.center, this.mapOptions.zoom); + if (changes.searchedValue.currentValue) { + this.processTownCoordinate(changes.searchedValue.currentValue); + } else { + this.map.setView(this.mapOptions.center, this.mapOptions.zoom); + } } if (changes.isMapPhone) { if (this.isMapPhone) { @@ -99,8 +102,10 @@ export class MapComponent implements OnChanges { public processTownCoordinate(queryString: string): void { this.geoJsonService.getTownshipCoord(queryString).subscribe( (townData) => { - const bounds = new L.LatLngBounds(townData.map((dataArray) => dataArray.reverse())); - this.map.fitBounds(bounds); + if (townData.length > 0) { + const bounds = new L.LatLngBounds(townData.map((dataArray) => dataArray.reverse())); + this.map.fitBounds(bounds); + } }, (err) => { this.map.setView(this.mapOptions.center, this.mapOptions.zoom); diff --git a/src/app/structure-list/components/search/search.component.html b/src/app/structure-list/components/structure-list-search/structure-list-search.component.html similarity index 100% rename from src/app/structure-list/components/search/search.component.html rename to src/app/structure-list/components/structure-list-search/structure-list-search.component.html diff --git a/src/app/structure-list/components/search/search.component.scss b/src/app/structure-list/components/structure-list-search/structure-list-search.component.scss similarity index 100% rename from src/app/structure-list/components/search/search.component.scss rename to src/app/structure-list/components/structure-list-search/structure-list-search.component.scss diff --git a/src/app/structure-list/components/search/search.component.spec.ts b/src/app/structure-list/components/structure-list-search/structure-list-search.component.spec.ts similarity index 93% rename from src/app/structure-list/components/search/search.component.spec.ts rename to src/app/structure-list/components/structure-list-search/structure-list-search.component.spec.ts index 8753300fe..2e96293cd 100644 --- a/src/app/structure-list/components/search/search.component.spec.ts +++ b/src/app/structure-list/components/structure-list-search/structure-list-search.component.spec.ts @@ -2,26 +2,26 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; import { Filter } from '../../models/filter.model'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { SearchComponent } from './search.component'; +import { StructureListSearchComponent } from './structure-list-search.component'; import { Module } from '../../models/module.model'; import { TypeModal } from '../../enum/typeModal.enum'; import { GeojsonService } from '../../../services/geojson.service'; import { GeoJson } from '../../../map/models/geojson.model'; import { of } from 'rxjs'; -describe('SearchComponent', () => { - let component: SearchComponent; - let fixture: ComponentFixture<SearchComponent>; +describe('StructureListSearchComponent', () => { + let component: StructureListSearchComponent; + let fixture: ComponentFixture<StructureListSearchComponent>; let geoService: GeojsonService; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [SearchComponent], + declarations: [StructureListSearchComponent], imports: [HttpClientTestingModule, ReactiveFormsModule], }).compileComponents(); }); beforeEach(() => { - fixture = TestBed.createComponent(SearchComponent); + fixture = TestBed.createComponent(StructureListSearchComponent); component = fixture.componentInstance; fixture.detectChanges(); geoService = TestBed.inject(GeojsonService); diff --git a/src/app/structure-list/components/search/search.component.ts b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts similarity index 97% rename from src/app/structure-list/components/search/search.component.ts rename to src/app/structure-list/components/structure-list-search/structure-list-search.component.ts index b743d1cfd..ad0bdcf73 100644 --- a/src/app/structure-list/components/search/search.component.ts +++ b/src/app/structure-list/components/structure-list-search/structure-list-search.component.ts @@ -12,10 +12,10 @@ import { SearchService } from '../../services/search.service'; @Component({ selector: 'app-structure-list-search', - templateUrl: './search.component.html', - styleUrls: ['./search.component.scss'], + templateUrl: './structure-list-search.component.html', + styleUrls: ['./structure-list-search.component.scss'], }) -export class SearchComponent implements OnInit, OnChanges { +export class StructureListSearchComponent implements OnInit, OnChanges { @Output() searchEvent = new EventEmitter(); // Show/hide form createStructure -- GitLab