@@ -18,7 +18,7 @@ import { Component, ElementRef, ViewChild } from '@angular/core';
1818import { InputGeometryComponent } from "../../components/input-geometry/input-geometry.component" ;
1919import { ComponentsModule } from 'src/app/components/components.module' ;
2020import { SvcSearchInputComponent } from "../../components/svc-search-input/svc-search-input.component" ;
21- import { SearchObjectResult , SearchParameters , SECOMService } from 'src/app/backend-api/secom' ;
21+ import { SearchFilterObject , SearchObjectResult , SearchParameters , SECOMService } from 'src/app/backend-api/secom' ;
2222import { InstanceInfo , ItemType } from 'src/app/common/menuType' ;
2323import { ColumnForResource } from 'src/app/common/columnForMenu' ;
2424import { InstanceControllerService , InstanceDto } from 'src/app/backend-api/service-registry' ;
@@ -72,6 +72,7 @@ export class SrSearchComponent {
7272 showPanel = false ;
7373 selectedInstance : any = { } ;
7474 instanceType = ItemType . Instance ;
75+ localOnly : boolean = true ;
7576
7677 constructor (
7778 private router : Router ,
@@ -107,14 +108,14 @@ export class SrSearchComponent {
107108 fetchData = async ( itemType : ItemType , pageNumber : number , elementsPerPage : number ) => {
108109 try {
109110 console . debug ( "Call fetch data with params:" , this . searchParams , this . queryGeometry ) ;
110- const secomSearchParam = this . buildSearchParam ( this . searchParams , Object . keys ( this . queryGeometry ) . length > 0 ? JSON . stringify ( this . queryGeometry ) : '' ) ; //geojsonToWKT(this.queryGeometry) : '');
111+ const secomSearchFilterObj = this . buildSearchFilterObject ( this . searchParams , Object . keys ( this . queryGeometry ) . length > 0 ? JSON . stringify ( this . queryGeometry ) : '' , this . localOnly ) ; //geojsonToWKT(this.queryGeometry) : '');
111112 if ( this . freetext === '' && Object . keys ( this . searchParams ) . length === 0 && Object . keys ( this . queryGeometry ) . length === 0 ) {
112113 return [ ] ;
113114 }
114115 // a bit of hack to deal with the fact that the search service does not support total number of elements....
115116 let fetchedItems ;
116117 try {
117- fetchedItems = await this . itemManagerService . fetchListOfData ( itemType , this . orgMrn , pageNumber , 100 , secomSearchParam ) ;
118+ fetchedItems = await this . itemManagerService . fetchListOfData ( itemType , this . orgMrn , pageNumber , 100 , secomSearchFilterObj ) ;
118119 } catch ( error ) {
119120 console . error ( 'Error fetching items:' , error ) ;
120121 this . notifier . notify ( 'error.search.general' , ( error as any ) . message ) ;
@@ -139,20 +140,23 @@ export class SrSearchComponent {
139140 }
140141 }
141142
142- buildSearchParam = ( searchParams : SearchParameters , geojsonString ?: string ) : object => {
143- const queryObject : any = { } ;
143+ buildSearchFilterObject = ( searchParams : SearchParameters , geojsonString ?: string , localOnly ? : boolean ) : object => {
144+ let searchFilterObj : SearchFilterObject = {
145+ } ;
144146
145147 // Only add the query section if it has data
146148 if ( searchParams && Object . keys ( searchParams ) . length > 0 ) {
147- queryObject [ " query" ] = searchParams ;
149+ searchFilterObj . query = searchParams ;
148150 }
149151
150152 // Add geometry only if provided
151153 if ( geojsonString ) {
152- queryObject [ " geometry" ] = geojsonString ;
154+ searchFilterObj . geometry = geojsonString ;
153155 }
154156
155- return queryObject ;
157+ searchFilterObj . localOnly = localOnly ;
158+
159+ return searchFilterObj ;
156160 } ;
157161
158162 onUpdateGeometry = ( event : any ) => {
@@ -175,7 +179,7 @@ export class SrSearchComponent {
175179
176180 search = ( searchParams : SearchParameters , geojsonString ?: string ) => {
177181 this . isLoading = true ;
178- const queryObject = this . buildSearchParam ( searchParams , geojsonString ) ;
182+ const queryObject = this . buildSearchFilterObject ( searchParams , geojsonString , this . localOnly ) ;
179183 this . secomSearchController . search ( queryObject ) . subscribe ( res => {
180184 this . instances = res . services ;
181185 this . refreshData ( this . instances ) ;
@@ -198,7 +202,14 @@ export class SrSearchComponent {
198202 if ( this . geometryMap ) {
199203 this . geometryMap . clearMap ( ) ;
200204 }
201- console . debug ( "Noermal search with params:" , this . searchParams ) ;
205+
206+ if ( payload . scope === 'global' ) {
207+ this . localOnly = false ;
208+ } else {
209+ this . localOnly = true ;
210+ }
211+
212+
202213 this . smartTable . loadData ( ) ;
203214 }
204215
0 commit comments