Commit 9c7e0245 authored by ext.sopra.ncastejon's avatar ext.sopra.ncastejon
Browse files

Add the municipality filter for the download files.

parent e6978d1a
......@@ -126,7 +126,7 @@
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
<span
*ngIf="selectedInsee">{{ selectedInsee ? selectedInsee.commune + ' - ' + selectedInsee.insee : ''}}</span>
<span *ngIf="!selectedInsee" i18n="@@dataset.resources.commune">Municipality</span>
<span *ngIf="!selectedInsee" i18n="@@dataset.resources.commune">All</span>
<svg xmlns="http://www.w3.org/2000/svg" id="chevron" viewBox="0 0 15 9">
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
......
......@@ -56,12 +56,8 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
this._meta.updateTag({ name: 'description', content: this.metadata.abstract });
this.isLoading = true;
this.initDatasetInfo();
// Retrieve the first data for the dataset (if exists). It will be used in the
// Data, Downloads and API tabs.
this._datasetDetailService.retrieveDatasetData().subscribe(() => {
this.initDatasetInfo();
});
});
}
......
......@@ -8,81 +8,85 @@
</span>
</div>
</div>
</div>
<div class="division-item" *ngIf="format.isCuttable && inseeLabel">
<div class="label-dropdown title-label">
<span i18n="@@dataset.resources.divisionbycommune">
Division by municipality
</span>
</div>
<div>
<!-- Dropdown for insee when needed -->
<div class="dropdown dropdown-insee" [ngClass]="{'is-active': dropDownInseeToggle}"
(click)="dropDownInseeToggle=!dropDownInseeToggle" (clickOutside)="dropDownInseeToggle = false;">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
<span
*ngIf="selectedInsee">{{ selectedInsee ? selectedInsee.commune + ' - ' + selectedInsee.insee : ''}}</span>
<span *ngIf="!selectedInsee" i18n="@@dataset.resources.commune">Municipality</span>
<svg xmlns="http://www.w3.org/2000/svg" id="chevron" viewBox="0 0 15 9">
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
class="brandcolor" />
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
class="brandcolor" />
</svg>
</button>
<div class="filter-items">
<div class="division-item" *ngIf="format.isCuttable && inseeLabel">
<div class="label-dropdown title-label">
<span i18n="@@dataset.resources.divisionbycommune">
Division by municipality
</span>
</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)">
{{ zone.commune }} - {{ zone.insee }}
</a>
<div>
<!-- Dropdown for insee when needed -->
<div class="dropdown dropdown-insee" [ngClass]="{'is-active': dropDownInseeToggle}"
(click)="dropDownInseeToggle=!dropDownInseeToggle" (clickOutside)="dropDownInseeToggle = false;">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
<span
*ngIf="selectedInsee">{{ selectedInsee ? selectedInsee.commune + ' - ' + selectedInsee.insee : ''}}</span>
<span *ngIf="!selectedInsee" i18n="@@dataset.resources.commune">All</span>
<svg xmlns="http://www.w3.org/2000/svg" id="chevron" viewBox="0 0 15 9">
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
class="brandcolor" />
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
class="brandcolor" />
</svg>
</button>
</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)">
{{ zone.commune }} - {{ zone.insee }}
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="projection-item" *ngIf="format.isProjectable">
<div class="label-dropdown title-label">
<span i18n="@@dataset.resources.projectionsystem">
Projection system
</span>
</div>
<div>
<!-- Dropdow for projections -->
<div class="dropdown" [ngClass]="{'is-active': dropDownProjectionToggle}"
(click)="dropDownProjectionToggle=!dropDownProjectionToggle"
(clickOutside)="dropDownProjectionToggle = false;">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
<span>{{ getProjectionLabel(selectedProjection.name) }}</span>
<svg xmlns="http://www.w3.org/2000/svg" id="chevron" viewBox="0 0 15 9">
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
class="brandcolor" />
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
class="brandcolor" />
</svg>
</button>
<div class="projection-item" *ngIf="format.isProjectable">
<div class="label-dropdown title-label">
<span i18n="@@dataset.resources.projectionsystem">
Projection system
</span>
</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)">
{{ getProjectionLabel(projection.name) }}
</a>
<div>
<!-- Dropdow for projections -->
<div class="dropdown" [ngClass]="{'is-active': dropDownProjectionToggle}"
(click)="dropDownProjectionToggle=!dropDownProjectionToggle"
(clickOutside)="dropDownProjectionToggle = false;">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
<span>{{ getProjectionLabel(selectedProjection.name) }}</span>
<svg xmlns="http://www.w3.org/2000/svg" id="chevron" viewBox="0 0 15 9">
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
class="brandcolor" />
<path
d="M7.5 7.5c-.1 0-.3-.1-.4-.1l-6-6C1 1.1 1 .8 1.1.6s.5-.2.7 0l5.6 5.6L13 .6c.2-.2.5-.2.7 0s.2.5 0 .7l-6 6c.1.1-.1.2-.2.2z"
class="brandcolor" />
</svg>
</button>
</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)">
{{ getProjectionLabel(projection.name) }}
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<app-download-button [url]="getQueryableUrl()" [fileName]="getFileName()">
<app-download-button [url]="queryableUrl" [fileName]="fileName">
</app-download-button>
</div>
\ No newline at end of file
......@@ -12,7 +12,6 @@
}
.resource-left {
display: flex;
align-items: center;
margin-right: 0.5rem;
......@@ -28,6 +27,10 @@
font-size: 1rem;
}
}
.filter-items {
display: flex;
}
}
.dropdown-menu {
......
......@@ -25,7 +25,7 @@ export class ResourceDownloadItemComponent implements OnInit {
abortMessage: string = geosource.downloads.abort;
downloadMessage: string = geosource.downloads.download;
queryableUrl = '';
_queryableUrl = '';
projectionList;
// Dropdown projection
......@@ -85,6 +85,15 @@ export class ResourceDownloadItemComponent implements OnInit {
ngOnInit() {
this.initItems();
// Retrieve the first data for the dataset (if exists). It will be used in the
// Data, Downloads and API tabs.
this._datasetDetailService.retrieveDatasetData().subscribe(() => {
this.initItems();
});
}
initItems() {
// Get projections and set the default one (depending on the resource)
this.projectionList = [];
if (this.resource.type === linkFormats.wms) {
......@@ -114,16 +123,13 @@ export class ResourceDownloadItemComponent implements OnInit {
this.communeInseeList.sort((a, b) => (a.commune > b.commune) ? 1 : -1);
this.setProjection(this.selectedProjection);
console.log('selected projeciton', this.selectedProjection);
}
getFormatName() {
return this.format ? this.format.name : this.link.formats[0];
}
getQueryableUrl() {
get queryableUrl() {
let queryableUrl = '';
if (this.isQueryable) {
......@@ -152,10 +158,12 @@ export class ResourceDownloadItemComponent implements OnInit {
} else {
queryableUrl = this.link.url;
}
queryableUrl += this.queryableParameters.insee;
return queryableUrl;
}
getFileName() {
get fileName() {
return this.resource ? `${this.resource.metadataLink.name}.${this.format.fileExtension}` : this.link.name;
}
......@@ -170,22 +178,22 @@ export class ResourceDownloadItemComponent implements OnInit {
// depending on the resource
setProjection(projection) {
this.selectedProjection = projection;
if (this.resource.type === linkFormats.wfs) {
this.queryableParameters.projection = `&SRSNAME=${projection.name}`;
} else if (this.resource.type === linkFormats.wms || this.resource.type === linkFormats.wcs) {
this.queryableParameters.projection = `&CRS=${projection.name}`;
this.queryableParameters.bbox = `&BBOX=${projection.bbox.minx},` +
`${projection.bbox.miny},` +
`${projection.bbox.maxx},` +
`${projection.bbox.maxy}`;
} else if (this.resource.type === linkFormats.ws) {
if (this.format.name !== 'JSON') {
this.queryableParameters.projection = `srsname=${projection.name}`;
}
}
// if (this.resource.type === linkFormats.wfs) {
// this.queryableParameters.projection = `&SRSNAME=${projection.name}`;
// } else if (this.resource.type === linkFormats.wms || this.resource.type === linkFormats.wcs) {
// this.queryableParameters.projection = `&CRS=${projection.name}`;
// this.queryableParameters.bbox = `&BBOX=${projection.bbox.minx},` +
// `${projection.bbox.miny},` +
// `${projection.bbox.maxx},` +
// `${projection.bbox.maxy}`;
// } else if (this.resource.type === linkFormats.ws) {
// if (this.format.name !== 'JSON') {
// this.queryableParameters.projection = `srsname=${projection.name}`;
// }
// }
this.queryableParameters.projectionActive = true;
this.updateQueryableUrl();
// this.updateQueryableUrl();
}
// Set the selected insee and set the queryable parameters
......@@ -216,18 +224,21 @@ export class ResourceDownloadItemComponent implements OnInit {
getProjectionAndBbox(format: Format) {
let projection = '';
let bboxRequest = '';
if (this.resource.type === linkFormats.wfs) {
projection = '&SRSNAME=EPSG:3946';
} else if (this.resource.type === linkFormats.wms || this.resource.type === linkFormats.wcs) {
projection = '&CRS=EPSG:3946';
const bbox = this.resource.metadataLink.bbox_by_projection['EPSG:3946'];
bboxRequest = `&BBOX=${bbox.minx},` +
`${bbox.miny},` +
`${bbox.maxx},` +
`${bbox.maxy}`;
} else if (this.resource.type === linkFormats.ws) {
if (format.name !== 'JSON') {
projection = 'srsname=EPSG:3946';
if (this.selectedProjection) {
if (this.resource.type === linkFormats.wfs) {
projection = `&SRSNAME=${this.selectedProjection.name}`;
} else if (this.resource.type === linkFormats.wms || this.resource.type === linkFormats.wcs) {
projection = `&CRS=${this.selectedProjection.name}`;
const bbox = this.resource.metadataLink.bbox_by_projection[this.selectedProjection.name];
bboxRequest = `&BBOX=${bbox.minx},` +
`${bbox.miny},` +
`${bbox.maxx},` +
`${bbox.maxy}`;
} else if (this.resource.type === linkFormats.ws) {
if (format.name !== 'JSON') {
projection = `srsname=${this.selectedProjection.name}`;
}
}
}
......@@ -240,9 +251,9 @@ export class ResourceDownloadItemComponent implements OnInit {
// When the user changes parameters (or when view init), we update the url provided
// to the <a> link
updateQueryableUrl() {
this.queryableUrl = this.queryableParameters.baseUrl +
this._queryableUrl = this.queryableParameters.baseUrl +
this.queryableParameters.baseParameters;
this.queryableUrl += this.queryableParameters.layer +
this._queryableUrl += this.queryableParameters.layer +
this.queryableParameters.outputFormat +
this.queryableParameters.insee +
this.queryableParameters.projection +
......
......@@ -132,7 +132,7 @@ export class ElasticsearchService {
{
query_string: {
query: searchString,
default_field: 'data',
default_field: '*.mapbox',
analyzer: 'my_search_analyzer',
fuzziness: 'AUTO',
minimum_should_match: '90%',
......
......@@ -38,7 +38,6 @@ export class DownloadButtonComponent implements OnInit {
download() {
this.loading = true;
fetch(this.url, { signal: this.signal }).then((response) => {
// To allow the download, get the repsons as a blob
return response.blob();
......
......@@ -328,8 +328,8 @@
<target>Division by municipality</target>
</trans-unit>
<trans-unit id="dataset.resources.commune" datatype="html">
<source>Municipality</source>
<target>Municipality</target>
<source>All</source>
<target>All</target>
</trans-unit>
<trans-unit id="dataset.resources.projectionsystem" datatype="html">
<source>Projection system</source>
......
......@@ -340,8 +340,8 @@
<target>Système de projection</target>
</trans-unit>
<trans-unit id="dataset.resources.commune" datatype="html">
<source>Municipality</source>
<target>Commune</target>
<source>All</source>
<target>Toutes</target>
</trans-unit>
<trans-unit id="dataset.resources.url.root" datatype="html">
<source>Resource root URL</source>
......
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