Skip to content

Commit 55164c8

Browse files
IOT-1380: Removed maxLenght from device AND gateway EUI (#147)
* Fixed routing of gateway list + fixed memory leak by unsubscribing properly from gateway fetches * Fixed routing errors in gateway list * Changed mqtt datatarget topic placeholder + added tooltip * Added additional text changes from Product Owner * Removed maxLenght from device AND gateway EUI, now removes non-hex digits on submit
1 parent deaba3c commit 55164c8

File tree

5 files changed

+49
-41
lines changed

5 files changed

+49
-41
lines changed

src/app/applications/iot-devices/iot-device-edit/iot-device-edit.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@
8080

8181
<div class="form-group mt-3 col-6">
8282
<label class="form-label" for="longitude">{{'IOTDEVICE.LONGITUDE' | translate}}</label>
83-
<input type="number" class="form-control" id="longitude" name="longitude" [placeholder]="00" required
83+
<input type="number" class="form-control" id="longitude" name="longitude" [placeholder]="'00'" required
8484
[(ngModel)]="iotDevice.longitude" step=".000001" min="-180" max="180" maxlength="9"
8585
(keyup)="onCoordinateKey($event)"
8686
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('longitude'), 'is-valid' : formFailedSubmit && !errorFields.includes('longitude')}">
8787
</div>
8888

8989
<div class="form-group mt-3 col-6">
9090
<label class="form-label" for="latitude">{{'IOTDEVICE.LATITUDE' | translate}}</label>
91-
<input type="number" class="form-control" id="latitude" name="latitude" [placeholder]="00" required
91+
<input type="number" class="form-control" id="latitude" name="latitude" [placeholder]="'00'" required
9292
[(ngModel)]="iotDevice.latitude" step=".000001" min="-90" max="90" maxlength="9"
9393
(keyup)="onCoordinateKey($event)"
9494
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('latitude'), 'is-valid' : formFailedSubmit && !errorFields.includes('latitude')}">
@@ -123,7 +123,7 @@ <h3>{{'IOTDEVICE.LORAWANSETUP' | translate}}</h3>
123123

124124
<div class="form-group mt-5">
125125
<label class="form-label" for="devEUI">{{'QUESTION.DEVEUI' | translate}}*</label>
126-
<input type="text" id="devEUI" name="devEUI" maxLength="16"
126+
<input type="text" id="devEUI" name="devEUI"
127127
[placeholder]="'QUESTION.DEVEUI-PLACEHOLDER' | translate" class="form-control"
128128
[(ngModel)]="iotDevice.lorawanSettings.devEUI" [disabled]="editmode"
129129
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('devEUI'), 'is-valid' : formFailedSubmit && !errorFields.includes('devEUI')}">

src/app/applications/iot-devices/iot-device-edit/iot-device-edit.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,14 @@ export class IotDeviceEditComponent implements OnInit, OnDestroy {
320320
}
321321

322322
postIoTDevice() {
323+
// Sanitize devEUI for non-hex characters
324+
if (this.iotDevice.type === DeviceType.LORAWAN) {
325+
this.iotDevice.lorawanSettings.devEUI = this.iotDevice.lorawanSettings.devEUI.replace(
326+
/[^0-9A-Fa-f]/g,
327+
''
328+
);
329+
}
330+
323331
this.iotDeviceService.createIoTDevice(this.iotDevice).subscribe(
324332
(response: IotDevice) => {
325333
this.router.navigate([

src/app/gateway/gateway-edit/gateway-edit.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<div class="form-group mt-3">
2929
<label class="form-label" for="id">{{'QUESTION-LORA-GATEWAY.GATEWAYID' | translate}}</label>*
3030
<input type="text" class="form-control" id="id" name="id"
31-
[placeholder]="'QUESTION-LORA-GATEWAY.GATEWAYID-PLACEHOLDER' | translate" maxlength="16" required
32-
[(ngModel)]="gateway.id" [readonly]="editMode ? true : false"
31+
[placeholder]="'QUESTION-LORA-GATEWAY.GATEWAYID-PLACEHOLDER' | translate" required
32+
[(ngModel)]="gateway.id" [readonly]="editMode"
3333
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('id'), 'is-valid' : formFailedSubmit && !errorFields.includes('id')}">
3434
</div>
3535

@@ -40,15 +40,15 @@
4040
<div class="row mb-5">
4141
<div class="form-group mt-3 col-6">
4242
<label class="form-label" for="longitude">{{'GATEWAY.LONGITUDE' | translate}}</label>
43-
<input type="number" class="form-control" id="longitude" name="longitude" [placeholder]="00" required
43+
<input type="number" class="form-control" id="longitude" name="longitude" [placeholder]="'00'" required
4444
[(ngModel)]="gateway.location.longitude" step=".000001" min="-180" max="180" maxlength="9"
4545
(keyup)="onCoordinateKey($event)"
4646
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('longitude'), 'is-valid' : formFailedSubmit && !errorFields.includes('longitude')}">
4747
</div>
4848

4949
<div class="form-group mt-3 col-6">
50-
<label class="form-label" for="latitude">{{'GATEWAY.LATITUDE' | translate}}</label>
51-
<input type="number" class="form-control" id="location.latitude" name="location.latitude" [placeholder]="00"
50+
<label class="form-label" for="location.latitude">{{'GATEWAY.LATITUDE' | translate}}</label>
51+
<input type="number" class="form-control" id="location.latitude" name="location.latitude" [placeholder]="'00'"
5252
required [(ngModel)]="gateway.location.latitude" step=".000001" min="-180" max="180" maxlength="9"
5353
(keyup)="onCoordinateKey($event)"
5454
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('latitude'), 'is-valid' : formFailedSubmit && !errorFields.includes('latitude')}">

src/app/gateway/gateway-edit/gateway-edit.component.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import { Gateway, GatewayResponse } from '../gateway.model';
1212
@Component({
1313
selector: 'app-gateway-edit',
1414
templateUrl: './gateway-edit.component.html',
15-
styleUrls: ['./gateway-edit.component.scss']
15+
styleUrls: ['./gateway-edit.component.scss'],
1616
})
1717
export class GatewayEditComponent implements OnInit, OnDestroy {
18-
1918
public backButton: BackButton = { label: '', routerLink: ['gateways'] };
2019
public multiPage = false;
2120
public title = '';
@@ -39,18 +38,19 @@ export class GatewayEditComponent implements OnInit, OnDestroy {
3938
private loraGatewayService: ChirpstackGatewayService,
4039
private errorMessageService: ErrorMessageService,
4140
private scrollToTopService: ScrollToTopService
42-
) { }
41+
) {}
4342

4443
ngOnInit(): void {
4544
this.translate.use('da');
4645
this.id = this.route.snapshot.paramMap.get('id');
4746
if (this.id) {
4847
this.getGateway(this.id);
4948
this.editMode = true;
50-
this.backButton.routerLink = ['gateways', 'gateway-detail', this.id]
49+
this.backButton.routerLink = ['gateways', 'gateway-detail', this.id];
5150
}
52-
this.translate.get(['NAV.LORA-GATEWAYS', 'FORM.EDIT-NEW-GATEWAY', 'GATEWAY.SAVE'])
53-
.subscribe(translations => {
51+
this.translate
52+
.get(['NAV.LORA-GATEWAYS', 'FORM.EDIT-NEW-GATEWAY', 'GATEWAY.SAVE'])
53+
.subscribe((translations) => {
5454
this.backButton.label = translations['NAV.LORA-GATEWAYS'];
5555
this.title = translations['FORM.EDIT-NEW-GATEWAY'];
5656
this.submitButton = translations['GATEWAY.SAVE'];
@@ -72,36 +72,35 @@ export class GatewayEditComponent implements OnInit, OnDestroy {
7272
latitude: this.gateway.location.latitude,
7373
draggable: true,
7474
useGeolocation: !this.editMode,
75-
editMode: this.editMode
75+
editMode: this.editMode,
7676
};
7777
}
7878

7979
createGateway(): void {
80-
this.loraGatewayService.post(this.gateway)
81-
.subscribe(
82-
(response) => {
83-
this.routeBack();
84-
},
85-
(error: HttpErrorResponse) => {
86-
this.showError(error);
87-
this.formFailedSubmit = true;
88-
}
89-
);
80+
this.gateway.id = this.gateway.id.replace(/[^0-9A-Fa-f]/g, '');
81+
this.loraGatewayService.post(this.gateway).subscribe(
82+
(response) => {
83+
this.routeBack();
84+
},
85+
(error: HttpErrorResponse) => {
86+
this.showError(error);
87+
this.formFailedSubmit = true;
88+
}
89+
);
9090
}
9191

9292
updateGateway(): void {
9393
// Gateway ID not allowed in update.
9494
this.gateway.id = undefined;
95-
this.loraGatewayService
96-
.put(this.gateway, this.id)
97-
.subscribe(
98-
(response) => {
99-
this.routeBack();
100-
},
101-
(error) => {
102-
this.showError(error);
103-
this.formFailedSubmit = true;
104-
});
95+
this.loraGatewayService.put(this.gateway, this.id).subscribe(
96+
(response) => {
97+
this.routeBack();
98+
},
99+
(error) => {
100+
this.showError(error);
101+
this.formFailedSubmit = true;
102+
}
103+
);
105104
}
106105

107106
onSubmit(): void {
@@ -134,10 +133,11 @@ export class GatewayEditComponent implements OnInit, OnDestroy {
134133
}
135134

136135
private showError(error: HttpErrorResponse) {
137-
const errorResponse = this.errorMessageService.handleErrorMessageWithFields(error);
136+
const errorResponse = this.errorMessageService.handleErrorMessageWithFields(
137+
error
138+
);
138139
this.errorFields = errorResponse.errorFields;
139140
this.errorMessages = errorResponse.errorMessages;
140141
this.scrollToTopService.scrollToTop();
141142
}
142-
143143
}

src/assets/i18n/da.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@
628628
"NFCNTDOWN": "nfcntdown",
629629
"NFCNTDOWN-PLACEHOLDER": "Angiv download framerate",
630630
"DEVEUI": "Enheds EUI (DevEUI)",
631-
"DEVEUI-PLACEHOLDER": "Enheds EUI (DevEUI)",
631+
"DEVEUI-PLACEHOLDER": "Angiv DevEUI (16 tegn)",
632632
"SKIPFCNTCHECK": "SkipFCntCheck",
633633
"SKIPFCNTCHECK-NO": "Nej",
634634
"SKIPFCNTCHECK-YES": "Ja",
@@ -786,7 +786,7 @@
786786
"DESCRIPTION": "LoRaWAN gateway beskrivelse",
787787
"DESCRIPTION-PLACEHOLDER": "Beskrivelse af LoRaWAN gateway",
788788
"GATEWAYID": "Gateway id (EUI)",
789-
"GATEWAYID-PLACEHOLDER": "0000-0000-0000-0000",
789+
"GATEWAYID-PLACEHOLDER": "0000000000000000",
790790
"METADATA": "Gateway tags",
791791
"METADATA-PLACEHOLDER": "Angiv JSON her",
792792
"ALTITUDE": "Højde",
@@ -964,9 +964,9 @@
964964
"REPORTBATTERYSTATUS": "Rapporter enhedens batteriniveau til applikationsserveren",
965965
"REPORTBATTERYMARGIN": "Rapporter device link margin til applikationsserver",
966966
"DRRATEMIN": "Min data rate",
967-
"DRRATEMINEXPLAINED": "Minimum tilladte data rate. Skal være et tal fra 0-7. \nBrugt til ADR",
967+
"DRRATEMINEXPLAINED": "Minimum tilladte data rate. Brugt til ADR",
968968
"DRRATEMAX": "Max data rate",
969-
"DRRATEMAXEXPLAINED": "Maximum tilladte data rate. Skal være et tal fra 0-7. \nBrugt til ADR",
969+
"DRRATEMAXEXPLAINED": "Maximum tilladte data rate. Brugt til ADR",
970970
"SAVE": "Gem",
971971
"CANCEL": "Annuller",
972972
"GOBACK": "Gå tilbage",

0 commit comments

Comments
 (0)