ing
This commit is contained in:
parent
485dc7e8c1
commit
7e94b5eb30
|
@ -50,8 +50,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||||
private readonly maxScale: number;
|
private readonly maxScale: number;
|
||||||
private readonly minScale: number;
|
private readonly minScale: number;
|
||||||
|
|
||||||
hosts: Host[];
|
hosts: Map<string, Host>;
|
||||||
ports: Port[];
|
ports: Map<string, Map<number, Port>>;
|
||||||
|
|
||||||
resultMsg: Message[] = [];
|
resultMsg: Message[] = [];
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||||
) {
|
) {
|
||||||
this.nodes = [];
|
this.nodes = [];
|
||||||
this.links = [];
|
this.links = [];
|
||||||
this.hosts = [];
|
this.hosts = new Map();
|
||||||
this.ports = [];
|
this.ports = new Map();
|
||||||
|
|
||||||
this.discoveryRequestID = null;
|
this.discoveryRequestID = null;
|
||||||
|
|
||||||
|
@ -511,6 +511,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||||
case 'zone':
|
case 'zone':
|
||||||
const zone: Zone = node.target;
|
const zone: Zone = node.target;
|
||||||
zone.hostList = [];
|
zone.hostList = [];
|
||||||
|
|
||||||
this.hosts.forEach(_host => {
|
this.hosts.forEach(_host => {
|
||||||
if (_host.zone.network === zone.network) {
|
if (_host.zone.network === zone.network) {
|
||||||
zone.hostList.push(_host);
|
zone.hostList.push(_host);
|
||||||
|
@ -520,11 +521,11 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||||
case 'host':
|
case 'host':
|
||||||
const host: Host = node.target;
|
const host: Host = node.target;
|
||||||
host.portList = [];
|
host.portList = [];
|
||||||
this.ports.forEach(port => {
|
if (this.ports.has(host.address)) {
|
||||||
if (port.host.address === host.address) {
|
this.ports.get(host.address).forEach(port => {
|
||||||
host.portList.push(port);
|
host.portList.push(port);
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -661,16 +662,22 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||||
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredHost' })
|
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredHost' })
|
||||||
public DiscoveredHost(host: Host) {
|
public DiscoveredHost(host: Host) {
|
||||||
console.log('DiscoveredHost', host);
|
console.log('DiscoveredHost', host);
|
||||||
let dup = false;
|
|
||||||
this.hosts.forEach((item) => {
|
// if (this.hosts.has(host.address)) {
|
||||||
if (item.address === host.address) {
|
|
||||||
dup = true;
|
// }
|
||||||
return;
|
|
||||||
}
|
// let dup = false;
|
||||||
});
|
// this.hosts.forEach((item) => {
|
||||||
if (!dup) {
|
// if (item.address === host.address) {
|
||||||
this.hosts.push(host);
|
// dup = true;
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// if (!dup) {
|
||||||
|
// this.hosts.push(host);
|
||||||
|
// }
|
||||||
|
this.hosts.set(host.address, host);
|
||||||
|
|
||||||
const hostId = `${host.address}`;
|
const hostId = `${host.address}`;
|
||||||
|
|
||||||
|
@ -698,7 +705,16 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||||
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredPort' })
|
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredPort' })
|
||||||
public DiscoveredPort(port: Port) {
|
public DiscoveredPort(port: Port) {
|
||||||
console.log('DiscoveredPort', port);
|
console.log('DiscoveredPort', port);
|
||||||
this.ports.push(port);
|
|
||||||
|
let _ports: Map<number, Port>;
|
||||||
|
if (!this.ports.has(port.host.address)) {
|
||||||
|
_ports = new Map();
|
||||||
|
this.ports.set(port.host.address, _ports);
|
||||||
|
} else {
|
||||||
|
_ports = this.ports.get(port.host.address);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ports.set(port.portNumber, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -708,7 +724,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||||
public DiscoveredService(service: Service) {
|
public DiscoveredService(service: Service) {
|
||||||
console.log('DiscoveredService', service);
|
console.log('DiscoveredService', service);
|
||||||
const hostId = service.port.host.address;
|
const hostId = service.port.host.address;
|
||||||
const serviceId = `${service.port.host.address}-${service.port.portNumber}-${service.key}`;
|
const serviceId = `${service.port.host.address}-${service.port.portNumber}-${service.port.metaPortType.key}`;
|
||||||
|
|
||||||
const hostNode = this.getNode(hostId);
|
const hostNode = this.getNode(hostId);
|
||||||
let serviceNode = this.getNode(serviceId);
|
let serviceNode = this.getNode(serviceId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user