Skip to content

Commit 82d83c2

Browse files
Merge branch 'stage' into feature/44457_hide_menu
2 parents 5f1b01a + fbef96a commit 82d83c2

File tree

13 files changed

+141
-161
lines changed

13 files changed

+141
-161
lines changed

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
}

src/app/navbar/navbar.component.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
aria-expanded="false"
44
[class.nav-visible]="isVisible"
55
>
6-
<img class="img-logo" alt="OS2IoT-logo" [src]="imagePath" />
6+
<img [src]="imagePath" alt="OS2IoT-logo" class="img-logo"/>
77

8-
<div *ngIf="!isLoggedIn(); else loggedInBlock" class="collapse navbar-collapse flex-grow-0" id="navbar">
8+
<div *ngIf="!isLoggedIn(); else loggedInBlock" class="collapse navbar-collapse flex-grow-0" id="navbar-login">
99
<ul class="navbar-nav flex-column">
1010
<li class="nav-item">
11-
<a routerLink="/auth" [routerLinkActive]="['active']" class="nav-link pl-5 position-relative rounded" id="auth">
11+
<a [routerLinkActive]="['active']" class="nav-link pl-5 position-relative rounded" id="auth" routerLink="/auth">
1212
{{ "NAV.LOGIN" | translate }}
1313
</a>
1414
<fa-icon [icon]="faSignInAlt" class="navbar-icon"></fa-icon>
@@ -19,31 +19,31 @@
1919
<ng-template #loggedInBlock>
2020
<div class="navbar-header">
2121
<button
22-
type="button"
23-
class="navbar-toggler collapsed"
22+
(click)="isCollapsed = !isCollapsed"
23+
aria-controls="navbar"
2424
aria-label="Toggle navigation"
25+
class="navbar-toggler collapsed"
2526
data-target="#navbar"
26-
aria-controls="navbar"
27-
(click)="isCollapsed = !isCollapsed"
27+
type="button"
2828
>
2929
<span class="navbar-toggler-icon"></span>
3030
</button>
3131
</div>
3232
<div
33-
class="navbar-collapse collapse overflow-auto flex-grow-0 h-100"
34-
id="navbar"
3533
[attr.aria-expanded]="!isCollapsed"
3634
[ngClass]="{ collapse: !isCollapsed }"
35+
class="navbar-collapse collapse overflow-auto flex-grow-0 h-100"
36+
id="navbar"
3737
>
38-
<ul class="navbar-nav d-flex flex-column h-100" (click)="isCollapsed = !isCollapsed">
38+
<ul (click)="isCollapsed = !isCollapsed" class="navbar-nav d-flex flex-column h-100">
3939
<div *ngIf="hasSomePermissions()" class="flex-column mb-1">
4040
<li class="nav-item">
4141
<mat-form-field appearance="outline">
4242
<mat-select (selectionChange)="onChange($event.value)" [value]="selected">
4343
<mat-select-trigger>
4444
<div class="nav-bar-selector-trigger">
4545
<div class="nav-bar-selector-building-icon">
46-
<img src="assets/images/building.svg" width="20" height="20" />
46+
<img height="20" src="assets/images/building.svg" width="20"/>
4747
</div>
4848
{{ getOrgName(selected) }}
4949
</div>
@@ -53,15 +53,15 @@
5353
</mat-option>
5454
</mat-select>
5555

56-
<div matSuffix class="custom-dropdown-icon">
57-
<img src="assets/images/angle-up.svg" class="dropdown-up" width="11" height="7" />
58-
<img src="assets/images/angle-down.svg" class="dropdown-down" width="11" height="7" />
56+
<div class="custom-dropdown-icon" matSuffix>
57+
<img class="dropdown-up" height="7" src="assets/images/angle-up.svg" width="11"/>
58+
<img class="dropdown-down" height="7" src="assets/images/angle-down.svg" width="11"/>
5959
</div>
6060
</mat-form-field>
6161

6262
<ul class="navbar-nav flex-column mb-2">
6363
<li class="nav-item">
64-
<a routerLink="/applications" routerLinkActive="active" id="applications">
64+
<a id="applications" routerLink="/applications" routerLinkActive="active">
6565
{{ "NAV.APPLICATIONS" | translate }}
6666
</a>
6767
</li>
@@ -102,12 +102,12 @@
102102
<li class="nav-item">
103103
<ul class="navbar-nav flex-column">
104104
<li class="nav-item">
105-
<a routerLink="/gateways" [routerLinkActive]="['active']" id="myLoraGateway">
105+
<a [routerLinkActive]="['active']" id="myLoraGateway" routerLink="/gateways">
106106
{{ "NAV.LORA-GATEWAYS" | translate }}
107107
</a>
108108
</li>
109109
<li class="nav-item">
110-
<a routerLink="/profiles" [routerLinkActive]="['active']" id="profiles">
110+
<a [routerLinkActive]="['active']" id="profiles" routerLink="/profiles">
111111
{{ "NAV.PROFILES" | translate }}
112112
</a>
113113
</li>
@@ -123,7 +123,7 @@
123123
<li class="nav-item">
124124
<ul class="navbar-nav flex-column">
125125
<li class="nav-item">
126-
<a routerLink="/payload-decoder" [routerLinkActive]="['active']" id="payload-decoder">
126+
<a [routerLinkActive]="['active']" id="payload-decoder" routerLink="/payload-decoder">
127127
{{ "NAV.PAYLOAD-DECODER" | translate }}
128128
</a>
129129
</li>

0 commit comments

Comments
 (0)