Commit d6cc9b77 authored by Venkat's avatar Venkat
Browse files

added parameters so that the dialog box gets auto populated upon clicking

parent 2d3935f7
<mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<ng-container matColumnDef="subnet_name">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> Subnet </mat-header-cell>
<mat-cell *matCellDef="let element" (click)="openDialog()"> {{element?.subnet_name}} </mat-cell>
<mat-cell *matCellDef="let element"> {{element?.subnet_name}} </mat-cell>
</ng-container>
<ng-container matColumnDef="ipv4">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> IPV4 </mat-header-cell>
<mat-cell *matCellDef="let element" (click)="openDialog()"> {{element?.ipv4}} </mat-cell>
<mat-cell *matCellDef="let element" (click) = "getClick('ipv4')" > {{element?.ipv4}} </mat-cell>
</ng-container>
<ng-container matColumnDef="ipv6">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> IPV6 </mat-header-cell>
<mat-cell *matCellDef="let element" (click)="openDialog()"> {{element?.ipv6}} </mat-cell>
<mat-cell *matCellDef="let element" (click)="getClick('ipv6')"> {{element?.ipv6}} </mat-cell>
</ng-container>
<ng-container matColumnDef="host">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> Host </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element?.host}} </mat-cell>
<mat-cell *matCellDef="let element" (click)="getClick('host')"> {{element?.host}} </mat-cell>
</ng-container>
<ng-container matColumnDef="mac_addr">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> Mac Address </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element?.mac_addr}} </mat-cell>
<mat-cell *matCellDef="let element" (click)="getClick('mac_addr')"> {{element?.mac_addr}} </mat-cell>
</ng-container>
<ng-container matColumnDef="adapter">
<mat-header-cell style="font-weight: bold" *matHeaderCellDef> Adapter </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element?.adapter}} </mat-cell>
<mat-cell *matCellDef="let element" (click)="getClick('adapter')"> {{element?.adapter}} </mat-cell>
</ng-container>
<mat-header-row style="font-weight: bold" *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
<mat-row *matRowDef="let row; columns: displayedColumns;" (click)="selectRow(row)"></mat-row>
</mat-table>
......
......@@ -6,7 +6,7 @@ import { Observable } from 'rxjs';
import { delay } from 'q';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
import { DialogOverviewComponent, Records } from './dialog-overview/dialog-overview.component';
import { isIPv6 } from 'net';
import { ConsoleReporter } from 'jasmine';
@Component({
selector: 'app-root',
......@@ -36,10 +36,21 @@ export class AppComponent {
postUIObject: PostUIObject = {};
selectedRow: PostUIObject = {};
selectedCell: string = '';
testRecords: Records[] = []
new_record: Records = {
id: 22,
Data: 'A',
record_type: 'A',
host: null
}
ngOnInit(){
// this.getUserInformation();
//this.getAvailableIPs();
this.testRecords.push(this.new_record);
this.getAllIps();
//this.PutRecords();
//this.getIPsByRange()
......@@ -63,6 +74,17 @@ export class AppComponent {
);
console.log(this.userInformation);
}
getClick(selectedValue): any{
this.selectedCell = selectedValue;
}
selectRow(row): any{
this.selectedRow = row;
if(this.selectedCell == 'ipv4' || this.selectedCell == 'ipv6'){
this.openDialog();
}
}
getUserInformation(): void {
......@@ -165,12 +187,13 @@ export class AppComponent {
})
})
})
console.log('Record Posted');
}
openDialog(): void {
}
openDialog(): void {
const dialogRef = this.dialog.open(DialogOverviewComponent, {
width: '250px',
data: {ipv4: this.ipv4, ipv6: this.ipv6, host: this.host, adapter: this.adapter, mac: this.mac}
data: {ipv4: this.selectedRow['ipv4'], ipv6: this.selectedRow['ipv6'], host: this.selectedRow['host'], adapter: this.selectedRow['adapter'], mac: this.selectedRow['mac_addr'], records: this.testRecords}
});
dialogRef.afterClosed().subscribe(result => {
......
......@@ -14,7 +14,7 @@
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Mac" [(ngModel)]="data.mac">
</mat-form-field>
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">No Thanks</button>
......
......@@ -30,6 +30,7 @@ export interface DialogData {
host: string;
adapter: string;
mac: string;
records: Records[]
}
export interface Records{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment