discovery
This commit is contained in:
parent
9b7a852d1c
commit
7d9fd23271
88
@overflow/discovery/component/discovery.component.ts
Normal file
88
@overflow/discovery/component/discovery.component.ts
Normal file
|
@ -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<boolean>;
|
||||||
|
error$: Observable<any>;
|
||||||
|
discoverySubscription: Subscription;
|
||||||
|
|
||||||
|
selectedProbe: ProbeHost;
|
||||||
|
requested: boolean;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private discoveryService: DiscoveryService,
|
||||||
|
private store: Store<any>
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<DiscoverZone>();
|
|
||||||
// @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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +1,3 @@
|
||||||
<div class="ui-g-12">
|
<p-listbox [options]="metaCrawlers$ | async" [(ngModel)]="selected" multiple="multiple" checkbox="checkbox" filter="filter" optionLabel="description"
|
||||||
<p-pickList
|
metaKeySelection="true" (onChange)="onChange($event)" [style]="{'width':'100%'}" [listStyle]="{'max-height':'250px'}">
|
||||||
[disabled]="disabled"
|
</p-listbox>
|
||||||
[source]="metaCrawlers$ | async"
|
|
||||||
[target]="includeServices"
|
|
||||||
sourceHeader="Available"
|
|
||||||
targetHeader="Selected"
|
|
||||||
[responsive]="true"
|
|
||||||
filterBy="description"
|
|
||||||
dragdrop="true"
|
|
||||||
dragdropScope="services"
|
|
||||||
[sourceStyle]="{'height':'200px'}"
|
|
||||||
[targetStyle]="{'height':'200px'}"
|
|
||||||
[showTargetControls]="false"
|
|
||||||
[showSourceControls]="false" >
|
|
||||||
<ng-template let-crawler pTemplate="item">
|
|
||||||
<div class="ui-helper-clearfix">
|
|
||||||
<div style="font-size:14px;margin:0;padding: 0;">{{crawler.description}}</div>
|
|
||||||
</div>
|
|
||||||
</ng-template>
|
|
||||||
</p-pickList>
|
|
||||||
</div>
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ export class ServiceSelectorComponent implements OnInit, AfterContentInit, OnDes
|
||||||
pending$: Observable<boolean>;
|
pending$: Observable<boolean>;
|
||||||
error$: Observable<any>;
|
error$: Observable<any>;
|
||||||
|
|
||||||
|
selected = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected store: Store<any>,
|
protected store: Store<any>,
|
||||||
protected metaCrawlerService: MetaCrawlerService,
|
protected metaCrawlerService: MetaCrawlerService,
|
||||||
|
@ -63,4 +65,9 @@ export class ServiceSelectorComponent implements OnInit, AfterContentInit, OnDes
|
||||||
// this.listStore.dispatch(new ListStore.ReadAll());
|
// this.listStore.dispatch(new ListStore.ReadAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onChange(e) {
|
||||||
|
this.selected.push(e.value);
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { ServiceSelectorComponent } from './discovery/service-selector/service-selector.component';
|
import { ServiceSelectorComponent } from './discovery/service-selector/service-selector.component';
|
||||||
import { DiscoveryComponent } from './discovery/discovery.component';
|
import { DiscoveryComponent } from './discovery.component';
|
||||||
import { SearchConfigComponent } from './discovery/search-config.component';
|
import { SearchConfigComponent } from './search-config.component';
|
||||||
import { SearchFilterComponent } from './discovery/search-filter.component';
|
import { SearchFilterComponent } from './search-filter.component';
|
||||||
import { SearchResultComponent } from './discovery/search-result.component';
|
import { SearchResultComponent } from './search-result.component';
|
||||||
import { IpInputComponent } from './discovery/ip-input.component';
|
import { IpInputComponent } from './ip-input.component';
|
||||||
import { RequestSummaryComponent } from './discovery/request-summary.component';
|
import { RequestSummaryComponent } from './request-summary.component';
|
||||||
|
|
||||||
export const COMPONENTS = [
|
export const COMPONENTS = [
|
||||||
ServiceSelectorComponent,
|
ServiceSelectorComponent,
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { RPCService } from '@loafer/ng-rpc';
|
import { RPCService } from '@loafer/ng-rpc';
|
||||||
import {
|
import {
|
||||||
DiscoveryStartInfo,
|
|
||||||
DiscoverZone as MDDiscoverZone,
|
DiscoverZone as MDDiscoverZone,
|
||||||
DiscoverHost as MDDiscoverHost,
|
DiscoverHost as MDDiscoverHost,
|
||||||
DiscoverPort as MDDiscoverPort,
|
DiscoverPort as MDDiscoverPort,
|
||||||
|
@ -22,11 +21,6 @@ export class DiscoveryService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public start(dsInfo: DiscoveryStartInfo): Observable<DiscoveryStartInfo> {
|
|
||||||
|
|
||||||
return this.rpcService.call('DiscoveryService.startDiscovery', dsInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
public discoverZone(probeID: string, discoverZone: MDDiscoverZone): void {
|
public discoverZone(probeID: string, discoverZone: MDDiscoverZone): void {
|
||||||
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone);
|
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,17 +35,17 @@ export class Effects {
|
||||||
private router: Router
|
private router: Router
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@Effect()
|
// @Effect()
|
||||||
startDiscovery$: Observable<Action> = this.actions$
|
// startDiscovery$: Observable<Action> = this.actions$
|
||||||
.ofType(ActionType.Setting)
|
// .ofType(ActionType.Setting)
|
||||||
.map((action: Setting) => action.payload)
|
// .map((action: Setting) => action.payload)
|
||||||
.switchMap(payload => this.discoveryService.start(payload))
|
// .switchMap(payload => this.discoveryService.start(payload))
|
||||||
.map(discoveryStartInfo => {
|
// .map(discoveryStartInfo => {
|
||||||
return new SettingSuccess(discoveryStartInfo);
|
// return new SettingSuccess(discoveryStartInfo);
|
||||||
})
|
// })
|
||||||
.catch((error: RPCClientError) => {
|
// .catch((error: RPCClientError) => {
|
||||||
console.log(error.response.message);
|
// console.log(error.response.message);
|
||||||
return of(new SettingFailure(error));
|
// return of(new SettingFailure(error));
|
||||||
});
|
// });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ export class MetaCrawlerService {
|
||||||
this.metaCrawlerCache$ = this.rpcService.call('MetaCrawlerService.readAll').pipe(
|
this.metaCrawlerCache$ = this.rpcService.call('MetaCrawlerService.readAll').pipe(
|
||||||
shareReplay<MetaCrawler[]>(1),
|
shareReplay<MetaCrawler[]>(1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.metaCrawlerCache$;
|
return this.metaCrawlerCache$;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user