discovery
This commit is contained in:
parent
b37da1441d
commit
0f6057e765
|
@ -23,21 +23,18 @@
|
|||
[style]="{'width':'200px'}" (onChange)="onTargetSelect($event, node)"></p-toggleButton> {{node.data.date | date: 'yy/MM/dd'}}
|
||||
</div>
|
||||
|
||||
<!-- 새로 Discovery된 Host -->
|
||||
<div *ngIf="!node.data.date" @discoveryResultAnim>
|
||||
<p-toggleButton onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square" [style]="{'width':'200px'}"
|
||||
(onChange)="onTargetSelect($event, node)"></p-toggleButton> New!!
|
||||
</div>
|
||||
<!-- <div @discoveryResultAnim>
|
||||
<div *ngIf="checkHighlight(node.label, 0) else unhighlightHost">
|
||||
<p-toggleButton [disabled]="checkExistTarget(node.data.target)" onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check"
|
||||
offIcon="fa-square" [style]="{'width':'200px'}" (onChange)="onTargetSelect($event, node)"></p-toggleButton>
|
||||
<p-toggleButton onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square" [style]="{'width':'200px'}"
|
||||
(onChange)="onTargetSelect($event, node)"></p-toggleButton> New!!
|
||||
</div>
|
||||
|
||||
<ng-template #unhighlightHost>
|
||||
<p-toggleButton [disabled]="checkExistTarget(node.data.target)" onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check"
|
||||
offIcon="fa-square" [style]="{'width':'200px', 'opacity': '0.2'}" (onChange)="onTargetSelect($event, node)"></p-toggleButton>
|
||||
<p-toggleButton onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square" [style]="{'width':'200px', 'opacity':'0.2'}"
|
||||
(onChange)="onTargetSelect($event, node)"></p-toggleButton> New!!
|
||||
</ng-template>
|
||||
</div> -->
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<!-- SERVICE node template -->
|
||||
|
@ -45,24 +42,21 @@
|
|||
<!-- 이미 저장된 Infra인 Node-->
|
||||
<div *ngIf="node.data.date">
|
||||
<p-toggleButton [disabled]="node.data.target" onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square"
|
||||
[style]="{'width':'400px'}" (onChange)="onTargetSelect($event, node)"></p-toggleButton> {{node.data.date | date: 'yy/MM/dd'}}
|
||||
[style]="{'width':'200px'}" (onChange)="onTargetSelect($event, node)"></p-toggleButton> {{node.data.date | date: 'yy/MM/dd'}}
|
||||
</div>
|
||||
|
||||
<!-- 새로 Discovery된 Service -->
|
||||
<div *ngIf="!node.data.date" @discoveryResultAnim>
|
||||
<p-toggleButton onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square" [style]="{'width':'200px'}"
|
||||
(onChange)="onTargetSelect($event, node)"></p-toggleButton> New!!
|
||||
</div>
|
||||
<!-- <div @discoveryResultAnim>
|
||||
<div *ngIf="checkHighlight(node.data.name, 1) else unhighlightServ">
|
||||
<p-toggleButton [disabled]="checkExistTarget(node.data.target)" 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)"></p-toggleButton>
|
||||
<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'}"
|
||||
(onChange)="onTargetSelect($event, node)"></p-toggleButton> New!!
|
||||
</div>
|
||||
|
||||
<ng-template #unhighlightServ>
|
||||
<p-toggleButton [disabled]="checkExistTarget(node.data.target)" 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)"></p-toggleButton>
|
||||
<ng-template #unhighlightHost>
|
||||
<p-toggleButton onLabel="{{node.label}}" offLabel="{{node.label}}" onIcon="fa-check" offIcon="fa-square" [style]="{'width':'200px', 'opacity':'0.2'}"
|
||||
(onChange)="onTargetSelect($event, node)"></p-toggleButton> New!!
|
||||
</ng-template>
|
||||
</div> -->
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-tree>
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@ import {
|
|||
SimpleChanges,
|
||||
} from '@angular/core';
|
||||
import { Host, Service } from '@overflow/commons-typescript/model/discovery';
|
||||
import { TreeNode, Message, Tree } from 'primeng/primeng';
|
||||
import { TreeNode, Message } 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, Infra, MetaInfraTypeEnum, toMetaInfraTypeEnum, toMetaInfraType, InfraZone, Target, Page, PageParams } from '@overflow/commons-typescript';
|
||||
import { InfraService, InfraHost, Infra, MetaInfraTypeEnum, toMetaInfraType, InfraZone, Target, Page, PageParams } from '@overflow/commons-typescript';
|
||||
import { InfraService as InfraManageService } from '../../infra/service/infra.service';
|
||||
import { Observable, of, Subscription } from 'rxjs';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { catchError, map, tap, take } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
|
@ -62,19 +62,13 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
}
|
||||
|
||||
getInfras() {
|
||||
const pageParams: PageParams = {
|
||||
pageNo: 0,
|
||||
countPerPage: 99999,
|
||||
sortCol: 'id',
|
||||
sortDirection: 'descending'
|
||||
};
|
||||
this.infraManageService.readAllByProbeID(this.probeHost.probe.id, pageParams)
|
||||
this.infraManageService.readAllByProbeID(this.probeHost.probe.id)
|
||||
.pipe(
|
||||
tap(() => {
|
||||
this.pending$ = of(true);
|
||||
}),
|
||||
map((infraPage: Page<Infra>) => {
|
||||
this.generateTree(infraPage.content);
|
||||
map((infras: Infra[]) => {
|
||||
this.generateTree(infras);
|
||||
}),
|
||||
catchError(error => {
|
||||
this.error$ = of(error);
|
||||
|
@ -88,19 +82,13 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
}
|
||||
|
||||
getTargets() {
|
||||
const pageParams: PageParams = {
|
||||
pageNo: 0,
|
||||
countPerPage: 99999,
|
||||
sortCol: 'id',
|
||||
sortDirection: 'descending'
|
||||
};
|
||||
this.targetService.readAllByProbeID(this.probeHost.probe.id, pageParams)
|
||||
this.targetService.readAllByProbeID(this.probeHost.probe.id)
|
||||
.pipe(
|
||||
tap(() => {
|
||||
this.pending$ = of(true);
|
||||
}),
|
||||
map((targetPage: Page<Target>) => {
|
||||
this.targets = targetPage.content;
|
||||
map((targets: Target[]) => {
|
||||
this.targets = targets;
|
||||
this.getInfras();
|
||||
}),
|
||||
catchError(error => {
|
||||
|
@ -177,13 +165,12 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
}
|
||||
|
||||
addInfraService(infraService: InfraService) {
|
||||
console.log(infraService);
|
||||
const target: Target = this.checkAlreadyTarget(infraService.id);
|
||||
const targetHostNode = this.findHostNodeByService(infraService.infraHostPort.infraHostIP.address);
|
||||
// const idx = this.findServiceIndex(targetHostNode.children, infraService.metaTargetServiceType.name);
|
||||
targetHostNode.children.push({
|
||||
const idx = this.findServiceIndex(targetHostNode.children, infraService.metaTargetServiceType.name);
|
||||
targetHostNode.children.splice(idx, 0, {
|
||||
type: 'SERVICE',
|
||||
label: 'metaTargetServiceType이 현재 null ' + ' (' + infraService.infraHostPort.port + ')',
|
||||
label: infraService.metaTargetServiceType.name + ' (' + infraService.infraHostPort.port + ')',
|
||||
data: {
|
||||
target: target,
|
||||
date: infraService.createDate,
|
||||
|
@ -191,6 +178,7 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
portNumber: infraService.infraHostPort.port,
|
||||
object: infraService,
|
||||
infraID: infraService.id,
|
||||
name: infraService.metaTargetServiceType.name
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -273,7 +261,7 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
addService(service: Service) {
|
||||
let exist = false;
|
||||
this.infraServices.forEach(infraService => {
|
||||
if (//infraService.metaTargetServiceType.name === service.name &&
|
||||
if (infraService.metaTargetServiceType.name === service.name &&
|
||||
infraService.infraHostPort.port === service.port.portNumber &&
|
||||
infraService.infraHostPort.infraHostIP.address === service.port.host.address
|
||||
) {
|
||||
|
@ -286,8 +274,8 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
}
|
||||
|
||||
const targetHostNode = this.findHostNodeByService(service.port.host.address);
|
||||
// const idx = this.findServiceIndex(targetHostNode.children, infraService.metaTargetServiceType.name);
|
||||
targetHostNode.children.push({
|
||||
const idx = this.findServiceIndex(targetHostNode.children, service.name);
|
||||
targetHostNode.children.splice(idx, 0, {
|
||||
type: 'SERVICE',
|
||||
label: service.name + ' (' + service.port.portNumber + ')',
|
||||
data: {
|
||||
|
@ -297,6 +285,7 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
portNumber: service.port.portNumber,
|
||||
object: service,
|
||||
InfraID: null,
|
||||
name: service.name
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -314,12 +303,9 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
return index;
|
||||
}
|
||||
|
||||
findServiceIndex(serviceNodes: TreeNode[], serviceName: string) {
|
||||
findServiceIndex(serviceNodes: TreeNode[], serviceName: string): number {
|
||||
let index = 0;
|
||||
serviceNodes.forEach(node => {
|
||||
// if (node.data.portNumber < service.port.portNumber) {
|
||||
// index++;
|
||||
// }
|
||||
if (node.data.name.toUpperCase().localeCompare(serviceName.toUpperCase()) === -1) {
|
||||
index++;
|
||||
}
|
||||
|
@ -327,7 +313,7 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
return index;
|
||||
}
|
||||
|
||||
findHostNodeByService(serviceAddress: string) {
|
||||
findHostNodeByService(serviceAddress: string): TreeNode {
|
||||
let targetHost = null;
|
||||
this.hostNode.forEach((value, i) => {
|
||||
if (value.data.ip === this.convertIPtoNumber(serviceAddress)) {
|
||||
|
@ -338,7 +324,7 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
return targetHost;
|
||||
}
|
||||
|
||||
convertIPtoNumber(ip: string) {
|
||||
convertIPtoNumber(ip: string): number {
|
||||
return ip.split('.').map((octet, index, array) => {
|
||||
return parseInt(octet) * Math.pow(256, (array.length - index - 1));
|
||||
}).reduce((prev, curr) => {
|
||||
|
@ -369,52 +355,52 @@ export class DiscoveryInfraTreeComponent implements OnChanges {
|
|||
saveTargets() {
|
||||
const targets: Target[] = [];
|
||||
this.selectedItems.forEach(node => {
|
||||
const infraID = node.data.infraID;
|
||||
if (null === infraID) { // 새로 발견된 Host / Service
|
||||
|
||||
let infraID = node.data.infraID;
|
||||
if (null === infraID) { // 새로 발견된 Host or Service
|
||||
for (const infra of this.savedInfras) {
|
||||
if (infra.metaInfraType.key === toMetaInfraType(MetaInfraTypeEnum.HOST).key) {
|
||||
const infraHost: InfraHost = infra;
|
||||
const host: Host = node.data.object;
|
||||
if (infraHost.infraHostIPs[0].address === host.address) {
|
||||
infraID = infraHost.id;
|
||||
}
|
||||
} else if (infra.metaInfraType.key === toMetaInfraType(MetaInfraTypeEnum.SERVICE).key) {
|
||||
const infraService: InfraService = infra;
|
||||
const service: Service = node.data.object;
|
||||
if (infraService.metaTargetServiceType.name === service.name &&
|
||||
infraService.infraHostPort.infraHostIP.address === service.port.host.address) {
|
||||
infraID = infraService.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// const infra: Infra = value;
|
||||
// let name: string;
|
||||
// if (value.metaInfraType === toMetaInfraType(MetaInfraTypeEnum.ZONE)) {
|
||||
// const infraZone: InfraZone = value;
|
||||
// name = infraZone.network;
|
||||
// } else if (value.metaInfraType === toMetaInfraType(MetaInfraTypeEnum.HOST)) {
|
||||
// const infraHost: InfraHost = value;
|
||||
// name = infraHost.infraHostIPs[0].address;
|
||||
// } else if (value.metaInfraType === toMetaInfraType(MetaInfraTypeEnum.SERVICE)) {
|
||||
// const infraService: InfraService = value;
|
||||
// name = infraService.metaInfraType.name;
|
||||
// }
|
||||
|
||||
const target: Target = {
|
||||
infra: {
|
||||
id: infraID
|
||||
},
|
||||
name: '',
|
||||
name: node.label,
|
||||
sensorCount: 0,
|
||||
};
|
||||
targets.push(target);
|
||||
});
|
||||
|
||||
console.log(targets);
|
||||
|
||||
// this.targetService.registAll(targets, this.probeHost.probe.id)
|
||||
// .pipe(
|
||||
// tap(() => {
|
||||
// }),
|
||||
// map((targets: Target[]) => {
|
||||
// if (targets) {
|
||||
// this.targetSaved = true;
|
||||
// }
|
||||
// }),
|
||||
// catchError(error => {
|
||||
// this.error$ = of(error);
|
||||
// return of();
|
||||
// }),
|
||||
// tap(() => {
|
||||
// }),
|
||||
// take(1),
|
||||
// ).subscribe();
|
||||
this.targetService.registAll(targets, this.probeHost.probe.id)
|
||||
.pipe(
|
||||
tap(() => {
|
||||
}),
|
||||
map((targets: Target[]) => {
|
||||
if (targets) {
|
||||
this.targetSaved = true;
|
||||
}
|
||||
}),
|
||||
catchError(error => {
|
||||
this.error$ = of(error);
|
||||
return of();
|
||||
}),
|
||||
tap(() => {
|
||||
}),
|
||||
take(1),
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
|
|||
import { Observable } from 'rxjs';
|
||||
import { RPCService } from '@loafer/ng-rpc';
|
||||
import { Infra } from '@overflow/commons-typescript/model/infra';
|
||||
import { Page, PageParams } from '@overflow/commons-typescript/core/model';
|
||||
import { Host, Service } from '@overflow/commons-typescript';
|
||||
import { gzip } from 'pako';
|
||||
|
||||
|
@ -37,12 +36,12 @@ export class InfraService {
|
|||
return this.rpcService.call<Infra>('InfraService.read', id);
|
||||
}
|
||||
|
||||
public readAllByProbeID(probeID: number, pageParams: PageParams): Observable<Page<Infra>> {
|
||||
return this.rpcService.call<Page<Infra>>('InfraService.readAllByProbeID', probeID, pageParams);
|
||||
public readAllByProbeID(probeID: number): Observable<Infra[]> {
|
||||
return this.rpcService.call<Infra[]>('InfraService.readAllByProbeID', probeID);
|
||||
}
|
||||
|
||||
public readAllByDomainID(domainID: number, pageParams: PageParams): Observable<Page<Infra>> {
|
||||
return this.rpcService.call<Page<Infra>>('InfraService.readAllByDomainID', domainID, pageParams);
|
||||
public readAllByDomainID(domainID: number): Observable<Infra[]> {
|
||||
return this.rpcService.call<Infra[]>('InfraService.readAllByDomainID', domainID);
|
||||
}
|
||||
|
||||
public readAllInfraZoneByProbeDomainID(probeDomainID: number): Observable<Infra[]> {
|
||||
|
|
Loading…
Reference in New Issue
Block a user