ing
This commit is contained in:
parent
e15de633c2
commit
f7a09c209e
|
@ -4,13 +4,9 @@ import {
|
|||
} from '@angular/core';
|
||||
import { Store, select, StateObservable } from '@ngrx/store';
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
// import * as ListStore from '@overflow/probe/store/list';
|
||||
// import { ListSelector } from '@overflow/probe/store';
|
||||
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
import { AuthSelector } from '@overflow/member/store';
|
||||
import { Domain } from '@overflow/commons-typescript/model/domain';
|
||||
import { Dropdown } from 'primeng/primeng';
|
||||
|
||||
@Component({
|
||||
selector: 'of-probe-selector',
|
||||
|
@ -33,7 +29,7 @@ export class ProbeSelectorComponent implements OnInit, AfterContentInit, OnDestr
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.probesSubscription$ = this.probes$.subscribe(
|
||||
this.probesSubscription$ = this.probes$.subscribe (
|
||||
(list: Probe[]) => {
|
||||
if (list !== null) {
|
||||
this.probes = list;
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
<div class="ui-inputgroup">
|
||||
<span style="margin-right: 18px">Start </span>
|
||||
<input id="0" type="text" pInputText placeholder="127" maxlength="3" [(ngModel)]="first" value="{{first}}" (keyup)="onIpInput($event)">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input id="1" type="text" pInputText placeholder="0" maxlength="3" [(ngModel)]="second" value="{{second}}" (keyup)="onIpInput($event)">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input id="2" type="text" pInputText placeholder="0" maxlength="3" [(ngModel)]="third" value="{{third}}" (keyup)="onIpInput($event)">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input id="3" type="text" pInputText placeholder="1" maxlength="3" [(ngModel)]="fourth" value="{{fourth}}" (keyup)="onIpInput($event)">
|
||||
</div>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import {
|
||||
AfterContentInit,
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
Output,
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'of-ip-input',
|
||||
templateUrl: './ip-input.component.html',
|
||||
})
|
||||
export class IpInputComponent implements OnInit, AfterContentInit {
|
||||
|
||||
first: string;
|
||||
second: string;
|
||||
third: string;
|
||||
fourth: string;
|
||||
|
||||
@Input() hostIp: string;
|
||||
@Output() inputIp = new EventEmitter();
|
||||
|
||||
constructor(
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.hostIp !== '' && this.hostIp !== null && this.hostIp !== undefined) {
|
||||
const tempIp = this.hostIp.split('.');
|
||||
|
||||
this.first = tempIp[0];
|
||||
this.second = tempIp[1];
|
||||
this.third = tempIp[2];
|
||||
this.fourth = tempIp[3];
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
}
|
||||
|
||||
onIpInput(event) {
|
||||
if (
|
||||
(this.first !== '' && this.first !== undefined) &&
|
||||
(this.second !== '' && this.second !== undefined) &&
|
||||
(this.third !== '' && this.third !== undefined) &&
|
||||
(this.fourth !== '' && this.fourth !== undefined) ) {
|
||||
event.target.data = this.first + '.' + this.second + '.' + this.third + '.' + this.fourth;
|
||||
this.inputIp.emit(event);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
<label>Probe</label>
|
||||
</div>
|
||||
<div class="ui-g-12 ui-bottom-space-20">
|
||||
<of-probe-selector [hidden]="requestStart" [preProbe]="probe" (probeSelected)="onProbeSelect($event)"></of-probe-selector>
|
||||
<of-probe-selector [preProbe]="probe" (probeSelected)="onProbeSelect($event)"></of-probe-selector>
|
||||
</div>
|
||||
<div class="ui-g-12">
|
||||
<label>IP Version</label>
|
||||
|
@ -24,40 +24,13 @@
|
|||
<input type="hidden" >
|
||||
</div>
|
||||
<div class="ui-g-12">
|
||||
<div class="ui-inputgroup">
|
||||
<span style="margin-right: 18px">Start </span>
|
||||
<input type="text" pInputText placeholder="127" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="0" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="0" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="1" maxlength="3">
|
||||
</div>
|
||||
<of-ip-input [hostIp]="startHostIp" (inputIp)="onInputIP($event, 0)" ></of-ip-input>
|
||||
</div>
|
||||
<div class="ui-g-12">
|
||||
<div class="ui-inputgroup">
|
||||
<span style="margin-right: 24px">End </span>
|
||||
<input type="text" pInputText placeholder="127" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="0" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="0" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="1" maxlength="3">
|
||||
</div>
|
||||
<of-ip-input [hostIp]="endHostIp" (inputIp)="onInputIP($event, 1)" ></of-ip-input>
|
||||
</div>
|
||||
<div class="ui-g-12 ui-bottom-space-20">
|
||||
<div class="ui-inputgroup">
|
||||
<span style="margin-right: 5px">Exclud </span>
|
||||
<input type="text" pInputText placeholder="127" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="0" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="0" maxlength="3">
|
||||
<span class="ui-inputgroup-addon">.</span>
|
||||
<input type="text" pInputText placeholder="1" maxlength="3">
|
||||
</div>
|
||||
<of-ip-input [hostIp]="excludeHostIp" (inputIp)="onInputIP($event, 2)" ></of-ip-input>
|
||||
</div>
|
||||
<div class="ui-g-12">
|
||||
<label>Port type</label>
|
||||
|
@ -90,7 +63,7 @@
|
|||
<label>Service</label>
|
||||
</div>
|
||||
<div class="ui-g-12 ui-g-nopad">
|
||||
<of-service-selector [disabled]="!serviceChecked" [(includeServices)]="includeServices"></of-service-selector>
|
||||
<of-service-selector [(includeServices)]="includeServices"></of-service-selector>
|
||||
</div>
|
||||
<div class="ui-g-12" dir="rtl">
|
||||
<button type="submit" label="Discovery Start" pButton class="ui-button-width-fit" ></button>
|
||||
|
|
|
@ -16,6 +16,8 @@ export class SearchConfigComponent implements OnInit, AfterContentInit {
|
|||
@Output() discoverySearchStartClick = new EventEmitter();
|
||||
@Output() selectProbe = new EventEmitter();
|
||||
|
||||
includeServices = [];
|
||||
|
||||
discoveryFormGroup: FormGroup;
|
||||
|
||||
ipVesion: number;
|
||||
|
@ -28,6 +30,12 @@ export class SearchConfigComponent implements OnInit, AfterContentInit {
|
|||
endPort: string;
|
||||
excludePort: string;
|
||||
|
||||
probe: number;
|
||||
|
||||
startHostIp: string;
|
||||
endHostIp: string;
|
||||
excludeHostIp: string;
|
||||
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
) {
|
||||
|
@ -37,6 +45,7 @@ export class SearchConfigComponent implements OnInit, AfterContentInit {
|
|||
this.ipVesion = 0;
|
||||
this.portType = 0;
|
||||
this.initForm();
|
||||
// this.hostIp = '192.168.1.10';
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
|
@ -56,4 +65,9 @@ export class SearchConfigComponent implements OnInit, AfterContentInit {
|
|||
console.log(probe);
|
||||
this.selectProbe.emit(probe);
|
||||
}
|
||||
|
||||
onInputIP(event, idx) {
|
||||
console.log(idx);
|
||||
console.log(event.target.data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,12 @@
|
|||
import { Component, OnInit, Input, AfterContentInit, Output, EventEmitter, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
Input,
|
||||
AfterContentInit,
|
||||
Output,
|
||||
EventEmitter,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
import { Store, select, StateObservable } from '@ngrx/store';
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
import * as ListStore from '@overflow/meta/crawler/store/list';
|
||||
|
@ -18,8 +26,6 @@ export class ServiceSelectorComponent implements OnInit, AfterContentInit, OnDes
|
|||
@Output() crawlerSelected = new EventEmitter<MetaCrawler>();
|
||||
@Input() includeServices;
|
||||
|
||||
@Input() disabled: boolean;
|
||||
|
||||
constructor(
|
||||
private listStore: Store<ListStore.State>,
|
||||
) {
|
|
@ -1,23 +1,17 @@
|
|||
import { SettingComponent } from './setting/setting.component';
|
||||
import { ProbeSelectorComponent } from './setting/probe-selector/probe-selector.component';
|
||||
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';
|
||||
import { ProbeSelectorComponent } from './discovery/probe-selector/probe-selector.component';
|
||||
import { ServiceSelectorComponent } from './discovery/service-selector/service-selector.component';
|
||||
import { DiscoveryComponent } from './discovery/discovery.component';
|
||||
import { SearchConfigComponent } from './discovery/search-config/search-config.component';
|
||||
import { SearchFilterComponent } from './discovery/search-filter/search-filter.component';
|
||||
import { SearchResultComponent } from './discovery/search-result/search-result.component';
|
||||
import { IpInputComponent } from './discovery/search-config/ip-input.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
SettingComponent,
|
||||
FilterComponent,
|
||||
ServiceSelectorComponent,
|
||||
ProbeSelectorComponent,
|
||||
ResultComponent,
|
||||
FilterSummaryComponent,
|
||||
DiscoveryComponent,
|
||||
SearchConfigComponent,
|
||||
SearchFilterComponent,
|
||||
SearchResultComponent
|
||||
SearchResultComponent,
|
||||
IpInputComponent
|
||||
];
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<div *ngIf="data" class="ui-g-12" (click)="onClick()">
|
||||
<of-key-value *ngIf="data.discoverHost" [key]="'Host'" [value]="hostRange"></of-key-value>
|
||||
<of-key-value *ngIf="data.discoverHost.discoverPort" [key]="'Port'" [value]="portRange"></of-key-value>
|
||||
<span *ngIf="includeTCP">
|
||||
TCP
|
||||
</span>
|
||||
<span *ngIf="includeUDP">
|
||||
UDP
|
||||
</span>
|
||||
<of-key-value *ngIf="services !== ''" [key]="'Services'" [value]="services"></of-key-value>
|
||||
</div>
|
|
@ -1,59 +0,0 @@
|
|||
import { Component, OnInit, Input, AfterContentInit, Output, EventEmitter, OnDestroy, OnChanges, SimpleChanges } 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, OnChanges {
|
||||
|
||||
@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() {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (!this.data) {
|
||||
return;
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
<div class="ui-g">
|
||||
<div>
|
||||
<div class="ui-g">
|
||||
<div class="ui-g-12">
|
||||
<p-checkbox value="host" label="Host" [(ngModel)]="hostChecked" binary="true" [disabled]="true"></p-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui-g form-group">
|
||||
<div class="ui-g-12 ui-md-6">
|
||||
<span class="ui-float-label">
|
||||
<input id="float-input" type="text" size="30" pInputText [(ngModel)]="startIP">
|
||||
<label for="float-input">Start Ip</label>
|
||||
</span>
|
||||
</div>
|
||||
<div class="ui-g-12 ui-md-6">
|
||||
<span class="ui-float-label">
|
||||
<input id="float-input" type="text" size="30" pInputText [(ngModel)]="endIP">
|
||||
<label for="float-input">End Ip</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="ui-g">
|
||||
<div class="ui-g-12">
|
||||
<p-checkbox #portCheckbox value="port" label="Port" [(ngModel)]="portChecked" binary="true" (onChange)="onPortCheckChange(serviceCheckbox, $event)"></p-checkbox>
|
||||
</div>
|
||||
<div class="ui-g-12">
|
||||
<div class="ui-g-6">
|
||||
TCP
|
||||
<p-inputSwitch [(ngModel)]="tcpChecked" [disabled]="!portChecked" binary="true"></p-inputSwitch>
|
||||
</div>
|
||||
<div class="ui-g-6">
|
||||
UDP
|
||||
<p-inputSwitch [(ngModel)]="udpChecked" [disabled]="!portChecked" binary="true"></p-inputSwitch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui-g form-group">
|
||||
<div class="ui-g-12 ui-md-6">
|
||||
<span class="ui-float-label">
|
||||
<input id="float-input" type="text" size="30" pInputText [(ngModel)]="startPort" [disabled]="!portChecked">
|
||||
<label for="float-input">Start Port</label>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="ui-g-12 ui-md-6">
|
||||
<span class="ui-float-label">
|
||||
<input id="float-input" type="text" size="30" pInputText [(ngModel)]="endPort" [disabled]="!portChecked">
|
||||
<label for="float-input">End Port</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui-g-12">
|
||||
<div class="ui-g-12 ui-g-nopad">
|
||||
<p-checkbox #serviceCheckbox value="service" label="Service" [(ngModel)]="serviceChecked" (onChange)="onServiceCheckChange(portCheckbox, $event)" binary="true"></p-checkbox>
|
||||
</div>
|
||||
|
||||
<of-service-selector [disabled]="!serviceChecked" [(includeServices)]="includeServices"></of-service-selector>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,116 +0,0 @@
|
|||
import { Component, OnInit, Input, AfterContentInit, Output, EventEmitter, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import * as CIDR from 'ip-cidr';
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
import { DiscoverZone, DiscoverPort, DiscoverService } from '@overflow/commons-typescript/model/discovery';
|
||||
|
||||
@Component({
|
||||
selector: 'of-discovery-filter',
|
||||
templateUrl: './filter.component.html',
|
||||
})
|
||||
export class FilterComponent implements OnInit, AfterContentInit, OnDestroy, OnChanges {
|
||||
|
||||
@Input() probe: Probe;
|
||||
@Input() requestStart: boolean;
|
||||
@Output() discoveryRequested = new EventEmitter<DiscoverZone>();
|
||||
|
||||
private startIP: string;
|
||||
private endIP: string;
|
||||
private startPort: string;
|
||||
private endPort: string;
|
||||
private includeServices = [];
|
||||
|
||||
private hostChecked = true;
|
||||
private portChecked = true;
|
||||
private serviceChecked = true;
|
||||
private tcpChecked = true;
|
||||
private udpChecked = true;
|
||||
|
||||
constructor(
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
}
|
||||
|
||||
hostRange() {
|
||||
if (!this.probe || this.probe === undefined) {
|
||||
return;
|
||||
}
|
||||
const cidr = new CIDR(this.probe.cidr);
|
||||
if (!cidr.isValid()) {
|
||||
alert('Invalid cidr : ' + this.probe.cidr);
|
||||
return;
|
||||
}
|
||||
this.startIP = cidr.addressStart.address;
|
||||
this.endIP = cidr.addressEnd.address;
|
||||
}
|
||||
|
||||
portRange() {
|
||||
this.startPort = '1';
|
||||
this.endPort = '1024';
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['probe']) {
|
||||
this.hostRange();
|
||||
this.portRange();
|
||||
}
|
||||
if (changes['requestStart'] && this.requestStart) {
|
||||
this.onStart();
|
||||
}
|
||||
}
|
||||
|
||||
onPortCheckChange(serviceCheckbox, checked) {
|
||||
if (!checked) {
|
||||
serviceCheckbox.checked = false;
|
||||
this.serviceChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
onServiceCheckChange(portCheckbox, checked) {
|
||||
if (checked) {
|
||||
portCheckbox.checked = true;
|
||||
this.portChecked = true;
|
||||
}
|
||||
}
|
||||
|
||||
onStart() {
|
||||
let discoverPort: DiscoverPort = null;
|
||||
let discoverService: DiscoverService = null;
|
||||
|
||||
if (this.serviceChecked) {
|
||||
const services = new Array();
|
||||
for (const service of this.includeServices) {
|
||||
services.push(service.description); // FIXME to const name
|
||||
}
|
||||
discoverService = {
|
||||
includeServices: services,
|
||||
};
|
||||
}
|
||||
if (this.portChecked) {
|
||||
discoverPort = {
|
||||
firstScanRange: Number(this.startPort),
|
||||
lastScanRange: Number(this.endPort),
|
||||
includeTCP: this.tcpChecked,
|
||||
includeUDP: this.udpChecked,
|
||||
excludePorts: null,
|
||||
discoverService: discoverService
|
||||
};
|
||||
}
|
||||
const discoverZone: DiscoverZone = {
|
||||
discoverHost: {
|
||||
firstScanRangev4: this.startIP,
|
||||
lastScanRangev4: this.endIP,
|
||||
discoverPort: discoverPort
|
||||
},
|
||||
};
|
||||
|
||||
this.discoveryRequested.emit(discoverZone);
|
||||
}
|
||||
}
|
|
@ -1,190 +0,0 @@
|
|||
import { Component, OnInit, Input, AfterContentInit, Output, EventEmitter, OnDestroy } from '@angular/core';
|
||||
import { Store, select, StateObservable } from '@ngrx/store';
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { TreeNode } from 'primeng/primeng';
|
||||
|
||||
import * as DiscoveredStore from '@overflow/discovery/store/setting';
|
||||
import { SettingSelector, DiscoverSelector } from '@overflow/discovery/store';
|
||||
import * as DiscoverStore from '@overflow/discovery/store/discover';
|
||||
import * as RegistStore from '@overflow/discovery/store/regist';
|
||||
|
||||
import { Zone } from '@overflow/commons-typescript/model/discovery';
|
||||
import { Host } from '@overflow/commons-typescript/model/discovery';
|
||||
import { Port } from '@overflow/commons-typescript/model/discovery';
|
||||
import { Service } from '@overflow/commons-typescript/model/discovery';
|
||||
|
||||
@Component({
|
||||
selector: 'of-discovery-result',
|
||||
templateUrl: './result.component.html',
|
||||
})
|
||||
export class ResultComponent implements OnInit, AfterContentInit, OnDestroy {
|
||||
|
||||
treeNodes = [];
|
||||
selectedNodes = [];
|
||||
zones: Map<string, Zone> = null;
|
||||
checkedSet = new Set();
|
||||
|
||||
resultSubscription$: Subscription;
|
||||
result$: any;
|
||||
startedSubscription$: Subscription;
|
||||
started$: any;
|
||||
endedSubscription$: Subscription;
|
||||
ended$: any;
|
||||
|
||||
inProgress = false;
|
||||
|
||||
|
||||
selectedDiscoveryResult: TreeNode[];
|
||||
|
||||
constructor(
|
||||
private discoverdStore: Store<DiscoveredStore.State>,
|
||||
private discoverStore: Store<DiscoverStore.State>,
|
||||
private registStore: Store<RegistStore.State>,
|
||||
) {
|
||||
this.result$ = discoverStore.pipe(select(DiscoverSelector.select('zones')));
|
||||
this.started$ = discoverStore.pipe(select(DiscoverSelector.select('isStart')));
|
||||
this.ended$ = discoverStore.pipe(select(DiscoverSelector.select('isEnd')));
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.resultSubscription$ = this.result$.subscribe(
|
||||
(zones: Map<string, Zone>) => {
|
||||
if (zones !== undefined && zones !== null) {
|
||||
console.log(zones);
|
||||
this.treeNodes = this.convertTreeViewZone(zones);
|
||||
this.zones = zones;
|
||||
}
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
this.startedSubscription$ = this.started$.subscribe(
|
||||
(isStart: boolean) => {
|
||||
if (isStart !== undefined && isStart !== null && isStart) {
|
||||
this.inProgress = true;
|
||||
console.log('##Discovery has started.##');
|
||||
}
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
this.endedSubscription$ = this.ended$.subscribe(
|
||||
(isEnd: boolean) => {
|
||||
if (isEnd !== undefined && isEnd !== null && isEnd) {
|
||||
console.log('##Discovery has done.##');
|
||||
}
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.startedSubscription$) {
|
||||
this.startedSubscription$.unsubscribe();
|
||||
}
|
||||
if (this.endedSubscription$) {
|
||||
this.endedSubscription$.unsubscribe();
|
||||
}
|
||||
if (this.resultSubscription$) {
|
||||
this.resultSubscription$.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
}
|
||||
|
||||
convertTreeViewZone(zones: Map<string, Zone>) {
|
||||
|
||||
if (zones === undefined || zones === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const treeNodes: any[] = [];
|
||||
|
||||
zones.forEach((value: Zone, key: string, map) => {
|
||||
const jZone: any = {
|
||||
label: 'Zone - ' + value.iface,
|
||||
// className: 'cn' + value.ip,
|
||||
expandedIcon: 'fa-folder-open',
|
||||
collapsedIcon: 'fa-folder',
|
||||
};
|
||||
jZone.obj = value;
|
||||
jZone.children = this.convertViewHost(value.hosts);
|
||||
treeNodes.push(jZone);
|
||||
});
|
||||
|
||||
return treeNodes;
|
||||
}
|
||||
|
||||
convertViewHost(hosts): any[] {
|
||||
if (hosts === undefined || hosts === null) {
|
||||
return null;
|
||||
}
|
||||
const hostNodes: any[] = [];
|
||||
|
||||
hosts.forEach((host, hostKey) => {
|
||||
|
||||
const jHost: any = {
|
||||
label: 'Host - ' + host.ipv4,
|
||||
// className: 'cn' + host.ip
|
||||
expandedIcon: 'fa-folder-open',
|
||||
collapsedIcon: 'fa-folder',
|
||||
};
|
||||
jHost.obj = host;
|
||||
jHost.children = this.convertViewPort(host.ports);
|
||||
hostNodes.push(jHost);
|
||||
|
||||
});
|
||||
|
||||
return hostNodes;
|
||||
|
||||
}
|
||||
|
||||
convertViewPort(ports): any[] {
|
||||
if (ports === undefined || ports === null || ports.size < 0) {
|
||||
return null;
|
||||
}
|
||||
const portChildren: any[] = [];
|
||||
ports.forEach((port, portKey) => {
|
||||
const jPort: any = {
|
||||
label: 'Port - ' + port.portNumber,
|
||||
// className: 'cn' + port.portNumber,
|
||||
expandedIcon: 'fa-folder-open',
|
||||
collapsedIcon: 'fa-folder',
|
||||
};
|
||||
jPort.obj = port;
|
||||
jPort.children = this.convertViewService(port.services);
|
||||
portChildren.push(jPort);
|
||||
});
|
||||
|
||||
return portChildren;
|
||||
}
|
||||
|
||||
convertViewService(services): any[] {
|
||||
if (services === undefined || services === null || services.size <= 0) {
|
||||
return null;
|
||||
}
|
||||
const serviceChildren: any[] = [];
|
||||
services.forEach((service, serviceKey) => {
|
||||
const jService: any = {
|
||||
label: 'Service - ' + service.serviceName,
|
||||
// className: 'cn' + service.serviceName,
|
||||
};
|
||||
jService.obj = service;
|
||||
|
||||
serviceChildren.push(jService);
|
||||
});
|
||||
|
||||
return serviceChildren;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<div class="ui-g-12">
|
||||
<div *ngIf="inProgress">
|
||||
<p-progressBar mode="indeterminate"></p-progressBar>
|
||||
</div>
|
||||
|
||||
<p-blockUI [target]="result" [blocked]="inProgress"></p-blockUI>
|
||||
<p-panel #result [showHeader]="false">
|
||||
<div>
|
||||
result
|
||||
</div>
|
||||
<p-tree [value]="treeNodes" selectionMode="checkbox" [(selection)]="selectedNodes"></p-tree>
|
||||
</p-panel>
|
||||
</div>
|
|
@ -1,198 +0,0 @@
|
|||
import { Component, OnInit, Input, AfterContentInit, Output, EventEmitter, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Store, select, StateObservable } from '@ngrx/store';
|
||||
import { RPCClientError } from '@loafer/ng-rpc';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { TreeNode } from 'primeng/primeng';
|
||||
|
||||
import * as DiscoveredStore from '@overflow/discovery/store/setting';
|
||||
import { SettingSelector, DiscoverSelector } from '@overflow/discovery/store';
|
||||
import * as DiscoverStore from '@overflow/discovery/store/discover';
|
||||
import * as RegistStore from '@overflow/discovery/store/regist';
|
||||
|
||||
import { Zone } from '@overflow/commons-typescript/model/discovery';
|
||||
import { Host } from '@overflow/commons-typescript/model/discovery';
|
||||
import { Port } from '@overflow/commons-typescript/model/discovery';
|
||||
import { Service } from '@overflow/commons-typescript/model/discovery';
|
||||
|
||||
@Component({
|
||||
selector: 'of-discovery-result',
|
||||
templateUrl: './result.component.html',
|
||||
})
|
||||
export class ResultComponent implements OnInit, AfterContentInit, OnDestroy, OnChanges {
|
||||
|
||||
@Input() started: boolean;
|
||||
|
||||
treeNodes = [];
|
||||
selectedNodes = [];
|
||||
zones: Map<string, Zone> = null;
|
||||
checkedSet = new Set();
|
||||
|
||||
resultSubscription$: Subscription;
|
||||
result$: any;
|
||||
startedSubscription$: Subscription;
|
||||
started$: any;
|
||||
endedSubscription$: Subscription;
|
||||
ended$: any;
|
||||
|
||||
inProgress = false;
|
||||
|
||||
|
||||
selectedDiscoveryResult: TreeNode[];
|
||||
|
||||
constructor(
|
||||
private discoverdStore: Store<DiscoveredStore.State>,
|
||||
private discoverStore: Store<DiscoverStore.State>,
|
||||
private registStore: Store<RegistStore.State>,
|
||||
) {
|
||||
this.result$ = discoverStore.pipe(select(DiscoverSelector.select('zones')));
|
||||
this.started$ = discoverStore.pipe(select(DiscoverSelector.select('isStart')));
|
||||
this.ended$ = discoverStore.pipe(select(DiscoverSelector.select('isEnd')));
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.inProgress = true;
|
||||
this.resultSubscription$ = this.result$.subscribe(
|
||||
(zones: Map<string, Zone>) => {
|
||||
if (zones !== undefined && zones !== null) {
|
||||
console.log(zones);
|
||||
this.treeNodes = this.convertTreeViewZone(zones);
|
||||
this.zones = zones;
|
||||
}
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
this.startedSubscription$ = this.started$.subscribe(
|
||||
(isStart: boolean) => {
|
||||
if (isStart !== undefined && isStart !== null && isStart) {
|
||||
console.log('##Discovery has started.##');
|
||||
}
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
this.endedSubscription$ = this.ended$.subscribe(
|
||||
(isEnd: boolean) => {
|
||||
if (isEnd !== undefined && isEnd !== null && isEnd) {
|
||||
console.log('##Discovery has done.##');
|
||||
}
|
||||
},
|
||||
(error: RPCClientError) => {
|
||||
console.log(error.response.message);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['started'] && !changes['started'].currentValue) {
|
||||
this.inProgress = false;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.startedSubscription$) {
|
||||
this.startedSubscription$.unsubscribe();
|
||||
}
|
||||
if (this.endedSubscription$) {
|
||||
this.endedSubscription$.unsubscribe();
|
||||
}
|
||||
if (this.resultSubscription$) {
|
||||
this.resultSubscription$.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
}
|
||||
|
||||
convertTreeViewZone(zones: Map<string, Zone>) {
|
||||
|
||||
if (zones === undefined || zones === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const treeNodes: any[] = [];
|
||||
|
||||
zones.forEach((value: Zone, key: string, map) => {
|
||||
const jZone: any = {
|
||||
label: 'Zone - ' + value.iface,
|
||||
// className: 'cn' + value.ip,
|
||||
expandedIcon: 'fa-folder-open',
|
||||
collapsedIcon: 'fa-folder',
|
||||
};
|
||||
jZone.obj = value;
|
||||
jZone.children = this.convertViewHost(value.hosts);
|
||||
treeNodes.push(jZone);
|
||||
});
|
||||
|
||||
return treeNodes;
|
||||
}
|
||||
|
||||
convertViewHost(hosts): any[] {
|
||||
if (hosts === undefined || hosts === null) {
|
||||
return null;
|
||||
}
|
||||
const hostNodes: any[] = [];
|
||||
|
||||
hosts.forEach((host, hostKey) => {
|
||||
|
||||
const jHost: any = {
|
||||
label: 'Host - ' + host.ipv4,
|
||||
// className: 'cn' + host.ip
|
||||
expandedIcon: 'fa-folder-open',
|
||||
collapsedIcon: 'fa-folder',
|
||||
};
|
||||
jHost.obj = host;
|
||||
jHost.children = this.convertViewPort(host.ports);
|
||||
hostNodes.push(jHost);
|
||||
|
||||
});
|
||||
|
||||
return hostNodes;
|
||||
|
||||
}
|
||||
|
||||
convertViewPort(ports): any[] {
|
||||
if (ports === undefined || ports === null || ports.size < 0) {
|
||||
return null;
|
||||
}
|
||||
const portChildren: any[] = [];
|
||||
ports.forEach((port, portKey) => {
|
||||
const jPort: any = {
|
||||
label: 'Port - ' + port.portNumber,
|
||||
// className: 'cn' + port.portNumber,
|
||||
expandedIcon: 'fa-folder-open',
|
||||
collapsedIcon: 'fa-folder',
|
||||
};
|
||||
jPort.obj = port;
|
||||
jPort.children = this.convertViewService(port.services);
|
||||
portChildren.push(jPort);
|
||||
});
|
||||
|
||||
return portChildren;
|
||||
}
|
||||
|
||||
convertViewService(services): any[] {
|
||||
if (services === undefined || services === null || services.size <= 0) {
|
||||
return null;
|
||||
}
|
||||
const serviceChildren: any[] = [];
|
||||
services.forEach((service, serviceKey) => {
|
||||
const jService: any = {
|
||||
label: 'Service - ' + service.serviceName,
|
||||
// className: 'cn' + service.serviceName,
|
||||
};
|
||||
jService.obj = service;
|
||||
|
||||
serviceChildren.push(jService);
|
||||
});
|
||||
|
||||
return serviceChildren;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<!-- <div [style.height.px]="height">
|
||||
<div dir="rtl">
|
||||
<p-button (onClick)="onCancel()" icon="fa fa-fw fa-close"></p-button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<of-probe-selector [hidden]="requestStart" #probeSelectorComponent [preProbe]="probe" (probeSelected)="onProbeSelect($event)"></of-probe-selector>
|
||||
|
||||
<p-blockUI [target]="df" [blocked]="!selectedProbe && !probe"></p-blockUI>
|
||||
<p-panel #df [showHeader]="false">
|
||||
<div [@discoveryFilter]="!requestStart ? 'full' : 'summary'">
|
||||
<div [hidden]="requestStart">
|
||||
<of-discovery-filter #filterComponent [probe]="selectedProbe" [requestStart]="requestStart" (discoveryRequested)="onDiscoveryStart($event)"></of-discovery-filter>
|
||||
</div>
|
||||
<div [hidden]="!requestStart">
|
||||
<of-discovery-filter-summary [data]="filterData" (click)="onSummaryClick($event)"></of-discovery-filter-summary>
|
||||
</div>
|
||||
</div>
|
||||
</p-panel>
|
||||
|
||||
<div dir="rtl" *ngIf="!requestStart">
|
||||
<button [disabled]="!selectedProbe && !probe" pButton type="button" label="Start" icon="fa-check" class="ui-button-width-fit"
|
||||
(click)="requestStart = true"></button>
|
||||
<button pButton type="button" label="Cancel" icon="fa-close" class="ui-button-secondary ui-button-width-fit" (click)="onCancel()"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="requestStart" [@result]="!requestStart ? 'hidden' : 'show'">
|
||||
<of-discovery-result (close)="onCancel()" [started]="started"></of-discovery-result>
|
||||
<div dir="rtl">
|
||||
<button [disabled]="!selectedProbe && !probe" pButton type="button" label="Save" icon="fa-check" class="ui-button-width-fit"
|
||||
(click)="onSave()"></button>
|
||||
<button pButton type="button" label="Stop" icon="fa-close" class="ui-button-secondary ui-button-width-fit" (click)="onStop()"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
|
@ -1,156 +0,0 @@
|
|||
import {
|
||||
Component, OnInit, AfterContentInit, Output, EventEmitter,
|
||||
Input, OnDestroy, OnChanges, SimpleChanges, ViewChild
|
||||
} from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import {
|
||||
DiscoverZone,
|
||||
} from '@overflow/commons-typescript/model/discovery';
|
||||
|
||||
import * as DiscoverStore from '../../store/discover';
|
||||
import { Probe } from '@overflow/commons-typescript/model/probe';
|
||||
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/animations';
|
||||
|
||||
@Component({
|
||||
selector: 'of-discovery-setting',
|
||||
templateUrl: './setting.component.html',
|
||||
animations: [
|
||||
trigger(
|
||||
'discoveryFilter', [
|
||||
state('summary', style({
|
||||
height: '70px',
|
||||
opacity: 0.9,
|
||||
})),
|
||||
state('full', style({
|
||||
height: '500px',
|
||||
opacity: 1,
|
||||
})),
|
||||
transition('* => *', animate('200ms ease-in')),
|
||||
]),
|
||||
trigger(
|
||||
'result', [
|
||||
state('show', style({
|
||||
height: '300px',
|
||||
opacity: 1,
|
||||
})),
|
||||
state('hidden', style({
|
||||
height: '0px',
|
||||
opacity: 0,
|
||||
})),
|
||||
transition('* => *', animate('200ms ease-in')),
|
||||
]
|
||||
)
|
||||
]
|
||||
})
|
||||
export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, OnChanges {
|
||||
|
||||
@Input() visible: boolean;
|
||||
@Input() probe: Probe;
|
||||
@Output() close = new EventEmitter();
|
||||
private requestStart = false;
|
||||
private started = false;
|
||||
private filterData: DiscoverZone;
|
||||
|
||||
private selectedProbe: Probe;
|
||||
private height: number;
|
||||
|
||||
@ViewChild('probeSelectorComponent') probeSelectorComponent: ProbeSelectorComponent;
|
||||
@ViewChild('filterComponent') filterComponent: FilterComponent;
|
||||
@ViewChild('resultComponent') resultComponent: ResultComponent;
|
||||
|
||||
constructor(
|
||||
private discoverStore: Store<DiscoverStore.State>,
|
||||
) {
|
||||
this.height = window.innerHeight * 0.9;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.selectedProbe = this.probe;
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['visible']) {
|
||||
const change = changes['visible'];
|
||||
if (!change.previousValue && change.currentValue) {
|
||||
this.initAll();
|
||||
} else if (change.previousValue && !change.currentValue) {
|
||||
this.destroyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.selectedProbe = null;
|
||||
this.started = false;
|
||||
this.close.emit();
|
||||
this.requestStart = false;
|
||||
}
|
||||
|
||||
initAll() {
|
||||
this.ngOnInit();
|
||||
if (this.probeSelectorComponent) {
|
||||
this.probeSelectorComponent.ngOnInit();
|
||||
}
|
||||
if (this.filterComponent) {
|
||||
this.filterComponent.ngOnInit();
|
||||
}
|
||||
if (this.resultComponent) {
|
||||
this.resultComponent.ngOnInit();
|
||||
}
|
||||
}
|
||||
|
||||
destroyAll() {
|
||||
this.ngOnDestroy();
|
||||
if (this.probeSelectorComponent) {
|
||||
this.probeSelectorComponent.ngOnDestroy();
|
||||
}
|
||||
if (this.filterComponent) {
|
||||
this.filterComponent.ngOnDestroy();
|
||||
}
|
||||
if (this.resultComponent) {
|
||||
this.resultComponent.ngOnDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
onProbeSelect(probe: Probe) {
|
||||
this.selectedProbe = probe;
|
||||
}
|
||||
|
||||
onDiscoveryStart(discoverZone: DiscoverZone) {
|
||||
this.filterData = discoverZone;
|
||||
this.discoverStore.dispatch(new DiscoverStore.DiscoverZone(
|
||||
{ probeID: this.selectedProbe.probeKey, discoverZone: discoverZone }));
|
||||
|
||||
setTimeout(() => {
|
||||
this.started = true;
|
||||
// this.requestStart = false;
|
||||
});
|
||||
}
|
||||
|
||||
onCancel() {
|
||||
this.destroyAll();
|
||||
}
|
||||
|
||||
onSave() {
|
||||
this.resultComponent.save();
|
||||
}
|
||||
|
||||
onStop() {
|
||||
this.started = false;
|
||||
}
|
||||
|
||||
onSummaryClick() {
|
||||
if (this.started) {
|
||||
return;
|
||||
}
|
||||
this.requestStart = false;
|
||||
}
|
||||
|
||||
}
|
|
@ -9,7 +9,6 @@ import { DiscoveryLoggerModule } from './discovery-logger.module';
|
|||
import { COMPONENTS } from './component';
|
||||
import { SERVICES } from './service';
|
||||
import { PrimeNGModules } from '@overflow/commons/prime-ng/prime-ng.module';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.module';
|
||||
|
||||
@NgModule({
|
||||
|
|
Loading…
Reference in New Issue
Block a user