This commit is contained in:
crusader 2018-09-19 14:04:53 +09:00
parent 778fe832c7
commit ddaec79ab6
5 changed files with 57 additions and 20 deletions

View File

@ -30,6 +30,7 @@
"src/assets"
],
"styles": [
"node_modules/primeicons/primeicons.css",
"node_modules/primeng/resources/primeng.min.css",
"src/styles.scss"
],

View File

@ -74,6 +74,7 @@
"karma-jasmine": "~1.1.1",
"ngrx-store-freeze": "^0.2.4",
"npm-run-all": "^4.1.3",
"primeicons": "^1.0.0-beta.10",
"primeng": "^6.1.3",
"primer-support": "^4.0.0",
"protractor": "~5.3.0",

View File

@ -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>

View File

@ -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();
}
/**

View File

@ -6005,6 +6005,10 @@ pretty-error@^2.0.2:
renderkid "^2.0.1"
utila "~0.4"
primeicons@^1.0.0-beta.10:
version "1.0.0-beta.10"
resolved "https://nexus.loafle.net/repository/npm-all/primeicons/-/primeicons-1.0.0-beta.10.tgz#b1a27a8a279c0b28d4bd537a29709b39cfebbd9f"
primeng@^6.1.3:
version "6.1.3"
resolved "https://nexus.loafle.net/repository/npm-all/primeng/-/primeng-6.1.3.tgz#720590da9e671fd47de15911636d1c0a7a442852"