diff --git a/src/app/network-server/adr-algorithm.model.ts b/src/app/network-server/adr-algorithm.model.ts new file mode 100644 index 000000000..9796e098f --- /dev/null +++ b/src/app/network-server/adr-algorithm.model.ts @@ -0,0 +1,7 @@ +export class AdrAlgorithm { + public id: string; + public name: string; +} +export interface AdrAlgorithmResponse { + adrAlgorithms: AdrAlgorithm[]; +} diff --git a/src/app/network-server/network-server.service.ts b/src/app/network-server/network-server.service.ts new file mode 100644 index 000000000..631bd9a8d --- /dev/null +++ b/src/app/network-server/network-server.service.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@angular/core'; +import { RestService } from '@shared/services/rest.service'; +import { Observable } from 'rxjs'; +import { AdrAlgorithmResponse } from '@app/network-server/adr-algorithm.model'; + + +@Injectable({ + providedIn: 'root' +}) +export class NetworkServerService { + URL = 'chirpstack/network-server'; + + constructor( + private restService: RestService) {} + + + getAllAdrAlgorithms(): Observable { + return this.restService.get(`${this.URL}/adr-algorithms`, {}); + } +} diff --git a/src/app/profiles/device-profiles/device-profile.model.ts b/src/app/profiles/device-profiles/device-profile.model.ts index 6cedd5df3..d211fea19 100644 --- a/src/app/profiles/device-profiles/device-profile.model.ts +++ b/src/app/profiles/device-profiles/device-profile.model.ts @@ -3,6 +3,7 @@ import { EditPermission } from '@shared/models/edit-permission.model'; export class DeviceProfile extends EditPermission { public id: string; public name: string; + public adrAlgorithmID = 'default'; public classBTimeout = 0; public classCTimeout = 0; public factoryPresetFreqs: number[]; diff --git a/src/app/profiles/device-profiles/device-profiles-edit/device-profiles-edit.component.html b/src/app/profiles/device-profiles/device-profiles-edit/device-profiles-edit.component.html index 6595db403..055a16c8c 100644 --- a/src/app/profiles/device-profiles/device-profiles-edit/device-profiles-edit.component.html +++ b/src/app/profiles/device-profiles/device-profiles-edit/device-profiles-edit.component.html @@ -67,6 +67,18 @@

{{ 'PROFILES.DEVICE_PROFILE.DETAILS' | translate }}

+ +
+ + + + {{ adr.name }} + + +
+
diff --git a/src/app/profiles/device-profiles/device-profiles-edit/device-profiles-edit.component.ts b/src/app/profiles/device-profiles/device-profiles-edit/device-profiles-edit.component.ts index 2674c83ca..a3a46ae9b 100644 --- a/src/app/profiles/device-profiles/device-profiles-edit/device-profiles-edit.component.ts +++ b/src/app/profiles/device-profiles/device-profiles-edit/device-profiles-edit.component.ts @@ -10,6 +10,8 @@ import { Subscription } from 'rxjs'; import { DeviceProfile } from '../device-profile.model'; import { DeviceProfileService } from '../device-profile.service'; import { OrganizationAccessScope } from '@shared/enums/access-scopes'; +import { AdrAlgorithm, AdrAlgorithmResponse } from '@app/network-server/adr-algorithm.model'; +import { NetworkServerService } from '@app/network-server/network-server.service'; @Component({ selector: 'app-device-profiles-edit', @@ -27,6 +29,7 @@ export class DeviceProfilesEditComponent implements OnInit, OnDestroy { public formFailedSubmit = false; public title = ''; public backButton: BackButton = { label: '', routerLink: '/profiles' }; + public adrAlgorithms: AdrAlgorithm[] = []; constructor( private route: ActivatedRoute, @@ -34,7 +37,8 @@ export class DeviceProfilesEditComponent implements OnInit, OnDestroy { private deviceProfileService: DeviceProfileService, private location: Location, private meService: MeService, - private errorMessageService: ErrorMessageService + private errorMessageService: ErrorMessageService, + private networkServerService: NetworkServerService ) { } ngOnInit(): void { @@ -44,6 +48,12 @@ export class DeviceProfilesEditComponent implements OnInit, OnDestroy { this.backButton.label = translations['PROFILES.NAME']; }); + this.networkServerService.getAllAdrAlgorithms() + .subscribe( + response => { + this.adrAlgorithms = response.adrAlgorithms; + }); + this.id = this.route.snapshot.paramMap.get('deviceId'); if (this.id) { this.getDeviceProfile(this.id); diff --git a/src/assets/i18n/da.json b/src/assets/i18n/da.json index e4367d90f..5f492ba1a 100644 --- a/src/assets/i18n/da.json +++ b/src/assets/i18n/da.json @@ -896,6 +896,7 @@ "NAME": "Device profil navn", "NAME_PLACEHOLDER": "Device profil navn", "MACVERSION": "LoRaWAN MAC version ", + "ADRALGORITHM": "ADR algoritme ", "REGPARAMSREVISION": "LoRaWAN regional parameters revision ", "MAXEIRP": "Max EIRP ", "GEOLOCBUFFERTTL": "Geolocation buffer TTL (seconds)",