diff --git a/nginx/default.conf b/nginx/default.conf index 97bc59ae9cf154844351f48504e86d417806abf5..3cc40f5d51b4b832ff3d420489872c09c12131cb 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -33,6 +33,10 @@ server { #allow 80.14.51.82; # Erasme #deny all; + location /data-grandlyon-cities { + proxy_pass https://data.grandlyon.com/fr/datapusher/ws/grandlyon/adr_voie_lieu.adrcomgl/all.json; + } + location / { add_header X-Frame-Options SAMEORIGIN always; add_header X-Content-Type-Options nosniff; @@ -75,10 +79,6 @@ server { proxy_pass https://download.data.grandlyon.com/wfs/grandlyon; } - location /fr/datapusher { - proxy_pass https://data.grandlyon.com/fr/datapusher; - } - # REALLY important for JavaScript modules (type="module") to work as expected!!! location ~ \.js { add_header Content-Type text/javascript; diff --git a/proxy.conf.json b/proxy.conf.json index 48ad4e75599947ce95d9bb9cf2ea4d7e864dc9d7..699e461ebbae4c51db483c810d23a2c3ee7608d6 100644 --- a/proxy.conf.json +++ b/proxy.conf.json @@ -29,10 +29,13 @@ "changeOrigin": true, "logLevel": "info" }, - "/fr/datapusher": { + "/data-grandlyon-cities": { "target": "https://data.grandlyon.com", "secure": false, "changeOrigin": true, + "pathRewrite": { + "^/data-grandlyon-cities": "/fr/datapusher/ws/grandlyon/adr_voie_lieu.adrcomgl/all.json" + }, "logLevel": "info" } } diff --git a/src/app/data/data.component.ts b/src/app/data/data.component.ts index 226379e6fcb3e83b9f3e79ce221eeea04d6248b7..4a01521572b0fb3833887b670ac1593196bb212f 100644 --- a/src/app/data/data.component.ts +++ b/src/app/data/data.component.ts @@ -67,32 +67,30 @@ export class DataComponent implements OnInit { }); // Get cities from data.grandlyon.com - // To change to have new city Oullins-Pierre-Bénite : - // .get('/fr/datapusher/ws/grandlyon/adr_voie_lieu.adrcomgl_2024/all.json', { headers: { skip: 'true' } }) - this.http - .get('/fr/datapusher/ws/grandlyon/adr_voie_lieu.adrcomgl/all.json', { headers: { skip: 'true' } }) - .subscribe((data: { values: any[] }) => { - this.categoriesInseeCodes = [ - { - id: 'inseeCode', - name: 'Commune', - theme: 'Commune', - modules: data.values - .flatMap((value) => { - if (value.nom === 'Lyon') { - // Replace city "Lyon" by the 9 districts of Lyon - return Array.from({ length: 9 }, (_, index) => ({ - disabled: false, - name: `Lyon ${index + 1}`, - id: `6938${index + 1}`, // Insee code for district of Lyon - })); - } - return [{ disabled: false, name: value.nom, id: value.insee }]; - }) - .sort((a, b) => a.name.localeCompare(b.name)), - }, - ]; - }); + // To change in proxy.conf.json and default.conf to have new city Oullins-Pierre-Bénite : + // /fr/datapusher/ws/grandlyon/adr_voie_lieu.adrcomgl_2024/all.json + this.http.get('/data-grandlyon-cities', { headers: { skip: 'true' } }).subscribe((data: { values: any[] }) => { + this.categoriesInseeCodes = [ + { + id: 'inseeCode', + name: 'Commune', + theme: 'Commune', + modules: data.values + .flatMap((value) => { + if (value.nom === 'Lyon') { + // Replace city "Lyon" by the 9 districts of Lyon + return Array.from({ length: 9 }, (_, index) => ({ + disabled: false, + name: `Lyon ${index + 1}`, + id: `6938${index + 1}`, // Insee code for district of Lyon + })); + } + return [{ disabled: false, name: value.nom, id: value.insee }]; + }) + .sort((a, b) => a.name.localeCompare(b.name)), + }, + ]; + }); this.resetFilters(); } diff --git a/src/app/structure-list/components/more-filters/more-filters.component.html b/src/app/structure-list/components/more-filters/more-filters.component.html index 46ebcb68609b1b454a37eb54872049f7d0379530..994405507476f1da83f16ea7f2c88392f5ab0491 100644 --- a/src/app/structure-list/components/more-filters/more-filters.component.html +++ b/src/app/structure-list/components/more-filters/more-filters.component.html @@ -18,7 +18,7 @@ /> </div> <!-- Filter with single category --> - <div *ngIf="categories.length === 1" class="modalContent"> + <div *ngIf="categories?.length === 1" class="modalContent"> <ng-container *ngIf="isRadio"> <app-radio *ngFor="let module of categories[0].modules" @@ -41,7 +41,7 @@ </ng-container> </div> <!-- Filter with multiple categories --> - <div *ngIf="categories.length > 1" class="modalContent multipleCollapse"> + <div *ngIf="categories?.length > 1" class="modalContent multipleCollapse"> <app-collapse *ngFor="let c of categories"> <app-collapse-header> <div class="collapseHeader">