This commit is contained in:
insanity 2018-09-18 21:25:47 +09:00
parent 47c618c936
commit bab8645418
9 changed files with 105 additions and 31 deletions

View File

@ -74,11 +74,38 @@
<p-sidebar [(visible)]="displaySidebar" styleClass="ui-sidebar-md" position="right" (onHide)="onHideDetail()"> <p-sidebar [(visible)]="displaySidebar" styleClass="ui-sidebar-md" position="right" (onHide)="onHideDetail()">
<div *ngIf="selectedNode !== null"> <div *ngIf="selectedNode !== null">
<app-node-detail [node]="selectedNode" (otherHostSelect)="otherHostSelected($event)"></app-node-detail> <app-node-detail [node]="selectedNode" (otherHostSelect)="otherHostSelected($event)" (ping)="displayPing($event)"></app-node-detail>
</div> </div>
</p-sidebar> </p-sidebar>
<p-dialog header="Ping" [(visible)]="pingDisplay" [modal]="true" [responsive]="true" [width]="350" [minWidth]="200"
[minY]="70" [maximizable]="true" [baseZIndex]="10000">
<div *ngIf="pingResult">
<ul>
<li *ngFor="let key of pingResult.responses | objectKeys">
<span *ngIf="pingResult.responses[key].error else value">
{{pingResult.responses[key].error}}
</span>
<ng-template #value>
TTL={{pingResult.responses[key].ttl}} : {{pingResult.responses[key].time}}ms
</ng-template>
</li>
</ul>
</div>
<div *ngIf="pingResult">
<span>Sent: {{pingResult.summary.sendCount || '-'}}</span><br />
<span>Received: {{pingResult.summary.receiveCount || '-'}}</span><br />
<span>Loss: {{pingResult.summary.lossPercent || '-'}} %</span><br />
<span>Avg: {{pingResult.summary.avgTime || '-'}} ms</span><br />
<span>Min: {{pingResult.summary.minTime || '-'}} ms</span><br />
<span>Min: {{pingResult.summary.maxTime || '-'}} ms</span>
</div>
<p-footer>
<button type="button" pButton icon="pi pi-check" (click)="pingDisplay=false" label="Close"></button>
</p-footer>
</p-dialog>
<!-- <div class="ui-fluid"> <!-- <div class="ui-fluid">
<div class="ui-g"> <div class="ui-g">
<div class="ui-g-12"> <div class="ui-g-12">

View File

@ -15,8 +15,8 @@ import { Link } from '../../../commons/model/link';
import { RPCError } from '@overflow/rpc-js'; import { RPCError } from '@overflow/rpc-js';
import { toMetaIPType, MetaIPTypeEnum, toMetaCryptoType, MetaCryptoTypeEnum } from '@overflow/model/meta'; import { toMetaIPType, MetaIPTypeEnum, toMetaCryptoType, MetaCryptoTypeEnum } from '@overflow/model/meta';
import { Message } from 'primeng/primeng';
import { DiscoveryModeType } from '@overflow/model/discovery/discovery'; import { DiscoveryModeType } from '@overflow/model/discovery/discovery';
import { PingResult } from '@overflow/model/ping';
@Component({ @Component({
selector: 'app-pages-home', selector: 'app-pages-home',
@ -54,6 +54,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
ports: Map<string, Map<number, Port>>; ports: Map<string, Map<number, Port>>;
resultMsg: string[]; resultMsg: string[];
pingDisplay = false;
pingResult: PingResult;
@HostListener('window:resize', ['$event']) @HostListener('window:resize', ['$event'])
onResize(event) { onResize(event) {
@ -117,8 +119,6 @@ export class HomePageComponent implements OnInit, OnDestroy {
} }
ngOnDestroy(): void { ngOnDestroy(): void {
this.probeService.unsubscribeNotification(this); this.probeService.unsubscribeNotification(this);
} }
@ -903,4 +903,15 @@ export class HomePageComponent implements OnInit, OnDestroy {
new Link(hostNode3, serviceNode32), new Link(hostNode3, serviceNode32),
); );
} }
displayPing(pingResult: PingResult) {
console.log(pingResult);
if (pingResult) {
this.pingDisplay = true;
this.pingResult = pingResult;
}
}
} }

View File

@ -19,7 +19,7 @@
</div> </div>
<p-tabView class="detail-content"> <p-tabView class="detail-content">
<button type="button" pButton label="Ping" (click)="ping()" class="ui-button-secondary ui-pingbn-position"></button> <button type="button" pButton label="Ping" (click)="doPing()" class="ui-button-secondary ui-pingbn-position"></button>
<p-tabPanel header="General"> <p-tabPanel header="General">
<ul class="key-value"> <ul class="key-value">

View File

@ -1,7 +1,9 @@
import { Component, Input } from '@angular/core'; import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Host, DiscoverHost } from '@overflow/model/discovery'; import { Host } from '@overflow/model/discovery';
import { ProbeService, requesterID } from '../service/probe.service'; import { ProbeService } from '../service/probe.service';
import { RPCSubscriber } from '@overflow/commons/ui/decorator/RPCSubscriber'; import { map, catchError, take } from 'rxjs/operators';
import { PingResult } from '@overflow/model/ping';
import { of } from 'rxjs';
@Component({ @Component({
@ -12,26 +14,34 @@ import { RPCSubscriber } from '@overflow/commons/ui/decorator/RPCSubscriber';
export class HostDetailComponent { export class HostDetailComponent {
@Input() host: Host; @Input() host: Host;
@Output() ping = new EventEmitter<PingResult>();
constructor( constructor(
private probeService: ProbeService private probeService: ProbeService
) { ) {
} }
ping() { doPing() {
console.log(this.host); const option = {
// const discoverHost: DiscoverHost = { Retry: 3,
// discoveryConfig: {}, Interval: 1,
// metaIPType: this.host.metaIPType, Deadline: 1,
// firstScanRange: this.host.address, };
// lastScanRange: this.host.address,
// discoverPort: null, this.probeService
// }; .call<PingResult>('PingService.PingHost', this.host, option)
// this.probeService.send('DiscoveryService.DiscoverHost', requesterID, this.host.zone, discoverHost); .pipe(
map((pingResult: PingResult) => {
this.ping.emit(pingResult);
}),
catchError(error => {
console.log(error);
alert('An error has occurred.');
return of();
}),
take(1)
)
.subscribe();
} }
// @RPCSubscriber({ method: 'DiscoveryService.DiscoveredHost' })
// public DiscoveredHost(host: Host) {
// console.log(host);
// }
} }

View File

@ -7,11 +7,11 @@
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'host'"> <ng-container *ngSwitchCase="'host'">
<app-host-detail [host]="node.target"></app-host-detail> <app-host-detail [host]="node.target" (ping)="ping.emit($event)"></app-host-detail>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'service'"> <ng-container *ngSwitchCase="'service'">
<app-service-detail [service]="node.target"></app-service-detail> <app-service-detail [service]="node.target" (ping)="ping.emit($event)"></app-service-detail>
</ng-container> </ng-container>
<ng-container *ngSwitchDefault> <ng-container *ngSwitchDefault>

View File

@ -1,4 +1,5 @@
import { Component, Input, Output, Host, EventEmitter } from '@angular/core'; import { Component, Input, Output, Host, EventEmitter } from '@angular/core';
import { PingResult } from '@overflow/model/ping';
@Component({ @Component({
@ -10,6 +11,7 @@ export class NodeDetailComponent {
@Input() node; @Input() node;
@Output() otherHostSelect = new EventEmitter<Host>(); @Output() otherHostSelect = new EventEmitter<Host>();
@Output() ping = new EventEmitter<PingResult>();
constructor( constructor(
) { ) {

View File

@ -21,7 +21,7 @@
<p-tabView class="detail-content"> <p-tabView class="detail-content">
<button type="button" pButton label="Ping" (click)="ping()" class="ui-button-secondary ui-pingbn-position"></button> <button type="button" pButton label="Ping" (click)="doPing()" class="ui-button-secondary ui-pingbn-position"></button>
<p-tabPanel header="General"> <p-tabPanel header="General">
<ul class="key-value"> <ul class="key-value">

View File

@ -1,6 +1,9 @@
import { Component, Input } from '@angular/core'; import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Service } from '@overflow/model/discovery'; import { Service } from '@overflow/model/discovery';
import { PingResult } from '@overflow/model/ping';
import { ProbeService } from '../service/probe.service';
import { map, catchError, take } from 'rxjs/operators';
import { of } from 'rxjs';
@Component({ @Component({
selector: 'app-service-detail', selector: 'app-service-detail',
@ -10,14 +13,35 @@ import { Service } from '@overflow/model/discovery';
export class ServiceDetailComponent { export class ServiceDetailComponent {
@Input() service: Service; @Input() service: Service;
@Output() ping = new EventEmitter<PingResult>();
constructor( constructor(
private probeService: ProbeService
) { ) {
} }
ping() { doPing() {
console.log(this.service); const option = {
Retry: 3,
Interval: 1,
Deadline: 1,
};
this.probeService
.call<PingResult>('PingService.PingService', this.service, option)
.pipe(
map((pingResult: PingResult) => {
this.ping.emit(pingResult);
}),
catchError(error => {
console.log(error);
alert('An error has occurred.');
return of();
}),
take(1)
)
.subscribe();
} }
} }