Skip to content
Snippets Groups Projects
Commit ba3a1b64 authored by ext.sopra.ncastejon's avatar ext.sopra.ncastejon
Browse files

Fix the download items for non geographical datasets.

parent ca859197
Branches
No related tags found
No related merge requests found
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</div> </div>
</a> </a>
</li> </li>
<li [routerLinkActive]="'is-active'"> <li [routerLinkActive]="'is-active'" *ngIf="datasetFormatsList">
<a (click)="setPosition()" [routerLink]="[AppRoutes.downloads.uri]" class="tab-link"> <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"> <svg class="tab-icon" xmlns="http://www.w3.org/2000/svg" data-name="Calque 1" viewBox="0 0 38 32">
<path class="primary" <path class="primary"
......
...@@ -107,7 +107,8 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { ...@@ -107,7 +107,8 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
get datasetFormatsList() { 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 // Flat the arrays
list = [].concat(...list); list = [].concat(...list);
// Remove duplicates // Remove duplicates
...@@ -121,6 +122,10 @@ export class DatasetDetailComponent implements OnInit, OnDestroy { ...@@ -121,6 +122,10 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
formatted = list.join(', '); formatted = list.join(', ');
} }
if (links.length === 1 && links[0].name.includes('Licence')) {
formatted = null;
}
return formatted; return formatted;
} }
......
...@@ -8,10 +8,11 @@ ...@@ -8,10 +8,11 @@
<span>{{downloadable.key}}</span> <span>{{downloadable.key}}</span>
</div> </div>
<div class="resource-downloadable-files" *ngFor="let resource of downloadable.value"> <div class="resource-downloadable-files" *ngFor="let resource of downloadable.value">
<ng-container *ngFor="let format of resource.formats; let i=index"> <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 [format]="format" [resource]="resource" [projections]="projections"
</app-resource-download-item> [isQueryable]="true">
</ng-container> </app-resource-download-item>
</ng-container>
</div> </div>
</div> </div>
</div> </div>
...@@ -22,8 +23,8 @@ ...@@ -22,8 +23,8 @@
<span>{{static.key}}</span> <span>{{static.key}}</span>
</div> </div>
<div class="resource-static-files" *ngFor="let metadataLink of static.value"> <div class="resource-static-files" *ngFor="let metadataLink of static.value">
<app-resource-download-item [link]="metadataLink" [isQueryable]="false"> <app-resource-download-item [link]="metadataLink" [isQueryable]="false">
</app-resource-download-item> </app-resource-download-item>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<span>{{isQueryable ? resource.metadataLink.name + '.' + format.fileExtension : link.name }} <span>{{isQueryable ? resource.metadataLink.name + '.' + format.fileExtension : link.name }}
</span> </span>
</div> </div>
<div class="resource-options"> <div class="resource-options is-hidden-mobile" *ngIf="format && format.isCuttable">
<div> <div>
<span *ngIf="this.selectedProjection"> {{this.selectedProjection.name}} <span *ngIf="this.selectedProjection"> {{this.selectedProjection.name}}
</span> </span>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<div *ngIf="! this.selectedInsee && format.isCuttable"> <div *ngIf="! this.selectedInsee && format.isCuttable">
<span>&nbsp;-&nbsp;</span> <span>&nbsp;-&nbsp;</span>
<span i18n="@@dataset.resources.divisionbycommune"> <span i18n="@@dataset.resources.allcommune">
All the municipalities All the municipalities
</span> </span>
</div> </div>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</div> </div>
<div class="right-buttons"> <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}" class="options-icon is-hidden-mobile" [ngClass]="{'is-open': isOptionOpen}"
(click)="isOptionOpen = !isOptionOpen"> (click)="isOptionOpen = !isOptionOpen">
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
</div> </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="division-item" *ngIf="format.isCuttable && inseeLabel">
<div class="label-dropdown title-label"> <div class="label-dropdown title-label">
...@@ -93,8 +93,9 @@ ...@@ -93,8 +93,9 @@
</div> </div>
<div class="dropdown-menu" id="dropdown-menu" role="menu"> <div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content"> <div class="dropdown-content">
<a class="dropdown-item" (click)="setInsee(null)" i18n="@@global.all.feminine">All</a> <a class="dropdown-item" (click)="setInsee(null)" i18n="@@global.all.commune">All</a>
<a class="dropdown-item" *ngFor="let zone of communeInseeList" (click)="setInsee(zone)"> <a class="dropdown-item" [title]="zone.commune + ' ' + zone.insee"
*ngFor="let zone of communeInseeList" (click)="setInsee(zone)">
{{ zone.commune }} - {{ zone.insee }} {{ zone.commune }} - {{ zone.insee }}
</a> </a>
</div> </div>
...@@ -129,7 +130,8 @@ ...@@ -129,7 +130,8 @@
</div> </div>
<div class="dropdown-menu" id="dropdown-menu" role="menu"> <div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content"> <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) }} {{ getProjectionLabel(projection.name) }}
</a> </a>
</div> </div>
......
...@@ -62,6 +62,9 @@ ...@@ -62,6 +62,9 @@
display: flex; display: flex;
} }
.dropdown-item {
overflow: hidden;
}
.dropdown-insee { .dropdown-insee {
.dropdown-menu { .dropdown-menu {
......
...@@ -15,8 +15,8 @@ export class ResourceDownloadItemComponent implements OnInit { ...@@ -15,8 +15,8 @@ export class ResourceDownloadItemComponent implements OnInit {
linkFormats = linkFormats; linkFormats = linkFormats;
@Input() format?: Format; @Input() format?: Format;
@Input() resource: Resource; @Input() resource?: Resource;
@Input() projections: Projection[]; @Input() projections?: Projection[];
@Input() link: IMetadataLink; @Input() link: IMetadataLink;
@Input() isQueryable: boolean; @Input() isQueryable: boolean;
@Output() saveEvent = new EventEmitter(); @Output() saveEvent = new EventEmitter();
...@@ -87,6 +87,8 @@ export class ResourceDownloadItemComponent implements OnInit { ...@@ -87,6 +87,8 @@ export class ResourceDownloadItemComponent implements OnInit {
ngOnInit() { ngOnInit() {
console.log(this.resource);
console.log(this.format);
this.initItems(); this.initItems();
// Retrieve the first data for the dataset (if exists). It will be used in the // Retrieve the first data for the dataset (if exists). It will be used in the
// Data, Downloads and API tabs. // Data, Downloads and API tabs.
...@@ -97,34 +99,38 @@ export class ResourceDownloadItemComponent implements OnInit { ...@@ -97,34 +99,38 @@ export class ResourceDownloadItemComponent implements OnInit {
initItems() { initItems() {
// Get projections and set the default one (depending on the resource) // Get projections and set the default one (depending on the resource)
this.projectionList = []; if (this.resource) {
if (this.resource.type === linkFormats.wms) {
this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection); this.projectionList = [];
this.selectedProjection = this.projectionList[0]; if (this.resource.type === linkFormats.wms) {
} else if (this.resource.type === linkFormats.wfs) { this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection);
this.resource.metadataLink.projections.forEach((key) => { this.selectedProjection = this.projectionList[0];
this.projectionList.push({ } else if (this.resource.type === linkFormats.wfs) {
name: key, this.resource.metadataLink.projections.forEach((key) => {
bbox: key, this.projectionList.push({
name: key,
bbox: key,
});
}); });
}); this.selectedProjection = this.projectionList[0];
this.selectedProjection = this.projectionList[0]; } else if (this.resource.type === linkFormats.wcs) {
} else if (this.resource.type === linkFormats.wcs) { this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection);
this.projectionList = this.transformObjectToArray(this.resource.metadataLink.bbox_by_projection); this.selectedProjection = this.projectionList[0];
this.selectedProjection = this.projectionList[0]; } else if (this.resource.type === linkFormats.ws) {
} else if (this.resource.type === linkFormats.ws) { this.projectionList = this.transformObjectToArray(this.shpProjections);
this.projectionList = this.transformObjectToArray(this.shpProjections); this.selectedProjection = this.projectionList[0];
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 this.setProjection(this.selectedProjection);
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);
this.setProjection(this.selectedProjection);
} }
getFormatName() { getFormatName() {
......
...@@ -54,6 +54,7 @@ export class ResourcesService { ...@@ -54,6 +54,7 @@ export class ResourcesService {
const downloadableResources = []; const downloadableResources = [];
const staticResources = []; const staticResources = [];
const otherResources = []; const otherResources = [];
console.log(metadata.link);
metadata.link.forEach((link) => { metadata.link.forEach((link) => {
if (link.service) { if (link.service) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment