Skip to content

Commit

Permalink
Merge pull request #173 from OS2iot/feature/IoT-1585_LimitGatewaysMap
Browse files Browse the repository at this point in the history
Feature/IoT-1585 limit gateways map
  • Loading branch information
augusthjerrild authored Sep 18, 2024
2 parents 33f6928 + ac976f6 commit ec9810c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
13 changes: 13 additions & 0 deletions src/app/shared/services/chirpstack-gateway.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ export class ChirpstackGatewayService {
);
}

public getForMaps(params = {}): Observable<GatewayResponseMany> {
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<GatewayData> {
const gatewayRequest: GatewayRequest = new GatewayRequest();
gatewayRequest.gateway = gateway;
Expand Down

0 comments on commit ec9810c

Please sign in to comment.