From ac976f6b684e37ab44444fe5985113a2e489d132 Mon Sep 17 00:00:00 2001 From: August Andersen Date: Tue, 17 Sep 2024 16:51:54 +0200 Subject: [PATCH] edited fetch call for gateways map --- .../application-detail.component.ts | 8 ++----- .../gateway-map/gateway-map.component.ts | 23 ++++++------------- .../services/chirpstack-gateway.service.ts | 13 +++++++++++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/app/applications/application-detail/application-detail.component.ts b/src/app/applications/application-detail/application-detail.component.ts index 2494f4a9..cbc27fba 100644 --- a/src/app/applications/application-detail/application-detail.component.ts +++ b/src/app/applications/application-detail/application-detail.component.ts @@ -10,7 +10,7 @@ import { DropdownButton } from "@shared/models/dropdown-button.model"; import { MeService } from "@shared/services/me.service"; import { Subscription } from "rxjs"; import { OrganizationAccessScope } from "@shared/enums/access-scopes"; -import { IotDevicesApplicationMapResponse, IotDevicesResponse } from "@applications/iot-devices/iot-device.model"; +import { IotDevicesApplicationMapResponse } from "@applications/iot-devices/iot-device.model"; import { RestService } from "@shared/services/rest.service"; import { Observable } from "rxjs"; import { map } from "rxjs/operators"; @@ -126,11 +126,7 @@ export class ApplicationDetailComponent implements OnInit, OnDestroy, AfterViewI private getGateways(): void { this.gatewaysSubscription = this.chirpstackGatewayService - .getMultiple({ - limit: null, - offset: null, - sort: null, - }) + .getForMaps() .subscribe((gateways: GatewayResponseMany) => { this.gateways = gateways.resultList; this.mapGatewaysToCoordinateList(); diff --git a/src/app/gateway/gateway-overview/gateway-tabs/gateway-map/gateway-map.component.ts b/src/app/gateway/gateway-overview/gateway-tabs/gateway-map/gateway-map.component.ts index e1d59e03..cf6ce2f6 100644 --- a/src/app/gateway/gateway-overview/gateway-tabs/gateway-map/gateway-map.component.ts +++ b/src/app/gateway/gateway-overview/gateway-tabs/gateway-map/gateway-map.component.ts @@ -42,26 +42,17 @@ export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit { } private getGateways(): void { - this.gatewaySubscription = this.chirpstackGatewayService - .getMultiple({ - limit: null, - offset: null, - sort: null, - }) - .subscribe((gateways: GatewayResponseMany) => { - this.gateways = gateways.resultList; - this.mapToCoordinateList(); - this.setCanEdit(); - this.isLoadingResults = false; - }); + this.gatewaySubscription = this.chirpstackGatewayService.getForMaps().subscribe((gateways: GatewayResponseMany) => { + this.gateways = gateways.resultList; + this.mapToCoordinateList(); + this.setCanEdit(); + this.isLoadingResults = false; + }); } private getGatewayWith(orgId: number): void { this.gatewaySubscription = this.chirpstackGatewayService - .getMultiple({ - limit: null, - offset: null, - sort: null, + .getForMaps({ organizationId: orgId, }) .subscribe((gateways: GatewayResponseMany) => { diff --git a/src/app/shared/services/chirpstack-gateway.service.ts b/src/app/shared/services/chirpstack-gateway.service.ts index 98cc3e2f..f9923e52 100644 --- a/src/app/shared/services/chirpstack-gateway.service.ts +++ b/src/app/shared/services/chirpstack-gateway.service.ts @@ -61,6 +61,19 @@ export class ChirpstackGatewayService { ); } + public getForMaps(params = {}): Observable { + return this.restService.get(`${this.chripstackGatewayUrl}/getAllForMaps`, params).pipe( + map((response: GatewayResponseMany) => { + response.resultList.map(gateway => { + gateway.organizationName = this.sharedVariableService + .getOrganizationInfo() + .find(org => org.id === gateway.organizationId)?.name; + }); + return response; + }) + ); + } + public post(gateway: Gateway): Observable { const gatewayRequest: GatewayRequest = new GatewayRequest(); gatewayRequest.gateway = gateway;