Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed maxLenght from device AND gateway EUI #147

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 75 additions & 65 deletions src/app/applications/datatarget/mqtt-edit/mqtt-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,79 +14,89 @@
<div class="form-group mt-3 col-12">
<label class="form-label" for="name">{{'QUESTION.GIVE-DATATARGET-NAME' | translate}}</label>*
<input type="text" class="form-control" id="name" name="name"
[placeholder]="'QUESTION.GIVE-DATATARGET-NAME-PLACEHOLDER' | translate" maxlength="50" required
[(ngModel)]="datatarget.name"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('name'), 'is-valid' : formFailedSubmit && !errorFields.includes('name')}">
[placeholder]="'QUESTION.GIVE-DATATARGET-NAME-PLACEHOLDER' | translate" maxlength="50" required
[(ngModel)]="datatarget.name"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('name'), 'is-valid' : formFailedSubmit && !errorFields.includes('name')}">
</div>
</div>

<div class="row mb-2">
<div class="form-group mt-3 col-12">
<label class="form-label" for="url">{{'QUESTION.DATATARGET.MQTT.GIVE-URL' | translate}}</label>*
<input type="text" class="form-control" id="url" name="url"
[placeholder]="'QUESTION.DATATARGET.MQTT.GIVE-URL-PLACEHOLDER' | translate" required
[(ngModel)]="datatarget.url"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('url'), 'is-valid' : formFailedSubmit && !errorFields.includes('url')}">
[placeholder]="'QUESTION.DATATARGET.MQTT.GIVE-URL-PLACEHOLDER' | translate" required
[(ngModel)]="datatarget.url"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('url'), 'is-valid' : formFailedSubmit && !errorFields.includes('url')}">
</div>
</div>

<div class="row mb-2">
<div class="form-group mt-3 col-12">
<label class="form-label" for="mqtt-port">{{'QUESTION.DATATARGET.MQTT.GIVE-PORT' | translate}}</label>*
<input type="number" class="form-control" id="mqtt-port" name="mqtt-port" [required]="true"
[placeholder]="'QUESTION.DATATARGET.MQTT.GIVE-PORT-PLACEHOLDER' | translate" [(ngModel)]="datatarget.mqttPort"
step="1" min="1025" max="65535"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttPort'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttPort')}">
[placeholder]="'QUESTION.DATATARGET.MQTT.GIVE-PORT-PLACEHOLDER' | translate"
[(ngModel)]="datatarget.mqttPort"
step="1" min="1025" max="65535"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttPort'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttPort')}">
</div>
</div>

<div class="row mb-2">
<div class="form-group mt-3 col-12">
<label class="form-label" for="mqtt-qos">{{'QUESTION.DATATARGET.MQTT.GIVE-QOS' | translate}}</label>*
<fa-icon [icon]="faQuestionCircle" class="form-info-icon"
[matTooltip]="'QUESTION.DATATARGET.MQTT.GIVE-QOS-INFO' | translate" matTooltipPosition="above"
matTooltipShowDelay="600" matTooltipHideDelay="2000"></fa-icon>
[matTooltip]="'QUESTION.DATATARGET.MQTT.GIVE-QOS-INFO' | translate" matTooltipPosition="above"
matTooltipShowDelay="600" matTooltipHideDelay="2000"></fa-icon>
<input type="number" class="form-control" id="mqtt-qos" name="mqtt-qos" [required]="true"
[placeholder]="'QUESTION.DATATARGET.MQTT.GIVE-QOS-PLACEHOLDER' | translate" [(ngModel)]="datatarget.mqttQos"
step="1" min="0" max="2"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttQos'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttQos')}">
[placeholder]="'QUESTION.DATATARGET.MQTT.GIVE-QOS-PLACEHOLDER' | translate"
[(ngModel)]="datatarget.mqttQos"
step="1" min="0" max="2"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttQos'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttQos')}">
</div>
</div>

<div class="row mb-2">
<div class="form-group mt-3 col-12">
<label class="form-label" for="mqtt-topic">{{'QUESTION.DATATARGET.MQTT.GIVE-TOPIC' | translate}}</label>*
<fa-icon
[icon]="faQuestionCircle"
class="form-info-icon"
[matTooltip]="'QUESTION.DATATARGET.MQTT.GIVE-TOPIC-INFO' | translate"
matTooltipPosition="above"
matTooltipShowDelay="600"
matTooltipHideDelay="2000"
></fa-icon>
<input type="text" class="form-control" id="mqtt-topic" name="mqtt-topic"
[placeholder]="'QUESTION.DATATARGET.MQTT.GIVE-TOPIC-PLACEHOLDER' | translate" required
[(ngModel)]="datatarget.mqttTopic"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttTopic'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttTopic')}">
[placeholder]="'QUESTION.DATATARGET.MQTT.GIVE-TOPIC-PLACEHOLDER' | translate" required
[(ngModel)]="datatarget.mqttTopic"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttTopic'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttTopic')}">
</div>
</div>

<div class="row mb-2">
<div class="form-group mt-3 col-12">
<label class="form-label" for="mqttUsername">{{'QUESTION.DATATARGET.MQTT.GIVE-USERNAME' | translate}}</label>*
<input type="text" class="form-control" id="mqttUsername" name="mqttUsername" [required]="true"
[(ngModel)]="datatarget.mqttUsername"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttUsername'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttUsername')}">
[(ngModel)]="datatarget.mqttUsername"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttUsername'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttUsername')}">
</div>
</div>

<div class="row mb-2">
<div class="form-group mt-3 col-12">
<label class="form-label" for="mqttPassword">{{'QUESTION.DATATARGET.MQTT.GIVE-PASSWORD' | translate}}</label>*
<input type="password" class="form-control" id="mqttPassword" name="mqttPassword" [required]="true"
[(ngModel)]="datatarget.mqttPassword"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttPassword'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttPassword')}">
[(ngModel)]="datatarget.mqttPassword"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('mqttPassword'), 'is-valid' : formFailedSubmit && !errorFields.includes('mqttPassword')}">
</div>
</div>

<div class="row mb-2">
<div class="form-group mt-3 col-12">
<label class="form-label" for="timeout">{{'QUESTION.GIVE-DATATARGET-TIMEOUT' | translate}}</label>*
<input type="number" class="form-control" id="timeout" name="timeout" required [(ngModel)]="datatarget.timeout"
step="1" min="0" max="100000" maxlength="7"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('timeout'), 'is-valid' : formFailedSubmit && !errorFields.includes('timeout')}">
step="1" min="0" max="100000" maxlength="7"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('timeout'), 'is-valid' : formFailedSubmit && !errorFields.includes('timeout')}">
</div>
</div>

Expand All @@ -99,49 +109,49 @@ <h6> {{'QUESTION.DATATARGET.RELATIONS' | translate}} </h6>
<ng-container *ngIf="devices && payloadDecoders && payloadDeviceDatatarget?.length > 0">
<table class="table table-striped table-bordered">
<tbody>
<tr *ngFor="let element of payloadDeviceDatatarget; let i = index;" [attr.data-index]="i">
<td>
<div class="row">
<mat-form-field appearance="fill">
<mat-label>{{'QUESTION.DATATARGET.SELECT-DEVICES' | translate}}</mat-label>
<mat-select multiple name="devices" [(value)]="element.iotDeviceIds">
<mat-option disabled="disabled" class="filter-option">
<button mat-raised-button class="mat-primary fill text-sm" (click)="selectAllDevices(i)">
{{'QUESTION.DATATARGET.SELECTALLDEVICES' | translate}}
</button>
<button mat-raised-button class="mat-primary fill text-sm" (click)="deselectAllDevices(i)">
{{'QUESTION.DATATARGET.DESELECTALLDEVICES' | translate}}
</button>
</mat-option>
<mat-option *ngFor="let device of devices" [value]="device.id">{{device.name}}</mat-option>
</mat-select>
</mat-form-field>
<tr *ngFor="let element of payloadDeviceDatatarget; let i = index;" [attr.data-index]="i">
<td>
<div class="row">
<mat-form-field appearance="fill">
<mat-label>{{'QUESTION.DATATARGET.SELECT-DEVICES' | translate}}</mat-label>
<mat-select multiple name="devices" [(value)]="element.iotDeviceIds">
<mat-option disabled="disabled" class="filter-option">
<button mat-raised-button class="mat-primary fill text-sm" (click)="selectAllDevices(i)">
{{'QUESTION.DATATARGET.SELECTALLDEVICES' | translate}}
</button>
<button mat-raised-button class="mat-primary fill text-sm" (click)="deselectAllDevices(i)">
{{'QUESTION.DATATARGET.DESELECTALLDEVICES' | translate}}
</button>
</mat-option>
<mat-option *ngFor="let device of devices" [value]="device.id">{{device.name}}</mat-option>
</mat-select>
</mat-form-field>
</div>
</td>
<td>
<div class="row">
<mat-form-field appearance="fill">
<mat-label>{{'QUESTION.DATATARGET.SELECT-PAYLOADDECODER' | translate}}</mat-label>
<mat-select matNativeControl name="payloadDecoderId" [(value)]="element.payloadDecoderId">
<mat-option [value]="0">
{{'QUESTION.DATATARGET.NO-PAYLOAD-DECODER-SELECTED' | translate}}
</mat-option>
<mat-option *ngFor="let payloadDecoder of payloadDecoders" [value]="payloadDecoder.id">
{{payloadDecoder.name}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</td>
<td>
<a (click)="openDeleteDialog(i)">
<div class="text-center m-2">
<fa-icon [icon]="faTimesCircle"></fa-icon>
<p>{{'DATATARGET.DELETE' | translate}}</p>
</div>
</td>
<td>
<div class="row">
<mat-form-field appearance="fill">
<mat-label>{{'QUESTION.DATATARGET.SELECT-PAYLOADDECODER' | translate}}</mat-label>
<mat-select matNativeControl name="payloadDecoderId" [(value)]="element.payloadDecoderId">
<mat-option [value]="0">
{{'QUESTION.DATATARGET.NO-PAYLOAD-DECODER-SELECTED' | translate}}
</mat-option>
<mat-option *ngFor="let payloadDecoder of payloadDecoders" [value]="payloadDecoder.id">
{{payloadDecoder.name}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</td>
<td>
<a (click)="openDeleteDialog(i)">
<div class="text-center m-2">
<fa-icon [icon]="faTimesCircle"></fa-icon>
<p>{{'DATATARGET.DELETE' | translate}}</p>
</div>
</a>
</td>
</tr>
</a>
</td>
</tr>
</tbody>
</table>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@

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

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

<div class="form-group mt-5">
<label class="form-label" for="devEUI">{{'QUESTION.DEVEUI' | translate}}*</label>
<input type="text" id="devEUI" name="devEUI" maxLength="16"
<input type="text" id="devEUI" name="devEUI"
[placeholder]="'QUESTION.DEVEUI-PLACEHOLDER' | translate" class="form-control"
[(ngModel)]="iotDevice.lorawanSettings.devEUI" [disabled]="editmode"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('devEUI'), 'is-valid' : formFailedSubmit && !errorFields.includes('devEUI')}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ export class IotDeviceEditComponent implements OnInit, OnDestroy {
}

postIoTDevice() {
// Sanitize devEUI for non-hex characters
if (this.iotDevice.type === DeviceType.LORAWAN) {
this.iotDevice.lorawanSettings.devEUI = this.iotDevice.lorawanSettings.devEUI.replace(
/[^0-9A-Fa-f]/g,
''
);
}

this.iotDeviceService.createIoTDevice(this.iotDevice).subscribe(
(response: IotDevice) => {
this.router.navigate([
Expand Down
10 changes: 5 additions & 5 deletions src/app/gateway/gateway-edit/gateway-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<div class="form-group mt-3">
<label class="form-label" for="id">{{'QUESTION-LORA-GATEWAY.GATEWAYID' | translate}}</label>*
<input type="text" class="form-control" id="id" name="id"
[placeholder]="'QUESTION-LORA-GATEWAY.GATEWAYID-PLACEHOLDER' | translate" maxlength="16" required
[(ngModel)]="gateway.id" [readonly]="editMode ? true : false"
[placeholder]="'QUESTION-LORA-GATEWAY.GATEWAYID-PLACEHOLDER' | translate" required
[(ngModel)]="gateway.id" [readonly]="editMode"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('id'), 'is-valid' : formFailedSubmit && !errorFields.includes('id')}">
</div>

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

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