Commit 2198d162 authored by Brandon Dunn's avatar Brandon Dunn
Browse files

Delete and update call work need to put in ui call

parent f879ad65
This diff is collapsed.
......@@ -43,21 +43,22 @@ export class AppComponent {
id: 22,
Data: 'A',
record_type: 'A',
host: null
host: null,
dropDownRecordType: null
}
ngOnInit(){
// this.getUserInformation();
//this.getAvailableIPs();
//this.testRecords.push(this.new_record);
this.UpdateIp();
//this.getAllIps();
//this.UpdateIp();
this.getAllIps();
//this.getRecords(3);
//this.PutRecords();
//this.getIPsByRange()
//this.PostPreambles()
//this.PostRecords();
//this.DeleteHost();
//this.DeleteHost(6);
// if(this.returned_record_id != null){
// this.PostHosts(this.returned_record_id);
// }else{
......@@ -108,11 +109,7 @@ export class AppComponent {
.toPromise()
.then((res) => {
res.forEach(x => {
<<<<<<< HEAD
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);
=======
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.hostRecords);
>>>>>>> 29eb9a4595cf6f43a75bd2798aac5f05d1c75c04
this.ipResultSet.push(item)
})
this.dataSource = this.ipResultSet;
......@@ -168,6 +165,16 @@ export class AppComponent {
console.log('update ip called')
});
}
UpdateMac(mac_id, mac_address): void{
this.sampleService.PutMac(mac_id, mac_address)
.toPromise()
.then((res) => {
console.log('updated mac')
})
}
// PostRecords(host_name, ipv4?, ipv6?, mac_address?, adapter_name?): void {
// this.UpdateMac(5, '1B:2A:3F:4E:5D')
// }
PostRecords(host_name, ipv4?, ipv6?, mac_address?, adapter_name?): void {
this.sampleService.PostHosts(host_name)
......
......@@ -166,6 +166,12 @@ export class SampleService {
return this.http.put<IPs>(this.HostLocation + this.endpoint, this.new_ip);
}
PutMac(mac_id, mac_address): Observable<any>{
this.endpoint = 'ipam/updatemac/' + mac_id +'/';
this.new_mac.mac = mac_address;
return this.http.put<any>(this.HostLocation + this.endpoint, this.new_mac)
}
DeleteHost(id): any {
this.endpoint = 'ipam/deletehost/'+ id +'/';
return this.http.delete<any>(this.HostLocation + this.endpoint);
......
......@@ -5,11 +5,10 @@ from .models import Record, Host, Adapter, Mac_Addr, Role, Preamble, Subnet, IP
class RecordSerializer(serializers.ModelSerializer):
class Meta:
model = Record
fields = ('record_type', 'RECORD_TYPES')
fields = '__all__'
depth = 5
class HostSerializer(serializers.ModelSerializer):
records = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
class Meta:
model = Host
fields = ('host_name', '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