-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added dialog for changing gateway organization. * rename of gateway db id. Also change to use extra button onclick event. * Added gateway endpoint for organizations and use.
- Loading branch information
1 parent
963a660
commit 56e5f70
Showing
12 changed files
with
199 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...eway/gateway-change-organization-dialog/gateway-change-organization-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div class="gateway-change-organization-dialog"> | ||
<h1 mat-dialog-title>{{ "GATEWAY.CHANGE-ORGANIZATION.TITLE" | translate }}</h1> | ||
<div mat-dialog-content> | ||
<label class="form-label" for="organizationSelect">{{ | ||
"GATEWAY.CHANGE-ORGANIZATION.CHOOSE-ORGANIZATION" | translate | ||
}}</label> | ||
<mat-select | ||
id="organizationSelect" | ||
class="form-control" | ||
panelClass="overflow-x-hidden" | ||
[(value)]="gateway.organizationId" | ||
[compareWith]="compare" | ||
> | ||
<mat-option *ngFor="let organization of filteredOrganizations | async" [value]="organization.id"> | ||
{{ organization.name }} | ||
</mat-option> | ||
</mat-select> | ||
</div> | ||
<div mat-dialog-actions class="d-flex flex-row"> | ||
<button (click)="onSubmit()" class="btn btn-primary"> | ||
{{ "GEN.SAVE" | translate }} | ||
</button> | ||
<button mat-dialog-close [mat-dialog-close]="false" class="btn btn-secondary ml-2"> | ||
{{ "GEN.CANCEL" | translate }} | ||
</button> | ||
</div> | ||
</div> |
3 changes: 3 additions & 0 deletions
3
...eway/gateway-change-organization-dialog/gateway-change-organization-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.gateway-change-organization-dialog { | ||
width: 50vw; | ||
} |
72 changes: 72 additions & 0 deletions
72
...ateway/gateway-change-organization-dialog/gateway-change-organization-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Component, Inject, OnInit } from "@angular/core"; | ||
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; | ||
import { MatSnackBar } from "@angular/material/snack-bar"; | ||
import { Organisation } from "@app/admin/organisation/organisation.model"; | ||
import { OrganisationService } from "@app/admin/organisation/organisation.service"; | ||
import { TranslateService } from "@ngx-translate/core"; | ||
import { GatewayDialogModel } from "@shared/models/dialog.model"; | ||
import { ChirpstackGatewayService } from "@shared/services/chirpstack-gateway.service"; | ||
import { SharedVariableService } from "@shared/shared-variable/shared-variable.service"; | ||
import { ReplaySubject, Subscription } from "rxjs"; | ||
import { UpdateGatewayOrganization } from "../gateway.model"; | ||
|
||
@Component({ | ||
selector: "app-gateway-change-organization-dialog", | ||
templateUrl: "./gateway-change-organization-dialog.component.html", | ||
styleUrls: ["./gateway-change-organization-dialog.component.scss"], | ||
}) | ||
export class GatewayChangeOrganizationDialogComponent implements OnInit { | ||
public gatewaysSubscription: Subscription; | ||
public organizationsSubscription: Subscription; | ||
public gateway: UpdateGatewayOrganization; | ||
public organizations: Organisation[]; | ||
public filteredOrganizations: ReplaySubject<Organisation[]> = new ReplaySubject<Organisation[]>(1); | ||
|
||
constructor( | ||
private gatewayService: ChirpstackGatewayService, | ||
public translate: TranslateService, | ||
private organizationService: OrganisationService, | ||
private sharedVariableService: SharedVariableService, | ||
private snackBar: MatSnackBar, | ||
private dialog: MatDialogRef<GatewayChangeOrganizationDialogComponent>, | ||
@Inject(MAT_DIALOG_DATA) public dialogModel: GatewayDialogModel | ||
) { | ||
this.gateway = { | ||
organizationId: this.dialogModel.organizationId ?? this.sharedVariableService.getSelectedOrganisationId(), | ||
}; | ||
} | ||
|
||
ngOnInit(): void { | ||
this.translate.use("da"); | ||
this.getOrganizations(); | ||
} | ||
|
||
getOrganizations() { | ||
this.organizationsSubscription = this.organizationService.getMultipleWithGatewayAdmin().subscribe(res => { | ||
this.organizations = res.data; | ||
this.filteredOrganizations.next(this.organizations.slice()); | ||
}); | ||
} | ||
|
||
public compare(o1: any, o2: any): boolean { | ||
return o1 === o2; | ||
} | ||
|
||
onSubmit() { | ||
this.gatewaysSubscription = this.gatewayService | ||
.updateGatewayOrganization(this.gateway, this.dialogModel.gatewayDbId) | ||
.subscribe(gateway => { | ||
this.snackBar.open( | ||
this.translate.instant("GATEWAY.CHANGE-ORGANIZATION.SNACKBAR-SAVED", { | ||
gatewayName: gateway.name, | ||
organizationName: gateway.organization.name, | ||
}), | ||
"", | ||
{ | ||
duration: 10000, | ||
} | ||
); | ||
this.dialog.close(true); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters