Skip to content

Commit

Permalink
Merge branch 'stage' into feature/IOT-1276-Column-administration-on-g…
Browse files Browse the repository at this point in the history
…ateway-table
  • Loading branch information
fcv-iteratorIt committed Dec 15, 2023
2 parents 88d1331 + c4cafb1 commit f04902f
Show file tree
Hide file tree
Showing 45 changed files with 704 additions and 1,392 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on-push-pr.action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- uses: actions/setup-node@v3
name: Set NodeJS version
with:
node-version: 14
node-version: 18
- name: Install packages
run: "npm ci"
- name: Build source
Expand Down
750 changes: 364 additions & 386 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"jwt-decode": "^3.1.2",
"leaflet": "^1.7.1",
"moment": "^2.29.4",
"monaco-editor": "^0.44.0",
"monaco-editor": "^0.33.0",
"ng": "0.0.0",
"ng-inline-svg": "^11.0.0",
"ngx-monaco-editor-v2": "^14.0.4",
Expand Down
3 changes: 0 additions & 3 deletions src/app/applications/bulk-import/bulk-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ export class BulkMapping {
applicationSessionKey: data.applicationSessionKey
? data.applicationSessionKey
: undefined,
serviceProfileID: data.serviceProfileID
? data.serviceProfileID
: undefined,
deviceProfileID: data.deviceProfileID ? data.deviceProfileID : undefined,
fCntUp: data.fCntUp ? +data.fCntUp : undefined,
nFCntDown: data.nFCntDown ? +data.nFCntDown : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class DownlinkComponent implements OnInit {
if (error?.error?.chirpstackError?.error == "f_port must be > 0") {
this.errorMessages = ["port must be > 0"]
return;
}
}
this.errorMessages = this.errorMessageService.handleErrorMessage(error);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<p><strong>{{ 'IOTDEVICE.LORA.DEVEUI' | translate }}</strong>{{device.lorawanSettings.devEUI}}</p>
<p><strong>{{ 'IOTDEVICE.LORA.SERVICEPROFILE' | translate }}</strong>{{serviceProfileName}}</p>
<p><strong>{{ 'IOTDEVICE.LORA.DEVICEPROFILE' | translate }}</strong>{{deviceProfileName}}</p>
<ng-container *ngIf="OTAA">
<p><strong>{{ 'IOTDEVICE.LORA.OTAAAPPLICATIONKEY' | translate }}</strong>{{device.lorawanSettings?.OTAAapplicationKey}}
Expand All @@ -15,4 +14,4 @@
<p><strong>{{ 'IOTDEVICE.LORA.NFCNTDOWN' | translate }}</strong>{{device.lorawanSettings?.nFCntDown }}</p>
</ng-container>
<p><strong>{{ 'IOTDEVICE.LORA.SKIPFCNTCHECK' | translate }}</strong>{{device.lorawanSettings?.skipFCntCheck | yesNo}}
</p>
</p>
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Component, Input, OnInit } from '@angular/core';
import { IotDevice } from '@applications/iot-devices/iot-device.model';
import { DeviceProfileService } from '@profiles/device-profiles/device-profile.service';
import { ServiceProfileResponseOne } from '@profiles/service-profiles/service-profile.model';
import { ServiceProfileService } from '@profiles/service-profiles/service-profile.service';
import { Subscribable, Subscription } from 'rxjs';
import { Subscription } from 'rxjs';

@Component({
selector: 'app-iot-device-detail-lorawan',
Expand All @@ -16,16 +14,13 @@ export class IotDeviceDetailLorawanComponent implements OnInit {
deviceProfileSubscription: Subscription;
public OTAA: boolean;
public deviceProfileName: string;
public serviceProfileName: string;

constructor(
private deviceProfileService: DeviceProfileService,
private serviceProfileService: ServiceProfileService
) { }

ngOnInit(): void {
this.getDeviceProfil();
this.getServiceProfil();
}

getDeviceProfil() {
Expand All @@ -35,12 +30,4 @@ export class IotDeviceDetailLorawanComponent implements OnInit {
this.deviceProfileName = response.deviceProfile.name;
});
}

getServiceProfil() {
this.deviceProfileSubscription = this.serviceProfileService.getOne(this.device.lorawanSettings?.serviceProfileID)
.subscribe((response: ServiceProfileResponseOne) => {
this.serviceProfileName = response.serviceProfile.name;
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,6 @@ <h3>{{'IOTDEVICE.LORAWANSETUP' | translate}}</h3>
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('devEUI'), 'is-valid' : formFailedSubmit && !errorFields.includes('devEUI')}">
</div>

<ng-container *ngIf="iotDevice.lorawanSettings.serviceProfileID || serviceProfiles">
<div class="form-group mt-3 col-12">
<label class="form-label" for="serviceProfileID">{{'QUESTION.CHOOSE-SERVICEPROFILE' | translate}}</label>*
<select id="serviceProfileID" class="form-select" name="serviceProfileID"
[(ngModel)]="iotDevice.lorawanSettings.serviceProfileID" required
[value]="iotDevice.lorawanSettings.serviceProfileID" [disabled]="editmode"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('serviceProfileID'), 'is-valid' : formFailedSubmit && !errorFields.includes('serviceProfileID')}">
<option *ngFor="let serviceProfile of serviceProfiles" [value]="serviceProfile.id"
[selected]="serviceProfile.id === iotDevice.lorawanSettings.serviceProfileID">
{{serviceProfile.name}}
</option>
</select>
</div>
</ng-container>
<ng-container *ngIf="iotDevice.lorawanSettings.deviceProfileID || deviceProfiles">
<div class="form-group mt-3 col-12">
<label class="form-label" for="deviceProfileID">{{'QUESTION.CHOOSE-DEVICE' | translate}}</label>*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import { DeviceModel } from '@app/device-model/device.model';
import { TranslateService } from '@ngx-translate/core';
import { DeviceProfile } from '@profiles/device-profiles/device-profile.model';
import { DeviceProfileService } from '@profiles/device-profiles/device-profile.service';
import {
ServiceProfile,
ServiceProfileResponseMany,
} from '@profiles/service-profiles/service-profile.model';
import { ServiceProfileService } from '@profiles/service-profiles/service-profile.service';
import { ActivationType } from '@shared/enums/activation-type';
import { DeviceType } from '@shared/enums/device-type';
import { ErrorMessageService } from '@shared/error-message.service';
Expand Down Expand Up @@ -42,7 +37,6 @@ export class IotDeviceEditComponent implements OnInit, OnDestroy {
public disableChoseApplication = true;
public loraDevice = DeviceType.LORAWAN;
public sigfoxDevice = DeviceType.SIGFOX;
public serviceProfiles: ServiceProfile[];
public deviceProfiles: DeviceProfile[];
public deviceModels: DeviceModel[];
iotDevice = new IotDevice();
Expand All @@ -52,7 +46,6 @@ export class IotDeviceEditComponent implements OnInit, OnDestroy {
errorMetadataFieldId: string | undefined;
public deviceSubscription: Subscription;
private applicationsSubscription: Subscription;
private serviceProfilesSubscription: Subscription;
private deviceProfileSubscription: Subscription;
private devicesProfileSubscription: Subscription;
canEdit: boolean;
Expand All @@ -61,7 +54,6 @@ export class IotDeviceEditComponent implements OnInit, OnDestroy {
private route: ActivatedRoute,
public translate: TranslateService,
private router: Router,
private serviceProfileService: ServiceProfileService,
private deviceProfileService: DeviceProfileService,
private applicationService: ApplicationService,
private iotDeviceService: IoTDeviceService,
Expand Down Expand Up @@ -90,7 +82,6 @@ export class IotDeviceEditComponent implements OnInit, OnDestroy {
});

this.getApplication();
this.getServiceProfiles();
this.getDeviceProfiles();
this.getDeviceModels();
this.canEdit = this.meService.hasAccessToTargetOrganization(
Expand Down Expand Up @@ -177,16 +168,6 @@ export class IotDeviceEditComponent implements OnInit, OnDestroy {
});
}

getServiceProfiles() {
this.serviceProfilesSubscription = this.serviceProfileService
.getMultiple()
.subscribe((result: ServiceProfileResponseMany) => {
this.serviceProfiles = result.result.sort((a, b) =>
a.name.localeCompare(b.name, 'en', { numeric: true })
);
});
}

getDeviceProfiles() {
this.devicesProfileSubscription = this.deviceProfileService
.getMultiple()
Expand Down Expand Up @@ -403,8 +384,5 @@ export class IotDeviceEditComponent implements OnInit, OnDestroy {
if (this.devicesProfileSubscription) {
this.devicesProfileSubscription.unsubscribe();
}
if (this.serviceProfilesSubscription) {
this.serviceProfilesSubscription.unsubscribe();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class MulticastDetailComponent implements OnInit, OnDestroy {
this.multicastService
.multicastGet(this.multicast.id)
.subscribe((response: any) => {
if (response.totalCount > 0) {
if (response.deviceQueueItems.length > 0) {
this.openDownlinkDialog();
} else {
this.startDownlink();
Expand Down
3 changes: 2 additions & 1 deletion src/app/gateway/gateway-detail/gateway-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class GatewayDetailComponent implements OnInit, OnDestroy, AfterViewInit

bindGateway(gatewayId: string): void {
this.gatewayService.get(gatewayId).subscribe((result: GatewayResponse) => {
// Mapping tuples to JSON
result.gateway.tagsString = JSON.stringify(result.gateway.tags);
this.gateway = result.gateway;
this.canEdit = this.meService.hasAccessToTargetOrganization(
Expand Down Expand Up @@ -177,9 +178,9 @@ export class GatewayDetailComponent implements OnInit, OnDestroy, AfterViewInit
if (response) {
this.gatewayService.delete(this.gateway.gatewayId).subscribe(response => {
if (response.ok && response.body.success === true) {
this.router.navigate(["gateways"]);
}
});
this.router.navigate(["gateways"]);
} else {
console.log(response);
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/gateway/gateway-edit/gateway-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import { Gateway, GatewayResponse } from "../gateway.model";
})
export class GatewayEditComponent implements OnInit, OnDestroy {
public backButton: BackButton = { label: "", routerLink: ["gateways"] };
public multiPage = false;
public title = "";
public sectionTitle = "";
public submitButton = "";

public gatewaySubscription: Subscription;
Expand Down Expand Up @@ -55,7 +57,6 @@ export class GatewayEditComponent implements OnInit, OnDestroy {

getGateway(gatewayId: string): void {
this.gatewaySubscription = this.loraGatewayService.get(gatewayId).subscribe((result: GatewayResponse) => {
result.gateway.tagsString = JSON.stringify(result.gateway.tags);
this.gateway = result.gateway;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit {
orderOn: null,
})
.subscribe((gateways: GatewayResponseMany) => {
this.gateways = gateways.result;
this.gateways = gateways.resultList;
this.mapToCoordinateList();
this.setCanEdit();
this.isLoadingResults = false;
Expand All @@ -67,7 +67,7 @@ export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit {
organizationId: orgId,
})
.subscribe((gateways: GatewayResponseMany) => {
this.gateways = gateways.result;
this.gateways = gateways.resultList;
this.mapToCoordinateList();
this.setCanEdit();
this.isLoadingResults = false;
Expand All @@ -86,9 +86,9 @@ export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit {
markerInfo: {
name: gateway.name,
active: this.gatewayStatus(gateway),
id: gateway.id,
internalOrganizationId: gateway.organizationId,
internalOrganizationName: gateway.organizationName,
id: gateway.gatewayId,
internalOrganizationId: gateway.organizationId,
internalOrganizationName: gateway.organizationName,
},
})
);
Expand Down
10 changes: 7 additions & 3 deletions src/app/gateway/gateway-table/gateway-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export class GatewayTableComponent implements AfterViewInit, OnDestroy {
faExclamationTriangle = faExclamationTriangle;
faCheckCircle = faCheckCircle;
refetchIntervalId: NodeJS.Timeout;
batteryStatusColor = "green";
batteryStatusPercentage = 50;
resultsLength = 0;
isLoadingResults = true;
private fetchSubscription: Subscription;
Expand Down Expand Up @@ -145,11 +147,11 @@ export class GatewayTableComponent implements AfterViewInit, OnDestroy {

private refresh() {
this.getGateways().subscribe(data => {
data.result.forEach(gw => {
data.resultList.forEach(gw => {
gw.canEdit = this.canEdit(gw.organizationId);
gw.tagsString = JSON.stringify(gw.tags ?? {});
});
this.data = data.result;
this.data = data.resultList;
this.resultsLength = data.totalCount;
this.isLoadingResults = false;
this.dataSource = new MatTableDataSource(this.data);
Expand Down Expand Up @@ -183,7 +185,9 @@ export class GatewayTableComponent implements AfterViewInit, OnDestroy {

lastActive(gateway: Gateway): string {
if (gateway?.lastSeenAt) {
const lastSeenAtUnixTimestamp = moment(gateway?.lastSeenAt).valueOf();
const date = gateway.lastSeenAt;

const lastSeenAtUnixTimestamp = moment(date).valueOf();
const now = moment(new Date()).valueOf();
return moment(Math.min(lastSeenAtUnixTimestamp, now)).fromNow();
} else {
Expand Down
9 changes: 5 additions & 4 deletions src/app/gateway/gateway.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ export class Gateway extends EditPermission {
updatedBy: number;
createdByName: string;
updatedByName: string;
map(): Map<string, number> {
throw new Error("Method not implemented.");
}
}
export interface GrpcTime {
seconds: number;
nanos: number;
}

export class GatewayData {
Expand All @@ -38,7 +39,7 @@ export class GatewayRequest {
}

export class GatewayResponseMany {
result: Gateway[];
resultList: Gateway[];
totalCount: number;
}

Expand Down
20 changes: 0 additions & 20 deletions src/app/network-server/network-server.service.ts

This file was deleted.

33 changes: 21 additions & 12 deletions src/app/profiles/device-profiles/device-profile.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,20 @@ export class DeviceProfile extends EditPermission {
public adrAlgorithmID = 'default';
public classBTimeout = 0;
public classCTimeout = 0;
public factoryPresetFreqs: number[];
public factoryPresetFreqsInput: string;
public geolocBufferTTL = 0;
public geolocMinBufferSize = 0;
public macVersion = '1.0.0';
public maxDutyCycle = 0;
public maxEIRP = 0;
public payloadDecoderScript: string;
public payloadEncoderScript: string;
public macVersion: MacVersionMap[keyof MacVersionMap];
public pingSlotDR = 0;
public pingSlotFreq = 0;
public pingSlotPeriod = 0;
public regParamsRevision = 'A';
public regParamsRevision: RegParamsRevisionMap[keyof RegParamsRevisionMap];
public rfRegion: string;
public rxDROffset1 = 0;
public rxDataRate2 = 0;
public rxDelay1 = 0;
public rxFreq2 = 0;
public supports32BitFCnt: boolean;
public supportsClassB: boolean;
public supportsClassC: boolean;
public supportsJoin = true;
public devStatusReqFreq: number;
public organizationID?: number;
public internalOrganizationId: number;
public internalOrganizationName?: string;
Expand Down Expand Up @@ -56,6 +48,23 @@ export class DeviceProfileRequest {
internalOrganizationId: number;
constructor(deviceProfile: DeviceProfile, orgId: number = null) {
this.deviceProfile = deviceProfile;
this.internalOrganizationId = orgId
this.internalOrganizationId = orgId;
}
}
export interface MacVersionMap {
LORAWAN_1_0_0: 0;
LORAWAN_1_0_1: 1;
LORAWAN_1_0_2: 2;
LORAWAN_1_0_3: 3;
LORAWAN_1_0_4: 4;
LORAWAN_1_1_0: 5;
}

export interface RegParamsRevisionMap {
A: 0;
B: 1;
RP002_1_0_0: 2;
RP002_1_0_1: 3;
RP002_1_0_2: 4;
RP002_1_0_3?: 5;
}
Loading

0 comments on commit f04902f

Please sign in to comment.