Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export class OrganisationDetailComponent implements OnInit, OnChanges, OnDestroy
label: '',
editRouterLink: 'edit-organisation',
isErasable: true,
}
};

this.translate.get(['NAV.ORGANISATIONS', 'ORGANISATION.DROPDOWN', 'TITLE.ORGANIZATION'])
.subscribe(translations => {
this.backButton.label = translations['NAV.ORGANISATIONS'];
Expand Down
10 changes: 5 additions & 5 deletions src/app/admin/organisation/organisation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { UserMinimalService } from '../users/user-minimal.service';
})
export class OrganisationService {
URL = 'organization';
URLMINIMAL ='organization/minimal'
URLMINIMAL = 'organization/minimal';

constructor(
private restService: RestService,
Expand All @@ -38,7 +38,7 @@ export class OrganisationService {
(response: OrganisationResponse) => {
response.createdByName = this.userMinimalService.getUserNameFrom(response.createdBy);
response.updatedByName = this.userMinimalService.getUserNameFrom(response.updatedBy);
return response
return response;
}
)
);
Expand All @@ -48,15 +48,15 @@ export class OrganisationService {
return this.restService.get(this.URLMINIMAL, {}).pipe(shareReplay(1));
}

getMultiple(
getMultiple(
limit: number = 1000,
offset: number = 0,
orderByColumn?: string,
orderByDirection?: string,
): Observable<OrganisationGetManyResponse> {
return this.restService.get(this.URL, {
limit: limit,
offset: offset,
limit,
offset,
orderOn: orderByColumn,
sort: orderByDirection,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export class ApplicationDetailComponent implements OnInit, OnDestroy {
label: '',
editRouterLink: '../../edit-application/' + this.id,
isErasable: true,
}
};

console.log(this.id);
}

Expand All @@ -58,7 +59,12 @@ export class ApplicationDetailComponent implements OnInit, OnDestroy {
}

onDeleteApplication() {
this.deleteDialogSubscription = this.deleteDialogService.showSimpleDialog().subscribe(
let message: string;
if (this.applicationHasDevices()) {
message = this.translate.instant('APPLICATION.DELETE-HAS-DEVICES-PROMPT');
}

this.deleteDialogSubscription = this.deleteDialogService.showSimpleDialog(message).subscribe(
(response) => {
if (response) {
this.applicationService.deleteApplication(this.application.id).subscribe((response) => {
Expand All @@ -76,6 +82,10 @@ export class ApplicationDetailComponent implements OnInit, OnDestroy {
);
}

applicationHasDevices(): boolean {
return this.application.iotDevices?.length > 0;
}

bindApplication(id: number): void {
this.applicationsSubscription = this.applicationService.getApplication(id).subscribe((application) => {
this.application = application;
Expand Down
16 changes: 8 additions & 8 deletions src/app/applications/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ export class ApplicationService {
permissionId?: number
): Observable<ApplicationData> {
const body: GetApplicationParameters = {
limit: limit,
offset: offset,
sort: sort,
orderOn: orderOn,
limit,
offset,
sort,
orderOn,
};
if (permissionId) {
body.permissionId = permissionId
return this.restService.get(`permission/${permissionId}/applications`, body)
body.permissionId = permissionId;
return this.restService.get(`permission/${permissionId}/applications`, body);
} else if (organizationId) {
body.organizationId = organizationId
body.organizationId = organizationId;
return this.restService.get('application', body);
}
return this.restService.get('application', body);
}

getApplicationsByOrganizationId(organizationId: number): Observable<ApplicationData> {
const body = {
organizationId: organizationId
organizationId
};
return this.restService.get('application', body);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Router } from '@angular/router';
import { Application, ApplicationData } from '@applications/application.model';
import { ApplicationService } from '@applications/application.service';
import { environment } from '@environments/environment';
import { TranslateService } from '@ngx-translate/core';
import { DeleteDialogService } from '@shared/components/delete-dialog/delete-dialog.service';
import { MeService } from '@shared/services/me.service';
import { merge, Observable, of as observableOf } from 'rxjs';
Expand Down Expand Up @@ -34,14 +35,15 @@ export class ApplicationsTableComponent implements AfterViewInit, OnInit {
@ViewChild(MatSort) sort: MatSort;

constructor(
public translate: TranslateService,
private applicationService: ApplicationService,
private router: Router,
private meService: MeService,
private deleteDialogService: DeleteDialogService
) { }

ngOnInit() {
this.canEdit = this.meService.canWriteInTargetOrganization()
this.canEdit = this.meService.canWriteInTargetOrganization();
}

ngAfterViewInit() {
Expand Down Expand Up @@ -85,7 +87,12 @@ export class ApplicationsTableComponent implements AfterViewInit, OnInit {
}

deleteApplication(id: number) {
this.deleteDialogService.showSimpleDialog().subscribe((response) => {
let message: string;
if (this.applicationHasDevices(id)) {
message = this.translate.instant('APPLICATION.DELETE-HAS-DEVICES-PROMPT');
}

this.deleteDialogService.showSimpleDialog(message).subscribe((response) => {
if (response) {
this.applicationService.deleteApplication(id).subscribe((response) => {
if (response.ok && response.body.affected > 0) {
Expand All @@ -102,6 +109,11 @@ export class ApplicationsTableComponent implements AfterViewInit, OnInit {
});
}

applicationHasDevices(id: number): boolean {
const applicationToDelete = this.data?.find(app => app.id === id);
return applicationToDelete && applicationToDelete.iotDevices.length > 0;
}

navigateToEditPage(applicationId: string) {
this.router.navigate(['applications', 'edit-application', applicationId]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/gateway/gateway-table/gateway-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</td>
</ng-container>

<!-- Location Column -->
<!-- Organization Column -->
<ng-container matColumnDef="internalOrganizationName">
<th mat-header-cell *matHeaderCellDef mat-sort-header>{{ 'LORA-GATEWAY-TABLE.ORGANIZATION' | translate }}
</th>
Expand Down
2 changes: 1 addition & 1 deletion src/app/gateway/gateway-table/gateway-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class GatewayTableComponent implements AfterViewInit {
) {
this.translate.use('da');
moment.locale('da');
}
}

ngAfterViewInit() {
this.organisationChangeSubject.subscribe((x) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/chirpstack-gateway.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ChirpstackGatewayService {
(response: GatewayResponse) => {
response.gateway.internalOrganizationName = this.sharedVariableService.getOrganizationInfo()
.find(org => org.id === response.gateway.internalOrganizationId)?.name;
//move createdat and updatedat to next level ease the use.
// Move createdat and updatedat to next level ease the use.
response.gateway.updatedAt = response.updatedAt;
response.gateway.createdAt = response.createdAt;
response.gateway.lastSeenAt = response.lastSeenAt;
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"CREATE": "Opret applikation",
"SAVE": "Gem applikation",
"DELETE": "Slet applikation",
"DELETE-HAS-DEVICES-PROMPT": "Der er knyttet IoT-enheder til denne applikation. Disse vil også blive slettet. Slet alligevel?",
"NAME": "Applikationens navn",
"DESCRIPTION": "Applikationens beskrivelse",
"ATTACHED-IOT": "Tilknyttede IoT enheder",
Expand Down