This commit is contained in:
insanity 2018-06-06 12:19:44 +09:00
parent e367ce3ee3
commit 1bbd827596
4 changed files with 22 additions and 20 deletions

View File

@ -15,7 +15,7 @@
<!-- HOST node template --> <!-- HOST node template -->
<ng-template let-node pTemplate="HOST"> <ng-template let-node pTemplate="HOST">
<div @discoveryResultAnim> <div @discoveryResultAnim>
<div *ngIf="checkHighlight(node.label) else unhighlightHost"> <div *ngIf="checkHighlight(node.label, 0) else unhighlightHost">
<p-toggleButton onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square" [style]="{'width':'200px'}" <p-toggleButton onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square" [style]="{'width':'200px'}"
(onChange)="onTargetSelect($event, node)"></p-toggleButton> (onChange)="onTargetSelect($event, node)"></p-toggleButton>
</div> </div>
@ -30,14 +30,14 @@
<!-- SERVICE node template --> <!-- SERVICE node template -->
<ng-template let-node pTemplate="SERVICE"> <ng-template let-node pTemplate="SERVICE">
<div @discoveryResultAnim> <div @discoveryResultAnim>
<div *ngIf="checkHighligt(node.data.name) else unhighlightServ"> <div *ngIf="checkHighlight(node.data.name, 1) else unhighlightServ">
<p-toggleButton onLabel="{{node.label}} {{node.data.portType}}" offLabel="{{node.label}} {{node.data.portType}} {{node.data.portNumber}}" <p-toggleButton onLabel="{{node.label}} {{node.data.portType}}" offLabel="{{node.label}} {{node.data.portType}} {{node.data.portNumber}}"
onIcon="fa-check" offIcon="fa-square" [style]="{'width':'300px'}" (onChange)="onTargetSelect($event, node.data.target)"></p-toggleButton> onIcon="fa-check" offIcon="fa-square" [style]="{'width':'300px'}" (onChange)="onTargetSelect($event, node)"></p-toggleButton>
</div> </div>
<ng-template #unhighlightServ> <ng-template #unhighlightServ>
<p-toggleButton onLabel="{{node.label}} {{node.data.portType}}" offLabel="{{node.label}} {{node.data.portType}} {{node.data.portNumber}}" <p-toggleButton onLabel="{{node.label}} {{node.data.portType}}" offLabel="{{node.label}} {{node.data.portType}} {{node.data.portNumber}}"
onIcon="fa-check" offIcon="fa-square" [style]="{'width':'300px', 'opacity': '0.2'}" (onChange)="onTargetSelect($event, node.data.target)"></p-toggleButton> onIcon="fa-check" offIcon="fa-square" [style]="{'width':'300px', 'opacity': '0.2'}" (onChange)="onTargetSelect($event, node)"></p-toggleButton>
</ng-template> </ng-template>
</div> </div>

View File

@ -8,22 +8,22 @@ import {
} from '@angular/core'; } from '@angular/core';
import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators'; import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators';
import { Subscription, Observable, of } from 'rxjs'; import { Subscription, Observable, of } from 'rxjs';
import { DiscoverZone, Zone, Host, Port, Service } from '@overflow/commons-typescript/model/discovery'; import { DiscoverZone, Zone, Host, Port, Service } from '@overflow/commons-typescript/model/discovery';
import { TreeNode, Message, Tree } from 'primeng/primeng'; import { TreeNode, Message, Tree } from 'primeng/primeng';
import { ProbeHost } from '@overflow/commons-typescript/model/probe'; import { ProbeHost } from '@overflow/commons-typescript/model/probe';
import { Anim } from './animation'; import { Anim } from './animation';
import { DiscoveryNotify } from '../subscriber/discovery.subscriber'; import { DiscoveryNotify } from '../subscriber/discovery.subscriber';
import { InfraHost, InfraService } from '@overflow/commons-typescript/model/infra'; import { InfraHost, InfraService } from '@overflow/commons-typescript/model/infra';
import { TargetService } from '../../target/service/target.service'; import { TargetService } from '@overflow/target/service/target.service';
import { Target } from '@overflow/commons-typescript/model/target'; import { Target } from '@overflow/commons-typescript/model/target';
@Component({ @Component({
selector: 'of-discovery-result', selector: 'of-discovery-result',
templateUrl: './search-result.component.html', templateUrl: './search-result.component.html',
animations: Anim animations: Anim,
providers: [
TargetService
]
}) })
export class SearchResultComponent implements OnInit, OnChanges { export class SearchResultComponent implements OnInit, OnChanges {
@ -118,7 +118,8 @@ export class SearchResultComponent implements OnInit, OnChanges {
}); });
} }
onTargetSelect(e, data) { onTargetSelect(e, node: TreeNode) {
const data = node.data.target;
if (e.checked) { if (e.checked) {
this.selectedItems.push(data); this.selectedItems.push(data);
} else { } else {
@ -171,12 +172,12 @@ export class SearchResultComponent implements OnInit, OnChanges {
}); });
} }
checkHighlight(label: string) { checkHighlight(label: string, type: number) {
let highlight = true; let highlight = true;
if (this.filterWord && (label.toUpperCase().indexOf(this.filterWord.toUpperCase()) < 0)) { if (this.filterWord && (label.toUpperCase().indexOf(this.filterWord.toUpperCase()) < 0)) {
highlight = false; highlight = false;
} }
if (this.filterServices[label] === false) { if (type === 1 && this.filterServices[label] === false) {
highlight = false; highlight = false;
} }
return highlight; return highlight;
@ -184,7 +185,6 @@ export class SearchResultComponent implements OnInit, OnChanges {
saveTargets() { saveTargets() {
console.log(this.selectedItems);
const hosts: Host[] = []; const hosts: Host[] = [];
const services: Service[] = []; const services: Service[] = [];
this.selectedItems.forEach(value => { this.selectedItems.forEach(value => {
@ -194,6 +194,8 @@ export class SearchResultComponent implements OnInit, OnChanges {
services.push(value); services.push(value);
} }
}); });
this.targetService.registDiscoveredTargets(this.probeHost.probe.id, null, null); console.log(hosts);
console.log(services);
this.targetService.registDiscoveredTargets(this.probeHost.probe.id, hosts, services);
} }
} }

View File

@ -6,8 +6,8 @@
<of-key-value [key]="'Authorized by'" [value]="probeHost.probe.authorizeMember.name"></of-key-value> <of-key-value [key]="'Authorized by'" [value]="probeHost.probe.authorizeMember.name"></of-key-value>
<!-- ProbeHost 정보 --> <!-- ProbeHost 정보 -->
<of-key-value [key]="'OS'" [value]="probeHost.host.os.vendor.name"></of-key-value> <of-key-value [key]="'OS'" [value]="probeHost.infraHost.infraOS.metaInfraVendor.name"></of-key-value>
<of-key-value [key]="'IPv4'" [value]="probeHost.host.ipv4"></of-key-value> <of-key-value [key]="'IPv4'" [value]="probeHost.infraHost.ipv4"></of-key-value>
<of-key-value [key]="'IPv6'" [value]="probeHost.host.ipv6"></of-key-value> <of-key-value [key]="'IPv6'" [value]="probeHost.infraHost.ipv6"></of-key-value>
<of-key-value [key]="'Mac Address'" [value]="probeHost.mac"></of-key-value> <of-key-value [key]="'Mac Address'" [value]="probeHost.mac"></of-key-value>
</div> </div>

View File

@ -5,10 +5,10 @@
</div> </div>
<div class="ui-g-12 ui-md-4 ui-nopad ui-key-value"> <div class="ui-g-12 ui-md-4 ui-nopad ui-key-value">
<of-key-value [key]="'Name'" [value]="probeHost.probe.displayName"></of-key-value> <of-key-value [key]="'Name'" [value]="probeHost.probe.displayName"></of-key-value>
<of-key-value [key]="'OS'" [value]="probeHost.host.os.vendor.name"></of-key-value> <of-key-value [key]="'OS'" [value]="probeHost.infraHost.infraOS.metaInfraVendor.name"></of-key-value>
</div> </div>
<div class="ui-g-12 ui-md-4 ui-nopad ui-key-value"> <div class="ui-g-12 ui-md-4 ui-nopad ui-key-value">
<of-key-value [key]="'IPv4'" [value]="probeHost.host.ipv4"></of-key-value> <of-key-value [key]="'IPv4'" [value]="probeHost.infraHost.ipv4"></of-key-value>
<of-key-value [key]="'Mac Address'" [value]="probeHost.host.mac"></of-key-value> <of-key-value [key]="'Mac Address'" [value]="probeHost.infraHost.mac"></of-key-value>
</div> </div>
</div> </div>