Skip to content

Commit f0ae23b

Browse files
changes from pr
1 parent b6bf45a commit f0ae23b

39 files changed

+302
-193
lines changed
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
<div class="map-page">
22
@if(coordinateList){
3-
<app-map [coordinateList]="coordinateList" [isFromApplication]="true" [applicationId]="22"></app-map>
3+
<app-map [coordinateList]="coordinateList" [isFromApplication]="true"></app-map>
44
}
5-
<div class="map-overlay">
6-
<div class="check-box-container">
7-
<mat-checkbox class="example-margin" [checked]="device" />
8-
<div>{{ "APPLICATION-INFORMATION-BOX.DEVICES" | translate }}</div>
9-
</div>
10-
<div class="check-box-container">
11-
<mat-checkbox class="example-margin" [checked]="gateway" />
12-
<div>{{ "APPLICATION-INFORMATION-BOX.GATEWAYS" | translate }}</div>
13-
</div>
14-
</div>
155
</div>

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "../../../../assets/scss/setup/variables";
2+
13
:host .map-page {
24
background-color: #ffffff;
35
padding: 20px;
@@ -6,9 +8,9 @@
68
}
79

810
:host .map-overlay {
9-
height: 89px;
11+
height: 50px;
1012
width: 132px;
11-
background-color: #ffffff;
13+
background-color: $white;
1214
position: absolute;
1315
bottom: 30px;
1416
left: 30px;
@@ -24,3 +26,11 @@
2426
flex-direction: row;
2527
align-items: center;
2628
}
29+
30+
.mdc-checkbox__background {
31+
background-color: $white !important;
32+
}
33+
34+
.mdc-checkbox {
35+
background-color: $white !important;
36+
}

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

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Component, OnDestroy, OnInit } from "@angular/core";
22
import { MatCheckboxModule } from "@angular/material/checkbox";
3+
import { Gateway } from "@app/gateway/gateway.model";
34
import { ApplicationService } from "@applications/application.service";
45
import { ApplicationStatus, ApplicationStatusCheck } from "@applications/enums/status.enum";
56
import { IotDevice } from "@applications/iot-devices/iot-device.model";
67
import { TranslateService } from "@ngx-translate/core";
78
import { MapCoordinates } from "@shared/components/map/map-coordinates.model";
9+
import { ChirpstackGatewayService } from "@shared/services/chirpstack-gateway.service";
810
import { SharedVariableService } from "@shared/shared-variable/shared-variable.service";
9-
import { Subscription } from "rxjs";
11+
import { forkJoin, Subscription } from "rxjs";
1012
import { SharedModule } from "../../../shared/shared.module";
1113
import { ApplicationsFilterService } from "../application-filter/applications-filter.service";
1214

@@ -19,6 +21,7 @@ import { ApplicationsFilterService } from "../application-filter/applications-fi
1921
})
2022
export class ApplicationMapComponent implements OnInit, OnDestroy {
2123
public devices: IotDevice[] = [];
24+
public gateways: Gateway[] = [];
2225
public device: boolean = true;
2326
public gateway: boolean = true;
2427
filterValues: {
@@ -32,11 +35,13 @@ export class ApplicationMapComponent implements OnInit, OnDestroy {
3235
private filterService: ApplicationsFilterService,
3336
private applicationService: ApplicationService,
3437
public translate: TranslateService,
35-
private sharedVariableService: SharedVariableService
38+
private sharedVariableService: SharedVariableService,
39+
private gatewayService: ChirpstackGatewayService
3640
) {}
3741

3842
ngOnInit() {
39-
this.getApplications();
43+
this.loadMapData();
44+
4045
this.valueSubscription = this.filterService.filterChanges$.subscribe(updatedValues => {
4146
this.filterValues = updatedValues;
4247
});
@@ -50,7 +55,7 @@ export class ApplicationMapComponent implements OnInit, OnDestroy {
5055

5156
coordinateList: MapCoordinates[] = null;
5257

53-
private mapDevicesToCoordinateList() {
58+
private mapToCoordinateList() {
5459
const tempCoordinateList: MapCoordinates[] = [];
5560

5661
if (Array.isArray(this.devices)) {
@@ -77,15 +82,41 @@ export class ApplicationMapComponent implements OnInit, OnDestroy {
7782
});
7883
}
7984

85+
if (Array.isArray(this.gateways)) {
86+
this.gateways.forEach(gw => {
87+
tempCoordinateList.push({
88+
longitude: gw.location.longitude,
89+
latitude: gw.location.latitude,
90+
draggable: false,
91+
editEnabled: false,
92+
useGeolocation: false,
93+
markerInfo: {
94+
internalOrganizationName: "s",
95+
name: gw.name,
96+
active: true,
97+
id: gw.id,
98+
isDevice: false,
99+
isGateway: true,
100+
internalOrganizationId: this.sharedVariableService.getSelectedOrganisationId(),
101+
networkTechnology: "loRaWAN",
102+
lastActive: undefined,
103+
},
104+
});
105+
});
106+
}
107+
80108
this.coordinateList = tempCoordinateList;
81109
}
82110

83-
getApplications(): void {
84-
this.applicationService
85-
.getApplicationDevices(this.sharedVariableService.getSelectedOrganisationId())
86-
.subscribe(data => {
87-
this.devices = data;
88-
this.mapDevicesToCoordinateList();
89-
});
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+
});
90121
}
91122
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
[width]="25"
3131
[matSVGSrc]="'satellite-dish'"
3232
[type]="'default'"
33-
[count]="gateways"
33+
[count]="totalGateways"
3434
[description]="'APPLICATION-INFORMATION-BOX.GATEWAYS' | translate"
3535
/>
3636
</div>

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { BasicInformationBoxComponent } from "../../../shared/components/basic-i
1515
styleUrl: "./applications-list-dashboard.component.scss",
1616
})
1717
export class ApplicationsListDashboardComponent implements OnInit {
18-
gateways: number = 0;
1918
total: number = 0;
2019
withError: number = 0;
2120
withoutError: number = 0;
@@ -55,12 +54,11 @@ export class ApplicationsListDashboardComponent implements OnInit {
5554
);
5655
}
5756
ngOnInit(): void {
58-
this.gatewayService.getMultiple().subscribe(data => (this.gateways = data.totalCount));
5957
this.applicationService
6058
.getApplicationsWithError(this.sharedVariableService.getSelectedOrganisationId())
6159
.subscribe(data => {
6260
this.withError = data.withError;
63-
this.totalDevices = data.withError;
61+
this.totalDevices = data.totalDevices;
6462
this.withoutError = data.total - data.withError;
6563
this.total = data.total;
6664
});

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ <h2>{{ "WELCOME-DIALOG.NO-ACCESS" | translate }}</h2>
2525
<app-application-filter />
2626
<app-applications-list-dashboard />
2727
<div class="switch-content-container">
28-
<app-basic-tap-switch [taps]="taps" (newItemEvent)="onNewSwitchIndex($event)"> </app-basic-tap-switch>
29-
@switch (index) { @case (1) {
30-
28+
<app-basic-tap-switch [tabs]="tabs"> </app-basic-tap-switch>
29+
@if(router.url === mapRoute){
3130
<app-application-map></app-application-map>
32-
} @default {
33-
31+
} @if(router.url === listRoute){
3432
<app-applications-table [organizationId]="organizationId" *ngIf="organizationId"></app-applications-table>
35-
36-
} }
33+
}
3734
</div>
3835
</ng-container>
3936
</ng-container>

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { Component, Input, OnInit } from "@angular/core";
22
import { MatDialog } from "@angular/material/dialog";
33
import { MatIconRegistry } from "@angular/material/icon";
44
import { DomSanitizer, Title } from "@angular/platform-browser";
5-
import { ActivatedRoute, Router } from "@angular/router";
5+
import { ActivatedRoute, NavigationEnd, Router } from "@angular/router";
66
import { UserMinimalService } from "@app/admin/users/user-minimal.service";
77
import { NavbarComponent } from "@app/navbar/navbar.component";
88
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, Tap } from "@shared/components/basic-tap-switch/basic-tap-switch.component";
12+
import { Counter, Tab } from "@shared/components/basic-tap-switch/basic-tap-switch.component";
1313
import { WelcomeDialogComponent } from "@shared/components/welcome-dialog/welcome-dialog.component";
1414
import { OrganizationAccessScope } from "@shared/enums/access-scopes";
1515
import { WelcomeDialogModel } from "@shared/models/dialog.model";
@@ -26,14 +26,15 @@ const welcomeDialogId = "welcome-dialog";
2626
})
2727
export class ApplicationsListComponent implements OnInit {
2828
currentSubPath: string = "";
29-
taps: Tap[];
29+
tabs: Tab[];
3030

31-
index = 0;
3231
isLoadingResults = true;
3332

3433
public pageLimit = environment.tablePageSize;
3534
public resultsLength: number;
3635
public pageOffset = 0;
36+
mapRoute = "/applications/map";
37+
listRoute = "/applications";
3738

3839
@Input() organizationId: number;
3940
canEdit: boolean;
@@ -43,8 +44,7 @@ export class ApplicationsListComponent implements OnInit {
4344
hasSomePermission: boolean;
4445
isGlobalAdmin = false;
4546

46-
applicationWithError = 0;
47-
totalApplication = 0;
47+
currentPath = "";
4848

4949
constructor(
5050
public translate: TranslateService,
@@ -53,8 +53,8 @@ export class ApplicationsListComponent implements OnInit {
5353
private meService: MeService,
5454
private sharedVariableService: SharedVariableService,
5555
private authService: AuthService,
56-
private route: ActivatedRoute,
57-
private router: Router,
56+
public route: ActivatedRoute,
57+
public router: Router,
5858
private dialog: MatDialog,
5959
private userMinimalService: UserMinimalService,
6060
private matIconRegistry: MatIconRegistry,
@@ -101,18 +101,25 @@ export class ApplicationsListComponent implements OnInit {
101101
counters.push({ color: "alert", value: data.withError.toString() });
102102
}
103103

104-
this.taps = [
104+
this.tabs = [
105105
{
106106
title: "Applikationer",
107107
icon: { matSVGSrc: "layers-tap", height: 16, width: 16 },
108108
counters: counters,
109+
uri: this.listRoute,
109110
},
110-
{ title: "Kort", icon: { matSVGSrc: "map-tap", height: 17, width: 18 } },
111+
{ title: "Kort", icon: { matSVGSrc: "map-tap", height: 17, width: 18 }, uri: this.mapRoute },
111112
];
112113
});
113114

114115
// Authenticate user
115116
this.verifyUserAndInit();
117+
118+
this.router.events.subscribe(event => {
119+
if (event instanceof NavigationEnd) {
120+
this.currentPath = event.url;
121+
}
122+
});
116123
}
117124

118125
verifyUserAndInit() {
@@ -208,8 +215,4 @@ export class ApplicationsListComponent implements OnInit {
208215
this.isLoadingResults = false;
209216
});
210217
}
211-
212-
onNewSwitchIndex(index: number) {
213-
this.index = index;
214-
}
215218
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<div class="options-container">
4141
<app-option-field
4242
[title]="'APPLICATION.STATUS.' + application.status | translate"
43-
[type]="application.status === 'IN-OPERATION' ? 'warring' : ''"
43+
[type]="application.status === 'IN-OPERATION' ? 'warning' : 'default'"
4444
/>
4545
</div>
4646
</td>
@@ -73,7 +73,6 @@
7373
<app-table-sort-icon [sortDirection]="getSortDirection('data')" />
7474
</th>
7575
<td mat-cell *matCellDef="let application">
76-
<!-- TODO:: add @for when data is found -->
7776
<div class="options-container">
7877
@for (property of application.controlledProperties; track $index) {
7978
<app-option-field [title]="property.type" />

src/app/applications/applications-list/applications-table/applications-table.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
.column-title-color {
6262
color: $color-link;
63+
font-weight: bold;
6364
}
6465

6566
.column-title-color-inactive {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class ApplicationsTableComponent implements AfterViewInit, OnInit {
164164
}
165165

166166
announceSortChange(event: { active: string; direction: string }) {
167-
this.columnDefinitions.find(column => column.id === event.active).sort = event.direction as "acs" | "desc";
167+
this.columnDefinitions.find(column => column.id === event.active).sort = event.direction as "asc" | "desc";
168168
}
169169
ngAfterViewInit() {
170170
// If the user changes the sort order, reset back to the first page.

0 commit comments

Comments
 (0)