Skip to content

Commit 84640de

Browse files
Merge branch 'stage' into feature/44446_missing_sorting_arrow
2 parents f681135 + 1eb467f commit 84640de

21 files changed

+249
-178
lines changed

src/app/app.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div *ngIf="isLoggedIn">
2-
<app-navbar></app-navbar>
2+
<app-navbar (navToggle)="onNavToggle($event)"></app-navbar>
33
</div>
4-
<div id="content">
4+
<div id="content" [class.nav-visible]="isNavVisible">
55
<div id="mainBody">
66
<router-outlet></router-outlet>
77
</div>

src/app/app.component.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#content {
55
@media (min-width: $screen-md-min) {
6-
padding-left: $navWidth;
6+
padding-left: 0;
7+
transition: padding-left 0.3s ease-in-out;
8+
&.nav-visible {
9+
padding-left: $navWidth;
10+
}
711
}
812
}

src/app/app.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import { LoggedInService } from "@shared/services/loggedin.service";
99
export class AppComponent {
1010
title = "OS2IoT-frontend";
1111
isLoggedIn = true;
12+
isNavVisible = true;
13+
14+
onNavToggle(isVisible: boolean) {
15+
this.isNavVisible = isVisible;
16+
}
1217

1318
constructor(private loggedInService: LoggedInService) {
1419
loggedInService.changeEmitted?.subscribe(change => {

src/app/applications/applications-list/application-map/application-map.component.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { SharedVariableService } from "@shared/shared-variable/shared-variable.s
1111
import { forkJoin, Subscription } from "rxjs";
1212
import { SharedModule } from "../../../shared/shared.module";
1313
import { ApplicationsFilterService } from "../application-filter/applications-filter.service";
14+
import moment from "moment";
1415

1516
@Component({
1617
selector: "app-application-map",
@@ -29,6 +30,7 @@ export class ApplicationMapComponent implements OnInit, OnDestroy {
2930
statusCheck: ApplicationStatusCheck | "All";
3031
owner: string | "All";
3132
};
33+
coordinateList: MapCoordinates[] = null;
3234
private valueSubscription!: Subscription;
3335

3436
constructor(
@@ -53,7 +55,17 @@ export class ApplicationMapComponent implements OnInit, OnDestroy {
5355
}
5456
}
5557

56-
coordinateList: MapCoordinates[] = null;
58+
private loadMapData(): void {
59+
forkJoin({
60+
devices: this.applicationService.getApplicationDevices(this.sharedVariableService.getSelectedOrganisationId()),
61+
gateways: this.gatewayService.getForMaps(),
62+
}).subscribe(({ devices, gateways }) => {
63+
this.devices = devices;
64+
this.gateways = gateways.resultList;
65+
66+
this.mapToCoordinateList();
67+
});
68+
}
5769

5870
private mapToCoordinateList() {
5971
const tempCoordinateList: MapCoordinates[] = [];
@@ -62,6 +74,10 @@ export class ApplicationMapComponent implements OnInit, OnDestroy {
6274
this.devices.forEach(dev => {
6375
const [longitude, latitude] = dev.location.coordinates;
6476

77+
const isActive = dev.latestReceivedMessage?.sentTime
78+
? moment(dev.latestReceivedMessage?.sentTime).unix() > moment(new Date()).subtract(1, "day").unix()
79+
: false;
80+
6581
tempCoordinateList.push({
6682
longitude: longitude,
6783
latitude: latitude,
@@ -71,12 +87,13 @@ export class ApplicationMapComponent implements OnInit, OnDestroy {
7187
markerInfo: {
7288
internalOrganizationName: "s",
7389
name: dev.name,
74-
active: true,
90+
active: isActive,
91+
isGateway: false,
7592
id: dev.id,
7693
isDevice: true,
7794
internalOrganizationId: this.sharedVariableService.getSelectedOrganisationId(),
7895
networkTechnology: dev.type,
79-
lastActive: dev?.latestReceivedMessage ? dev?.latestReceivedMessage.sentTime : null,
96+
lastActive: dev?.latestReceivedMessage?.sentTime,
8097
},
8198
});
8299
});
@@ -91,32 +108,20 @@ export class ApplicationMapComponent implements OnInit, OnDestroy {
91108
editEnabled: false,
92109
useGeolocation: false,
93110
markerInfo: {
94-
internalOrganizationName: "s",
111+
internalOrganizationName: gw.organizationName,
95112
name: gw.name,
96-
active: true,
113+
active: this.gatewayService.isGatewayActive(gw),
97114
id: gw.id,
98115
isDevice: false,
99116
isGateway: true,
100117
internalOrganizationId: this.sharedVariableService.getSelectedOrganisationId(),
101-
networkTechnology: "loRaWAN",
102-
lastActive: undefined,
118+
networkTechnology: "",
119+
lastActive: gw.lastSeenAt,
103120
},
104121
});
105122
});
106123
}
107124

108125
this.coordinateList = tempCoordinateList;
109126
}
110-
111-
loadMapData(): void {
112-
forkJoin({
113-
devices: this.applicationService.getApplicationDevices(this.sharedVariableService.getSelectedOrganisationId()),
114-
gateways: this.gatewayService.getForMaps(),
115-
}).subscribe(({ devices, gateways }) => {
116-
this.devices = devices;
117-
this.gateways = gateways.resultList;
118-
119-
this.mapToCoordinateList();
120-
});
121-
}
122127
}

src/app/applications/applications-list/applications-list.component.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,28 @@ <h2>{{ "WELCOME-DIALOG.NO-ACCESS" | translate }}</h2>
1313
</header>
1414
</ng-template>
1515
<app-top-bar
16-
[title]="'NAV.APPLICATIONS' | translate"
16+
[canEdit]="canEdit"
1717
[ctaLabel]="'FORM.CREATE-NEW-APPLICATION' | translate"
1818
[ctaRouterLink]="'new-application'"
19-
[canEdit]="canEdit"
19+
[title]="'NAV.APPLICATIONS' | translate"
2020
>
2121
</app-top-bar>
2222
<div class="main-page d-flex flex-column">
2323
<ng-container *ngIf="!isLoadingResults">
2424
<ng-container *ngIf="hasSomePermission" ; else noPermissions>
25-
<app-application-filter />
26-
<app-applications-list-dashboard />
25+
<app-application-filter/>
26+
<app-applications-list-dashboard/>
2727
<div class="switch-content-container">
28-
<app-basic-tap-switch [tabs]="tabs" [currentUrl]="currentPath" (tabClicked)="onTapClicked($event)">
29-
</app-basic-tap-switch>
30-
@if(currentPath === mapRoute){
31-
<app-application-map></app-application-map>
32-
} @if(currentPath === listRoute){
33-
<app-applications-table [organizationId]="organizationId" *ngIf="organizationId"></app-applications-table>
28+
<app-basic-tab-switch (tabClicked)="onTapClicked($event)" [currentUrl]="currentPath" [tabs]="tabs">
29+
</app-basic-tab-switch>
30+
@if (currentPath === mapRoute) {
31+
<app-application-map></app-application-map>
32+
}
33+
@if (currentPath === listRoute) {
34+
<app-applications-table [organizationId]="organizationId" *ngIf="organizationId"></app-applications-table>
3435
}
3536
</div>
3637
</ng-container>
3738
</ng-container>
38-
<mat-spinner ngClass="align-self-center" *ngIf="isLoadingResults"></mat-spinner>
39+
<mat-spinner *ngIf="isLoadingResults" ngClass="align-self-center"></mat-spinner>
3940
</div>

src/app/applications/applications-list/applications-list.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { ApplicationService } from "@applications/application.service";
99
import { AuthService } from "@auth/auth.service";
1010
import { environment } from "@environments/environment";
1111
import { TranslateService } from "@ngx-translate/core";
12-
import { Counter, Tab } from "@shared/components/basic-tap-switch/basic-tap-switch.component";
1312
import { WelcomeDialogComponent } from "@shared/components/welcome-dialog/welcome-dialog.component";
1413
import { OrganizationAccessScope } from "@shared/enums/access-scopes";
1514
import { WelcomeDialogModel } from "@shared/models/dialog.model";
1615
import { MeService } from "@shared/services/me.service";
1716
import { SharedVariableService } from "@shared/shared-variable/shared-variable.service";
17+
import { Counter, Tab } from "@shared/components/basic-tab-switch/basic-tab-switch.component";
1818

1919
const welcomeDialogId = "welcome-dialog";
2020

@@ -32,19 +32,17 @@ export class ApplicationsListComponent implements OnInit {
3232

3333
public pageLimit = environment.tablePageSize;
3434
public resultsLength: number;
35-
public pageOffset = 0;
3635
mapRoute = "/applications/map";
3736
listRoute = "/applications";
3837

3938
@Input() organizationId: number;
4039
canEdit: boolean;
41-
private unauthorizedMessage: string;
42-
private kombitError: string;
43-
private noAccess: string;
4440
hasSomePermission: boolean;
4541
isGlobalAdmin = false;
46-
4742
currentPath = "";
43+
private unauthorizedMessage: string;
44+
private kombitError: string;
45+
private noAccess: string;
4846

4947
constructor(
5048
public translate: TranslateService,

src/app/applications/applications.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { RouterModule } from "@angular/router";
55
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
66
import { TranslateModule } from "@ngx-translate/core";
77
import { BasicInformationBoxComponent } from "@shared/components/basic-information-box/basic-information-box.component";
8-
import { BasicTapSwitchComponent } from "@shared/components/basic-tap-switch/basic-tap-switch.component";
98
import { FormModule } from "@shared/components/forms/form.module";
109
import { OptionFieldComponent } from "@shared/components/option-field/option-field.component";
1110
import { StatusIconComponent } from "@shared/components/status-icon/status-icon.component";
@@ -29,6 +28,7 @@ import { BulkImportComponent } from "./bulk-import/bulk-import.component";
2928
import { DatatargetModule } from "./datatarget/datatarget.module";
3029
import { IotDevicesModule } from "./iot-devices/iot-devices.module";
3130
import { MulticastModule } from "./multicast/multicast.module";
31+
import { BasicTabSwitchComponent } from "@shared/components/basic-tab-switch/basic-tab-switch.component";
3232

3333
@NgModule({
3434
declarations: [
@@ -59,7 +59,7 @@ import { MulticastModule } from "./multicast/multicast.module";
5959
StatusIconComponent,
6060
TableSortIconComponent,
6161
TablePaginatorComponent,
62-
BasicTapSwitchComponent,
62+
BasicTabSwitchComponent,
6363
ApplicationMapComponent,
6464
BasicInformationBoxComponent,
6565
ApplicationFilterComponent,

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

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import { MeService } from "@shared/services/me.service";
1414
export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit {
1515
public gateways: Gateway[];
1616
public coordinateList = [];
17+
isLoadingResults = true;
1718
private gatewaySubscription: Subscription;
1819
private organizationChangeSubscription: Subscription;
19-
isLoadingResults = true;
2020

2121
constructor(
2222
private chirpstackGatewayService: ChirpstackGatewayService,
@@ -41,6 +41,25 @@ export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit {
4141
}
4242
}
4343

44+
gatewayStatus(gateway: Gateway): boolean {
45+
return this.chirpstackGatewayService.isGatewayActive(gateway);
46+
}
47+
48+
setCanEdit() {
49+
this.gateways.forEach(gateway => {
50+
gateway.canEdit = this.meService.hasAccessToTargetOrganization(
51+
OrganizationAccessScope.GatewayWrite,
52+
gateway.organizationId
53+
);
54+
});
55+
}
56+
57+
ngOnDestroy() {
58+
// prevent memory leak by unsubscribing
59+
this.gatewaySubscription?.unsubscribe();
60+
this.organizationChangeSubscription.unsubscribe();
61+
}
62+
4463
private getGateways(): void {
4564
this.gatewaySubscription = this.chirpstackGatewayService.getForMaps().subscribe((gateways: GatewayResponseMany) => {
4665
this.gateways = gateways.resultList;
@@ -75,6 +94,7 @@ export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit {
7594
markerInfo: {
7695
name: gateway.name,
7796
active: this.gatewayStatus(gateway),
97+
isGateway: true,
7898
id: gateway.gatewayId,
7999
internalOrganizationId: gateway.organizationId,
80100
internalOrganizationName: gateway.organizationName,
@@ -83,23 +103,4 @@ export class GatewayMapComponent implements OnInit, OnDestroy, AfterViewInit {
83103
);
84104
this.coordinateList = tempcoordinateList;
85105
}
86-
87-
gatewayStatus(gateway: Gateway): boolean {
88-
return this.chirpstackGatewayService.isGatewayActive(gateway);
89-
}
90-
91-
setCanEdit() {
92-
this.gateways.forEach(gateway => {
93-
gateway.canEdit = this.meService.hasAccessToTargetOrganization(
94-
OrganizationAccessScope.GatewayWrite,
95-
gateway.organizationId
96-
);
97-
});
98-
}
99-
100-
ngOnDestroy() {
101-
// prevent memory leak by unsubscribing
102-
this.gatewaySubscription?.unsubscribe();
103-
this.organizationChangeSubscription.unsubscribe();
104-
}
105106
}

0 commit comments

Comments
 (0)