Skip to content

Commit

Permalink
feat(query): Dynamic info panel
Browse files Browse the repository at this point in the history
Configure content via QUERY_INFO_PANEL injection token
  • Loading branch information
FilipLeitner committed Nov 19, 2024
1 parent 2eafa5f commit 5b5ec2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions projects/hslayers/components/query/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './feature/feature.component';
export * from './query-wms.service';
export * from './query-wmts.service';
export * from './query.component';
export * from './query.tokens';
2 changes: 1 addition & 1 deletion projects/hslayers/components/query/query.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
}
@if (hsLayoutService.mainpanel === 'query') {
<ng-container *ngComponentOutlet="infoPanelComponent">
<ng-container *ngComponentOutlet="infoPanelComponent; injector: injector">
</ng-container>
}
@if (hsQueryBaseService?.coordinates !== undefined && hsQueryBaseService?.coordinates.length > 0) {
Expand Down
18 changes: 9 additions & 9 deletions projects/hslayers/components/query/query.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//TODO: Check if this import is still needed. Breaks production though
//import 'ol-popup/src/ol-popup.css';
import {Component, Inject, OnInit, Type} from '@angular/core';
import {Component, Injector, OnInit, inject} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';

import Popup from 'ol-popup';
import {Subject} from 'rxjs';
import {debounceTime, takeUntil} from 'rxjs/operators';

import {AsyncPipe, NgClass} from '@angular/common';
import {AsyncPipe, NgClass, NgComponentOutlet} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {HsDrawService} from 'hslayers-ng/services/draw';
import {HsLogService} from 'hslayers-ng/services/log';
Expand All @@ -33,12 +33,7 @@ import {TranslateCustomPipe} from 'hslayers-ng/services/language';
AsyncPipe,
NgClass,
FormsModule,
],
providers: [
{
provide: QUERY_INFO_PANEL,
useValue: HsQueryDefaultInfoPanelBodyComponent, // Default value
},
NgComponentOutlet,
],
})
export class HsQueryComponent extends HsPanelBaseComponent implements OnInit {
Expand All @@ -48,14 +43,19 @@ export class HsQueryComponent extends HsPanelBaseComponent implements OnInit {
//To deactivate queries (unsubscribe subscribers) per app
queryDeactivator = new Subject<void>();

// Inject QUERY_INFO_PANEL if available, otherwise fallback to HsQueryDefaultInfoPanelBodyComponent
infoPanelComponent =
inject(QUERY_INFO_PANEL, {optional: true}) ||
HsQueryDefaultInfoPanelBodyComponent;
injector = inject(Injector);

constructor(
public hsQueryBaseService: HsQueryBaseService,
private hsMapService: HsMapService,
private hsLog: HsLogService,
private hsQueryVectorService: HsQueryVectorService,
private hsDrawService: HsDrawService,
private hsQueryWmsService: HsQueryWmsService,
@Inject(QUERY_INFO_PANEL) public infoPanelComponent: Type<any>,
) {
super();
}
Expand Down

0 comments on commit 5b5ec2d

Please sign in to comment.