ing
This commit is contained in:
@@ -80,6 +80,8 @@
|
||||
</p-card>
|
||||
</div>
|
||||
|
||||
<p-confirmDialog></p-confirmDialog>
|
||||
|
||||
<p-sidebar [(visible)]="displaySidebar" styleClass="ui-sidebar-md" position="right" (onHide)="onHideDetail()">
|
||||
<div *ngIf="selectedNode !== null">
|
||||
<app-node-detail [node]="selectedNode" (otherHostSelect)="otherHostSelected($event)"></app-node-detail>
|
||||
|
||||
@@ -1,27 +1,34 @@
|
||||
|
||||
import { Component, OnInit, OnDestroy, ViewChild, ElementRef, ChangeDetectorRef, HostListener } from '@angular/core';
|
||||
|
||||
|
||||
import { ProbeService, requesterID } from '../../../commons/service/probe.service';
|
||||
|
||||
import { Zone, Host, Port, Service, DiscoverHost } from '@overflow/model/discovery';
|
||||
|
||||
import { RPCSubscriber } from '@overflow/commons/ui/decorator/RPCSubscriber';
|
||||
import { DiscoveryConfigService } from '../../../commons/service/discovery-config.service';
|
||||
import { Subject, Subscription, of } from 'rxjs';
|
||||
import { map, catchError, take } from 'rxjs/operators';
|
||||
|
||||
import * as d3 from 'd3';
|
||||
import { Node } from '../../../commons/model/node';
|
||||
import { Link } from '../../../commons/model/link';
|
||||
|
||||
import { ConfirmationService } from 'primeng/primeng';
|
||||
|
||||
import { Zone, Host, Port, Service, DiscoverHost } from '@overflow/model/discovery';
|
||||
import { RPCSubscriber } from '@overflow/commons/ui/decorator/RPCSubscriber';
|
||||
import { TypeUtil } from '@overflow/core-js';
|
||||
import { RPCError } from '@overflow/rpc-js';
|
||||
import { toMetaIPType, MetaIPTypeEnum, toMetaCryptoType, MetaCryptoTypeEnum, toMetaPortType, MetaPortTypeEnum } from '@overflow/model/meta';
|
||||
import { DiscoveryModeType } from '@overflow/model/discovery/discovery';
|
||||
import { PingResult } from '@overflow/model/ping';
|
||||
|
||||
import { ProbeService, requesterID } from '../../../commons/service/probe.service';
|
||||
import { DiscoveryConfigService } from '../../../commons/service/discovery-config.service';
|
||||
import { Node } from '../../../commons/model/node';
|
||||
import { Link } from '../../../commons/model/link';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-pages-home',
|
||||
templateUrl: './home-page.component.html',
|
||||
styleUrls: ['./home-page.component.scss'],
|
||||
providers: [
|
||||
ConfirmationService,
|
||||
],
|
||||
})
|
||||
export class HomePageComponent implements OnInit, OnDestroy {
|
||||
|
||||
@@ -45,15 +52,16 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||
private zoomBehavior: d3.ZoomBehavior<Element, {}>;
|
||||
private discoveryContainerWidth: number;
|
||||
private discoveryContainerHeight: number;
|
||||
private discoveryStartDate: Date;
|
||||
private discoveryRequestID: string | null;
|
||||
private readonly maxScale: number;
|
||||
private readonly minScale: number;
|
||||
|
||||
private discoveryStartDate: Date;
|
||||
private discoveryRequestID: string | null;
|
||||
hosts: Map<string, Host>;
|
||||
ports: Map<string, Map<number, Port>>;
|
||||
|
||||
resultMsg: string[];
|
||||
private preventBrowserCloseSubject: Subject<void>;
|
||||
private preventBrowserCloseSubscription: Subscription;
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
onResize(event) {
|
||||
@@ -69,11 +77,11 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
@HostListener('window:beforeunload', ['$event'])
|
||||
onBeforeUnload(event) {
|
||||
onBeforeUnload($event: Event) {
|
||||
if (null !== this.discoveryRequestID) {
|
||||
this.probeService.send('DiscoveryService.DiscoverStop', requesterID, this.discoveryRequestID);
|
||||
this.preventBrowserCloseSubject.next();
|
||||
$event.returnValue = true;
|
||||
}
|
||||
// event.returnValue = true;
|
||||
}
|
||||
|
||||
@ViewChild('discoveryTarget') set discoveryTarget(content: ElementRef) {
|
||||
@@ -82,18 +90,20 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
private changeDetector: ChangeDetectorRef,
|
||||
private confirmationService: ConfirmationService,
|
||||
private probeService: ProbeService,
|
||||
private discoveryConfigService: DiscoveryConfigService,
|
||||
) {
|
||||
this.nodes = [];
|
||||
this.links = [];
|
||||
this.maxScale = 1;
|
||||
this.minScale = 0.7;
|
||||
|
||||
this.hosts = new Map();
|
||||
this.ports = new Map();
|
||||
|
||||
this.discoveryRequestID = null;
|
||||
|
||||
this.maxScale = 1;
|
||||
this.minScale = 0.7;
|
||||
this.preventBrowserCloseSubject = new Subject<void>();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -114,10 +124,31 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
});
|
||||
this.preventBrowserCloseSubscription = this.preventBrowserCloseSubject
|
||||
.pipe(
|
||||
map(() => {
|
||||
this.confirmationService.confirm({
|
||||
message: 'Discovery is in progress.',
|
||||
header: 'Alert',
|
||||
icon: 'pi pi-info-circle',
|
||||
acceptLabel: 'Yes',
|
||||
acceptVisible: true,
|
||||
rejectVisible: false,
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
console.log(error);
|
||||
alert('An error has occurred.');
|
||||
return of();
|
||||
}),
|
||||
take(1)
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.probeService.unsubscribeNotification(this);
|
||||
this.preventBrowserCloseSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
blockDocument() {
|
||||
@@ -635,8 +666,6 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||
this.resultMsg.push(hostCount + '');
|
||||
this.resultMsg.push(serviceCount + '');
|
||||
this.resultMsg.push(hours + ':' + minutes + ':' + seconds);
|
||||
|
||||
// this.simulation.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user