From a432368a8ec43da16bc8873844852fd24cbfc8be Mon Sep 17 00:00:00 2001 From: insanity Date: Tue, 5 Jun 2018 15:07:12 +0900 Subject: [PATCH] test --- .../component/search-filter.component.ts | 3 +- .../component/search-result.component.html | 8 +-- .../component/search-result.component.ts | 55 +++++++++++++++++-- .../infra/component/infra-map.component.ts | 4 +- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/@overflow/discovery/component/search-filter.component.ts b/@overflow/discovery/component/search-filter.component.ts index 4abff73..f868053 100644 --- a/@overflow/discovery/component/search-filter.component.ts +++ b/@overflow/discovery/component/search-filter.component.ts @@ -37,7 +37,8 @@ export class SearchFilterComponent implements OnInit { addService(service: Service) { if (service.serviceName.indexOf('Not Supported Service') >= 0) { - return; + const tempName = service.serviceName.split('Perhaps ')[1].split('[')[0]; + service.serviceName = '*' + tempName; } let exist = false; this.services.forEach(value => { diff --git a/@overflow/discovery/component/search-result.component.html b/@overflow/discovery/component/search-result.component.html index 4e216ca..7466d94 100644 --- a/@overflow/discovery/component/search-result.component.html +++ b/@overflow/discovery/component/search-result.component.html @@ -17,11 +17,11 @@
+ (onChange)="onTargetSelect($event, node)">
-
{{node.label}}
+
{{node.label}}
@@ -31,11 +31,11 @@
+ onIcon="fa-check" offIcon="fa-square" [style]="{'width':'300px'}" (onChange)="onTargetSelect($event, node)">
-
{{node.label}} {{node.data.portType}}
+
{{node.label}} {{node.data.portType}}
diff --git a/@overflow/discovery/component/search-result.component.ts b/@overflow/discovery/component/search-result.component.ts index 9a60748..b717d85 100644 --- a/@overflow/discovery/component/search-result.component.ts +++ b/@overflow/discovery/component/search-result.component.ts @@ -10,12 +10,13 @@ import { import { Subscription } from 'rxjs'; import { DiscoverZone, Zone, Host, Port, Service } from '@overflow/commons-typescript/model/discovery'; -import { TreeNode, Message } from 'primeng/primeng'; +import { TreeNode, Message, Tree } from 'primeng/primeng'; 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'; @Component({ selector: 'of-discovery-result', @@ -32,9 +33,12 @@ export class SearchResultComponent implements OnInit, OnChanges { discoverySubscription: Subscription; zoneNode: TreeNode[] = []; hostNode: TreeNode[] = []; - selectedItems = []; + selectedItems: TreeNode[] = []; msgs: Message[]; + infraHosts = []; + infraServices = []; + constructor( ) { } @@ -52,6 +56,8 @@ 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', @@ -67,9 +73,11 @@ export class SearchResultComponent implements OnInit, OnChanges { type: 'HOST', label: host.ipv4, data: { - id: host.id, ip: this.convertIPtoNumber(host.ipv4), - openPorts: [] + ipv6: host.ipv6, + mac: host.mac, + openPorts: [], + zone: host.zone, }, expanded: true, children: [] @@ -83,10 +91,10 @@ export class SearchResultComponent implements OnInit, OnChanges { type: 'SERVICE', label: service.serviceName + ' (' + service.port.portNumber + ')', data: { - id: service.id, name: service.serviceName, portType: service.port.portType, portNumber: service.port.portNumber, + host: service.port.host }, }); } @@ -170,7 +178,44 @@ export class SearchResultComponent implements OnInit, OnChanges { return false; } + saveInfras(host: Host, service: Service) { + // Host + const infraHost: InfraHost = { + probe: this.probeHost.probe, + infraType: { + id: 2 + }, + os: {}, + ipv4: host.ipv4, + ipv6: host.ipv6, + mac: host.mac, + }; + + // 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? + } + } } } diff --git a/@overflow/infra/component/infra-map.component.ts b/@overflow/infra/component/infra-map.component.ts index 85a8245..78f5b08 100644 --- a/@overflow/infra/component/infra-map.component.ts +++ b/@overflow/infra/component/infra-map.component.ts @@ -16,6 +16,7 @@ import { Domain, DomainMember } from '@overflow/commons-typescript/model/domain' import { AuthSelector } from '@overflow/shared/auth/store'; import { Sensor } from '@overflow/commons-typescript/model/sensor'; +import { Router } from '@angular/router'; interface HostData { @@ -64,6 +65,7 @@ export class InfraMapComponent implements OnInit, AfterContentInit { constructor( private store: Store, + private router: Router // private infraService: InfraService, ) { @@ -353,7 +355,7 @@ export class InfraMapComponent implements OnInit, AfterContentInit { showDialog() { // this.display = true; - // this.router.navigateByUrl('/discovery'); + this.router.navigateByUrl('/discovery'); } // closeDialog() {