Commit 711ab613 authored by Venkat's avatar Venkat
Browse files

added get records call

parent e5255c77
......@@ -37,7 +37,7 @@ export class AppComponent {
selectedRow: PostUIObject = {};
selectedCell: string = '';
testRecords: Records[] = []
hostRecords: Records[] = []
new_record: Records = {
id: 22,
Data: 'A',
......@@ -50,8 +50,8 @@ export class AppComponent {
//this.getAvailableIPs();
//this.testRecords.push(this.new_record);
//this.UpdateIp();
//this.getAllIps();
this.getRecords();
this.getAllIps();
//this.getRecords(3);
//this.PutRecords();
//this.getIPsByRange()
//this.PostPreambles()
......@@ -75,6 +75,7 @@ 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();
}
}
......@@ -94,7 +95,7 @@ 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);
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);
this.ipResultSet.push(item)
})
this.dataSource = this.ipResultSet;
......@@ -102,8 +103,8 @@ export class AppComponent {
}
getRecords(): void{
this.sampleService.GetRecords()
getRecords(host_id): void{
this.sampleService.GetRecords(host_id)
.toPromise()
.then((res) => {
console.log('records retrieved')
......@@ -189,27 +190,13 @@ export class AppComponent {
openDialog(): void {
const dialogRef = this.dialog.open(DialogOverviewComponent, {
width: '250px',
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}
});
const dialogRef1 = this.dialog.open(DialogOverviewComponent, {
width: '500px',
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}
});
dialogRef1.afterClosed().subscribe(result => {
console.log('The dialog was closed');
this.postUIObject.ipv4 = result.ipv4;
this.postUIObject.ipv6 = result.ipv6;
this.postUIObject.host_name = result.host;
this.postUIObject.mac_address = result.mac;
this.postUIObject.adapter_name = result.adapter;
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}
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
if(result !== undefined){
this.postUIObject.ipv4 = result.ipv4;
this.postUIObject.ipv6 = result.ipv6;
this.postUIObject.host_name = result.host;
......@@ -218,6 +205,7 @@ export class AppComponent {
this.PostRecords(this.postUIObject.host_name, this.postUIObject.ipv4, this.postUIObject.ipv6, this.postUIObject.mac_address, this.postUIObject.adapter_name);
}
});
......@@ -301,9 +289,10 @@ export class IPResultSet{
mac_addr: any;
adapter: any;
subnet_name: any
records: any
constructor(id, ipv4, ipv6, host, mac_addr, adapter, subnet_name){
constructor(id, ipv4, ipv6, host, mac_addr, adapter, subnet_name, records){
this.ip_id = id;
this.ipv4 = ipv4;
this.ipv6 = ipv6;
......@@ -311,6 +300,7 @@ export class IPResultSet{
this.mac_addr = mac_addr;
this.adapter = adapter;
this.subnet_name = subnet_name;
this.records = records
}
}
......@@ -5,7 +5,7 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component'
import {MatToolbarModule} from '@angular/material/toolbar';
import {MatIconModule} from '@angular/material/icon';
import { MatCardModule, MatInputModule, MatSelectModule, MatDialogModule } from '@angular/material';
import { MatCardModule, MatInputModule, MatSelectModule, MatDialogModule, MatListModule } from '@angular/material';
import { HttpClientModule } from '@angular/common/http';
import { RecordFormComponent } from './record-form/record-form.component';
import { ReactiveFormsModule, FormsModule} from '@angular/forms'
......@@ -36,6 +36,7 @@ import { DialogOverviewComponent } from './dialog-overview/dialog-overview.compo
MatInputModule,
MatSelectModule,
MatDialogModule,
MatListModule
],
providers: [],
......
#main {
width: 800px;
margin: 0 auto;
}
#sidebar {
width: 300px;
height: 500px;
float: left;
}
#page-wrap {
width: 200px;
background: #ffffff;
height: 400px;
margin-left: 400px;
}
<div mat-dialog-content>
<div id="main">
<div mat-dialog-content id="sidebar">
<p>Enter the data in the fields</p>
<mat-form-field>
<input matInput placeholder="IPV4" [(ngModel)]="data.ipv4">
......@@ -16,7 +17,16 @@
<input matInput placeholder="Mac" [(ngModel)]="data.mac">
</mat-form-field>
</div>
<div id="page-wrap">
<p>Available Records</p>
<mat-selection-list>
<mat-list-option *ngFor="let record of data.records">
{{record.record_type}}
</mat-list-option>
</mat-selection-list>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">No Thanks</button>
<button mat-button [mat-dialog-close]="data" cdkFocusInitial>Ok</button>
</div>
</div>
......@@ -11,6 +11,8 @@ import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
export class DialogOverviewComponent implements OnInit {
typesOfShoes: string[] = ['Boots', 'Clogs', 'Loafers', 'Moccasins', 'Sneakers'];
ngOnInit() {
}
......
......@@ -179,8 +179,8 @@ export class SampleService {
return this.http.put<any>(this.HostLocation + this.endpoint, this.new_record_dict)
}
GetRecords(): Observable<any>{
this.endpoint = 'ipam/listrecords/';
GetRecords(host_id): Observable<any>{
this.endpoint = 'ipam/listrecords/' + host_id + '/';
return this.http.get<any>(this.HostLocation + this.endpoint, this.httpOptions);
}
......
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