ing
This commit is contained in:
parent
ee1b5c6bfc
commit
6f8f0e970c
|
@ -43,12 +43,6 @@
|
|||
}
|
||||
|
||||
.vis-container {
|
||||
// position: absolute;
|
||||
// top:78px;
|
||||
// left:0px;
|
||||
// bottom: 0px;
|
||||
// width: 100%;
|
||||
// margin: 0;
|
||||
height: 100vh;
|
||||
margin: -0.6em -0.9em -0.7em -0.9em; //-0.5em -0.75em;
|
||||
padding: 0;
|
||||
|
|
|
@ -32,6 +32,10 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
|
||||
showIntro = true;
|
||||
|
||||
private visNetwork: any;
|
||||
private nodeSet: any;
|
||||
private edgeSet: any;
|
||||
|
||||
constructor(
|
||||
private changeDetector: ChangeDetectorRef,
|
||||
private probeService: ProbeService,
|
||||
|
@ -54,59 +58,47 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
discoverHost(dfd: string) {
|
||||
// const zone: Zone = {
|
||||
// network: '192.168.1.0/24',
|
||||
// iface: 'enp3s0',
|
||||
// metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
||||
// address: '192.168.1.101',
|
||||
// mac: '44:8a:5b:f1:f1:f3',
|
||||
// };
|
||||
|
||||
// const discoverHost: DiscoverHost = {
|
||||
// metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
||||
// firstScanRange: '192.168.1.1',
|
||||
// lastScanRange: '192.168.1.254',
|
||||
// discoveryConfig: {
|
||||
// },
|
||||
// discoverPort: {
|
||||
// firstScanRange: 1,
|
||||
// lastScanRange: 65535,
|
||||
// includeTCP: true,
|
||||
// includeUDP: true,
|
||||
// discoverService: {
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// this.probeService.send('DiscoveryService.DiscoverHost', requesterID, zone, discoverHost);
|
||||
this.showIntro = false;
|
||||
this.changeDetector.detectChanges();
|
||||
|
||||
const nodes = [
|
||||
{ id: 1, label: 'a' },
|
||||
{ id: 2, label: 'b' },
|
||||
{ id: 3, label: 'c' },
|
||||
];
|
||||
const edges = [
|
||||
{ from: 1, to: 2 },
|
||||
{ from: 1, to: 3 },
|
||||
{ from: 2, to: 3 },
|
||||
];
|
||||
|
||||
const data = {
|
||||
nodes: nodes,
|
||||
edges: edges,
|
||||
};
|
||||
this.nodeSet = new vis.DataSet([
|
||||
{ id: '192.168.1.0/24', label: 'Zone' },
|
||||
]);
|
||||
this.edgeSet = new vis.DataSet([]);
|
||||
|
||||
const options = {
|
||||
width: '100%',
|
||||
height: '100%'
|
||||
};
|
||||
|
||||
const network = new vis.Network(this.discoveryTargetRef.nativeElement, data, options);
|
||||
this.visNetwork = new vis.Network(this.discoveryTargetRef.nativeElement, { nodes: this.nodeSet, edges: this.edgeSet }, options);
|
||||
|
||||
|
||||
const zone: Zone = {
|
||||
network: '192.168.1.0/24',
|
||||
iface: 'enp3s0',
|
||||
metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
||||
address: '192.168.1.101',
|
||||
mac: '44:8a:5b:f1:f1:f3',
|
||||
};
|
||||
|
||||
const discoverHost: DiscoverHost = {
|
||||
metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
||||
firstScanRange: '192.168.1.1',
|
||||
lastScanRange: '192.168.1.254',
|
||||
discoveryConfig: {
|
||||
},
|
||||
discoverPort: {
|
||||
firstScanRange: 1,
|
||||
lastScanRange: 65535,
|
||||
includeTCP: true,
|
||||
includeUDP: true,
|
||||
discoverService: {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.probeService.send('DiscoveryService.DiscoverHost', requesterID, zone, discoverHost);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,6 +139,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
@RPCSubscriber({ method: 'DiscoveryService.DiscoveryStop' })
|
||||
public DiscoveryStop(stopDate: Date) {
|
||||
console.log('DiscoveryStop', stopDate);
|
||||
this.visNetwork.stabilize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,6 +156,21 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredHost' })
|
||||
public DiscoveredHost(host: Host) {
|
||||
console.log('DiscoveredHost', host);
|
||||
const hostId = `${host.address}`;
|
||||
|
||||
if (null !== this.nodeSet.get(hostId)) {
|
||||
this.nodeSet.update([
|
||||
{ id: hostId, label: `${host.name}(${host.address})` }
|
||||
]);
|
||||
} else {
|
||||
this.nodeSet.add([
|
||||
{ id: hostId, label: `${host.name}(${host.address})` }
|
||||
]);
|
||||
this.edgeSet.add([
|
||||
{ from: '192.168.1.0/24', to: hostId },
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,5 +187,14 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredService' })
|
||||
public DiscoveredService(service: Service) {
|
||||
console.log('DiscoveredService', service);
|
||||
const hostId = service.port.host.address;
|
||||
const serviceId = `${service.port.host.address}-${service.port.portNumber}-${service.key}`;
|
||||
this.nodeSet.add([
|
||||
{ id: `${serviceId}`, label: `${service.key}` }
|
||||
]);
|
||||
this.edgeSet.add([
|
||||
{ from: `${hostId}`, to: `${serviceId}` },
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user