From e2f2b59df33f171355e83553f677a7d3f946dc7d Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 31 May 2018 16:03:59 +0900 Subject: [PATCH] discovery --- .../discovery/discovery.component.html | 13 ++-- .../discovery/discovery.component.ts | 6 +- .../discovery/request-summary.component.html | 9 +++ .../discovery/request-summary.component.ts | 32 ++++++++++ .../discovery/search-config.component.html | 22 +++++-- .../discovery/search-config.component.ts | 59 +++++++++++++++++-- .../discovery/search-result.component.html | 3 +- @overflow/discovery/component/index.ts | 2 + .../component/summary/summary.component.html | 25 ++++---- .../component/summary/summary.component.ts | 9 ++- 10 files changed, 152 insertions(+), 28 deletions(-) create mode 100644 @overflow/discovery/component/discovery/request-summary.component.html create mode 100644 @overflow/discovery/component/discovery/request-summary.component.ts diff --git a/@overflow/discovery/component/discovery/discovery.component.html b/@overflow/discovery/component/discovery/discovery.component.html index d386f6e..064d758 100644 --- a/@overflow/discovery/component/discovery/discovery.component.html +++ b/@overflow/discovery/component/discovery/discovery.component.html @@ -1,10 +1,11 @@ +
Choose a Probe to perform Discovery. - + @@ -12,9 +13,13 @@
-
+
- +
-
\ No newline at end of file +
+ + + INFO + \ No newline at end of file diff --git a/@overflow/discovery/component/discovery/discovery.component.ts b/@overflow/discovery/component/discovery/discovery.component.ts index 5f12e73..784b73d 100644 --- a/@overflow/discovery/component/discovery/discovery.component.ts +++ b/@overflow/discovery/component/discovery/discovery.component.ts @@ -16,6 +16,8 @@ export class DiscoveryComponent { @Output() requestDiscovery = new EventEmitter(); @Output() requestStop = new EventEmitter(); + discoverZone: DiscoverZone; + requested: boolean; constructor( @@ -24,11 +26,13 @@ export class DiscoveryComponent { onRequestDiscovery(dz: DiscoverZone) { this.requested = true; + this.discoverZone = dz; this.requestDiscovery.emit(dz); } - onStop() { + onRequestDiscoveryStop() { this.requested = false; + this.discoverZone = null; this.requestStop.emit(); } } diff --git a/@overflow/discovery/component/discovery/request-summary.component.html b/@overflow/discovery/component/discovery/request-summary.component.html new file mode 100644 index 0000000..f79671f --- /dev/null +++ b/@overflow/discovery/component/discovery/request-summary.component.html @@ -0,0 +1,9 @@ +
+ + + TCP + UDP +
+ {{service}} +
+
diff --git a/@overflow/discovery/component/discovery/request-summary.component.ts b/@overflow/discovery/component/discovery/request-summary.component.ts new file mode 100644 index 0000000..65ba759 --- /dev/null +++ b/@overflow/discovery/component/discovery/request-summary.component.ts @@ -0,0 +1,32 @@ +import { + Component, Input, OnChanges, SimpleChanges, +} from '@angular/core'; +import { DiscoverZone } from '@overflow/commons-typescript/model/discovery'; + +@Component({ + selector: 'of-discovery-request-summary', + templateUrl: './request-summary.component.html', +}) +export class RequestSummaryComponent implements OnChanges { + + @Input() discoverZone: DiscoverZone; + hostRange: string; + hostExclude: string; + portRange: string; + portExclude: string; + services: string[]; + + constructor( + ) { + } + + ngOnChanges(changes: SimpleChanges): void { + this.hostRange = this.discoverZone.discoverHost.firstScanRangev4 + + ' ~ ' + + this.discoverZone.discoverHost.lastScanRangev4; + this.portRange = this.discoverZone.discoverHost.discoverPort.firstScanRange + + ' ~ ' + + this.discoverZone.discoverHost.discoverPort.lastScanRange; + this.services = this.discoverZone.discoverHost.discoverPort.discoverService.includeServices; + } +} diff --git a/@overflow/discovery/component/discovery/search-config.component.html b/@overflow/discovery/component/discovery/search-config.component.html index e846775..fb35d62 100644 --- a/@overflow/discovery/component/discovery/search-config.component.html +++ b/@overflow/discovery/component/discovery/search-config.component.html @@ -25,8 +25,8 @@
- +
{{ipErrMsg}} @@ -67,7 +67,10 @@
{{portErrMsg}} @@ -81,10 +84,21 @@
- +
+ + + + Add Ports to exclude. + + + + + + \ No newline at end of file diff --git a/@overflow/discovery/component/discovery/search-config.component.ts b/@overflow/discovery/component/discovery/search-config.component.ts index c3c4e30..c00f988 100644 --- a/@overflow/discovery/component/discovery/search-config.component.ts +++ b/@overflow/discovery/component/discovery/search-config.component.ts @@ -40,6 +40,8 @@ export class SearchConfigComponent implements OnChanges { fixedIPrange: number; ipArray = []; + portExcludeDisplay = false; + portChips = []; constructor( ) { @@ -113,7 +115,7 @@ export class SearchConfigComponent implements OnChanges { lastScanRange: Number(this.endPort), includeTCP: this.tcpChecked, includeUDP: this.udpChecked, - excludePorts: null, + excludePorts: this.excludePorts, discoverService: discoverService }; } @@ -121,7 +123,8 @@ export class SearchConfigComponent implements OnChanges { discoverHost: { firstScanRangev4: this.startIP, lastScanRangev4: this.endIP, - discoverPort: discoverPort + discoverPort: discoverPort, + excludeHostsv4: this.excludeIPs, }, }; @@ -249,11 +252,57 @@ export class SearchConfigComponent implements OnChanges { } - onSaveIPExclude() { - + onAddExcludePort(event) { + const port = event.value.replace(/\s/g, ''); + if (port.indexOf('~') > 0) { // e.g. 1~3000 + const splited = port.split('~'); + this.portChips.pop(); + const from = Number(splited[0]); + const to = Number(splited[1]); + if (this.checkInvalidPort(from) + || this.checkInvalidPort(to) + || !Number.isInteger(from) + || !Number.isInteger(to)) { + return; + } + const chipItem = 'All ' + from + ' ~ ' + to; + this.portChips.push(chipItem); + for (let i = from; i <= to; i++) { + this.excludePorts.push(String(i)); + } + } else { + const num = Number(event.value); + if (!Number.isInteger(num) || this.checkInvalidPort(num) || this.checkExistExcludePort(event.value)) { + this.portChips.pop(); + return; + } + this.excludePorts.push(event.value); + } } - onSavePortExclude() { + onRemoveExcludePort(event) { + if (event.value.indexOf('~') > 0) { + // e.g. 'All 1 ~ 30' + const splited = event.value.replace(/\s/g, '').replace('All', '').split('~'); + for (let i = Number(splited[0]); i <= Number(splited[1]); i++) { + console.log(String(i)); + const index = this.excludePorts.indexOf(String(i)); + this.excludePorts.splice(index, 1); + } + return; + } + const idx = this.excludePorts.indexOf(event.value); + this.excludePorts.splice(idx, 1); + } + + checkExistExcludePort(portNum) { + return this.excludePorts.find((value) => { + return value === portNum; + }); + } + + checkInvalidPort(port) { + return port <= 0 || port > 65535; } } diff --git a/@overflow/discovery/component/discovery/search-result.component.html b/@overflow/discovery/component/discovery/search-result.component.html index 3c67cfe..7903146 100644 --- a/@overflow/discovery/component/discovery/search-result.component.html +++ b/@overflow/discovery/component/discovery/search-result.component.html @@ -1,5 +1,6 @@
- +
diff --git a/@overflow/discovery/component/index.ts b/@overflow/discovery/component/index.ts index 93ec142..b5003e3 100644 --- a/@overflow/discovery/component/index.ts +++ b/@overflow/discovery/component/index.ts @@ -4,6 +4,7 @@ import { SearchConfigComponent } from './discovery/search-config.component'; import { SearchFilterComponent } from './discovery/search-filter.component'; import { SearchResultComponent } from './discovery/search-result.component'; import { IpInputComponent } from './discovery/ip-input.component'; +import { RequestSummaryComponent } from './discovery/request-summary.component'; export const COMPONENTS = [ ServiceSelectorComponent, @@ -12,4 +13,5 @@ export const COMPONENTS = [ SearchFilterComponent, SearchResultComponent, IpInputComponent, + RequestSummaryComponent, ]; diff --git a/@overflow/probe/component/summary/summary.component.html b/@overflow/probe/component/summary/summary.component.html index 0815c6e..f1ef59f 100644 --- a/@overflow/probe/component/summary/summary.component.html +++ b/@overflow/probe/component/summary/summary.component.html @@ -1,11 +1,14 @@ -
- - - - - - - - - -
+
+
+ + +
+
+ + +
+
+ + +
+
\ No newline at end of file diff --git a/@overflow/probe/component/summary/summary.component.ts b/@overflow/probe/component/summary/summary.component.ts index 8be7642..9685846 100644 --- a/@overflow/probe/component/summary/summary.component.ts +++ b/@overflow/probe/component/summary/summary.component.ts @@ -1,15 +1,20 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe'; @Component({ selector: 'of-probe-summary', templateUrl: './summary.component.html', }) -export class ProbeSummaryComponent { +export class ProbeSummaryComponent implements OnChanges { @Input() probeHost: ProbeHost; + connectionStatus: string; constructor() { } + + ngOnChanges(changes: SimpleChanges): void { + this.connectionStatus = this.probeHost.probe.connectDate ? 'Connected' : 'Not connected'; + } }