From 7d9fd23271d3887c8a31f24a36ff09106db80b19 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 31 May 2018 20:53:11 +0900 Subject: [PATCH] discovery --- .../component/{discovery => }/animation.ts | 0 .../{discovery => }/discovery.component.html | 0 .../component/discovery.component.ts | 88 +++++++++++++++++++ .../discovery/discovery.component.ts | 38 -------- .../service-selector.component.html | 25 +----- .../service-selector.component.ts | 7 ++ @overflow/discovery/component/index.ts | 12 +-- .../{discovery => }/ip-input.component.html | 0 .../{discovery => }/ip-input.component.ts | 0 .../request-summary.component.html | 0 .../request-summary.component.ts | 0 .../search-config.component.html | 0 .../search-config.component.ts | 0 .../search-filter.component.html | 0 .../search-filter.component.ts | 0 .../search-result.component.html | 0 .../search-result.component.ts | 0 .../discovery/service/discovery.service.ts | 6 -- .../discovery/store/setting/setting.effect.ts | 24 ++--- .../meta/service/meta-crawler.service.ts | 2 +- 20 files changed, 117 insertions(+), 85 deletions(-) rename @overflow/discovery/component/{discovery => }/animation.ts (100%) rename @overflow/discovery/component/{discovery => }/discovery.component.html (100%) create mode 100644 @overflow/discovery/component/discovery.component.ts delete mode 100644 @overflow/discovery/component/discovery/discovery.component.ts rename @overflow/discovery/component/{discovery => }/ip-input.component.html (100%) rename @overflow/discovery/component/{discovery => }/ip-input.component.ts (100%) rename @overflow/discovery/component/{discovery => }/request-summary.component.html (100%) rename @overflow/discovery/component/{discovery => }/request-summary.component.ts (100%) rename @overflow/discovery/component/{discovery => }/search-config.component.html (100%) rename @overflow/discovery/component/{discovery => }/search-config.component.ts (100%) rename @overflow/discovery/component/{discovery => }/search-filter.component.html (100%) rename @overflow/discovery/component/{discovery => }/search-filter.component.ts (100%) rename @overflow/discovery/component/{discovery => }/search-result.component.html (100%) rename @overflow/discovery/component/{discovery => }/search-result.component.ts (100%) diff --git a/@overflow/discovery/component/discovery/animation.ts b/@overflow/discovery/component/animation.ts similarity index 100% rename from @overflow/discovery/component/discovery/animation.ts rename to @overflow/discovery/component/animation.ts diff --git a/@overflow/discovery/component/discovery/discovery.component.html b/@overflow/discovery/component/discovery.component.html similarity index 100% rename from @overflow/discovery/component/discovery/discovery.component.html rename to @overflow/discovery/component/discovery.component.html diff --git a/@overflow/discovery/component/discovery.component.ts b/@overflow/discovery/component/discovery.component.ts new file mode 100644 index 0000000..0ab96a3 --- /dev/null +++ b/@overflow/discovery/component/discovery.component.ts @@ -0,0 +1,88 @@ +import { + Component, Input, Output, EventEmitter, +} from '@angular/core'; +import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe'; +import { Anim } from './animation'; +import { Store, select } from '@ngrx/store'; +import { Observable, of, Subscription } from 'rxjs'; +import { DiscoveryService } from '../service/discovery.service'; +import { DiscoveryNotify } from '../core/discovery-subject'; +import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; +import { DiscoverZone, Zone, Host, Port, Service } from '@overflow/commons-typescript/model/discovery'; + +@Component({ + selector: 'of-discovery', + templateUrl: './discovery.component.html', + animations: Anim +}) +export class DiscoveryComponent { + + @Input() probeHostID; + pending$: Observable; + error$: Observable; + discoverySubscription: Subscription; + + selectedProbe: ProbeHost; + requested: boolean; + + + constructor( + private discoveryService: DiscoveryService, + private store: Store + ) { + } + + onRequestDiscovery(dz: DiscoverZone) { + this.requested = true; + + this.requested = true; + + this.discoverySubscription = this.discoveryService.discoverZone(this.selectedProbe.probe.probeKey, dz).pipe( + map((discoveryNotify: DiscoveryNotify) => { + switch (discoveryNotify.method) { + case 'DiscoveryService.discoveryStart': { + const startDate = discoveryNotify.params as Date; + break; + } + case 'DiscoveryService.discoveryStop': { + const stopDate = discoveryNotify.params as Date; + + this.discoverySubscription.unsubscribe(); + break; + } + case 'DiscoveryService.discoveredZone': { + const zone = discoveryNotify.params as Zone; + + break; + } + case 'DiscoveryService.discoveredHost': { + const host = discoveryNotify.params as Host; + + break; + } + case 'DiscoveryService.discoveredPort': { + const port = discoveryNotify.params as Port; + + break; + } + case 'DiscoveryService.discoveredService': { + const service = discoveryNotify.params as Service; + + break; + } + default: { + break; + } + } + }), + catchError(error => { + + return of(); + }), + ).subscribe(); + } + + onRequestDiscoveryStop() { + this.requested = false; + } +} diff --git a/@overflow/discovery/component/discovery/discovery.component.ts b/@overflow/discovery/component/discovery/discovery.component.ts deleted file mode 100644 index 2118120..0000000 --- a/@overflow/discovery/component/discovery/discovery.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { - Component, Input, Output, EventEmitter, -} from '@angular/core'; -import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe'; -import { DiscoverZone } from '@overflow/commons-typescript/model/discovery'; -import { Anim } from './animation'; - -@Component({ - selector: 'of-discovery', - templateUrl: './discovery.component.html', - animations: Anim -}) -export class DiscoveryComponent { - - @Input() probeHostID; - selectedProbe: ProbeHost; - // @Output() requestDiscovery = new EventEmitter(); - // @Output() requestStop = new EventEmitter(); - - discoverZone: DiscoverZone; - requested: boolean; - - constructor( - ) { - } - - onRequestDiscovery(dz: DiscoverZone) { - this.requested = true; - this.discoverZone = dz; - // this.requestDiscovery.emit(dz); - } - - onRequestDiscoveryStop() { - this.requested = false; - this.discoverZone = null; - // this.requestStop.emit(); - } -} diff --git a/@overflow/discovery/component/discovery/service-selector/service-selector.component.html b/@overflow/discovery/component/discovery/service-selector/service-selector.component.html index cee3283..6298863 100644 --- a/@overflow/discovery/component/discovery/service-selector/service-selector.component.html +++ b/@overflow/discovery/component/discovery/service-selector/service-selector.component.html @@ -1,22 +1,3 @@ -
- - -
-
{{crawler.description}}
-
-
-
-
+ + diff --git a/@overflow/discovery/component/discovery/service-selector/service-selector.component.ts b/@overflow/discovery/component/discovery/service-selector/service-selector.component.ts index 254ce4b..516457b 100644 --- a/@overflow/discovery/component/discovery/service-selector/service-selector.component.ts +++ b/@overflow/discovery/component/discovery/service-selector/service-selector.component.ts @@ -29,6 +29,8 @@ export class ServiceSelectorComponent implements OnInit, AfterContentInit, OnDes pending$: Observable; error$: Observable; + selected = []; + constructor( protected store: Store, protected metaCrawlerService: MetaCrawlerService, @@ -63,4 +65,9 @@ export class ServiceSelectorComponent implements OnInit, AfterContentInit, OnDes // this.listStore.dispatch(new ListStore.ReadAll()); } + onChange(e) { + this.selected.push(e.value); + console.log(e); + } + } diff --git a/@overflow/discovery/component/index.ts b/@overflow/discovery/component/index.ts index b5003e3..f283699 100644 --- a/@overflow/discovery/component/index.ts +++ b/@overflow/discovery/component/index.ts @@ -1,10 +1,10 @@ import { ServiceSelectorComponent } from './discovery/service-selector/service-selector.component'; -import { DiscoveryComponent } from './discovery/discovery.component'; -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'; +import { DiscoveryComponent } from './discovery.component'; +import { SearchConfigComponent } from './search-config.component'; +import { SearchFilterComponent } from './search-filter.component'; +import { SearchResultComponent } from './search-result.component'; +import { IpInputComponent } from './ip-input.component'; +import { RequestSummaryComponent } from './request-summary.component'; export const COMPONENTS = [ ServiceSelectorComponent, diff --git a/@overflow/discovery/component/discovery/ip-input.component.html b/@overflow/discovery/component/ip-input.component.html similarity index 100% rename from @overflow/discovery/component/discovery/ip-input.component.html rename to @overflow/discovery/component/ip-input.component.html diff --git a/@overflow/discovery/component/discovery/ip-input.component.ts b/@overflow/discovery/component/ip-input.component.ts similarity index 100% rename from @overflow/discovery/component/discovery/ip-input.component.ts rename to @overflow/discovery/component/ip-input.component.ts diff --git a/@overflow/discovery/component/discovery/request-summary.component.html b/@overflow/discovery/component/request-summary.component.html similarity index 100% rename from @overflow/discovery/component/discovery/request-summary.component.html rename to @overflow/discovery/component/request-summary.component.html diff --git a/@overflow/discovery/component/discovery/request-summary.component.ts b/@overflow/discovery/component/request-summary.component.ts similarity index 100% rename from @overflow/discovery/component/discovery/request-summary.component.ts rename to @overflow/discovery/component/request-summary.component.ts diff --git a/@overflow/discovery/component/discovery/search-config.component.html b/@overflow/discovery/component/search-config.component.html similarity index 100% rename from @overflow/discovery/component/discovery/search-config.component.html rename to @overflow/discovery/component/search-config.component.html diff --git a/@overflow/discovery/component/discovery/search-config.component.ts b/@overflow/discovery/component/search-config.component.ts similarity index 100% rename from @overflow/discovery/component/discovery/search-config.component.ts rename to @overflow/discovery/component/search-config.component.ts diff --git a/@overflow/discovery/component/discovery/search-filter.component.html b/@overflow/discovery/component/search-filter.component.html similarity index 100% rename from @overflow/discovery/component/discovery/search-filter.component.html rename to @overflow/discovery/component/search-filter.component.html diff --git a/@overflow/discovery/component/discovery/search-filter.component.ts b/@overflow/discovery/component/search-filter.component.ts similarity index 100% rename from @overflow/discovery/component/discovery/search-filter.component.ts rename to @overflow/discovery/component/search-filter.component.ts diff --git a/@overflow/discovery/component/discovery/search-result.component.html b/@overflow/discovery/component/search-result.component.html similarity index 100% rename from @overflow/discovery/component/discovery/search-result.component.html rename to @overflow/discovery/component/search-result.component.html diff --git a/@overflow/discovery/component/discovery/search-result.component.ts b/@overflow/discovery/component/search-result.component.ts similarity index 100% rename from @overflow/discovery/component/discovery/search-result.component.ts rename to @overflow/discovery/component/search-result.component.ts diff --git a/@overflow/discovery/service/discovery.service.ts b/@overflow/discovery/service/discovery.service.ts index 8699116..a9e682b 100644 --- a/@overflow/discovery/service/discovery.service.ts +++ b/@overflow/discovery/service/discovery.service.ts @@ -2,7 +2,6 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { RPCService } from '@loafer/ng-rpc'; import { - DiscoveryStartInfo, DiscoverZone as MDDiscoverZone, DiscoverHost as MDDiscoverHost, DiscoverPort as MDDiscoverPort, @@ -22,11 +21,6 @@ export class DiscoveryService { } - public start(dsInfo: DiscoveryStartInfo): Observable { - - return this.rpcService.call('DiscoveryService.startDiscovery', dsInfo); - } - public discoverZone(probeID: string, discoverZone: MDDiscoverZone): void { this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone); } diff --git a/@overflow/discovery/store/setting/setting.effect.ts b/@overflow/discovery/store/setting/setting.effect.ts index 5d19efe..ee49794 100644 --- a/@overflow/discovery/store/setting/setting.effect.ts +++ b/@overflow/discovery/store/setting/setting.effect.ts @@ -35,17 +35,17 @@ export class Effects { private router: Router ) { } - @Effect() - startDiscovery$: Observable = this.actions$ - .ofType(ActionType.Setting) - .map((action: Setting) => action.payload) - .switchMap(payload => this.discoveryService.start(payload)) - .map(discoveryStartInfo => { - return new SettingSuccess(discoveryStartInfo); - }) - .catch((error: RPCClientError) => { - console.log(error.response.message); - return of(new SettingFailure(error)); - }); + // @Effect() + // startDiscovery$: Observable = this.actions$ + // .ofType(ActionType.Setting) + // .map((action: Setting) => action.payload) + // .switchMap(payload => this.discoveryService.start(payload)) + // .map(discoveryStartInfo => { + // return new SettingSuccess(discoveryStartInfo); + // }) + // .catch((error: RPCClientError) => { + // console.log(error.response.message); + // return of(new SettingFailure(error)); + // }); } diff --git a/@overflow/meta/service/meta-crawler.service.ts b/@overflow/meta/service/meta-crawler.service.ts index f7bc6ec..bc248d4 100644 --- a/@overflow/meta/service/meta-crawler.service.ts +++ b/@overflow/meta/service/meta-crawler.service.ts @@ -20,7 +20,7 @@ export class MetaCrawlerService { this.metaCrawlerCache$ = this.rpcService.call('MetaCrawlerService.readAll').pipe( shareReplay(1), ); - } + } return this.metaCrawlerCache$; }