Skip to content

Commit

Permalink
use new type for image preview
Browse files Browse the repository at this point in the history
  • Loading branch information
TIL-EBP committed Oct 28, 2024
1 parent d1b2d4a commit 1f7e186
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
30 changes: 15 additions & 15 deletions src/app/shared/models/gb3-api-generated.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,8 @@ export interface Contact {
export interface Dataset {
/** UUID */
uuid: string;
/** Link auf Bild */
image_url: string | null;
/** image object of the thumbnail image */
image_url: Image;
/** Verfügbarkeit OGD/NOGD */
ogd: boolean;
/** Kontakt: Verantwortlich für Geodaten */
Expand Down Expand Up @@ -951,24 +951,24 @@ export type InfoFeatureField =
label: string;
/** Field value (string, numeric or null) */
value: string | number | null;
/** type for the link object */
type: string;
/** type for the text object (here 'text') */
type: 'text';
}
| {
/** Field label */
label: string;
/** Field link */
value: LinkObject;
/** type for the link object */
type: string;
/** type for the link object (here 'link') */
type: 'link';
}
| {
/** Field label */
label: string;
/** Field image */
value: Image;
/** type for the image object */
type: string;
/** type for the image object (here 'image') */
type: 'image';
};

/** A link MUST be represented as either: a string containing the link’s URL or a link object. */
Expand All @@ -992,10 +992,10 @@ export interface LinkObject {
export interface Map {
/** Map UUID */
uuid: string;
/** Link auf Bild */
image_url: string | null;
/** image object of the thumbnail image */
image_url: Image;
/** Kontakt: Verantwortlich für Geodaten */
kontakt_geodaten: Contact;
kontakt_metadaten: Contact;
/** Map GB2-Nummer */
gb2_id: number;
/** Topic name */
Expand Down Expand Up @@ -1047,8 +1047,8 @@ export interface MunicipalityItem {
export interface Product {
/** Product UUID */
uuid: string;
/** Link auf Bild */
image_url: string | null;
/** image object of the thumbnail image */
image_url: Image;
/** Kontakt: Zuständig für Geometadaten */
kontakt_metadaten: Contact;
/** Product GDP-Nummer */
Expand Down Expand Up @@ -1125,8 +1125,8 @@ export interface SearchMatch {
export interface Service {
/** Service UUID */
uuid: string;
/** Link auf Bild */
image_url: string | null;
/** image object of the thumbnail image */
image_url: Image;
/** Kontakt: Zuständig für Geometadaten */
kontakt_metadaten: Contact;
/** Service GDSer-Nummer */
Expand Down
10 changes: 5 additions & 5 deletions src/app/shared/services/apis/gb3/gb3-metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class Gb3MetadataService extends Gb3ApiService {
mxd: dataset.mxd ? this.createLinkObject(dataset.mxd) : null,
lyr: dataset.lyrs,
pdf: dataset.pdf ? {href: this.createAbsoluteUrl(dataset.pdf.href), title: dataset.pdf.title} : null,
imageUrl: dataset.image_url ? this.createAbsoluteUrl(dataset.image_url) : null,
imageUrl: dataset.image_url ? this.createAbsoluteUrl(dataset.image_url.src.href) : null,
contact: {
geodata: this.extractContactDetails(dataset.kontakt_geodaten),
metadata: this.extractContactDetails(dataset.kontakt_metadaten),
Expand Down Expand Up @@ -220,7 +220,7 @@ export class Gb3MetadataService extends Gb3ApiService {
gisZHNr: mapData.gb2_id,
name: mapData.name,
description: mapData.beschreibung,
imageUrl: mapData.image_url ? this.createAbsoluteUrl(mapData.image_url) : null,
imageUrl: mapData.image_url ? this.createAbsoluteUrl(mapData.image_url.src.href) : null,
externalLinks: mapData.verweise,
gb2Url: mapData.gb2_url
? {
Expand All @@ -230,7 +230,7 @@ export class Gb3MetadataService extends Gb3ApiService {
: null,
datasets: mapData.datasets.map(this.extractDatasetDetail),
contact: {
geodata: this.extractContactDetails(mapData.kontakt_geodaten),
geodata: this.extractContactDetails(mapData.kontakt_metadaten),
},
};
}
Expand All @@ -249,7 +249,7 @@ export class Gb3MetadataService extends Gb3ApiService {
datasets: service.datasets.map(this.extractDatasetDetail),
serviceType: service.servicetyp,
description: service.beschreibung,
imageUrl: service.image_url ? this.createAbsoluteUrl(service.image_url) : null,
imageUrl: service.image_url ? this.createAbsoluteUrl(service.image_url.src.href) : null,
};
}

Expand All @@ -262,7 +262,7 @@ export class Gb3MetadataService extends Gb3ApiService {
metadata: this.extractContactDetails(product.kontakt_metadaten),
},
description: product.beschreibung,
imageUrl: product.image_url ? this.createAbsoluteUrl(product.image_url) : null,
imageUrl: product.image_url ? this.createAbsoluteUrl(product.image_url.src.href) : null,
datasets: product.datasets.map(this.extractDatasetDetail),
};
}
Expand Down
23 changes: 10 additions & 13 deletions src/app/shared/services/apis/gb3/gb3-topics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,16 @@ export class Gb3TopicsService extends Gb3ApiService {
}

private createFeatureInfoFieldValue(field: InfoFeatureField): string | LinkObject | Image | null {
if (field.value === null) {
return null;
}
if (typeof field.value === 'number') {
return field.value.toString();
}
if (typeof field.value === 'string' || 'alt' in field.value) {
return field.value;
} else {
return {
title: field.value.title,
href: field.value.href,
};
switch (field.type) {
case 'image':
return field.value;
case 'link':
return {
title: field.value.title,
href: field.value.href,
};
case 'text':
return typeof field.value === 'number' ? field.value.toString() : null;
}
}
}

0 comments on commit 1f7e186

Please sign in to comment.