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 ce14da80de209f65d52f39582f9e296d016bb566..1ecd9692b058604ce593c6076c2fa1b9188c4907 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 @@ -1,4 +1,7 @@ <div class="downloads-container"> + <div class="restricted-access-container" *ngIf="isSample"> + <app-restricted-access-banner></app-restricted-access-banner> + </div> <div class="downloads" [ngClass]="{'blury': cguModalIsOpened}"> <div class="resources-downloadable" *ngIf="hasDownloadableResources || hasStaticResources"> <div class="resource-download" *ngFor="let downloadable of downloadableResources | keyvalue"> diff --git a/src/app/dataset-detail/components/dataset-table/dataset-table.component.html b/src/app/dataset-detail/components/dataset-table/dataset-table.component.html index 54a66f3f429a84c5c138488d33d1c82004761bf1..f316dfa2c05672e75614ef1652d4873868c81719 100644 --- a/src/app/dataset-detail/components/dataset-table/dataset-table.component.html +++ b/src/app/dataset-detail/components/dataset-table/dataset-table.component.html @@ -6,10 +6,10 @@ (keydown.enter)="sortBy(key)" [tabindex]="isDisplayed ? 0 : -1" [attr.role]="'columnheader'"> <span class="sort-icons"> <span class="icon"> - <i class="fas fa-sort-up" [ngClass]="{'icon-red': sortValue === key && sortOrder === 'desc'}"></i> + <i class="fas fa-sort-up" [ngClass]="{'icon-red': sortValue.includes(key) && sortOrder === 'desc'}"></i> </span> <span class="icon"> - <i class="fas fa-sort-down" [ngClass]="{'icon-red': sortValue === key && sortOrder === 'asc'}"></i> + <i class="fas fa-sort-down" [ngClass]="{'icon-red': sortValue.includes(key) && sortOrder === 'asc'}"></i> </span> </span> <span class="column-title" [ngClass]="{'active': sortValue === key}">{{ key }}</span> diff --git a/src/app/dataset-detail/components/dataset-table/dataset-table.component.ts b/src/app/dataset-detail/components/dataset-table/dataset-table.component.ts index 9fb3bd1c2b81656db665885270d9cd5bf8713cf9..c0580dfefb55ec7db9840d0ccf00dd415241fd2b 100644 --- a/src/app/dataset-detail/components/dataset-table/dataset-table.component.ts +++ b/src/app/dataset-detail/components/dataset-table/dataset-table.component.ts @@ -96,8 +96,9 @@ export class DatasetTableComponent implements OnInit, OnDestroy { } sortBy(key: string) { + const keyType = this._datasetDetailService.getKeyType(key); // Set the new sort value in the service - this._datasetDetailService.sortBy(key); + this._datasetDetailService.sortBy(keyType); // Retrieve date sorted with the new value this._datasetDetailService.retrieveDatasetData().subscribe(() => { this.tableWidthModified.emit(true); @@ -124,8 +125,9 @@ export class DatasetTableComponent implements OnInit, OnDestroy { return this._datasetDetailService.datasetData; } - get sortValue() { - return this._datasetDetailService.sortValue; + get sortValue(): String { + var sortValue: String = this._datasetDetailService.sortValue; + return sortValue ? sortValue:'' ; } get sortOrder() { diff --git a/src/app/dataset-detail/services/dataset-detail.service.ts b/src/app/dataset-detail/services/dataset-detail.service.ts index 06d828f5f9f052da3101b10227b254a3467ae5f4..684d5d713c14adf3b763d3a71988aa5ebb0a92a9 100644 --- a/src/app/dataset-detail/services/dataset-detail.service.ts +++ b/src/app/dataset-detail/services/dataset-detail.service.ts @@ -272,11 +272,22 @@ export class DatasetDetailService { } } + getKeyType(key: string) { + return key+'_'+ eval(`this._dataset.fields.types.${key}`); + } + orderProperties(data: any, orderedProperties: string[]) { const newDataPropertiesOrder = {}; orderedProperties.forEach((field) => { - newDataPropertiesOrder[field] = data.properties[field] ? data.properties[field] : ''; + // Adds type to field. First time, the field with type is used, and attributed to field without type + // force _json detection since the fieldtype is not listed. (used for complex data) + var fieldtype = field + '_' + eval(`this._dataset.fields.types.${field}`); + newDataPropertiesOrder[field] = data.properties[fieldtype] ? data.properties[fieldtype] : + data.properties[field] ? data.properties[field] : data.properties[`${field}_json`] ? + data.properties[`${field}_json`] : ''; }); + + data.properties = newDataPropertiesOrder; } diff --git a/src/app/dataset-detail/services/usage-statistics.service.ts b/src/app/dataset-detail/services/usage-statistics.service.ts index c87153c64c52e689f959608ada5d34642eae4852..4c650549f2f5866780914c32f45025552117c496 100644 --- a/src/app/dataset-detail/services/usage-statistics.service.ts +++ b/src/app/dataset-detail/services/usage-statistics.service.ts @@ -19,12 +19,12 @@ export class UsageStatisticsService { // However the months in javascript dates goes from 0 to 11 so when passing start and end dates, we don't need to subsctract a month // The backend service expect a 2 digits month while javascript date does not give 'O1' but only '1'. This is while we use a small trick // to make sure there always two digits for the month in the date + const monthListArray = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; const today = new Date(); - const aMonthAgo = `${today.getFullYear()}-${`0${today.getMonth()}`.slice(-2)}-${today.getDate()}`; - + today.setMonth(today.getMonth() - 1); + const aMonthAgo = `${today.getFullYear()}-${monthListArray[today.getMonth()]}-${today.getDate()}`; today.setFullYear(today.getFullYear() - 1); - const aMonthAndAYearAgo = `${today.getFullYear()}-${`0${today.getMonth()}`.slice(-2)}-${today.getDate()}`; - + const aMonthAndAYearAgo = `${today.getFullYear()}-${monthListArray[today.getMonth()]}-${today.getDate()}`; const url = `${APP_CONFIG.backendUrls.datasetUsageStatistics}?start=${aMonthAndAYearAgo}&uuid=${uuid}&granularity=month&end=${aMonthAgo}`; return this._httpClient.get(url).pipe( diff --git a/src/app/elasticsearch/services/elasticsearch.service.ts b/src/app/elasticsearch/services/elasticsearch.service.ts index b03dca5adda0402314d8cdb556b762112bfda549..62e429c3b47074225407b9d59f87b87d07a31aeb 100644 --- a/src/app/elasticsearch/services/elasticsearch.service.ts +++ b/src/app/elasticsearch/services/elasticsearch.service.ts @@ -135,7 +135,10 @@ export class ElasticsearchService { if (options.sortOptions.value !== null) { const sort = {}; const key = `data-fr.properties.${options.sortOptions.value}.sort`; - sort[key] = options.sortOptions.order; + sort[key] = { + order: options.sortOptions.order, + unmapped_type: 'string' + }; body['sort'] = [sort]; } @@ -513,19 +516,18 @@ export class ElasticsearchService { requestOptions.body.query.bool['must'] = mustExpression; // Filter by scope (dataset, service, post, page). If the scope is 'all', we don't apply any filter - if (options.scope.key !== scopesResearch.all.key) { - const filtersScope = []; - options.scope.elasticType.forEach((type) => { - filtersScope.push(type); - }); - // For the scopes we use post_filter instead of filter. - // The difference is that the aggregations will be calculated before this filter is applied. - requestOptions.body['post_filter'] = { - terms: { - 'type.keyword': filtersScope, - }, - }; - } + const filtersScope = []; + options.scope.elasticType.forEach((type) => { + filtersScope.push(type); + }); + // For the scopes we use post_filter instead of filter. + // The difference is that the aggregations will be calculated before this filter is applied. + requestOptions.body['post_filter'] = { + terms: { + 'type.keyword': filtersScope, + }, + }; + // Aggregations for the filter options // We have different filters determined by 'index' property. diff --git a/src/app/shared/models/data.model.ts b/src/app/shared/models/data.model.ts index f2342e4f8960a0773c56b27292689d13be5bf481..a6a2b9fb32f30ebac980413e5348e6187676efbe 100644 --- a/src/app/shared/models/data.model.ts +++ b/src/app/shared/models/data.model.ts @@ -20,7 +20,7 @@ export class Data implements IData { this.geometry = data.geometry; this.type = data.type; this.properties = data.properties; - this.id = data.properties.gid; + this.id = data.properties.gid ? data.properties.gid:data.properties.gid_int; } } } diff --git a/src/app/shared/variables.ts b/src/app/shared/variables.ts index 1ce8326326ffc7ccea049107c0e095010992f7e5..44819e091cc00268884ed2836cabd51a5b5613fb 100644 --- a/src/app/shared/variables.ts +++ b/src/app/shared/variables.ts @@ -4,7 +4,7 @@ export const scopesResearch = { all: { key: 'all', label: geosource.researchScope.all, - elasticType: [''], + elasticType: ['dataset', 'nonGeographicDataset', 'series', 'nonGeographicSeries','service','post'], errorItem: geosource.errorItem.all, }, datasets: