diff --git a/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.html b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.html index e7fc7b22a..ba12d94ac 100644 --- a/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.html +++ b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.html @@ -4,65 +4,75 @@ [showContent]="!!record?.title" >
- {{ record.title }} + {{ record?.title || 'No Title Available' }}
- + + - -
- record.metadata.download - + + +
+
+ record.metadata.download + +
+ + +
- - - -
- record.metadata.links - +
+
+ record.metadata.links + +
+ + +
- - - -
- record.metadata.api - +
+
+ record.metadata.api + +
+ + +
- - - + + +

No record found for the provided ID.

+
diff --git a/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.ts b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.ts index 357636d3a..ac5fb466b 100644 --- a/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.ts +++ b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.ts @@ -8,7 +8,7 @@ import { } from '@angular/core' import { SearchFacade } from '@geonetwork-ui/feature/search' import { BaseComponent } from '../base.component' -import { Observable } from 'rxjs' +import { Observable, map } from 'rxjs' import { CatalogRecord, OnlineResource, @@ -26,28 +26,42 @@ import { encapsulation: ViewEncapsulation.ShadowDom, providers: [SearchFacade], }) -export class GnRecordViewComponent extends BaseComponent implements OnInit { - @Input() recordId!: string - record$: Observable +export class GnRecordViewComponent extends BaseComponent implements OnInit { + @Input() recordId!: string; + record$: Observable; + downloads$: Observable; + links$: Observable; + apis$: Observable; constructor(injector: Injector) { - super(injector) + super(injector); } ngOnInit() { - super.ngOnInit() - // todo - this.record$ = this.recordsRepository.getRecord(this.recordId) + super.ngOnInit(); + this.record$ = this.recordsRepository.getRecord(this.recordId); + + this.downloads$ = this.record$.pipe( + map((record) => this.getDownloads(record?.onlineResources || [])) + ); + this.links$ = this.record$.pipe( + map((record) => this.getLinks(record?.onlineResources || [])) + ); + this.apis$ = this.record$.pipe( + map((record) => this.getAPIs(record?.onlineResources || [])) + ); } - getDownloads(onlineResources: OnlineResource[]) { - return onlineResources.filter((d) => d.type === 'download') + getDownloads(onlineResources: OnlineResource[]): OnlineResource[] { + return onlineResources.filter((resource) => resource.type === 'download'); } - getAPIs(onlineResources: OnlineResource[]) { - return onlineResources.filter((d) => d.type === 'service') + + getLinks(onlineResources: OnlineResource[]): OnlineResource[] { + return onlineResources.filter((resource) => resource.type === 'link'); } - getLinks(onlineResources: OnlineResource[]) { - return onlineResources.filter((d) => d.type === 'link') + + getAPIs(onlineResources: OnlineResource[]): OnlineResource[] { + return onlineResources.filter((resource) => resource.type === 'service'); } }