diff --git a/apps/geoadmin-demo/src/index.html b/apps/geoadmin-demo/src/index.html index 51f87eed0..7f230b875 100644 --- a/apps/geoadmin-demo/src/index.html +++ b/apps/geoadmin-demo/src/index.html @@ -13,19 +13,34 @@ id="geoadmin-root" src="https://map.geo.admin.ch/#embed?bgLayer=ch.swisstopo.pixelkarte-grau" > + + + + - + record-id="417e9f31-d9d7-4165-9a5c-2f12b7191926" + > diff --git a/apps/geoadmin-demo/src/styles.css b/apps/geoadmin-demo/src/styles.css index 85944f45b..bcc021bda 100644 --- a/apps/geoadmin-demo/src/styles.css +++ b/apps/geoadmin-demo/src/styles.css @@ -14,7 +14,7 @@ body { border: 0; } -gn-search-input { +.search-input { position: absolute; left: 20px; top: 55px; @@ -32,3 +32,14 @@ gn-results-list { background: white; overflow: auto; } + +gn-record-view { + position: absolute; + right: 20px; + top: 125px; + bottom: 20px; + width: 40%; + padding: 8px; + background: white; + overflow: auto; +} diff --git a/apps/geoadmin-demo/src/test-setup.ts b/apps/geoadmin-demo/src/test-setup.ts index a5e675acf..5626c49f2 100644 --- a/apps/geoadmin-demo/src/test-setup.ts +++ b/apps/geoadmin-demo/src/test-setup.ts @@ -1,8 +1,9 @@ -// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment -globalThis.ngJest = { - testEnvironmentOptions: { - errorOnUnknownElements: true, - errorOnUnknownProperties: true, - }, -} import 'jest-preset-angular/setup-jest' +import '../../../jest.setup' + +class ResizeObserverMock { + observe = jest.fn() + unobserve = jest.fn() +} + +;(window as any).ResizeObserver = ResizeObserverMock diff --git a/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.css b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.css new file mode 100644 index 000000000..eeaf25b47 --- /dev/null +++ b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.css @@ -0,0 +1,10 @@ +@import '../../../styles.css'; + +.mdc-menu-surface.mat-mdc-autocomplete-panel { + margin-top: 10px !important; + border-radius: 8px; +} + +:host { + display: block; +} 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 new file mode 100644 index 000000000..e7fc7b22a --- /dev/null +++ b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.html @@ -0,0 +1,68 @@ + + +
+ {{ record.title }} +
+ + + + + + +
+ record.metadata.download + +
+ + + + +
+ record.metadata.links + +
+ + + + +
+ record.metadata.api + +
+ + + +
+
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 new file mode 100644 index 000000000..357636d3a --- /dev/null +++ b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.ts @@ -0,0 +1,53 @@ +import { + ChangeDetectionStrategy, + Component, + Injector, + Input, + OnInit, + ViewEncapsulation, +} from '@angular/core' +import { SearchFacade } from '@geonetwork-ui/feature/search' +import { BaseComponent } from '../base.component' +import { Observable } from 'rxjs' +import { + CatalogRecord, + OnlineResource, +} from '@geonetwork-ui/common/domain/model/record' + +// TODO in this component: +// - Support metadata quality option +// - show data preview + +@Component({ + selector: 'wc-gn-record-view', + templateUrl: './gn-record-view.component.html', + styleUrls: ['./gn-record-view.component.css'], + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.ShadowDom, + providers: [SearchFacade], +}) +export class GnRecordViewComponent extends BaseComponent implements OnInit { + @Input() recordId!: string + + record$: Observable + + constructor(injector: Injector) { + super(injector) + } + + ngOnInit() { + super.ngOnInit() + // todo + this.record$ = this.recordsRepository.getRecord(this.recordId) + } + + getDownloads(onlineResources: OnlineResource[]) { + return onlineResources.filter((d) => d.type === 'download') + } + getAPIs(onlineResources: OnlineResource[]) { + return onlineResources.filter((d) => d.type === 'service') + } + getLinks(onlineResources: OnlineResource[]) { + return onlineResources.filter((d) => d.type === 'link') + } +} diff --git a/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.sample.html b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.sample.html new file mode 100644 index 000000000..52facab6d --- /dev/null +++ b/apps/webcomponents/src/app/components/gn-record-view/gn-record-view.sample.html @@ -0,0 +1,51 @@ + + + + + Web Component Demo + + + + + + + + +
+
+ + +
+
+
+ + diff --git a/apps/webcomponents/src/app/webcomponents.module.ts b/apps/webcomponents/src/app/webcomponents.module.ts index 1b29facb8..5a0a8b342 100644 --- a/apps/webcomponents/src/app/webcomponents.module.ts +++ b/apps/webcomponents/src/app/webcomponents.module.ts @@ -11,7 +11,18 @@ import { BrowserModule } from '@angular/platform-browser' import { Configuration } from '@geonetwork-ui/data-access/gn4' import { FeatureRecordModule } from '@geonetwork-ui/feature/record' import { FeatureSearchModule } from '@geonetwork-ui/feature/search' -import { UiElementsModule } from '@geonetwork-ui/ui/elements' +import { + ApiCardComponent, + ContentGhostComponent, + DownloadItemComponent, + DownloadsListComponent, + ImageOverlayPreviewComponent, + LinkCardComponent, + MetadataContactComponent, + MetadataInfoComponent, + MetadataQualityComponent, + UiElementsModule, +} from '@geonetwork-ui/ui/elements' import { UiInputsModule } from '@geonetwork-ui/ui/inputs' import { UiSearchModule } from '@geonetwork-ui/ui/search' import { @@ -46,6 +57,12 @@ import { UiDatavizModule } from '@geonetwork-ui/ui/dataviz' import { GnDatasetViewMapComponent } from './components/gn-dataset-view-map/gn-dataset-view-map.component' import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' +import { GnRecordViewComponent } from './components/gn-record-view/gn-record-view.component' +import { LetDirective } from '@ngrx/component' +import { + BlockListComponent, + PreviousNextButtonsComponent, +} from '@geonetwork-ui/ui/layout' const CUSTOM_ELEMENTS: [new (...args) => BaseComponent, string][] = [ [GnFacetsComponent, 'gn-facets'], @@ -57,6 +74,7 @@ const CUSTOM_ELEMENTS: [new (...args) => BaseComponent, string][] = [ [GnMapViewerComponent, 'gn-map-viewer'], [GnFigureDatasetsComponent, 'gn-figure-datasets'], [GnDatasetViewMapComponent, 'gn-dataset-view-map'], + [GnRecordViewComponent, 'gn-record-view'], ] @NgModule({ @@ -73,6 +91,7 @@ const CUSTOM_ELEMENTS: [new (...args) => BaseComponent, string][] = [ GnMapViewerComponent, GnFigureDatasetsComponent, GnDatasetViewMapComponent, + GnRecordViewComponent, ], imports: [ CommonModule, @@ -99,6 +118,18 @@ const CUSTOM_ELEMENTS: [new (...args) => BaseComponent, string][] = [ BrowserAnimationsModule, MapStateContainerComponent, LayersPanelComponent, + MetadataInfoComponent, + ContentGhostComponent, + LetDirective, + ImageOverlayPreviewComponent, + MetadataContactComponent, + MetadataQualityComponent, + DownloadsListComponent, + BlockListComponent, + LinkCardComponent, + ApiCardComponent, + DownloadItemComponent, + PreviousNextButtonsComponent, ], providers: [ provideGn4(),