discovery result modified

This commit is contained in:
crusader 2018-09-28 15:13:12 +09:00
parent 316b2d033d
commit dd15424eec
2 changed files with 64 additions and 10 deletions

View File

@ -68,15 +68,15 @@
</g>
</g>
</svg>
<p-card class="ui-map-info" *ngIf="resultMsg">
<p-card class="ui-map-info" *ngIf="discoveryResult">
<div class="ui-map-info-row ui-border-bottom">
<div>Total Hosts: </div>{{resultMsg[0]}}
<div>Total Hosts: </div>{{discoveryResult.totalHosts}}
</div>
<div class="ui-map-info-row ui-border-bottom">
<div>Total Services: </div>{{resultMsg[1]}}
<div>Total Services: </div>{{discoveryResult.totalServices}}
</div>
<div class="ui-map-info-row">
<div>Elapsed: </div>{{resultMsg[2]}}
<div>Elapsed: </div>{{discoveryResult.elapsedTime}}
</div>
</p-card>

View File

@ -20,6 +20,52 @@ import { Node } from '../../../commons/model/node';
import { Link } from '../../../commons/model/link';
export class DiscoveryResult {
totalHosts: number;
totalServices: number;
elapsedTime: string;
hTimer: any;
constructor() {
this.totalHosts = 0;
this.totalServices = 0;
this.elapsedTime = '00:00:00';
}
start() {
const __this = this;
const startTime = new Date().getTime();
this.hTimer = setInterval(function () {
// Get todays date and time
const now = new Date().getTime();
// Find the distance between now and the count down date
const distance = now - startTime;
// Time calculations for days, hours, minutes and seconds
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
__this.elapsedTime = hours + ':' + minutes + ':' + seconds;
}, 1000);
}
stop(elapsedTime: string) {
clearInterval(this.hTimer);
this.elapsedTime = elapsedTime;
}
increaseHost() {
this.totalHosts++;
}
increaseService() {
this.totalServices++;
}
}
@Component({
selector: 'app-pages-home',
templateUrl: './home-page.component.html',
@ -58,7 +104,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
discoveryRequestID: string | null;
hosts: Map<string, Host>;
ports: Map<string, Map<number, Port>>;
resultMsg: string[];
discoveryResult: DiscoveryResult;
private preventBrowserCloseSubject: Subject<void>;
private preventBrowserCloseSubscription: Subscription;
@ -103,6 +149,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
this.discoveryRequestID = null;
this.preventBrowserCloseSubject = new Subject<void>();
this.discoveryResult = null;
}
ngOnInit() {
@ -187,7 +234,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
console.log(this.discoverHost);
console.log('########################################################');
this.resultMsg = null;
this.discoveryResult = new DiscoveryResult();
this.showIntro = false;
this.changeDetector.detectChanges();
@ -630,6 +677,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
public DiscoveryStart(startDate: Date) {
console.log('DiscoveryStart', startDate);
this.discoveryStartDate = startDate;
this.discoveryResult.start();
}
/**
@ -677,10 +726,11 @@ export class HomePageComponent implements OnInit, OnDestroy {
this.simulationRestart(true);
this.zoomToFit(0.95, 500);
this.resultMsg = [];
this.resultMsg.push(hostCount + '');
this.resultMsg.push(serviceCount + '');
this.resultMsg.push(hours + ':' + minutes + ':' + seconds);
this.discoveryResult.stop(hours + ':' + minutes + ':' + seconds);
// this.resultMsg = [];
// this.resultMsg.push(hostCount + '');
// this.resultMsg.push(serviceCount + '');
// this.resultMsg.push(hours + ':' + minutes + ':' + seconds);
this.stopping = false;
}
@ -738,6 +788,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
this.nodes.push(hostNode);
this.links.push(new Link(this.zoneNode, hostNode));
this.discoveryResult.increaseHost();
}
this.simulationRestart();
@ -784,6 +836,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
this.nodes.push(serviceNode);
this.links.push(new Link(hostNode, serviceNode));
this.discoveryResult.increaseService();
}
this.simulationRestart();