diff --git a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html index 05a0bf8074b99296391e96b47029ae8cc3254552..ec361916bebf49da2ca71643e48ebfae99467426 100644 --- a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html +++ b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.html @@ -46,7 +46,7 @@ </div> </a> </li> - <li [routerLinkActive]="'is-active'"> + <li [routerLinkActive]="'is-active'" *ngIf="datasetFormatsList"> <a (click)="setPosition()" [routerLink]="[AppRoutes.downloads.uri]" class="tab-link"> <svg class="tab-icon" xmlns="http://www.w3.org/2000/svg" data-name="Calque 1" viewBox="0 0 38 32"> <path class="primary" diff --git a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts index ea8cc7d9768fc51e6e7f5637ed035fbd91ac4802..8602c83db0f43d45a91d997947453d1aacd5b9ce 100644 --- a/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts +++ b/src/app/dataset-detail/components/dataset-detail/dataset-detail.component.ts @@ -111,7 +111,8 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { get datasetFormatsList() { - let list = this._datasetDetailService.datasetMetadata.link.map(l => l.formats); + const links = this._datasetDetailService.datasetMetadata.link; + let list = links.map(l => l.formats); // Flat the arrays list = [].concat(...list); // Remove duplicates @@ -125,6 +126,10 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { formatted = list.join(', '); } + if (links.length === 1 && links[0].name.includes('Licence')) { + formatted = null; + } + return formatted; } diff --git a/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.html b/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.html index 173a6c1eb597e7e9adff6a9b5260b691e51f1cab..4e132e8fced7270dfc27dfecee8815ab7553ec96 100644 --- a/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.html +++ b/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.html @@ -8,10 +8,11 @@ <span>{{downloadable.key}}</span> </div> <div class="resource-downloadable-files" *ngFor="let resource of downloadable.value"> - <ng-container *ngFor="let format of resource.formats; let i=index"> - <app-resource-download-item [format]="format" [resource]="resource" [projections]="projections" [isQueryable]="true"> - </app-resource-download-item> - </ng-container> + <ng-container *ngFor="let format of resource.formats; let i=index"> + <app-resource-download-item [format]="format" [resource]="resource" [projections]="projections" + [isQueryable]="true"> + </app-resource-download-item> + </ng-container> </div> </div> </div> @@ -22,8 +23,8 @@ <span>{{static.key}}</span> </div> <div class="resource-static-files" *ngFor="let metadataLink of static.value"> - <app-resource-download-item [link]="metadataLink" [isQueryable]="false"> - </app-resource-download-item> + <app-resource-download-item [link]="metadataLink" [isQueryable]="false"> + </app-resource-download-item> </div> </div> </div> diff --git a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.html b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.html index 331a5a461f5253fcda6f6bffaebe9756804394de..0e2575e1659b3f27aad49c5a781c4883a7603a92 100644 --- a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.html +++ b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.html @@ -9,7 +9,7 @@ <span>{{isQueryable ? resource.metadataLink.name + '.' + format.fileExtension : link.name }} </span> </div> - <div class="resource-options"> + <div class="resource-options is-hidden-mobile" *ngIf="format && format.isCuttable"> <div> <span *ngIf="this.selectedProjection"> {{this.selectedProjection.name}} </span> @@ -22,7 +22,7 @@ <div *ngIf="! this.selectedInsee && format.isCuttable"> <span> - </span> - <span i18n="@@dataset.resources.divisionbycommune"> + <span i18n="@@dataset.resources.allcommune"> All the municipalities </span> </div> @@ -31,7 +31,7 @@ </div> <div class="right-buttons"> - <div *ngIf="(format.isCuttable && inseeLabel) || format.isProjectable" + <div *ngIf="format && ((format.isCuttable && inseeLabel) || format.isProjectable)" class="options-icon is-hidden-mobile" [ngClass]="{'is-open': isOptionOpen}" (click)="isOptionOpen = !isOptionOpen"> @@ -64,7 +64,7 @@ </div> - <div class="filter-items is-hidden-mobile" *ngIf="isOptionOpen"> + <div class="filter-items is-hidden-mobile" *ngIf="isQueryable && isOptionOpen"> <div class="division-item" *ngIf="format.isCuttable && inseeLabel"> <div class="label-dropdown title-label"> @@ -93,8 +93,9 @@ </div> <div class="dropdown-menu" id="dropdown-menu" role="menu"> <div class="dropdown-content"> - <a class="dropdown-item" (click)="setInsee(null)" i18n="@@global.all.feminine">All</a> - <a class="dropdown-item" *ngFor="let zone of communeInseeList" (click)="setInsee(zone)"> + <a class="dropdown-item" (click)="setInsee(null)" i18n="@@global.all.commune">All</a> + <a class="dropdown-item" [title]="zone.commune + ' ' + zone.insee" + *ngFor="let zone of communeInseeList" (click)="setInsee(zone)"> {{ zone.commune }} - {{ zone.insee }} </a> </div> @@ -129,7 +130,8 @@ </div> <div class="dropdown-menu" id="dropdown-menu" role="menu"> <div class="dropdown-content"> - <a class="dropdown-item" *ngFor="let projection of projectionList" (click)="setProjection(projection)"> + <a class="dropdown-item" [title]="getProjectionLabel(projection.name)" + *ngFor="let projection of projectionList" (click)="setProjection(projection)"> {{ getProjectionLabel(projection.name) }} </a> </div> diff --git a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.scss b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.scss index c8f6f53929bdfc30b6203ba19280469a66e542dd..aea974c86de80caa840eaaf9c37988e289d9d413 100644 --- a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.scss +++ b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.scss @@ -62,6 +62,9 @@ display: flex; } +.dropdown-item { + overflow: hidden; +} .dropdown-insee { .dropdown-menu { diff --git a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts index 99e64d66ddd95ba710191a7fbd6bfbe67b4fad8c..feb199d06bf5b4f2a6199d48639eebfe13a95a3d 100644 --- a/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts +++ b/src/app/dataset-detail/components/dataset-downloads/resource-download-item/resource-download-item/resource-download-item.component.ts @@ -15,8 +15,8 @@ export class ResourceDownloadItemComponent implements OnInit { linkFormats = linkFormats; @Input() format?: Format; - @Input() resource: Resource; - @Input() projections: Projection[]; + @Input() resource?: Resource; + @Input() projections?: Projection[]; @Input() link: IMetadataLink; @Input() isQueryable: boolean; @Output() saveEvent = new EventEmitter(); @@ -87,6 +87,8 @@ export class ResourceDownloadItemComponent implements OnInit { ngOnInit() { + console.log(this.resource); + console.log(this.format); this.initItems(); // Retrieve the first data for the dataset (if exists). It will be used in the // Data, Downloads and API tabs. @@ -97,34 +99,38 @@ export class ResourceDownloadItemComponent implements OnInit { initItems() { // Get projections and set the default one (depending on the resource) - this.projectionList = []; - if (this.resource.type === linkFormats.wms) { - this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection); - this.selectedProjection = this.projectionList[0]; - } else if (this.resource.type === linkFormats.wfs) { - this.resource.metadataLink.projections.forEach((key) => { - this.projectionList.push({ - name: key, - bbox: key, + if (this.resource) { + + this.projectionList = []; + if (this.resource.type === linkFormats.wms) { + this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection); + this.selectedProjection = this.projectionList[0]; + } else if (this.resource.type === linkFormats.wfs) { + this.resource.metadataLink.projections.forEach((key) => { + this.projectionList.push({ + name: key, + bbox: key, + }); }); - }); - this.selectedProjection = this.projectionList[0]; - } else if (this.resource.type === linkFormats.wcs) { - this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection); - this.selectedProjection = this.projectionList[0]; - } else if (this.resource.type === linkFormats.ws) { - this.projectionList = this.transformObjectToArray(this.shpProjections); - this.selectedProjection = this.projectionList[0]; - } + this.selectedProjection = this.projectionList[0]; + } else if (this.resource.type === linkFormats.wcs) { + this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection); + this.selectedProjection = this.projectionList[0]; + } else if (this.resource.type === linkFormats.ws) { + this.projectionList = this.transformObjectToArray(this.shpProjections); + this.selectedProjection = this.projectionList[0]; + } + + // Set the insee property label for this dataset + if (this._datasetDetailService.datasetData[0]) { + const properties = Object.keys(this._datasetDetailService.datasetData[0].properties); + this.inseeLabel = properties.find((prop) => { return prop.includes('insee'); }); + } + this.communeInseeList.sort((a, b) => (a.commune > b.commune) ? 1 : -1); - // Set the insee property label for this dataset - if (this._datasetDetailService.datasetData[0]) { - const properties = Object.keys(this._datasetDetailService.datasetData[0].properties); - this.inseeLabel = properties.find((prop) => { return prop.includes('insee'); }); + this.setProjection(this.selectedProjection); } - this.communeInseeList.sort((a, b) => (a.commune > b.commune) ? 1 : -1); - this.setProjection(this.selectedProjection); } getFormatName() { diff --git a/src/app/dataset-detail/services/resources.service.ts b/src/app/dataset-detail/services/resources.service.ts index f494a77b708e344f45caf3b73b89e05c5bfc058d..0da5c3545ec6a708a6d110c1dcd797f9d2f629e7 100644 --- a/src/app/dataset-detail/services/resources.service.ts +++ b/src/app/dataset-detail/services/resources.service.ts @@ -54,6 +54,7 @@ export class ResourcesService { const downloadableResources = []; const staticResources = []; const otherResources = []; + console.log(metadata.link); metadata.link.forEach((link) => { if (link.service) {