From e23ad4419171c7e173f53306d37d8a07ca8bbac6 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 29 Mar 2018 20:33:29 +0900 Subject: [PATCH] discovery condition port + service --- .../input-chip/input-chip.component.ts | 11 +++- .../component/setting/setting.component.html | 63 ++++++++++--------- .../component/setting/setting.component.ts | 45 ++++++++----- 3 files changed, 70 insertions(+), 49 deletions(-) diff --git a/src/packages/commons/component/input-chip/input-chip.component.ts b/src/packages/commons/component/input-chip/input-chip.component.ts index cd18ce8..6320092 100644 --- a/src/packages/commons/component/input-chip/input-chip.component.ts +++ b/src/packages/commons/component/input-chip/input-chip.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, OnDestroy } from '@angular/core'; +import { Component, OnInit, Input, OnDestroy, Output, EventEmitter } from '@angular/core'; import { MatChipInputEvent } from '@angular/material'; @Component({ @@ -10,6 +10,7 @@ export class InputChipComponent implements OnInit, OnDestroy { selectedItems = new Array(); @Input() unselectedItems; + @Output() change = new EventEmitter(); constructor() { } @@ -25,11 +26,13 @@ export class InputChipComponent implements OnInit, OnDestroy { selected(app: any) { this.selectedItems.push(app); this.remove(this.unselectedItems, app); + this.emitEvent(); } unselected(app: any): void { this.remove(this.selectedItems, app); this.unselectedItems.push(app); + this.emitEvent(); } remove(list: any, target: any) { @@ -45,6 +48,7 @@ export class InputChipComponent implements OnInit, OnDestroy { t.selectedItems.push(v); }); this.unselectedItems.length = 0; + this.emitEvent(); } unselectAll() { @@ -53,5 +57,10 @@ export class InputChipComponent implements OnInit, OnDestroy { t.unselectedItems.push(v); }); this.selectedItems.length = 0; + this.emitEvent(); + } + + emitEvent() { + this.change.emit(this.selectedItems); } } diff --git a/src/packages/discovery/component/setting/setting.component.html b/src/packages/discovery/component/setting/setting.component.html index 380228c..e72a586 100644 --- a/src/packages/discovery/component/setting/setting.component.html +++ b/src/packages/discovery/component/setting/setting.component.html @@ -11,40 +11,44 @@ +
-
- Host -
-
- - - - - - -
+ Host
-
- Port -
-
- - - - - - -
+ + + + + + +
+
+
+
+ Port
-
- Service -
-
- +
+ TCP + UDP
+ + + + + +
+
+
+
+ Service +
+
+ +
+
@@ -65,10 +69,7 @@
-
{{ node.data.title }}
diff --git a/src/packages/discovery/component/setting/setting.component.ts b/src/packages/discovery/component/setting/setting.component.ts index 08460b5..3c6a3aa 100644 --- a/src/packages/discovery/component/setting/setting.component.ts +++ b/src/packages/discovery/component/setting/setting.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, AfterContentInit } from '@angular/core'; -import { MatCheckboxChange } from '@angular/material'; +import { MatCheckboxChange, MatSlideToggleChange } from '@angular/material'; import { Store, select } from '@ngrx/store'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; import { @@ -45,12 +45,25 @@ export class SettingComponent implements OnInit, AfterContentInit { hostChecked = true; portChecked = true; serviceChecked = true; + tcpChecked = true; + udpChecked = true; + includeServices = null; serviceItems = [ + { name: 'SSH' }, + { name: 'PostgreSQL' }, + { name: 'DNS' }, + { name: 'WMI'}, + { name: 'SMB' }, + { name: 'ActiveDirectory' }, + { name: 'Cassandra' }, + { name: 'FTP' }, + { name: 'HTTP' }, + { name: 'IMAP' }, + { name: 'LDAP' }, + { name: 'MongoDB' }, { name: 'MySQL' }, - { name: 'Redis' }, - { name: 'Tomcat' }, - { name: 'Nginx' }, + { name: 'NBSS' }, ]; treeNodes = []; @@ -172,6 +185,11 @@ export class SettingComponent implements OnInit, AfterContentInit { } handleServiceCheckChange(e: MatCheckboxChange) { + this.includeServices = null; + } + + handleServiceChange(list: any) { + this.includeServices = list; } discovery() { @@ -179,16 +197,10 @@ export class SettingComponent implements OnInit, AfterContentInit { this.startPort = '0'; this.endPort = '0'; } - if (!this.serviceChecked) { - + const services = new Array(); + for (const service of this.includeServices) { + services.push(service.name); } - const startInfo: DiscoveryStartInfo = { - startIp: this.startIP, - endIP: this.endIP, - startPort: this.startPort, - endPort: this.endPort - }; - const discoveryZone: DiscoveryZone = { discoveryHost: { firstScanRange: this.startIP, @@ -196,11 +208,11 @@ export class SettingComponent implements OnInit, AfterContentInit { discoveryPort: { firstScanRange: this.startPort, lastScanRange: this.endPort, - includeTCP: true, - includeUDP: true, + includeTCP: this.tcpChecked, + includeUDP: this.udpChecked, excludePorts: null, discoveryService: { - includeServices: ['SSH', 'PostgreSQL', 'DNS', 'WMI', 'SMB'], + includeServices: services } }, }, @@ -210,7 +222,6 @@ export class SettingComponent implements OnInit, AfterContentInit { this.discoverstore.dispatch(new DiscoverStore.DiscoverZone( { probeID: this.probe.probeKey, discoveryZone: discoveryZone })); - this.started = true; }