This commit is contained in:
insanity 2018-09-12 20:18:38 +09:00
parent 82532dad3f
commit bab2dbfb94
6 changed files with 57 additions and 13 deletions

View File

@ -11,4 +11,6 @@ export interface Zone {
meta?: Map<string, Map<string, string>>; meta?: Map<string, Map<string, string>>;
discoveredBy?: string[]; discoveredBy?: string[];
discoveredDate?: Date; discoveredDate?: Date;
hostList?: Host[];
} }

View File

@ -5,7 +5,6 @@ import { Component, OnInit, OnDestroy, ViewChild, ElementRef, ChangeDetectorRef
import { ProbeService, requesterID } from '../../../commons/service/probe.service'; import { ProbeService, requesterID } from '../../../commons/service/probe.service';
import { Zone, Host, Port, Service, DiscoverHost } from '@overflow/model/discovery'; import { Zone, Host, Port, Service, DiscoverHost } from '@overflow/model/discovery';
import { toMetaIPType, MetaIPTypeEnum } from '@overflow/model/meta';
import { RPCSubscriber } from '@overflow/commons/ui/decorator/RPCSubscriber'; import { RPCSubscriber } from '@overflow/commons/ui/decorator/RPCSubscriber';
import { DiscoveryConfigService } from '../../../commons/service/discovery-config.service'; import { DiscoveryConfigService } from '../../../commons/service/discovery-config.service';
@ -45,6 +44,9 @@ export class HomePageComponent implements OnInit, OnDestroy {
private links: Link[]; private links: Link[];
public simulation: d3.Simulation<Node, Link> | undefined; public simulation: d3.Simulation<Node, Link> | undefined;
hosts: Host[];
ports: Port[];
constructor( constructor(
private changeDetector: ChangeDetectorRef, private changeDetector: ChangeDetectorRef,
private probeService: ProbeService, private probeService: ProbeService,
@ -52,6 +54,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
) { ) {
this.nodes = []; this.nodes = [];
this.links = []; this.links = [];
this.hosts = [];
this.ports = [];
} }
ngOnInit() { ngOnInit() {
@ -245,8 +249,30 @@ export class HomePageComponent implements OnInit, OnDestroy {
onTargetClick(node: Node) { onTargetClick(node: Node) {
console.log(node); console.log(node);
this.displaySidebar = true; this.displaySidebar = true;
switch (node.group) {
case 'zone':
var zone: Zone = node.target;
zone.hostList = [];
this.hosts.forEach(host => {
if (host.zone.network === zone.network) {
zone.hostList.push(host);
}
});
break;
case 'host':
var host: Host = node.target;
host.portList = [];
this.ports.forEach(port => {
if (port.host.address === host.address) {
host.portList.push(port);
}
});
break;
default:
break;
}
this.selectedNode = node; this.selectedNode = node;
} }
@ -307,6 +333,17 @@ export class HomePageComponent implements OnInit, OnDestroy {
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredHost' }) @RPCSubscriber({ method: 'DiscoveryService.DiscoveredHost' })
public DiscoveredHost(host: Host) { public DiscoveredHost(host: Host) {
console.log('DiscoveredHost', host); console.log('DiscoveredHost', host);
var dup = false;
this.hosts.forEach((item) => {
if (item.address === host.address) {
dup = true;
return;
}
});
if (!dup) {
this.hosts.push(host);
}
const hostId = `${host.address}`; const hostId = `${host.address}`;
const zoneNode = this.getNode('192.168.1.0/24'); const zoneNode = this.getNode('192.168.1.0/24');
@ -334,6 +371,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredPort' }) @RPCSubscriber({ method: 'DiscoveryService.DiscoveredPort' })
public DiscoveredPort(port: Port) { public DiscoveredPort(port: Port) {
console.log('DiscoveredPort', port); console.log('DiscoveredPort', port);
this.ports.push(port);
} }
/** /**

View File

@ -65,6 +65,11 @@
</p-tabPanel> </p-tabPanel>
<p-tabPanel header="Ports" *ngIf="host.portList"> <p-tabPanel header="Ports" *ngIf="host.portList">
<p-listbox [options]="ports" [(ngModel)]="selectedPort" optionLabel="name"></p-listbox> <ul class="key-value">
<li *ngFor="let port of host.portList">
<span class="meta-value">{{port.portNumber}} ({{port.metaPortType.key}})</span>
</li>
</ul>
</p-tabPanel> </p-tabPanel>
</p-tabView> </p-tabView>
</div>

View File

@ -10,9 +10,6 @@ import { Host, Port } from '@overflow/model/discovery';
export class HostDetailComponent { export class HostDetailComponent {
@Input() host: Host; @Input() host: Host;
ports: Port[];
selectedPort: Port;
discoveredBy: string;
constructor( constructor(
) { ) {

View File

@ -45,10 +45,14 @@
</ul> </ul>
</p-tabPanel> <p-tabPanel header="Hosts">
<p-tabPanel header="Host"> <ul class="key-value">
<p-listbox [options]="hosts" [(ngModel)]="selectedHost" optionLabel="name"></p-listbox> <li *ngFor="let host of zone.hostList">
</p-tabPanel> <span class="meta-value">{{host.address}}</span> <span *ngIf="host.name" class="meta-value">
({{host.name}})</span>
</li>
</ul>
</p-tabPanel>
</p-tabView> </p-tabView>
</div> </div>

View File

@ -12,8 +12,6 @@ export class ZoneDetailComponent implements OnInit {
@Input() zone: Zone; @Input() zone: Zone;
ipRange: string; ipRange: string;
hosts: Host[];
selectedHost: Host;
constructor( constructor(
) { ) {