Configurator for switch

This commit is contained in:
Piotr Pekala 2019-09-12 07:55:17 -07:00
parent 36a8387ea2
commit aea8010e0a
4 changed files with 37 additions and 5 deletions

View File

@ -4,13 +4,22 @@
<div class="content">
<div class="default-content">
<mat-card>
<!-- <table class="table" mat-table [dataSource]="ethernetPorts">
<ng-container matColumnDef="port_number">
<form [formGroup]="inputForm">
<mat-form-field class="form-field">
<input
matInput type="text"
[(ngModel)]="node.name"
formControlName="name"
placeholder="Name">
</mat-form-field>
</form>
<table class="table" mat-table [dataSource]="dataSource">
<ng-container matColumnDef="Port: DLCI">
<th mat-header-cell *matHeaderCellDef> Port number </th>
<td mat-cell *matCellDef="let element"> {{element.port_number}} </td>
</ng-container>
<ng-container matColumnDef="vlan">
<ng-container matColumnDef="Port: DLCI ">
<th mat-header-cell *matHeaderCellDef> VLAN </th>
<td mat-cell *matCellDef="let element"> {{element.vlan}} </td>
</ng-container>
@ -26,7 +35,7 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table><br/> -->
</table><br/>
<!-- <mat-form-field class="form-field">
<input
matInput type="number"

View File

@ -19,6 +19,10 @@ export class ConfiguratorDialogSwitchComponent implements OnInit {
inputForm: FormGroup;
consoleTypes: string[] = [];
nodeMappings = new Map<string, string>();
dataSource = [];
displayedColumns = ['Port: DLCI', 'Port: DLCI ']
constructor(
public dialogRef: MatDialogRef<ConfiguratorDialogSwitchComponent>,
public nodeService: NodeService,
@ -34,11 +38,30 @@ export class ConfiguratorDialogSwitchComponent implements OnInit {
this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => {
this.node = node;
this.name = node.name;
})
let mappings = node.properties.mappings;
Object.keys(mappings).forEach(key => {
this.nodeMappings.set(key, mappings[key]);
});
});
}
delete(elem) {
}
strMapToObj(strMap) {
let obj = Object.create(null);
for (let [k,v] of strMap) {
obj[k] = v;
}
return obj;
}
onSaveClick() {
if (this.inputForm.valid) {
this.node.properties.mappings = Array.from(this.nodeMappings).reduce((obj, [key, value]) => (Object.assign(obj, { [key]: value })), {});
this.nodeService.updateNode(this.server, this.node).subscribe(() => {
this.toasterService.success(`Node ${this.node.name} updated.`);
this.onCancelClick();