From 836f9f5f52daa1d869eb13cb4e12bfe0e012cfec Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 10 May 2018 21:21:20 +0900 Subject: [PATCH] discovery design --- src/packages/discovery/component/index.ts | 4 +- .../filter-summary.component.html | 11 ++++ .../filter-summary.component.ts | 54 ++++++++++++++++++ .../service-selector.component.ts | 2 +- .../setting/result/result.component.html | 1 + .../setting/result/result.component.ts | 2 +- .../component/setting/setting.component.html | 26 +++++---- .../component/setting/setting.component.ts | 57 ++++++++++++++++--- src/packages/discovery/discovery.module.ts | 2 + 9 files changed, 139 insertions(+), 20 deletions(-) create mode 100644 src/packages/discovery/component/setting/filter-summary/filter-summary.component.html create mode 100644 src/packages/discovery/component/setting/filter-summary/filter-summary.component.ts diff --git a/src/packages/discovery/component/index.ts b/src/packages/discovery/component/index.ts index 3d66cef..2686ec6 100644 --- a/src/packages/discovery/component/index.ts +++ b/src/packages/discovery/component/index.ts @@ -3,11 +3,13 @@ import { ProbeSelectorComponent } from './setting/probe-selector/probe-selector. import { ServiceSelectorComponent } from './setting/filter/service-selector/service-selector.component'; import { FilterComponent } from './setting/filter/filter.component'; import { ResultComponent } from './setting/result/result.component'; +import { FilterSummaryComponent } from './setting/filter-summary/filter-summary.component'; export const COMPONENTS = [ SettingComponent, FilterComponent, ServiceSelectorComponent, ProbeSelectorComponent, - ResultComponent + ResultComponent, + FilterSummaryComponent ]; diff --git a/src/packages/discovery/component/setting/filter-summary/filter-summary.component.html b/src/packages/discovery/component/setting/filter-summary/filter-summary.component.html new file mode 100644 index 0000000..95d33f2 --- /dev/null +++ b/src/packages/discovery/component/setting/filter-summary/filter-summary.component.html @@ -0,0 +1,11 @@ +
+ + + + TCP + + + UDP + + +
\ No newline at end of file diff --git a/src/packages/discovery/component/setting/filter-summary/filter-summary.component.ts b/src/packages/discovery/component/setting/filter-summary/filter-summary.component.ts new file mode 100644 index 0000000..04a9bd2 --- /dev/null +++ b/src/packages/discovery/component/setting/filter-summary/filter-summary.component.ts @@ -0,0 +1,54 @@ +import { Component, OnInit, Input, AfterContentInit, Output, EventEmitter, OnDestroy } from '@angular/core'; +import { DiscoverZone } from '@overflow/commons-typescript/model/discovery'; + +@Component({ + selector: 'of-discovery-filter-summary', + templateUrl: './filter-summary.component.html', +}) +export class FilterSummaryComponent implements OnInit, AfterContentInit, OnDestroy { + + @Output() click = new EventEmitter(); + @Input() data: DiscoverZone; + + private hostRange: string; + private portRange: string; + private includeTCP: boolean; + private includeUDP: boolean; + private services: string; + + constructor( + ) { + this.services = ''; + } + + ngOnInit() { + } + + ngAfterContentInit() { + console.log(this.data); + this.hostRange = this.data.discoverHost.firstScanRangev4 + ' ~ ' + this.data.discoverHost.lastScanRangev4; + if (this.data.discoverHost.discoverPort) { + this.portRange = this.data.discoverHost.discoverPort.firstScanRange + ' ~ ' + this.data.discoverHost.discoverPort.lastScanRange; + this.includeTCP = this.data.discoverHost.discoverPort.includeTCP; + this.includeUDP = this.data.discoverHost.discoverPort.includeUDP; + } + + if (this.data.discoverHost.discoverPort.discoverService) { + const services = this.data.discoverHost.discoverPort.discoverService.includeServices; + if (services.length > 3) { + this.services = String(services.length) + ' services selected.'; + return; + } + for (const service of services) { + this.services += service; + } + } + } + + ngOnDestroy() { + } + + onClick() { + this.click.emit(); + } +} diff --git a/src/packages/discovery/component/setting/filter/service-selector/service-selector.component.ts b/src/packages/discovery/component/setting/filter/service-selector/service-selector.component.ts index 54d07bb..9f203d8 100644 --- a/src/packages/discovery/component/setting/filter/service-selector/service-selector.component.ts +++ b/src/packages/discovery/component/setting/filter/service-selector/service-selector.component.ts @@ -31,7 +31,7 @@ export class ServiceSelectorComponent implements OnInit, AfterContentInit, OnDes (list: MetaCrawler[]) => { if (list !== null) { this.crawlers = []; - this.includeServices = list; + this.crawlers = list; } }, (error: RPCClientError) => { diff --git a/src/packages/discovery/component/setting/result/result.component.html b/src/packages/discovery/component/setting/result/result.component.html index f09b77c..3aae979 100644 --- a/src/packages/discovery/component/setting/result/result.component.html +++ b/src/packages/discovery/component/setting/result/result.component.html @@ -1,4 +1,5 @@
+ result
diff --git a/src/packages/discovery/component/setting/result/result.component.ts b/src/packages/discovery/component/setting/result/result.component.ts index 9e741b7..c51d46b 100644 --- a/src/packages/discovery/component/setting/result/result.component.ts +++ b/src/packages/discovery/component/setting/result/result.component.ts @@ -48,6 +48,7 @@ export class ResultComponent implements OnInit, AfterContentInit, OnDestroy { } ngOnInit() { + this.inProgress = true; this.resultSubscription$ = this.result$.subscribe( (zones: Map) => { if (zones !== undefined && zones !== null) { @@ -63,7 +64,6 @@ export class ResultComponent implements OnInit, AfterContentInit, OnDestroy { this.startedSubscription$ = this.started$.subscribe( (isStart: boolean) => { if (isStart !== undefined && isStart !== null && isStart) { - this.inProgress = true; console.log('##Discovery has started.##'); } }, diff --git a/src/packages/discovery/component/setting/setting.component.html b/src/packages/discovery/component/setting/setting.component.html index 7c8d856..78a25e0 100644 --- a/src/packages/discovery/component/setting/setting.component.html +++ b/src/packages/discovery/component/setting/setting.component.html @@ -3,28 +3,34 @@
-
+
- +
+
+ +
+ + + +
-
+
- - - +
+
- - +
- -
\ No newline at end of file +
+
diff --git a/src/packages/discovery/component/setting/setting.component.ts b/src/packages/discovery/component/setting/setting.component.ts index 59d7f1d..65d27da 100644 --- a/src/packages/discovery/component/setting/setting.component.ts +++ b/src/packages/discovery/component/setting/setting.component.ts @@ -1,5 +1,7 @@ -import { Component, OnInit, AfterContentInit, Output, EventEmitter, - Input, OnDestroy, OnChanges, SimpleChanges, ViewChild } from '@angular/core'; +import { + Component, OnInit, AfterContentInit, Output, EventEmitter, + Input, OnDestroy, OnChanges, SimpleChanges, ViewChild +} from '@angular/core'; import { Store, select, StateObservable } from '@ngrx/store'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; import { @@ -29,9 +31,34 @@ import { ResultComponent } from './result/result.component'; import { ProbeSelectorComponent } from './probe-selector/probe-selector.component'; import { FilterComponent } from './filter/filter.component'; +import { trigger, state, transition, style, animate } from '@angular/core'; + @Component({ selector: 'of-discovery-setting', templateUrl: './setting.component.html', + animations: [ + trigger( + 'discoveryFilter', [ + state('summary', style({ + height: '70px', + })), + state('full', style({ + height: '500px', + })), + transition('* => *', animate('200ms cubic-bezier(0.86, 0, 0.07, 1)')), + ]), + trigger( + 'result', [ + state('show', style({ + height: '300px', + })), + state('hidden', style({ + height: '0px', + })), + transition('* => *', animate('200ms cubic-bezier(0.86, 0, 0.07, 1)')), + ] + ) + ] }) export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, OnChanges { @@ -40,10 +67,13 @@ export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, On @Output() close = new EventEmitter(); private requestStart = false; private started = false; + private filterData: DiscoverZone; private selectedProbe: Probe; private height: number; + private filterExpand = true; + @ViewChild('probeSelectorComponent') probeSelectorComponent: ProbeSelectorComponent; @ViewChild('filterComponent') filterComponent: FilterComponent; @ViewChild('resultComponent') resultComponent: ResultComponent; @@ -51,11 +81,11 @@ export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, On constructor( private discoverStore: Store, ) { + this.height = window.innerHeight * 0.9; } ngOnInit() { this.selectedProbe = this.probe; - this.height = window.innerHeight * 0.9; } ngAfterContentInit() { @@ -66,7 +96,7 @@ export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, On const change = changes['visible']; if (!change.previousValue && change.currentValue) { this.initAll(); - } else if (change.previousValue && !change.currentValue) { + } else if (change.previousValue && !change.currentValue) { this.destroyAll(); } } @@ -77,6 +107,7 @@ export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, On this.started = false; this.close.emit(); this.requestStart = false; + this.filterExpand = true; } initAll() { @@ -110,9 +141,10 @@ export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, On } onDiscoveryStart(discoverZone: DiscoverZone) { - console.log('DiscoveryStart requested'); - this.discoverStore.dispatch(new DiscoverStore.DiscoverZone( - { probeID: this.selectedProbe.probeKey, discoverZone: discoverZone })); + this.filterData = discoverZone; + this.filterExpand = false; + // this.discoverStore.dispatch(new DiscoverStore.DiscoverZone( + // { probeID: this.selectedProbe.probeKey, discoverZone: discoverZone })); setTimeout(() => { this.started = true; @@ -128,4 +160,15 @@ export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, On this.resultComponent.save(); } + onStop() { + this.started = false; + } + + onSummaryClick() { + if (this.started) { + return; + } + this.filterExpand = true; + } + } diff --git a/src/packages/discovery/discovery.module.ts b/src/packages/discovery/discovery.module.ts index f7c2daa..860ca63 100644 --- a/src/packages/discovery/discovery.module.ts +++ b/src/packages/discovery/discovery.module.ts @@ -9,6 +9,7 @@ import { DiscoveryLoggerModule } from './discovery-logger.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; import { PrimeNGModules } from 'packages/commons/prime-ng/prime-ng.module'; +import { KeyValueModule } from 'app/commons/component/key-value/key-value.module'; @NgModule({ imports: [ @@ -18,6 +19,7 @@ import { PrimeNGModules } from 'packages/commons/prime-ng/prime-ng.module'; DiscoveryStoreModule, DiscoveryRPCModule, DiscoveryLoggerModule, + KeyValueModule ], declarations: [ COMPONENTS