Skip to content

Commit

Permalink
gpf - use geoadmin.ch iframe
Browse files Browse the repository at this point in the history
for records which refers a map.geoadmin.ch link
  • Loading branch information
fgravin authored and jahow committed Nov 29, 2024
1 parent 84f29c7 commit fd31fc5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@
style="height: 500px"
*ngIf="displayMap$ | async"
>
<gn-ui-map-view></gn-ui-map-view>
<gn-ui-map-view
*ngIf="(geoAdminUrl$ | async) === null"
></gn-ui-map-view>
<iframe
class="w-full h-full"
*ngIf="geoAdminUrl$ | async"
[src]="geoAdminUrl$ | async"
></iframe>
</div>
</mat-tab>
<mat-tab [disabled]="(displayData$ | async) === false">
Expand All @@ -106,7 +113,10 @@
</div>
</div>
<gn-ui-data-view-share
*ngIf="(displayMap$ | async) || (displayData$ | async)"
*ngIf="
(geoAdminUrl$ | async) === false &&
((displayMap$ | async) || (displayData$ | async))
"
[viewType]="selectedView$ | async"
></gn-ui-data-view-share>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ErrorComponent,
ErrorType,
ImageOverlayPreviewComponent,
MetadataCatalogComponent,
MetadataContactComponent,
MetadataInfoComponent,
MetadataQualityComponent,
Expand All @@ -31,6 +30,7 @@ import { RecordApisComponent } from '../record-apis/record-apis.component'
import { RecordOtherlinksComponent } from '../record-otherlinks/record-otherlinks.component'
import { RecordRelatedRecordsComponent } from '../record-related-records/record-related-records.component'
import { TranslateModule } from '@ngx-translate/core'
import { DomSanitizer } from '@angular/platform-browser'

@Component({
selector: 'datahub-record-metadata',
Expand All @@ -51,7 +51,6 @@ import { TranslateModule } from '@ngx-translate/core'
MetadataInfoComponent,
MetadataContactComponent,
MetadataQualityComponent,
MetadataCatalogComponent,
RecordRelatedRecordsComponent,
DataViewComponent,
MapViewComponent,
Expand All @@ -71,6 +70,21 @@ export class RecordMetadataComponent {
startWith(false)
)

geoAdminUrl$ = this.metadataViewFacade.otherLinks$.pipe(
map((mapApiLinks) => {
return mapApiLinks?.find((link) =>
link?.url.toString().startsWith('https://map.geo.admin.ch/')
)
}),
filter((geoAdminUrl) => !!geoAdminUrl),
map((link) =>
this.sanitizer.bypassSecurityTrustResourceUrl(
link.url.toString().replace('?layers=', '#/embed?layers=')
)
),
startWith(null)
)

displayData$ = combineLatest([
this.metadataViewFacade.dataLinks$,
this.metadataViewFacade.geoDataLinks$,
Expand Down Expand Up @@ -149,6 +163,7 @@ export class RecordMetadataComponent {
public metadataViewFacade: MdViewFacade,
private searchService: SearchService,
private sourceService: SourcesService,
private sanitizer: DomSanitizer,
private orgsService: OrganizationsServiceInterface
) {}

Expand Down

0 comments on commit fd31fc5

Please sign in to comment.