-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
253 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
10 changes: 10 additions & 0 deletions
10
apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import '../../../styles.css'; | ||
|
||
.mdc-menu-surface.mat-mdc-autocomplete-panel { | ||
margin-top: 10px !important; | ||
border-radius: 8px; | ||
} | ||
|
||
:host { | ||
display: block; | ||
} |
68 changes: 68 additions & 0 deletions
68
apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<ng-container *ngrxLet="record$ as record"> | ||
<gn-ui-content-ghost | ||
ghostClass="w-full h-full" | ||
[showContent]="!!record?.title" | ||
> | ||
<div class="font-title text-[28px] line-clamp-3 mb-4"> | ||
{{ record.title }} | ||
</div> | ||
<gn-ui-metadata-info [metadata]="record"></gn-ui-metadata-info> | ||
|
||
<gn-ui-image-overlay-preview | ||
class="block h-[185px] mb-5" | ||
[imageUrl]="record?.overviews?.[0]?.url" | ||
> | ||
</gn-ui-image-overlay-preview> | ||
<gn-ui-metadata-contact [metadata]="record"> </gn-ui-metadata-contact> | ||
|
||
<div class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"> | ||
<span translate> record.metadata.download</span> | ||
<gn-ui-previous-next-buttons | ||
*ngIf="downloads.pagesCount > 1" | ||
[listComponent]="downloads" | ||
></gn-ui-previous-next-buttons> | ||
</div> | ||
<gn-ui-block-list | ||
[pageSize]="4" | ||
containerClass="gap-4 pt-3 pb-6" | ||
#downloads | ||
> | ||
<gn-ui-download-item | ||
#block | ||
*ngFor="let otherLink of getDownloads(record.onlineResources)" | ||
[link]="otherLink" | ||
></gn-ui-download-item> | ||
</gn-ui-block-list> | ||
|
||
<div class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"> | ||
<span translate>record.metadata.links</span> | ||
<gn-ui-previous-next-buttons | ||
*ngIf="links.pagesCount > 1" | ||
[listComponent]="links" | ||
></gn-ui-previous-next-buttons> | ||
</div> | ||
<gn-ui-block-list [pageSize]="4" containerClass="gap-4 pt-3 pb-6" #links> | ||
<gn-ui-link-card | ||
#block | ||
*ngFor="let otherLink of getLinks(record.onlineResources)" | ||
[link]="otherLink" | ||
[compact]="true" | ||
></gn-ui-link-card> | ||
</gn-ui-block-list> | ||
|
||
<div class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"> | ||
<span translate>record.metadata.api</span> | ||
<gn-ui-previous-next-buttons | ||
*ngIf="apis.pagesCount > 1" | ||
[listComponent]="apis" | ||
></gn-ui-previous-next-buttons> | ||
</div> | ||
<gn-ui-block-list [pageSize]="4" containerClass="gap-4 pt-3 pb-6" #apis> | ||
<gn-ui-api-card | ||
#block | ||
*ngFor="let otherLink of getAPIs(record.onlineResources)" | ||
[link]="otherLink" | ||
></gn-ui-api-card> | ||
</gn-ui-block-list> | ||
</gn-ui-content-ghost> | ||
</ng-container> |
53 changes: 53 additions & 0 deletions
53
apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CatalogRecord> | ||
|
||
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') | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
apps/webcomponents/src/app/components/gn-record-view/gn-record-view.sample.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Web Component Demo</title> | ||
<base href="./" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@200;300;400;500;600;700&display=swap" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
<style> | ||
body { | ||
margin: 0; | ||
} | ||
header { | ||
height: 200px; | ||
background-color: #5bd261; | ||
} | ||
.container { | ||
max-width: 750px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
padding-top: 3rem; | ||
padding-bottom: 3rem; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<header> | ||
<div class="container"> | ||
<script src="gn-wc.js"></script> | ||
<gn-record-view | ||
api-url="https://www.geo2france.fr/geonetwork/srv/api" | ||
open-on-search="https://www.geo2france.fr/datahub/home/search/?q=${search}" | ||
open-on-select="https://www.geo2france.fr/datahub/dataset/${uuid}" | ||
primary-color="#0f4395" | ||
secondary-color="#8bc832" | ||
main-color="#555" | ||
background-color="#fdfbff" | ||
main-font="'Inter', sans-serif" | ||
title-font="'DM Serif Display', serif" | ||
></gn-record-view> | ||
</div> | ||
</header> | ||
<main></main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters