test
This commit is contained in:
parent
27b3490d39
commit
d82a4beef7
|
@ -15,7 +15,7 @@
|
|||
<!-- HOST node template -->
|
||||
<ng-template let-node pTemplate="HOST">
|
||||
<div @discoveryResultAnim>
|
||||
<div *ngIf="checkHighligt(node.label) else unhighlightHost">
|
||||
<div *ngIf="checkHighlight(node.label) else unhighlightHost">
|
||||
<p-toggleButton onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square" [style]="{'width':'200px'}"
|
||||
(onChange)="onTargetSelect($event, node)"></p-toggleButton>
|
||||
</div>
|
||||
|
|
|
@ -6,8 +6,8 @@ import {
|
|||
OnInit,
|
||||
OnChanges,
|
||||
} from '@angular/core';
|
||||
|
||||
import { Subscription } from 'rxjs';
|
||||
import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators';
|
||||
import { Subscription, Observable, of } from 'rxjs';
|
||||
|
||||
import { DiscoverZone, Zone, Host, Port, Service } from '@overflow/commons-typescript/model/discovery';
|
||||
import { TreeNode, Message, Tree } from 'primeng/primeng';
|
||||
|
@ -17,6 +17,8 @@ import { ProbeHost } from '@overflow/commons-typescript/model/probe';
|
|||
import { Anim } from './animation';
|
||||
import { DiscoveryNotify } from '../subscriber/discovery.subscriber';
|
||||
import { InfraHost, InfraService } from '@overflow/commons-typescript/model/infra';
|
||||
import { TargetService } from '../../target/service/target.service';
|
||||
import { Target } from '@overflow/commons-typescript/model/target';
|
||||
|
||||
@Component({
|
||||
selector: 'of-discovery-result',
|
||||
|
@ -33,13 +35,12 @@ export class SearchResultComponent implements OnInit, OnChanges {
|
|||
discoverySubscription: Subscription;
|
||||
zoneNode: TreeNode[] = [];
|
||||
hostNode: TreeNode[] = [];
|
||||
selectedItems: TreeNode[] = [];
|
||||
selectedItems = [];
|
||||
msgs: Message[];
|
||||
|
||||
discoveredHosts: Host[] = [];
|
||||
discoveredServices: Service[] = [];
|
||||
error$: Observable<any>;
|
||||
|
||||
constructor(
|
||||
private targetService: TargetService
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -56,8 +57,6 @@ export class SearchResultComponent implements OnInit, OnChanges {
|
|||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['finished'] && changes['finished'].currentValue === true) {
|
||||
this.saveInfras();
|
||||
// TODO: Comes after save infra
|
||||
this.msgs = [];
|
||||
this.msgs.push({
|
||||
severity: 'success',
|
||||
|
@ -68,12 +67,23 @@ export class SearchResultComponent implements OnInit, OnChanges {
|
|||
|
||||
|
||||
addHost(host: Host) {
|
||||
this.discoveredHosts.push(host);
|
||||
// this.targetService.findExistHostTarget(this.probeHost.probe.id, host.ipv4)
|
||||
// .pipe(
|
||||
// map((target: Target) => {
|
||||
|
||||
// }),
|
||||
// catchError(error => {
|
||||
// this.error$ = of(error);
|
||||
// return of();
|
||||
// }),
|
||||
// ).subscribe();
|
||||
|
||||
const idx = this.findHostIndex(host);
|
||||
this.hostNode.splice(idx, 0, {
|
||||
type: 'HOST',
|
||||
label: host.ipv4,
|
||||
data: {
|
||||
exist: false,
|
||||
ip: this.convertIPtoNumber(host.ipv4),
|
||||
ipv6: host.ipv6,
|
||||
mac: host.mac,
|
||||
|
@ -86,7 +96,6 @@ export class SearchResultComponent implements OnInit, OnChanges {
|
|||
}
|
||||
|
||||
addService(service: Service) {
|
||||
this.discoveredServices.push(service);
|
||||
const targetHostNode = this.findHostNodeByService(service);
|
||||
const idx = this.findServiceIndex(targetHostNode.children, service);
|
||||
targetHostNode.children.splice(idx, 0, {
|
||||
|
@ -162,7 +171,7 @@ export class SearchResultComponent implements OnInit, OnChanges {
|
|||
});
|
||||
}
|
||||
|
||||
checkHighligt(label: string) {
|
||||
checkHighlight(label: string) {
|
||||
let highlight = true;
|
||||
if (this.filterWord && (label.toUpperCase().indexOf(this.filterWord.toUpperCase()) < 0)) {
|
||||
highlight = false;
|
||||
|
@ -173,46 +182,18 @@ export class SearchResultComponent implements OnInit, OnChanges {
|
|||
return highlight;
|
||||
}
|
||||
|
||||
saveInfras() {
|
||||
this.discoveredHosts.forEach(host => {
|
||||
const infraHost: InfraHost = {
|
||||
probe: this.probeHost.probe,
|
||||
infraType: {
|
||||
id: 2
|
||||
},
|
||||
os: {},
|
||||
ipv4: host.ipv4,
|
||||
ipv6: host.ipv6,
|
||||
mac: host.mac,
|
||||
};
|
||||
});
|
||||
|
||||
this.discoveredServices.forEach(service => {
|
||||
const infraService: InfraService = {
|
||||
probe: this.probeHost.probe,
|
||||
infraType: {
|
||||
id: 7
|
||||
},
|
||||
host: {
|
||||
},
|
||||
portType: service.port.portType,
|
||||
port: service.port.portNumber,
|
||||
vendor: {
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
saveTargets() {
|
||||
console.log(this.selectedItems);
|
||||
let node: TreeNode;
|
||||
for (node of this.selectedItems) {
|
||||
if (node.type === 'HOST') {
|
||||
// InfraHost
|
||||
} else if (node.type === 'SERVICE') {
|
||||
// InfraService
|
||||
// InfraOSPort?
|
||||
}
|
||||
const hosts: Host[] = [];
|
||||
const services: Service[] = [];
|
||||
this.selectedItems.forEach(value => {
|
||||
if (value.ipv4) {
|
||||
hosts.push(value);
|
||||
} else {
|
||||
services.push(value);
|
||||
}
|
||||
});
|
||||
this.targetService.registDiscoveredTargets(this.probeHost.probe.id, null, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ export class InfraMapComponent implements OnInit, AfterContentInit {
|
|||
|
||||
for (const sensor of sensorList) {
|
||||
const st = {
|
||||
label: 'Sensors - ' + sensor.crawler.name,
|
||||
label: 'Sensors - ' + sensor.metaCrawler.name,
|
||||
type: 'sensor',
|
||||
obj: sensor,
|
||||
expanded: true
|
||||
|
@ -254,7 +254,7 @@ export class InfraMapComponent implements OnInit, AfterContentInit {
|
|||
|
||||
for (let i = 0; i < ifsl.length; ++i) {
|
||||
const ts = {
|
||||
label: 'Service - ' + ifsl[i].vendor.name,
|
||||
label: 'Service - ' + ifsl[i].metaInfraVendor.name,
|
||||
type: 'service',
|
||||
expandedIcon: 'fa-folder-open',
|
||||
collapsedIcon: 'fa-folder',
|
||||
|
@ -285,7 +285,7 @@ export class InfraMapComponent implements OnInit, AfterContentInit {
|
|||
sortInfraToMap(probeMap: Map<number, InfraHost[]>, hostMap: Map<string, InfraService[]>, filterStr: string) {
|
||||
|
||||
for (const infra of this.totalList) {
|
||||
const infraType = infra.infraType.name;
|
||||
const infraType = infra.metaInfraType.name;
|
||||
if (infraType === 'HOST') {
|
||||
const infraHost: InfraHost = infra;
|
||||
if (filterStr && String(infraHost.ipv4).indexOf(filterStr) < 0) {
|
||||
|
@ -306,11 +306,11 @@ export class InfraMapComponent implements OnInit, AfterContentInit {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (hostMap.has(infraService.host.ipv4) === false) {
|
||||
hostMap.set(infraService.host.ipv4, []);
|
||||
if (hostMap.has(infraService.infraHost.ipv4) === false) {
|
||||
hostMap.set(infraService.infraHost.ipv4, []);
|
||||
}
|
||||
|
||||
const isl = hostMap.get(infraService.host.ipv4);
|
||||
const isl = hostMap.get(infraService.infraHost.ipv4);
|
||||
isl.push(infraService);
|
||||
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ export class InfraMapComponent implements OnInit, AfterContentInit {
|
|||
|
||||
checkFilterString(infraService: InfraService, filterStr: string) {
|
||||
const upperCased = filterStr.toUpperCase().toUpperCase();
|
||||
if (infraService.vendor.name.toUpperCase().indexOf(upperCased) < 0 &&
|
||||
if (infraService.metaInfraVendor.name.toUpperCase().indexOf(upperCased) < 0 &&
|
||||
String(infraService.port).toUpperCase().indexOf(upperCased) < 0 &&
|
||||
infraService.portType.toUpperCase().indexOf(upperCased)) {
|
||||
return true;
|
||||
|
|
|
@ -23,4 +23,11 @@ export class TargetService {
|
|||
return this.rpcService.call<Target>('TargetService.modify', target);
|
||||
}
|
||||
|
||||
public findExistHostTarget(probeID: number, hostIP: string): Observable<Target> {
|
||||
return this.rpcService.call<Target>('TargetService.readExistHostTarget', probeID, hostIP);
|
||||
}
|
||||
|
||||
public findExistServiceTarget(hostID: number, portNumber: number, portType: string): Observable<Target> {
|
||||
return this.rpcService.call<Target>('TargetService.readExistServiceTarget', hostID, portNumber, portType);
|
||||
}
|
||||
}
|
||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -453,9 +453,9 @@
|
|||
}
|
||||
},
|
||||
"@overflow/commons-typescript": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://nexus.loafle.net/repository/npm-all/@overflow/commons-typescript/-/commons-typescript-0.0.7.tgz",
|
||||
"integrity": "sha512-qbrNlHEZjUfmuExcHEQ1Bf+PNQfkAZsbinDSGU4ndD4H8hNg/Cv2i4TWaLSWVqXrbIEZkKmv4AZJC9WQTUcFPA=="
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://nexus.loafle.net/repository/npm-all/@overflow/commons-typescript/-/commons-typescript-0.0.8.tgz",
|
||||
"integrity": "sha512-yaN3kYofzzJjRJsMuRHbryWVQU6AdsmVbGBmvdKvXQrI/xZzss2K5ZRTqDAOAHEXpyk1Ty+yeXMEPihfLv5bqw=="
|
||||
},
|
||||
"@schematics/angular": {
|
||||
"version": "0.6.5",
|
||||
|
|
Loading…
Reference in New Issue
Block a user