Skip to content

Commit ce85785

Browse files
cmoinierjahow
authored andcommitted
feat: display error message when record not loaded (#27)
1 parent fc22ef3 commit ce85785

File tree

3 files changed

+89
-76
lines changed

3 files changed

+89
-76
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,97 @@
11
<ng-container *ngrxLet="record$ as record">
2-
<gn-ui-content-ghost
3-
ghostClass="w-full h-full"
4-
[showContent]="!!record?.title"
5-
>
6-
<div class="font-title text-[28px] line-clamp-3 mb-4">
7-
{{ record.title }}
8-
</div>
2+
<ng-container *ngIf="record; else loadingOrError">
3+
<gn-ui-content-ghost
4+
ghostClass="w-full h-full"
5+
[showContent]="!!record?.title"
6+
>
7+
<div class="font-title text-[28px] line-clamp-3 mb-4">
8+
{{ record.title }}
9+
</div>
910

10-
<gn-ui-metadata-info [metadata]="record"></gn-ui-metadata-info>
11-
<div class="grid grid-cols-2 items-center mt-5">
12-
<gn-ui-image-overlay-preview
13-
class="block h-[185px] mb-5 mr-2"
14-
*ngIf="record?.overviews?.length > 0"
15-
[imageUrl]="record?.overviews?.[0]?.url"
16-
>
17-
</gn-ui-image-overlay-preview>
11+
<gn-ui-metadata-info [metadata]="record"></gn-ui-metadata-info>
12+
<div class="grid grid-cols-2 items-center mt-5">
13+
<gn-ui-image-overlay-preview
14+
class="block h-[185px] mb-5 mr-2"
15+
*ngIf="record?.overviews?.length > 0"
16+
[imageUrl]="record?.overviews?.[0]?.url"
17+
>
18+
</gn-ui-image-overlay-preview>
1819

19-
<gn-ui-metadata-contact
20-
class="pl-2"
21-
[metadata]="record"
22-
></gn-ui-metadata-contact>
23-
</div>
24-
<div *ngIf="getDownloads(record?.onlineResources)?.length > 0">
25-
<div
26-
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
27-
>
28-
<span translate>record.metadata.download</span>
29-
<gn-ui-previous-next-buttons
30-
*ngIf="downloads?.pagesCount > 1"
31-
[listComponent]="downloads"
32-
></gn-ui-previous-next-buttons>
20+
<gn-ui-metadata-contact
21+
class="pl-2"
22+
[metadata]="record"
23+
></gn-ui-metadata-contact>
24+
</div>
25+
<div *ngIf="getDownloads(record?.onlineResources)?.length > 0">
26+
<div
27+
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
28+
>
29+
<span translate>record.metadata.download</span>
30+
<gn-ui-previous-next-buttons
31+
*ngIf="downloads?.pagesCount > 1"
32+
[listComponent]="downloads"
33+
></gn-ui-previous-next-buttons>
34+
</div>
35+
<gn-ui-block-list
36+
[pageSize]="4"
37+
containerClass="gap-4 pt-3 pb-6"
38+
#downloads
39+
>
40+
<gn-ui-download-item
41+
*ngFor="let otherLink of getDownloads(record?.onlineResources)"
42+
[link]="otherLink"
43+
></gn-ui-download-item>
44+
</gn-ui-block-list>
3345
</div>
34-
<gn-ui-block-list
35-
[pageSize]="4"
36-
containerClass="gap-4 pt-3 pb-6"
37-
#downloads
38-
>
39-
<gn-ui-download-item
40-
*ngFor="let otherLink of getDownloads(record?.onlineResources)"
41-
[link]="otherLink"
42-
></gn-ui-download-item>
43-
</gn-ui-block-list>
44-
</div>
4546

46-
<div *ngIf="getLinks(record?.onlineResources)?.length > 0">
47-
<div
48-
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
49-
>
50-
<span translate>record.metadata.links</span>
51-
<gn-ui-previous-next-buttons
52-
*ngIf="links?.pagesCount > 1"
53-
[listComponent]="links"
54-
></gn-ui-previous-next-buttons>
47+
<div *ngIf="getLinks(record?.onlineResources)?.length > 0">
48+
<div
49+
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
50+
>
51+
<span translate>record.metadata.links</span>
52+
<gn-ui-previous-next-buttons
53+
*ngIf="links?.pagesCount > 1"
54+
[listComponent]="links"
55+
></gn-ui-previous-next-buttons>
56+
</div>
57+
<gn-ui-block-list
58+
[pageSize]="4"
59+
containerClass="gap-4 pt-3 pb-6"
60+
#links
61+
>
62+
<gn-ui-link-card
63+
*ngFor="let otherLink of getLinks(record?.onlineResources)"
64+
[link]="otherLink"
65+
[compact]="true"
66+
></gn-ui-link-card>
67+
</gn-ui-block-list>
5568
</div>
56-
<gn-ui-block-list [pageSize]="4" containerClass="gap-4 pt-3 pb-6" #links>
57-
<gn-ui-link-card
58-
*ngFor="let otherLink of getLinks(record?.onlineResources)"
59-
[link]="otherLink"
60-
[compact]="true"
61-
></gn-ui-link-card>
62-
</gn-ui-block-list>
63-
</div>
6469

65-
<div *ngIf="getAPIs(record?.onlineResources)?.length > 0">
66-
<div
67-
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
68-
>
69-
<span translate>record.metadata.api</span>
70-
<gn-ui-previous-next-buttons
71-
*ngIf="apis?.pagesCount > 1"
72-
[listComponent]="apis"
73-
></gn-ui-previous-next-buttons>
70+
<div *ngIf="getAPIs(record?.onlineResources)?.length > 0">
71+
<div
72+
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
73+
>
74+
<span translate>record.metadata.api</span>
75+
<gn-ui-previous-next-buttons
76+
*ngIf="apis?.pagesCount > 1"
77+
[listComponent]="apis"
78+
></gn-ui-previous-next-buttons>
79+
</div>
80+
<gn-ui-block-list [pageSize]="4" containerClass="gap-4 pt-3 pb-6" #apis>
81+
<gn-ui-api-card
82+
*ngFor="let otherLink of getAPIs(record?.onlineResources)"
83+
[link]="otherLink"
84+
[currentLink]="otherLink"
85+
></gn-ui-api-card>
86+
</gn-ui-block-list>
7487
</div>
75-
<gn-ui-block-list [pageSize]="4" containerClass="gap-4 pt-3 pb-6" #apis>
76-
<gn-ui-api-card
77-
*ngFor="let otherLink of getAPIs(record?.onlineResources)"
78-
[link]="otherLink"
79-
[currentLink]="otherLink"
80-
></gn-ui-api-card>
81-
</gn-ui-block-list>
82-
</div>
83-
</gn-ui-content-ghost>
88+
</gn-ui-content-ghost>
89+
</ng-container>
8490
</ng-container>
8591

8692
<ng-template #loadingOrError>
87-
<p *ngIf="(record$ | async) === null">No record found for the provided ID.</p>
93+
<gn-ui-error
94+
[type]="errorTypes.RECORD_NOT_FOUND"
95+
[recordId]="recordId"
96+
></gn-ui-error>
8897
</ng-template>

apps/webcomponents/src/app/components/gn-record-view/gn-record-view.component.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
CatalogRecord,
1414
OnlineResource,
1515
} from '@geonetwork-ui/common/domain/model/record'
16+
import { ErrorType } from '@geonetwork-ui/ui/elements'
1617

1718
// TODO in this component:
1819
// - Support metadata quality option
@@ -32,6 +33,7 @@ export class GnRecordViewComponent extends BaseComponent implements OnInit {
3233
downloads$: Observable<OnlineResource[]>
3334
links$: Observable<OnlineResource[]>
3435
apis$: Observable<OnlineResource[]>
36+
errorType = ErrorType
3537

3638
constructor(injector: Injector) {
3739
super(injector)

apps/webcomponents/src/app/webcomponents.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
ContentGhostComponent,
1717
DownloadItemComponent,
1818
DownloadsListComponent,
19+
ErrorComponent,
1920
ImageOverlayPreviewComponent,
2021
LinkCardComponent,
2122
MetadataContactComponent,
@@ -130,6 +131,7 @@ const CUSTOM_ELEMENTS: [new (...args) => BaseComponent, string][] = [
130131
ApiCardComponent,
131132
DownloadItemComponent,
132133
PreviousNextButtonsComponent,
134+
ErrorComponent,
133135
],
134136
providers: [
135137
provideGn4(),

0 commit comments

Comments
 (0)