This commit is contained in:
crusader 2018-09-13 19:40:14 +09:00
parent 79885e9a8c
commit 5f0f49c1be

View File

@ -43,6 +43,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
private zoomBehavior: d3.ZoomBehavior<Element, {}>; private zoomBehavior: d3.ZoomBehavior<Element, {}>;
private discoveryContainerWidth: number; private discoveryContainerWidth: number;
private discoveryContainerHeight: number; private discoveryContainerHeight: number;
private discoveryStartDate: Date;
hosts: Host[]; hosts: Host[];
ports: Port[]; ports: Port[];
@ -389,10 +390,9 @@ export class HomePageComponent implements OnInit, OnDestroy {
zoomToFit(paddingPercent, transitionDuration) { zoomToFit(paddingPercent, transitionDuration) {
const root = d3.select(this.discoveryTargetRef.nativeElement); const root = d3.select(this.discoveryTargetRef.nativeElement);
const bounds = root.node().getBBox(); const bounds = root.node().getBBox();
const parent = root.node().parentElement;
const fullWidth = parent.clientWidth; const fullWidth = this.discoveryContainerWidth;
const fullHeight = parent.clientHeight; const fullHeight = this.discoveryContainerHeight;
const width = bounds.width; const width = bounds.width;
const height = bounds.height; const height = bounds.height;
@ -470,6 +470,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
@RPCSubscriber({ method: 'DiscoveryService.DiscoveryStart' }) @RPCSubscriber({ method: 'DiscoveryService.DiscoveryStart' })
public DiscoveryStart(startDate: Date) { public DiscoveryStart(startDate: Date) {
console.log('DiscoveryStart', startDate); console.log('DiscoveryStart', startDate);
this.discoveryStartDate = startDate;
} }
/** /**
@ -478,6 +479,38 @@ export class HomePageComponent implements OnInit, OnDestroy {
@RPCSubscriber({ method: 'DiscoveryService.DiscoveryStop' }) @RPCSubscriber({ method: 'DiscoveryService.DiscoveryStop' })
public DiscoveryStop(stopDate: Date) { public DiscoveryStop(stopDate: Date) {
console.log('DiscoveryStop', stopDate); console.log('DiscoveryStop', stopDate);
const _millisecond = Math.abs(stopDate.getTime() - this.discoveryStartDate.getTime());
const _seconds = _millisecond / 1000;
const seconds = Math.floor(_seconds % 60);
const _minutes = _seconds / 60;
const minutes = Math.floor(_minutes % 60);
const _hours = _minutes / 60;
const hours = Math.floor(_hours % 24);
const days = Math.floor(_hours / 24);
console.log(`${days}${hours}${minutes}${seconds}`);
let hostCount = 0;
let serviceCount = 0;
this.nodes.forEach((node) => {
switch (node.group) {
case 'host':
hostCount++;
break;
case 'service':
serviceCount++;
break;
default:
break;
}
});
console.log(`Host: ${hostCount}개 Service: ${serviceCount}`);
this.discoveryConfigService.setStarted(false); this.discoveryConfigService.setStarted(false);
this.simulationRestart(true); this.simulationRestart(true);
this.zoomToFit(0.95, 500); this.zoomToFit(0.95, 500);