diff --git a/src/app/dataset-detail/components/dataset-api/dataset-api.component.ts b/src/app/dataset-detail/components/dataset-api/dataset-api.component.ts index ba65a838cddb403abca2c414fd401b2f40d71d31..a8004befd7c63fce40d923a768e45c9a96a21eb4 100644 --- a/src/app/dataset-detail/components/dataset-api/dataset-api.component.ts +++ b/src/app/dataset-detail/components/dataset-api/dataset-api.component.ts @@ -45,15 +45,11 @@ export class DatasetAPIComponent implements OnInit, OnDestroy { this.cguModalIsOpened = (this._cookieService.get(environment.cguAcceptedCookieName) !== 'true') && !this._userService.userIsSignedIn; - this.initialize(); this._resourcesService.getResources().subscribe( (results) => { this.resources = results; this.initialize(); - this.sub = this._datasetDetailService.dataset$.subscribe(() => { - this.initialize(); - }); }, (err) => { this._notificationService.notify(new Notification({ @@ -63,6 +59,9 @@ export class DatasetAPIComponent implements OnInit, OnDestroy { }, ); + this.sub = this._datasetDetailService.dataset$.subscribe(() => { + this.initialize(); + }); } ngOnDestroy() { 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 cd5b42ad11c91a9a8bea3f3ba0fb8b979d5cab21..06984893884be851efdab7a704cfbd46fdc771e4 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,12 +8,12 @@ <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"> + <div class="resource-download-item-wrapper" *ngFor="let format of resource.formats; let i=index"> <app-resource-download-item [metadata]="metadata" [format]="format" [resource]="resource" [projections]="projections" [isQueryable]="true"> </app-resource-download-item> - </ng-container> + </div> </div> </div> </div> diff --git a/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.scss b/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.scss index 06f3ae3479771bdcee4fab9a25684f8c408e64d3..cdc0c0476179bde12e1e22fd5de60e3690cdc868 100644 --- a/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.scss +++ b/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.scss @@ -48,11 +48,11 @@ .resource-download { margin-bottom: 1.5rem; - border-bottom: 2px solid $grey-background-color; background-color: white; padding: 2.5rem; box-shadow: 0 6px 12px 0 rgba(129, 128, 128, 0.1); border-radius: 8px; + border-bottom: 2px solid $grey-background-color; } .resource-description { @@ -136,6 +136,15 @@ } } +.resource-download-item-wrapper, +.resource-static-files { + border-bottom: 1px solid #f2f2f2; +} +.resource-downloadable-files:last-of-type .resource-download-item-wrapper:last-of-type, +.resource-static-files:last-of-type { + border-bottom: none; +} + ::ng-deep .downloads-container { .modal { overflow-y: auto; diff --git a/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.ts b/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.ts index 99be9c70c80c4ca5c455ceeff0c8e7ee37965e5d..73e742bb779b1c764f35ead38621a6b0656b8883 100644 --- a/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.ts +++ b/src/app/dataset-detail/components/dataset-downloads/dataset-downloads.component.ts @@ -53,29 +53,26 @@ export class DatasetDownloadsComponent implements OnInit { this.isSample = this._datasetDetailService.dataset.editorialMetadata.isSample; - this.initialize(); - - // Why retrieveDatasetData(): - // to retrieve the first data for the dataset (if exists). It will be used in the - // Data, Downloads and API tabs. forkJoin([ this._resourcesService.getProjections(), this._resourcesService.getResources(), - this._datasetDetailService.retrieveDatasetData(), - ]).subscribe((response) => { - this.projections = response[0]; - this.resources = response[1]; + ]).subscribe( + (response) => { + this.projections = response[0]; + this.resources = response[1]; - this.initialize(); - this.sub = this._datasetDetailService.dataset$.subscribe(() => { this.initialize(); - }); - // tslint:disable-next-line: align - }, (err) => { - this._notificationService.notify(new Notification({ - type: 'error', - message: `${notificationMessages.resources.initializationError}`, - })); + }, + (err) => { + this._notificationService.notify(new Notification({ + type: 'error', + message: `${notificationMessages.resources.initializationError}`, + })); + }, + ); + + this.sub = this._datasetDetailService.dataset$.subscribe(() => { + this.initialize(); }); } 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 0267c2aad187a504204c987e332a962e42bab313..8119b62bd5f74bb13c3f96951852252c32e2930a 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 @@ -1,4 +1,4 @@ - <div class="resource-download"> + <div class="resource-download-item"> <div class="first-line"> <div class="resource-left"> 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 949318b2d8f0d9c414da96a72ba08804de7318ae..b4f9bb3f8bc23a8a73f2edab7c25d93ad5044f41 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 @@ -1,10 +1,9 @@ @import '../../../../../../scss/variables.scss'; @import '../.././../../../../../node_modules/bulma/sass/utilities/_all.sass'; -.resource-download { +.resource-download-item { background-color: white; align-items: center; - border-bottom: 1px solid #f2f2f2; margin-top: 1rem; padding-bottom: 1rem; } diff --git a/src/app/dataset-detail/services/resources.service.ts b/src/app/dataset-detail/services/resources.service.ts index 7fb483590c0d08f0a181f1755147315ef7aa9484..e9b4569ed23233389fa04479782d6b33974c2704 100644 --- a/src/app/dataset-detail/services/resources.service.ts +++ b/src/app/dataset-detail/services/resources.service.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import lodashClonedeep from 'lodash.clonedeep'; +import { of } from 'rxjs'; import { map } from 'rxjs/operators'; import { APP_CONFIG } from '../../core/services/app-config.service'; import { IMetadataLink, linkFormats, Metadata } from '../../shared/models'; @@ -11,24 +12,36 @@ export class ResourcesService { linkFormats = linkFormats; resources: Resource[]; + projections: Projection[]; constructor( private _httpClient: HttpClient, ) { } getResources() { + if (this.resources && this.resources.length > 0) { + return of(this.resources); + } + return this._httpClient.get<IResource[]>(`${APP_CONFIG.backendUrls.resources}/resources`).pipe( map((resourcesBack) => { this.resources = resourcesBack.map(r => new Resource(r)); return this.resources; - })); + }), + ); } getProjections() { + if (this.projections && this.projections.length > 0) { + return of(this.projections); + } + return this._httpClient.get<IProjection[]>(`${APP_CONFIG.backendUrls.resources}/projections`).pipe( - map((resourcesBack) => { - return resourcesBack.map(r => new Projection(r)); - })); + map((projections) => { + this.projections = projections.map(r => new Projection(r)); + return this.projections; + }), + ); } getQueryableResources(link: IMetadataLink[]) {