Skip to content

Commit ec9810c

Browse files
Merge pull request #173 from OS2iot/feature/IoT-1585_LimitGatewaysMap
Feature/IoT-1585 limit gateways map
2 parents 33f6928 + ac976f6 commit ec9810c

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/app/applications/application-detail/application-detail.component.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { DropdownButton } from "@shared/models/dropdown-button.model";
1010
import { MeService } from "@shared/services/me.service";
1111
import { Subscription } from "rxjs";
1212
import { OrganizationAccessScope } from "@shared/enums/access-scopes";
13-
import { IotDevicesApplicationMapResponse, IotDevicesResponse } from "@applications/iot-devices/iot-device.model";
13+
import { IotDevicesApplicationMapResponse } from "@applications/iot-devices/iot-device.model";
1414
import { RestService } from "@shared/services/rest.service";
1515
import { Observable } from "rxjs";
1616
import { map } from "rxjs/operators";
@@ -126,11 +126,7 @@ export class ApplicationDetailComponent implements OnInit, OnDestroy, AfterViewI
126126

127127
private getGateways(): void {
128128
this.gatewaysSubscription = this.chirpstackGatewayService
129-
.getMultiple({
130-
limit: null,
131-
offset: null,
132-
sort: null,
133-
})
129+
.getForMaps()
134130
.subscribe((gateways: GatewayResponseMany) => {
135131
this.gateways = gateways.resultList;
136132
this.mapGatewaysToCoordinateList();

src/app/gateway/gateway-overview/gateway-tabs/gateway-map/gateway-map.component.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,17 @@ export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit {
4242
}
4343

4444
private getGateways(): void {
45-
this.gatewaySubscription = this.chirpstackGatewayService
46-
.getMultiple({
47-
limit: null,
48-
offset: null,
49-
sort: null,
50-
})
51-
.subscribe((gateways: GatewayResponseMany) => {
52-
this.gateways = gateways.resultList;
53-
this.mapToCoordinateList();
54-
this.setCanEdit();
55-
this.isLoadingResults = false;
56-
});
45+
this.gatewaySubscription = this.chirpstackGatewayService.getForMaps().subscribe((gateways: GatewayResponseMany) => {
46+
this.gateways = gateways.resultList;
47+
this.mapToCoordinateList();
48+
this.setCanEdit();
49+
this.isLoadingResults = false;
50+
});
5751
}
5852

5953
private getGatewayWith(orgId: number): void {
6054
this.gatewaySubscription = this.chirpstackGatewayService
61-
.getMultiple({
62-
limit: null,
63-
offset: null,
64-
sort: null,
55+
.getForMaps({
6556
organizationId: orgId,
6657
})
6758
.subscribe((gateways: GatewayResponseMany) => {

src/app/shared/services/chirpstack-gateway.service.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ export class ChirpstackGatewayService {
6161
);
6262
}
6363

64+
public getForMaps(params = {}): Observable<GatewayResponseMany> {
65+
return this.restService.get(`${this.chripstackGatewayUrl}/getAllForMaps`, params).pipe(
66+
map((response: GatewayResponseMany) => {
67+
response.resultList.map(gateway => {
68+
gateway.organizationName = this.sharedVariableService
69+
.getOrganizationInfo()
70+
.find(org => org.id === gateway.organizationId)?.name;
71+
});
72+
return response;
73+
})
74+
);
75+
}
76+
6477
public post(gateway: Gateway): Observable<GatewayData> {
6578
const gatewayRequest: GatewayRequest = new GatewayRequest();
6679
gatewayRequest.gateway = gateway;

0 commit comments

Comments
 (0)