discovery condition port + service
This commit is contained in:
parent
e557f7a608
commit
e23ad44191
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
|
import { Component, OnInit, Input, OnDestroy, Output, EventEmitter } from '@angular/core';
|
||||||
import { MatChipInputEvent } from '@angular/material';
|
import { MatChipInputEvent } from '@angular/material';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -10,6 +10,7 @@ export class InputChipComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
selectedItems = new Array();
|
selectedItems = new Array();
|
||||||
@Input() unselectedItems;
|
@Input() unselectedItems;
|
||||||
|
@Output() change = new EventEmitter<any>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
@ -25,11 +26,13 @@ export class InputChipComponent implements OnInit, OnDestroy {
|
||||||
selected(app: any) {
|
selected(app: any) {
|
||||||
this.selectedItems.push(app);
|
this.selectedItems.push(app);
|
||||||
this.remove(this.unselectedItems, app);
|
this.remove(this.unselectedItems, app);
|
||||||
|
this.emitEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
unselected(app: any): void {
|
unselected(app: any): void {
|
||||||
this.remove(this.selectedItems, app);
|
this.remove(this.selectedItems, app);
|
||||||
this.unselectedItems.push(app);
|
this.unselectedItems.push(app);
|
||||||
|
this.emitEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(list: any, target: any) {
|
remove(list: any, target: any) {
|
||||||
|
@ -45,6 +48,7 @@ export class InputChipComponent implements OnInit, OnDestroy {
|
||||||
t.selectedItems.push(v);
|
t.selectedItems.push(v);
|
||||||
});
|
});
|
||||||
this.unselectedItems.length = 0;
|
this.unselectedItems.length = 0;
|
||||||
|
this.emitEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
unselectAll() {
|
unselectAll() {
|
||||||
|
@ -53,5 +57,10 @@ export class InputChipComponent implements OnInit, OnDestroy {
|
||||||
t.unselectedItems.push(v);
|
t.unselectedItems.push(v);
|
||||||
});
|
});
|
||||||
this.selectedItems.length = 0;
|
this.selectedItems.length = 0;
|
||||||
|
this.emitEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
emitEvent() {
|
||||||
|
this.change.emit(this.selectedItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,40 +11,44 @@
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<!-- <form (ngSubmit)="discovery()"> -->
|
<!-- <form (ngSubmit)="discovery()"> -->
|
||||||
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<mat-checkbox [checked]="true" [(ngModel)]="hostChecked" (change)="handleHostCheckChange($event)">Host</mat-checkbox>
|
||||||
<mat-checkbox [checked]="true" [(ngModel)]="hostChecked" (change)="handleHostCheckChange($event)">Host</mat-checkbox>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<mat-form-field *ngIf="hostChecked">
|
|
||||||
<input matInput placeholder="Start IP" type="string" [(ngModel)]="startIP">
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field *ngIf="hostChecked">
|
|
||||||
<input matInput placeholder="End IP" type="string" [(ngModel)]="endIP">
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<mat-form-field *ngIf="hostChecked">
|
||||||
<mat-checkbox [(ngModel)]="portChecked" (change)="handlePortCheckChange($event)">Port</mat-checkbox>
|
<input matInput placeholder="Start IP" type="string" [(ngModel)]="startIP">
|
||||||
</div>
|
</mat-form-field>
|
||||||
<div>
|
<mat-form-field *ngIf="hostChecked">
|
||||||
<mat-form-field *ngIf="portChecked">
|
<input matInput placeholder="End IP" type="string" [(ngModel)]="endIP">
|
||||||
<input matInput placeholder="Start Port" type="number" [(ngModel)]="startPort">
|
</mat-form-field>
|
||||||
</mat-form-field>
|
</div>
|
||||||
<mat-form-field *ngIf="portChecked">
|
</div>
|
||||||
<input matInput placeholder="End Port" type="number" [(ngModel)]="endPort">
|
<div>
|
||||||
</mat-form-field>
|
<div>
|
||||||
</div>
|
<mat-checkbox [(ngModel)]="portChecked" (change)="handlePortCheckChange($event)">Port</mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div *ngIf="portChecked">
|
||||||
<mat-checkbox [(ngModel)]="serviceChecked" (change)="handleServiceCheckChange($event)">Service</mat-checkbox>
|
<mat-slide-toggle [checked]="true" [(ngModel)]="tcpChecked">TCP</mat-slide-toggle>
|
||||||
</div>
|
<mat-slide-toggle [checked]="true" [(ngModel)]="udpChecked">UDP</mat-slide-toggle>
|
||||||
<div>
|
|
||||||
<of-input-chip *ngIf="serviceChecked" [unselectedItems]="serviceItems"></of-input-chip>
|
|
||||||
</div>
|
</div>
|
||||||
|
<mat-form-field *ngIf="portChecked">
|
||||||
|
<input matInput placeholder="Start Port" type="number" [(ngModel)]="startPort">
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field *ngIf="portChecked">
|
||||||
|
<input matInput placeholder="End Port" type="number" [(ngModel)]="endPort">
|
||||||
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<mat-checkbox [(ngModel)]="serviceChecked" (change)="handleServiceCheckChange($event)">Service</mat-checkbox>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<of-input-chip *ngIf="serviceChecked" [unselectedItems]="serviceItems" (change)="handleServiceChange($event)"></of-input-chip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- </form> -->
|
<!-- </form> -->
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
@ -65,10 +69,7 @@
|
||||||
<div class="tree-node">
|
<div class="tree-node">
|
||||||
<input type="checkbox" [checked]="node.isActive" (change)="checkDiscoveryResult(node)" />
|
<input type="checkbox" [checked]="node.isActive" (change)="checkDiscoveryResult(node)" />
|
||||||
<tree-node-expander [node]="node"></tree-node-expander>
|
<tree-node-expander [node]="node"></tree-node-expander>
|
||||||
<div
|
<div class="node-content-wrapper" [class.node-content-wrapper-active]="node.isActive" [class.node-content-wrapper-focused]="node.isFocused"
|
||||||
class="node-content-wrapper"
|
|
||||||
[class.node-content-wrapper-active]="node.isActive"
|
|
||||||
[class.node-content-wrapper-focused]="node.isFocused"
|
|
||||||
(click)="checkDiscoveryResult(node)">
|
(click)="checkDiscoveryResult(node)">
|
||||||
<span [class]="node.data.className" [class.title]="true">{{ node.data.title }}</span>
|
<span [class]="node.data.className" [class.title]="true">{{ node.data.title }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, OnInit, AfterContentInit } from '@angular/core';
|
import { Component, OnInit, AfterContentInit } from '@angular/core';
|
||||||
import { MatCheckboxChange } from '@angular/material';
|
import { MatCheckboxChange, MatSlideToggleChange } from '@angular/material';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import { RPCClientError } from '@loafer/ng-rpc/protocol';
|
import { RPCClientError } from '@loafer/ng-rpc/protocol';
|
||||||
import {
|
import {
|
||||||
|
@ -45,12 +45,25 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
||||||
hostChecked = true;
|
hostChecked = true;
|
||||||
portChecked = true;
|
portChecked = true;
|
||||||
serviceChecked = true;
|
serviceChecked = true;
|
||||||
|
tcpChecked = true;
|
||||||
|
udpChecked = true;
|
||||||
|
includeServices = null;
|
||||||
|
|
||||||
serviceItems = [
|
serviceItems = [
|
||||||
|
{ name: 'SSH' },
|
||||||
|
{ name: 'PostgreSQL' },
|
||||||
|
{ name: 'DNS' },
|
||||||
|
{ name: 'WMI'},
|
||||||
|
{ name: 'SMB' },
|
||||||
|
{ name: 'ActiveDirectory' },
|
||||||
|
{ name: 'Cassandra' },
|
||||||
|
{ name: 'FTP' },
|
||||||
|
{ name: 'HTTP' },
|
||||||
|
{ name: 'IMAP' },
|
||||||
|
{ name: 'LDAP' },
|
||||||
|
{ name: 'MongoDB' },
|
||||||
{ name: 'MySQL' },
|
{ name: 'MySQL' },
|
||||||
{ name: 'Redis' },
|
{ name: 'NBSS' },
|
||||||
{ name: 'Tomcat' },
|
|
||||||
{ name: 'Nginx' },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
treeNodes = [];
|
treeNodes = [];
|
||||||
|
@ -172,6 +185,11 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleServiceCheckChange(e: MatCheckboxChange) {
|
handleServiceCheckChange(e: MatCheckboxChange) {
|
||||||
|
this.includeServices = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleServiceChange(list: any) {
|
||||||
|
this.includeServices = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
discovery() {
|
discovery() {
|
||||||
|
@ -179,16 +197,10 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
||||||
this.startPort = '0';
|
this.startPort = '0';
|
||||||
this.endPort = '0';
|
this.endPort = '0';
|
||||||
}
|
}
|
||||||
if (!this.serviceChecked) {
|
const services = new Array();
|
||||||
|
for (const service of this.includeServices) {
|
||||||
|
services.push(service.name);
|
||||||
}
|
}
|
||||||
const startInfo: DiscoveryStartInfo = {
|
|
||||||
startIp: this.startIP,
|
|
||||||
endIP: this.endIP,
|
|
||||||
startPort: this.startPort,
|
|
||||||
endPort: this.endPort
|
|
||||||
};
|
|
||||||
|
|
||||||
const discoveryZone: DiscoveryZone = {
|
const discoveryZone: DiscoveryZone = {
|
||||||
discoveryHost: {
|
discoveryHost: {
|
||||||
firstScanRange: this.startIP,
|
firstScanRange: this.startIP,
|
||||||
|
@ -196,11 +208,11 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
||||||
discoveryPort: {
|
discoveryPort: {
|
||||||
firstScanRange: this.startPort,
|
firstScanRange: this.startPort,
|
||||||
lastScanRange: this.endPort,
|
lastScanRange: this.endPort,
|
||||||
includeTCP: true,
|
includeTCP: this.tcpChecked,
|
||||||
includeUDP: true,
|
includeUDP: this.udpChecked,
|
||||||
excludePorts: null,
|
excludePorts: null,
|
||||||
discoveryService: {
|
discoveryService: {
|
||||||
includeServices: ['SSH', 'PostgreSQL', 'DNS', 'WMI', 'SMB'],
|
includeServices: services
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -210,7 +222,6 @@ export class SettingComponent implements OnInit, AfterContentInit {
|
||||||
this.discoverstore.dispatch(new DiscoverStore.DiscoverZone(
|
this.discoverstore.dispatch(new DiscoverStore.DiscoverZone(
|
||||||
{ probeID: this.probe.probeKey, discoveryZone: discoveryZone }));
|
{ probeID: this.probe.probeKey, discoveryZone: discoveryZone }));
|
||||||
|
|
||||||
|
|
||||||
this.started = true;
|
this.started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user