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-pickList
|
||||
[disabled]="disabled"
|
||||
[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>
|
||||
<p-listbox [options]="metaCrawlers$ | async" [(ngModel)]="selected" multiple="multiple" checkbox="checkbox" filter="filter" optionLabel="description"
|
||||
metaKeySelection="true" (onChange)="onChange($event)" [style]="{'width':'100%'}" [listStyle]="{'max-height':'250px'}">
|
||||
</p-listbox>
|
||||
|
|
|
@ -29,6 +29,8 @@ export class ServiceSelectorComponent implements OnInit, AfterContentInit, OnDes
|
|||
pending$: Observable<boolean>;
|
||||
error$: Observable<any>;
|
||||
|
||||
selected = [];
|
||||
|
||||
constructor(
|
||||
protected store: Store<any>,
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<DiscoveryStartInfo> {
|
||||
|
||||
return this.rpcService.call('DiscoveryService.startDiscovery', dsInfo);
|
||||
}
|
||||
|
||||
public discoverZone(probeID: string, discoverZone: MDDiscoverZone): void {
|
||||
this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone);
|
||||
}
|
||||
|
|
|
@ -35,17 +35,17 @@ export class Effects {
|
|||
private router: Router
|
||||
) { }
|
||||
|
||||
@Effect()
|
||||
startDiscovery$: Observable<Action> = 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<Action> = 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));
|
||||
// });
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ export class MetaCrawlerService {
|
|||
this.metaCrawlerCache$ = this.rpcService.call('MetaCrawlerService.readAll').pipe(
|
||||
shareReplay<MetaCrawler[]>(1),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return this.metaCrawlerCache$;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user