Commit c2c9a7f1 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Fix bug of array data being modified unwillingly by the component

parent 2e8b36b4
Pipeline #5046 passed with stage
in 6 minutes and 8 seconds
{
"name": "webapp",
"version": "2.5.1",
"version": "2.5.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -4863,12 +4863,6 @@
"integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==",
"dev": true
},
"@types/file-saver": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.1.tgz",
"integrity": "sha512-g1QUuhYVVAamfCifK7oB7G3aIl4BbOyzDOqVyUfEr4tfBKrXfeH+M+Tg7HKCXSrbzxYdhyCP7z9WbKo0R2hBCw==",
"dev": true
},
"@types/geojson": {
"version": "7946.0.7",
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.7.tgz",
......@@ -4907,6 +4901,21 @@
"integrity": "sha512-aWw2YTtAdT7CskFyxEX2K21/zSDStuf/ikI3yBqmwpwJF0pS+/IX5DWv+1UFffZIbruP6cnT9/LAJV1gFwAT1A==",
"dev": true
},
"@types/lodash": {
"version": "4.14.150",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.150.tgz",
"integrity": "sha512-kMNLM5JBcasgYscD9x/Gvr6lTAv2NVgsKtet/hm93qMyf/D1pt+7jeEZklKJKxMVmXjxbRVQQGfqDSfipYCO6w==",
"dev": true
},
"@types/lodash.clonedeep": {
"version": "4.5.6",
"resolved": "https://registry.npmjs.org/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.6.tgz",
"integrity": "sha512-cE1jYr2dEg1wBImvXlNtp0xDoS79rfEdGozQVgliDZj1uERH4k+rmEMTudP9b4VQ8O6nRb5gPqft0QzEQGMQgA==",
"dev": true,
"requires": {
"@types/lodash": "*"
}
},
"@types/mapbox-gl": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/@types/mapbox-gl/-/mapbox-gl-1.7.0.tgz",
......@@ -8011,11 +8020,6 @@
}
}
},
"file-saver": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.2.tgz",
"integrity": "sha512-Wz3c3XQ5xroCxd1G8b7yL0Ehkf0TC9oYC6buPFkNnU9EnaPlifeAFCyCh+iewXTyFRcg0a6j3J7FmJsIhlhBdw=="
},
"fileset": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/fileset/-/fileset-2.0.3.tgz",
......
......@@ -28,7 +28,7 @@ export class DatasetAPIComponent implements OnInit, OnDestroy {
isSample = false;
// To display in the template
queryableResources: Resource[];
queryableResources; // each property of this object is an Array of Resource;
constructor(
private _datasetDetailService: DatasetDetailService,
......@@ -40,7 +40,7 @@ export class DatasetAPIComponent implements OnInit, OnDestroy {
ngOnInit() {
this.resources = [];
this.queryableResources = [];
this.queryableResources = {};
this.isSample = this._datasetDetailService.dataset.editorialMetadata.isSample;
this.cguModalIsOpened = (this._cookieService.get(environment.cguAcceptedCookieName) !== 'true') &&
!this._userService.userIsSignedIn;
......
......@@ -21,8 +21,8 @@ export class DatasetDownloadsComponent implements OnInit {
metadata: Metadata;
sub: Subscription;
downloadableResources: Resource[];
staticResources: IMetadataLink[];
downloadableResources; // Each property of the object is an array of Resource;
staticResources; // Each property of the object is an array of IMetadataLink;
otherResources: IMetadataLink[];
cguModalIsOpened: boolean;
......@@ -44,8 +44,8 @@ export class DatasetDownloadsComponent implements OnInit {
ngOnInit() {
this.resources = [];
this.projections = [];
this.downloadableResources = [];
this.staticResources = [];
this.downloadableResources = {};
this.staticResources = {};
this.otherResources = [];
this.cguModalIsOpened = (this._cookieService.get(environment.cguAcceptedCookieName) !== 'true') &&
......@@ -101,8 +101,7 @@ export class DatasetDownloadsComponent implements OnInit {
if (this.metadata && this.resources.length > 0 && !this.hasBeenInitialized) {
this.hasBeenInitialized = true;
if (this.metadata.link) {
[this.downloadableResources, this.staticResources, this.otherResources] =
this._resourcesService.getResourcesForDownload(this.metadata);
[this.downloadableResources, this.staticResources, this.otherResources] = this._resourcesService.getResourcesForDownload(this.metadata);
}
}
}
......
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import lodashClonedeep from 'lodash.clonedeep';
import { map } from 'rxjs/operators';
import { APP_CONFIG } from '../../core/services/app-config.service';
import { IMetadataLink, linkFormats, Metadata } from '../../shared/models';
import { IResource, Resource } from '../models';
import { IProjection, Projection } from '../models/projection.model';
@Injectable()
export class ResourcesService {
......@@ -32,7 +32,7 @@ export class ResourcesService {
}
getQueryableResources(link: IMetadataLink[]) {
const queryableResources = [];
const queryableResources = {};
link.forEach((link) => {
if (link.service) {
this.resources.forEach((resource) => {
......@@ -50,12 +50,13 @@ export class ResourcesService {
return queryableResources;
}
getResourcesForDownload(metadata: Metadata) {
const downloadableResources = [];
const staticResources = [];
const otherResources = [];
getResourcesForDownload(metadata: Metadata): [any, any, IMetadataLink[]] {
const downloadableResources = {};
const staticResources = {};
const otherResources: IMetadataLink[] = [];
metadata.link.forEach((link) => {
const links = lodashClonedeep(metadata.link);
links.forEach((link) => {
if (link.service) {
this.resources.forEach((resource) => {
const resourceCopy = Object.assign({}, resource);
......@@ -100,6 +101,7 @@ export class ResourcesService {
'https://download.data.grandlyon.com',
`${APP_CONFIG.backendUrls.proxyQuery}/download`,
);
staticResources[link.description].push(link);
} else {
......@@ -109,6 +111,7 @@ export class ResourcesService {
'https://download.data.grandlyon.com',
`${APP_CONFIG.backendUrls.proxyQuery}/download`,
);
otherResources.push(link);
}
}
......
......@@ -5,6 +5,7 @@
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"allowSyntheticDefaultImports" : true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment