Skip to content

Commit c05ad16

Browse files
committed
Merge branch 'stage' into feature/1220_api-key
# Conflicts: # src/app/shared/pipes/pipes.module.ts
2 parents 93dea8c + 883aa87 commit c05ad16

40 files changed

+1670
-336
lines changed
Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<div *ngIf="application">
22
<app-top-bar [data]="application" [backButton]="backButton" [subPage]="true"
3-
[dtRouterLink]="['datatarget-list', application.name]" [dtLabel]="'APPLICATION.DATATARGET-SHOW' | translate"
43
[addDetailDowndown]="true" [dropDownButton]="dropdownButton" (deleteSelectedInDropdown)="onDeleteApplication()">
54
</app-top-bar>
65
<div class="container-fluid">
@@ -18,22 +17,68 @@ <h3>Detaljer</h3>
1817
</div>
1918
</div>
2019
</div>
21-
<div class="row">
22-
<div class="col-sm-12">
23-
<div class="jumbotron">
24-
<div *ngIf="canEdit else readOnly">
25-
<app-top-bar-table [component]="true" [title]="'APPLICATION.ATTACHED-IOT' | translate"
26-
[ctaLabelPrimary]="'FORM.CREATE-NEW-IOT-DEVICE' | translate" [ctaRouterLinkPrimary]="'new-iot-device'"
27-
[ctaLabelSecondary]="'APPLICATION.IMPORT-CSV' | translate" [ctaRouterLinkSecondary]="'bulk-import'">
28-
</app-top-bar-table>
20+
<mat-tab-group animationDuration="200ms">
21+
<mat-tab label="{{'APPLICATION.IOT-DEVICES' | translate}}">
22+
<div class="jumbotron--table">
23+
<div class="row">
24+
<div class="col-sm-12">
25+
<div class="jumbotron">
26+
<div *ngIf="canEdit else readOnly">
27+
<app-top-bar-table [component]="true" [title]="'APPLICATION.ATTACHED-IOT' | translate"
28+
[ctaLabelPrimary]="'FORM.CREATE-NEW-IOT-DEVICE' | translate" [ctaRouterLinkPrimary]="'new-iot-device'"
29+
[ctaLabelSecondary]="'APPLICATION.IMPORT-CSV' | translate" [ctaRouterLinkSecondary]="'bulk-import'">
30+
</app-top-bar-table>
31+
</div>
32+
<ng-template #readOnly>
33+
<app-top-bar-table [component]="true" [title]="'APPLICATION.ATTACHED-IOT' | translate">
34+
</app-top-bar-table>
35+
</ng-template>
36+
<app-iot-devices-table [applicationId]="id"></app-iot-devices-table>
37+
</div>
38+
</div>
2939
</div>
30-
<ng-template #readOnly>
31-
<app-top-bar-table [component]="true" [title]="'APPLICATION.ATTACHED-IOT' | translate">
32-
</app-top-bar-table>
33-
</ng-template>
34-
<app-iot-devices-table [applicationId]="id"></app-iot-devices-table>
3540
</div>
36-
</div>
37-
</div>
41+
</mat-tab>
42+
<mat-tab label="{{'APPLICATION.MULTICAST-GROUPS' | translate}}">
43+
<div class="jumbotron--table">
44+
<div class="row">
45+
<div class="col-sm-12">
46+
<div class="jumbotron">
47+
<div *ngIf="canEdit else readOnly">
48+
<app-top-bar-table [component]="true" [title]="'APPLICATION.MULTICAST-SHOW' | translate"
49+
[ctaLabelPrimary]="'FORM.CREATE-NEW-MULTICAST' | translate" [ctaRouterLinkPrimary]="'multicast-edit'">
50+
</app-top-bar-table>
51+
</div>
52+
<ng-template #readOnly>
53+
<app-top-bar-table [component]="true" [title]="'APPLICATION.ATTACHED-IOT' | translate">
54+
</app-top-bar-table>
55+
</ng-template>
56+
<app-multicast-table></app-multicast-table>
57+
</div>
58+
</div>
59+
</div>
60+
</div>
61+
</mat-tab>
62+
<mat-tab label="{{'APPLICATION.DATATARGET-SHOW' | translate}}">
63+
<div class="jumbotron--table">
64+
<div class="row">
65+
<div class="col-sm-12">
66+
<div class="jumbotron">
67+
<div *ngIf="canEdit else readOnly">
68+
<app-top-bar-table [component]="true" [title]="'APPLICATION.DATATARGET-SHOW' | translate"
69+
[ctaLabelPrimary]="'FORM.CREATE-NEW-DATATARGET' | translate" [ctaRouterLinkPrimary]="'datatarget-edit'">
70+
</app-top-bar-table>
71+
</div>
72+
<ng-template #readOnly>
73+
<app-top-bar-table [component]="true" [title]="'APPLICATION.ATTACHED-IOT' | translate">
74+
</app-top-bar-table>
75+
</ng-template>
76+
<app-datatarget-table [pageLimit]="pageLimit"></app-datatarget-table>
77+
</div>
78+
</div>
79+
</div>
80+
</div>
81+
</mat-tab>
82+
</mat-tab-group>
3883
</div>
3984
</div>
Lines changed: 87 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,111 @@
1-
import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
1+
import {
2+
Component,
3+
EventEmitter,
4+
OnDestroy,
5+
OnInit,
6+
Output,
7+
} from '@angular/core';
28
import { Title } from '@angular/platform-browser';
39
import { ActivatedRoute, Router } from '@angular/router';
410
import { Application } from '@applications/application.model';
511
import { ApplicationService } from '@applications/application.service';
12+
import { environment } from '@environments/environment';
613
import { TranslateService } from '@ngx-translate/core';
714
import { DeleteDialogService } from '@shared/components/delete-dialog/delete-dialog.service';
15+
import { DeviceType } from '@shared/enums/device-type';
816
import { BackButton } from '@shared/models/back-button.model';
917
import { DropdownButton } from '@shared/models/dropdown-button.model';
1018
import { MeService } from '@shared/services/me.service';
1119
import { Subscription } from 'rxjs';
1220

1321
@Component({
14-
selector: 'app-application',
15-
templateUrl: './application-detail.component.html',
16-
styleUrls: ['./application-detail.component.scss'],
22+
selector: 'app-application',
23+
templateUrl: './application-detail.component.html',
24+
styleUrls: ['./application-detail.component.scss'],
1725
})
1826
export class ApplicationDetailComponent implements OnInit, OnDestroy {
19-
@Output() deleteApplication = new EventEmitter();
20-
public applicationsSubscription: Subscription;
21-
private deleteDialogSubscription: Subscription;
22-
public application: Application;
23-
public backButton: BackButton = { label: '', routerLink: '/applications' };
24-
public id: number;
25-
public dropdownButton: DropdownButton;
26-
public errorMessage: string;
27-
public canEdit = false;
27+
@Output() deleteApplication = new EventEmitter();
28+
public applicationsSubscription: Subscription;
29+
public application: Application;
30+
public backButton: BackButton = { label: '', routerLink: '/applications' };
31+
public id: number;
32+
public pageLimit = environment.tablePageSize;
33+
public dropdownButton: DropdownButton;
34+
public errorMessage: string;
35+
public canEdit = false;
2836

29-
constructor(
30-
private applicationService: ApplicationService,
31-
private route: ActivatedRoute,
32-
public translate: TranslateService,
33-
public router: Router,
34-
private meService: MeService,
35-
private titleService: Title,
36-
private deleteDialogService: DeleteDialogService
37-
) { }
37+
constructor(
38+
private applicationService: ApplicationService,
39+
private route: ActivatedRoute,
40+
public translate: TranslateService,
41+
public router: Router,
42+
private meService: MeService,
43+
private titleService: Title,
44+
private deleteDialogService: DeleteDialogService
45+
) {}
3846

39-
ngOnInit(): void {
40-
this.id = +this.route.snapshot.paramMap.get('id');
41-
if (this.id) {
42-
this.bindApplication(this.id);
43-
this.dropdownButton = {
44-
label: '',
45-
editRouterLink: '../../edit-application/' + this.id,
46-
isErasable: true,
47-
};
47+
ngOnInit(): void {
48+
this.id = +this.route.snapshot.paramMap.get('id');
49+
if (this.id) {
50+
this.bindApplication(this.id);
51+
this.dropdownButton = {
52+
label: '',
53+
editRouterLink: '../../edit-application/' + this.id,
54+
isErasable: true,
55+
};
4856

49-
console.log(this.id);
50-
}
51-
52-
this.translate.get(['NAV.APPLICATIONS', 'APPLICATION-TABLE-ROW.SHOW-OPTIONS', 'TITLE.APPLICATION'])
53-
.subscribe(translations => {
54-
this.backButton.label = translations['NAV.APPLICATIONS'];
55-
this.dropdownButton.label = translations['APPLICATION-TABLE-ROW.SHOW-OPTIONS'];
56-
this.titleService.setTitle(translations['TITLE.APPLICATION']);
57-
});
58-
this.canEdit = this.meService.canWriteInTargetOrganization();
57+
console.log(this.id);
5958
}
6059

61-
onDeleteApplication() {
62-
let message: string;
63-
if (this.applicationHasDevices()) {
64-
message = this.translate.instant('APPLICATION.DELETE-HAS-DEVICES-PROMPT');
65-
}
66-
67-
this.deleteDialogSubscription = this.deleteDialogService.showSimpleDialog(message).subscribe(
68-
(response) => {
69-
if (response) {
70-
this.applicationService.deleteApplication(this.application.id).subscribe((response) => {
71-
if (response.ok && response.body.affected > 0) {
72-
console.log('delete application with id:' + this.application.id.toString());
73-
this.router.navigate(['applications']);
74-
} else {
75-
this.errorMessage = response?.error?.message;
76-
}
77-
});
78-
} else {
79-
console.log(response);
80-
}
81-
}
82-
);
83-
}
60+
this.translate
61+
.get([
62+
'NAV.APPLICATIONS',
63+
'APPLICATION-TABLE-ROW.SHOW-OPTIONS',
64+
'TITLE.APPLICATION',
65+
])
66+
.subscribe((translations) => {
67+
this.backButton.label = translations['NAV.APPLICATIONS'];
68+
this.dropdownButton.label =
69+
translations['APPLICATION-TABLE-ROW.SHOW-OPTIONS'];
70+
this.titleService.setTitle(translations['TITLE.APPLICATION']);
71+
});
72+
this.canEdit = this.meService.canWriteInTargetOrganization();
73+
}
8474

85-
applicationHasDevices(): boolean {
86-
return this.application.iotDevices?.length > 0;
87-
}
75+
onDeleteApplication() {
76+
this.deleteDialogService
77+
.showApplicationDialog(this.application)
78+
.subscribe((response) => {
79+
if (response) {
80+
this.applicationService
81+
.deleteApplication(this.application.id)
82+
.subscribe((response) => {
83+
if (response.ok && response.body.affected > 0) {
84+
console.log(
85+
'delete application with id:' + this.application.id.toString()
86+
);
87+
this.router.navigate(['applications']);
88+
} else {
89+
this.errorMessage = response?.error?.message;
90+
}
91+
});
92+
} else {
93+
console.log(response);
94+
}
95+
});
96+
}
8897

89-
bindApplication(id: number): void {
90-
this.applicationsSubscription = this.applicationService.getApplication(id).subscribe((application) => {
91-
this.application = application;
92-
});
93-
}
98+
bindApplication(id: number): void {
99+
this.applicationsSubscription = this.applicationService
100+
.getApplication(id)
101+
.subscribe((application) => {
102+
this.application = application;
103+
});
104+
}
94105

95-
ngOnDestroy() {
96-
if (this.applicationsSubscription) {
97-
this.applicationsSubscription.unsubscribe();
98-
}
99-
if (this.deleteDialogSubscription) {
100-
this.deleteDialogSubscription.unsubscribe();
101-
}
106+
ngOnDestroy() {
107+
if (this.applicationsSubscription) {
108+
this.applicationsSubscription.unsubscribe();
102109
}
110+
}
103111
}

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

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Component, ViewChild, AfterViewInit, Input, OnInit } from '@angular/core';
1+
import {
2+
Component,
3+
ViewChild,
4+
AfterViewInit,
5+
Input,
6+
OnInit,
7+
} from '@angular/core';
28
import { MatPaginator } from '@angular/material/paginator';
39
import { MatSort } from '@angular/material/sort';
410
import { Router } from '@angular/router';
@@ -10,6 +16,7 @@ import { DeleteDialogService } from '@shared/components/delete-dialog/delete-dia
1016
import { MeService } from '@shared/services/me.service';
1117
import { merge, Observable, of as observableOf } from 'rxjs';
1218
import { catchError, map, startWith, switchMap } from 'rxjs/operators';
19+
import { DeviceType } from '@shared/enums/device-type';
1320

1421
/**
1522
* @title Table retrieving data through HTTP
@@ -40,7 +47,7 @@ export class ApplicationsTableComponent implements AfterViewInit, OnInit {
4047
private router: Router,
4148
private meService: MeService,
4249
private deleteDialogService: DeleteDialogService
43-
) { }
50+
) {}
4451

4552
ngOnInit() {
4653
this.canEdit = this.meService.canWriteInTargetOrganization();
@@ -87,33 +94,28 @@ export class ApplicationsTableComponent implements AfterViewInit, OnInit {
8794
}
8895

8996
deleteApplication(id: number) {
90-
let message: string;
91-
if (this.applicationHasDevices(id)) {
92-
message = this.translate.instant('APPLICATION.DELETE-HAS-DEVICES-PROMPT');
93-
}
97+
const applicationToDelete = this.data?.find((app) => app.id === id);
9498

95-
this.deleteDialogService.showSimpleDialog(message).subscribe((response) => {
96-
if (response) {
97-
this.applicationService.deleteApplication(id).subscribe((response) => {
98-
if (response.ok && response.body.affected > 0) {
99-
this.paginator.page.emit({
100-
pageIndex: this.paginator.pageIndex,
101-
pageSize: this.paginator.pageSize,
102-
length: this.resultsLength,
99+
this.deleteDialogService
100+
.showApplicationDialog(applicationToDelete)
101+
.subscribe((response) => {
102+
if (response) {
103+
this.applicationService
104+
.deleteApplication(id)
105+
.subscribe((response) => {
106+
if (response.ok && response.body.affected > 0) {
107+
this.paginator.page.emit({
108+
pageIndex: this.paginator.pageIndex,
109+
pageSize: this.paginator.pageSize,
110+
length: this.resultsLength,
111+
});
112+
} else {
113+
this.errorMessage = response?.error?.message;
114+
}
103115
});
104-
} else {
105-
this.errorMessage = response?.error?.message;
106-
}
107-
});
108-
}
109-
});
116+
}
117+
});
110118
}
111-
112-
applicationHasDevices(id: number): boolean {
113-
const applicationToDelete = this.data?.find(app => app.id === id);
114-
return applicationToDelete && applicationToDelete.iotDevices.length > 0;
115-
}
116-
117119
navigateToEditPage(applicationId: string) {
118120
this.router.navigate(['applications', 'edit-application', applicationId]);
119121
}

0 commit comments

Comments
 (0)