This commit is contained in:
insanity 2018-06-15 19:18:50 +09:00
parent 02fbb31949
commit ab2ef8f5bd
9 changed files with 79 additions and 40 deletions

View File

@ -59,9 +59,9 @@ export class DiscoveryComponent implements OnDestroy {
// TODO: fix
const zone: Zone = {
network: '192.168.1.0/24', // this.selectedProbe.probe.cidr
address: '192.168.1.103',
address: '192.168.1.101',
iface: 'enp3s0',
mac: '44:8a:5b:44:8c:e8',
mac: '44:8a:5b:f1:f1:f3',
};
this.discoveryService.discoverHost(this.selectedProbe.probe.probeKey, zone, dz.discoverHost);

View File

@ -1,4 +1,4 @@
<div *ngIf="discoverZone" class="ui-key-value ui-left-info2">
<!-- <div *ngIf="discoverZone" class="ui-key-value ui-left-info2">
<div class="ui-g">
<of-key-value [key]="'Host Range'" [value]="hostRange"></of-key-value>
<of-key-value [key]="'Port Range'" [value]="portRange"></of-key-value>
@ -21,4 +21,4 @@
<a style="cursor: pointer" (click)="op.toggle($event)">{{services.length}} services has selected.</a>
</div>
</div>
</div>
</div> -->

View File

@ -104,10 +104,10 @@ export class SearchConfigComponent implements OnChanges {
if (this.serviceChecked) {
const services = [];
for (const service of this.includeServices) {
services.push(service.description);
services.push(service.key);
}
discoverService = {
includeServices: services,
includeServices: null,
};
}
if (this.portChecked) {

View File

@ -44,13 +44,13 @@
</ng-template>
</p-tree>
<button class="ui-button-width-fit ui-float-right ui-top-space-10" [disabled]="selectedItems.length === 0" type="button" label="Save" icon="ui-icon-close"
pButton (click)="saveTargets()"></button>
<button class="ui-button-width-fit ui-float-right ui-top-space-10" [disabled]="selectedItems.length === 0" type="button"
label="Save" icon="ui-icon-close" pButton (click)="saveTargets()"></button>
</p-panel>
<p-dialog header="Title" [(visible)]="displayTargetDone" [modal]="true" [responsive]="true" [width]="600" [minWidth]="200" [minY]="70"
<!-- <p-dialog header="Title" [(visible)]="displayTargetDone" [modal]="true" [responsive]="true" [width]="600" [minWidth]="200" [minY]="70"
[closeOnEscape]="false">
<span>Target 지정이 완료되었습니다. 이어서 Sensor를 등록하시면 좋겠다능</span>
<p-footer>
@ -58,4 +58,4 @@
<button type="button" pButton label="Target으로"></button>
<button type="button" pButton label="InfraMap으로"></button>
</p-footer>
</p-dialog>
</p-dialog> -->

View File

@ -4,17 +4,24 @@ import {
OnInit,
OnChanges,
} from '@angular/core';
import { Subscription, Observable } from 'rxjs';
import { Host, Port, Service } from '@overflow/commons-typescript/model/discovery';
import { TreeNode, Message, Tree } from 'primeng/primeng';
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
import { Anim } from './animation';
import { TargetService } from '@overflow/target/service/target.service';
import { InfraService, InfraHost, MetaTargetHostTypeEnum, toMetaTargetHostType, Infra } from '@overflow/commons-typescript';
import { InfraService as InfraRegistService } from '../../infra/service/infra.service';
import { Observable, of, Subscription } from 'rxjs';
import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators';
@Component({
selector: 'of-discovery-result',
templateUrl: './search-result.component.html',
animations: Anim,
providers: [
TargetService,
InfraRegistService
]
})
export class SearchResultComponent implements OnInit, OnChanges {
@ -33,8 +40,14 @@ export class SearchResultComponent implements OnInit, OnChanges {
targetSaveSucceed: boolean;
displayTargetDone: boolean;
discoveredHosts: Host[] = [];
discoveredServices: Service[] = [];
pending$: Observable<boolean>;
constructor(
private targetService: TargetService
private targetService: TargetService,
private infraRegistService: InfraRegistService
) {
this.targetSaveSucceed = false;
this.displayTargetDone = false;
@ -58,9 +71,34 @@ export class SearchResultComponent implements OnInit, OnChanges {
severity: 'success',
summary: 'Discovery가 완료되었습니다. 모니터링 대상(들)을 선택 후 저장하세요.',
});
this.saveDiscoveredInfras();
}
}
saveDiscoveredInfras() {
this.infraRegistService.registDiscoverd(
this.probeHost.probe.id,
this.discoveredHosts,
this.discoveredServices)
.pipe(
tap(() => {
this.pending$ = of(true);
}),
map((infras: Infra[]) => {
console.log(infras);
}),
catchError(error => {
this.error$ = of(error);
return of();
}),
tap(() => {
this.pending$ = of(false);
}),
take(1),
).subscribe();
}
addHost(host: Host) {
// this.targetService.findExistHostTarget(this.probeHost.probe.id, host.ipv4)
@ -89,6 +127,8 @@ export class SearchResultComponent implements OnInit, OnChanges {
expanded: true,
children: []
});
this.discoveredHosts.push(host);
}
addService(service: Service) {
@ -104,6 +144,7 @@ export class SearchResultComponent implements OnInit, OnChanges {
target: service
},
});
this.discoveredServices.push(service);
}
addPort(port: Port) {
// this.hostNode.forEach(node => {
@ -181,16 +222,15 @@ export class SearchResultComponent implements OnInit, OnChanges {
saveTargets() {
const hosts: Host[] = [];
const services: Service[] = [];
this.selectedItems.forEach(value => {
if (value.ipv4) {
hosts.push(value);
} else {
services.push(value);
}
});
// const hosts: Host[] = [];
// const services: Service[] = [];
// this.selectedItems.forEach(value => {
// if (!value.port) {
// hosts.push(value);
// } else {
// services.push(value);
// }
// });
// this.targetService.registDiscoveredTargets(this.probeHost.probe.id, hosts, services)
// .pipe(
// tap(() => {

View File

@ -18,7 +18,7 @@
</td> -->
<td>
<p-tableCheckbox [value]="rowData"></p-tableCheckbox>
{{rowData.description}}
{{rowData.key}}
</td>
</tr>
</ng-template>

View File

@ -47,7 +47,7 @@
</div>
<div class="ui-g-12 ui-md-6 ui-key-value">
<of-host-ips-overlay [infraHostIPs]="infraHost.infraHostIPs"></of-host-ips-overlay>
<!-- <of-host-ips-overlay [infraHostIPs]="infraHost.infraHostIPs"></of-host-ips-overlay> -->
</div>
</div>

View File

@ -1,4 +1,3 @@
<div *ngIf="!probeHostID">
<p-dropdown [options]="options" [(ngModel)]="selected" optionLabel="displayName" placeholder="Select a Probe"
(onChange)="onSelect()"></p-dropdown>
<p-dropdown [options]="options" [(ngModel)]="selected" optionLabel="name" placeholder="Select a Probe" (onChange)="onSelect()"></p-dropdown>
</div>

View File

@ -1,16 +1,16 @@
<p-panel [showHeader]="false" class="ui-top-space-10">
<div *ngIf="probeHost" class="ui-g">
<div class="ui-g-12 ui-md-4 ui-key-value">
<of-key-value [key]="'Status'" [value]="connectionStatus"></of-key-value>
<!-- <of-key-value [key]="'Status'" [value]="connectionStatus"></of-key-value> -->
<of-key-value [key]="'CIDR'" [value]="probeHost.probe.cidr"></of-key-value>
</div>
<div class="ui-g-12 ui-md-4 ui-key-value">
<of-key-value [key]="'Name'" [value]="probeHost.probe.displayName"></of-key-value>
<of-key-value [key]="'OS'" [value]="probeHost.infraHost.infraOS.metaInfraVendor.name"></of-key-value>
<of-key-value [key]="'Name'" [value]="probeHost.probe.name"></of-key-value>
<!-- <of-key-value [key]="'OS'" [value]="probeHost.infraHost.infraOS.metaInfraVendor.name"></of-key-value> -->
</div>
<div class="ui-g-12 ui-md-4 ui-key-value">
<of-key-value [key]="'IPv4'" [value]="probeHost.infraHost.ipv4"></of-key-value>
<of-key-value [key]="'Mac Address'" [value]="probeHost.infraHost.mac"></of-key-value>
<!-- <of-key-value [key]="'IPv4'" [value]="probeHost.infraHost.ipv4"></of-key-value> -->
<!-- <of-key-value [key]="'Mac Address'" [value]="probeHost.infraHost.mac"></of-key-value> -->
</div>
</div>
</p-panel>