Commit b2dacef0 authored by Venkat's avatar Venkat
Browse files

added the drop down list to show record types

parent fdca6dd0
......@@ -37,6 +37,7 @@ export class AppComponent {
selectedRow: PostUIObject = {};
selectedCell: string = '';
AllRecordList: Records[] =[]
hostRecords: Records[] = []
new_record: Records = {
id: 22,
......@@ -65,6 +66,10 @@ export class AppComponent {
}
ngOnDestroy(){
this.hostRecords = [];
}
displayedColumns: string[] = ['subnet_name', 'ipv4', 'ipv6', 'host', 'mac_addr', 'adapter'];
......@@ -75,8 +80,16 @@ export class AppComponent {
selectRow(row): any{
this.selectedRow = row;
if(this.selectedCell == 'ipv4' || this.selectedCell == 'ipv6'){
this.hostRecords = this.ipResultSet.find(x => x.host == row['host']).records;
this.openDialog();
this.sampleService.GetRecords()
.toPromise()
.then((res) => {
let records = res.find(x => x.host.id == row['host_id']);
if(records !== undefined || records !== null){
this.AllRecordList.push(records);
}
this.openDialog();
})
}
}
......@@ -95,22 +108,14 @@ export class AppComponent {
.toPromise()
.then((res) => {
res.forEach(x => {
let item = new IPResultSet(x.id != null ? x.id : null , x.ipv4, x.ipv6, x.mac_addr != null ? x.mac_addr.adapter.host.host_name: null, x.mac_addr != null ? x.mac_addr.mac : null, x.mac_addr!== null && x.mac_addr.adapter !== null ? x.mac_addr.adapter.adapter_name : null, x.subnet !== null ? x.subnet.subnet_name : null, this.testRecords);
let item = new IPResultSet(x.id != null ? x.id : null , x.ipv4, x.ipv6, x.mac_addr != null ? x.mac_addr.adapter.host.host_name: null, x.mac_addr != null ? x.mac_addr.mac : null, x.mac_addr!== null && x.mac_addr.adapter !== null ? x.mac_addr.adapter.adapter_name : null, x.subnet !== null ? x.subnet.subnet_name : null, null, x.mac_addr !== null ? x.mac_addr.adapter.host.id : null);
this.ipResultSet.push(item)
})
this.dataSource = this.ipResultSet;
})
}
getRecords(host_id): void{
this.sampleService.GetRecords(host_id)
.toPromise()
.then((res) => {
console.log('records retrieved')
});
}
getIPsByRange(): void{
this.sampleService.ListIPsByRange()
.toPromise()
......@@ -190,7 +195,8 @@ export class AppComponent {
openDialog(): void {
const dialogRef = this.dialog.open(DialogOverviewComponent, {
data: {ipv4: this.selectedRow['ipv4'], ipv6: this.selectedRow['ipv6'], host: this.selectedRow['host'], adapter: this.selectedRow['adapter'], mac: this.selectedRow['mac_addr'], records: this.hostRecords}
width: '700px',
data: {ipv4: this.selectedRow['ipv4'], ipv6: this.selectedRow['ipv6'], host: this.selectedRow['host'], adapter: this.selectedRow['adapter'], mac: this.selectedRow['mac_addr'], records: this.AllRecordList}
});
......@@ -206,6 +212,7 @@ export class AppComponent {
this.PostRecords(this.postUIObject.host_name, this.postUIObject.ipv4, this.postUIObject.ipv6, this.postUIObject.mac_address, this.postUIObject.adapter_name);
}
this.AllRecordList = [];
});
......@@ -288,11 +295,12 @@ export class IPResultSet{
host: any
mac_addr: any;
adapter: any;
subnet_name: any
records: any
subnet_name: any;
records: any;
host_id: any
constructor(id, ipv4, ipv6, host, mac_addr, adapter, subnet_name, records){
constructor(id, ipv4, ipv6, host, mac_addr, adapter, subnet_name, records, host_Id){
this.ip_id = id;
this.ipv4 = ipv4;
this.ipv6 = ipv6;
......@@ -300,7 +308,8 @@ export class IPResultSet{
this.mac_addr = mac_addr;
this.adapter = adapter;
this.subnet_name = subnet_name;
this.records = records
this.records = records;
this.host_id = host_Id;
}
}
......@@ -18,14 +18,24 @@
</mat-form-field>
</div>
<div id="page-wrap">
<p>Available Records</p>
<p>Currently Assigned Records</p>
<mat-selection-list>
<mat-list-option *ngFor="let record of data.records">
<mat-list-option *ngFor="let record of data.records" [selected]="true">
{{record.record_type}}
</mat-list-option>
</mat-selection-list>
<mat-form-field>
<mat-label>Pick a Record Type</mat-label>
<mat-select>
<mat-option *ngFor="let record of data.records" [value]="record.dropDownRecordType">
{{record.record_type}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div mat-dialog-actions>
<div>
<button mat-button (click)="onNoClick()">No Thanks</button>
<button mat-button [mat-dialog-close]="data" cdkFocusInitial>Ok</button>
</div>
......
......@@ -32,14 +32,16 @@ export interface DialogData {
host: string;
adapter: string;
mac: string;
records: Records[]
records: Records[],
dropDownValue: any
}
export interface Records{
id: any,
Data: any,
record_type: string,
host: any
host: any,
dropDownRecordType: string
}
......@@ -179,9 +179,9 @@ export class SampleService {
return this.http.put<any>(this.HostLocation + this.endpoint, this.new_record_dict)
}
GetRecords(host_id): Observable<any>{
this.endpoint = 'ipam/listrecords/' + host_id + '/';
return this.http.get<any>(this.HostLocation + this.endpoint, this.httpOptions);
GetRecords(): Observable<Records[]>{
this.endpoint = 'ipam/listrecords/';
return this.http.get<any>(this.HostLocation + this.endpoint);
}
//Add Record Types
......
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