fixed infra and discovery
This commit is contained in:
parent
c57f1193f3
commit
f2a16ac753
|
@ -233,10 +233,10 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
|||
console.log(discoveryZone);
|
||||
|
||||
// console.log('start discovery - ' + this.probe.probeKey);
|
||||
// this.discoverstore.dispatch(new DiscoverStore.DiscoverZone(
|
||||
// { probeID: this.probe.probeKey, discoveryZone: discoveryZone }));
|
||||
this.discoverstore.dispatch(new DiscoverStore.DiscoverZone(
|
||||
{ probeID: this.probe.probeKey, discoveryZone: discoveryZone }));
|
||||
|
||||
// this.started = true;
|
||||
this.started = true;
|
||||
}
|
||||
|
||||
checkDiscoveryResult(node) {
|
||||
|
|
|
@ -178,20 +178,32 @@ export class MapComponent implements OnInit, AfterContentInit {
|
|||
|
||||
const itl: TreeNode[] = [];
|
||||
|
||||
const root: TreeNode = {
|
||||
label: 'Infra',
|
||||
expandedIcon: 'fa-folder-open',
|
||||
collapsedIcon: 'fa-folder',
|
||||
expanded: true,
|
||||
children: [],
|
||||
};
|
||||
|
||||
const probeMap: Map<number, InfraHost[]> = new Map();
|
||||
|
||||
const hostMap: Map<number, InfraService[]> = new Map();
|
||||
|
||||
this.loading = true;
|
||||
|
||||
this.sortInfraToMap(probeMap, hostMap, filterStr);
|
||||
|
||||
this.targetTreeMap.clear();
|
||||
|
||||
const infraTree: TreeNode = this.generateInfraTree(probeMap, hostMap);
|
||||
|
||||
for (const infra of this.totalList) {
|
||||
this.getSensorByInfra(infra);
|
||||
}
|
||||
|
||||
this.loading = false;
|
||||
|
||||
itl.push(infraTree);
|
||||
|
||||
return itl;
|
||||
|
||||
}
|
||||
|
||||
generateInfraTree(probeMap: Map<number, InfraHost[]>, hostMap: Map<number, InfraService[]>): TreeNode {
|
||||
|
||||
const infraTree = {
|
||||
label: 'Infra',
|
||||
expandedIcon: 'fa-folder-open',
|
||||
|
@ -200,52 +212,6 @@ export class MapComponent implements OnInit, AfterContentInit {
|
|||
children: [],
|
||||
};
|
||||
|
||||
for (const infra of this.totalList) {
|
||||
const infraType = infra.infraType.name;
|
||||
if (infraType === 'HOST') {
|
||||
const infraHost: InfraHost = infra;
|
||||
if (filterStr && String(infraHost.ip).indexOf(filterStr) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (probeMap.has(infraHost.probe.id) === false) {
|
||||
probeMap.set(infraHost.probe.id, []);
|
||||
}
|
||||
|
||||
const ihl: InfraHost[] = probeMap.get(infraHost.probe.id);
|
||||
ihl.push(infraHost);
|
||||
probeMap.set(infraHost.probe.id, ihl);
|
||||
|
||||
} else if (infraType === 'OS_SERVICE') {
|
||||
const infraService: InfraService = infra;
|
||||
if (filterStr && this.checkFilterString(infraService, filterStr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hostMap.has(infraService.host.ip) === false) {
|
||||
hostMap.set(infraService.host.ip, []);
|
||||
}
|
||||
|
||||
const isl = hostMap.get(infraService.host.ip);
|
||||
isl.push(infraService);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// const ProbeTree = {
|
||||
// label: 'Probe',
|
||||
// expandedIcon: 'fa-folder-open',
|
||||
// collapsedIcon: 'fa-folder',
|
||||
// expanded: true,
|
||||
// children: [],
|
||||
// };
|
||||
|
||||
// const probeTreeNodes: TreeNode[] = [];
|
||||
|
||||
this.targetTreeMap.clear();
|
||||
|
||||
probeMap.forEach((ifhl: InfraHost[], key: number) => {
|
||||
|
||||
const tp = {
|
||||
|
@ -303,17 +269,44 @@ export class MapComponent implements OnInit, AfterContentInit {
|
|||
infraTree.children.push(tp);
|
||||
});
|
||||
|
||||
return infraTree;
|
||||
}
|
||||
|
||||
sortInfraToMap(probeMap: Map<number, InfraHost[]>, hostMap: Map<number, InfraService[]>, filterStr: string) {
|
||||
|
||||
for (const infra of this.totalList) {
|
||||
this.getSensorByInfra(infra);
|
||||
const infraType = infra.infraType.name;
|
||||
if (infraType === 'HOST') {
|
||||
const infraHost: InfraHost = infra;
|
||||
if (filterStr && String(infraHost.ip).indexOf(filterStr) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (probeMap.has(infraHost.probe.id) === false) {
|
||||
probeMap.set(infraHost.probe.id, []);
|
||||
}
|
||||
|
||||
const ihl: InfraHost[] = probeMap.get(infraHost.probe.id);
|
||||
ihl.push(infraHost);
|
||||
probeMap.set(infraHost.probe.id, ihl);
|
||||
|
||||
} else if (infraType === 'OS_SERVICE') {
|
||||
const infraService: InfraService = infra;
|
||||
if (filterStr && this.checkFilterString(infraService, filterStr)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hostMap.has(infraService.host.ip) === false) {
|
||||
hostMap.set(infraService.host.ip, []);
|
||||
}
|
||||
|
||||
const isl = hostMap.get(infraService.host.ip);
|
||||
isl.push(infraService);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.loading = false;
|
||||
|
||||
itl.push(infraTree);
|
||||
|
||||
return itl;
|
||||
|
||||
}
|
||||
|
||||
getSensorByInfra(infra: Infra) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user