This commit is contained in:
crusader 2018-09-19 21:34:48 +09:00
commit 3792ef3ea6
4 changed files with 44 additions and 50 deletions

View File

@ -80,46 +80,22 @@
<p-tabPanel header="Health"> <p-tabPanel header="Health">
<div class="ui-g-10 ui-g-offset-2">Retries : <div class="ui-g-10 ui-g-offset-2">Retries :
<input type="number" pInputText style="width:100px;" [(ngModel)]="retries" min="1" max="10"> <input type="number" pInputText [(ngModel)]="retries" min="1" max="50">
</div>
<div class="ui-g-10 ui-g-offset-2">Interval :
<input type="number" pInputText [(ngModel)]="interval" min="1" max="10">
</div>
<div class="ui-g-10 ui-g-offset-2">Deadline :
<input type="number" pInputText [(ngModel)]="deadline" min="1" max="10">
</div> </div>
<!-- <div class="ui-g-10 ui-g-offset-2">Interval :
<input type="text" pInputText placeholder="3" style="width:100px;" [(ngModel)]="interval" (ngModelChange)="validateIP($event, 0)"
(keypress)="ipPressed($event)">
</div>
<div class="ui-g-10 ui-g-offset-2">Deadline :
<input type="text" pInputText placeholder="3" style="width:100px;" [(ngModel)]="deadline" (ngModelChange)="validateIP($event, 0)"
(keypress)="ipPressed($event)">
</div> -->
<button type="button" pButton label="Ping" (click)="doPing()" class="ui-button-secondary ui-pingbn-position"></button> <button type="button" pButton label="Ping" (click)="doPing()" class="ui-button-secondary ui-pingbn-position"></button>
<br /> <br />
<textarea style="width: 100%; height: 200px" pInputTextarea autoResize="autoResize" [(ngModel)]="healthResponse"></textarea> <p-progressSpinner *ngIf="pingWaiting"></p-progressSpinner>
<div *ngIf="pingWaiting"> <textarea style="width: 100%; height: 200px; background-color: black; color:#fff;" *ngIf="!pingWaiting && pingResult"
Checking.... pInputTextarea autoResize="autoResize" [(ngModel)]="pingResult.raw"></textarea>
</div>
<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.summary.sendCount">Sent: {{pingResult.summary.sendCount}}</div>
<div *ngIf="pingResult.summary.receiveCount">Received: {{pingResult.summary.receiveCount}}</div>
<div *ngIf="pingResult.summary.lossPercent">Loss: {{pingResult.summary.lossPercent}} %</div>
<div *ngIf="pingResult.summary.avgTime">Avg: {{pingResult.summary.avgTime}} ms</div>
<div *ngIf="pingResult.summary.minTime">Min: {{pingResult.summary.minTime}} ms</div>
<div *ngIf="pingResult.summary.maxTime">Min: {{pingResult.summary.maxTime}} ms</div>
</div>
</div>
</p-tabPanel> </p-tabPanel>
</p-tabView> </p-tabView>

View File

@ -18,34 +18,36 @@ export class HostDetailComponent {
@Input() host: Host; @Input() host: Host;
healthResponse: string;
pingWaiting: boolean; pingWaiting: boolean;
pingResult: PingResult;
retries: number; retries: number;
interval: number;
deadline: number;
pingResult: PingResult;
constructor( constructor(
private probeService: ProbeService, private probeService: ProbeService,
) { ) {
this.pingWaiting = false; this.pingWaiting = false;
this.retries = 5; this.retries = 5;
this.interval = 1;
this.deadline = 1;
} }
doPing() { doPing() {
this.pingWaiting = true; this.pingWaiting = true;
this.pingWaiting = true;
const option = { const option = {
Retry: this.retries, Retry: this.retries,
Interval: 1, Interval: this.interval,
Deadline: 1, Deadline: this.deadline,
}; };
this.probeService this.probeService
.call<PingResult>('PingService.PingHost', this.host, option) .call<PingResult>('PingService.PingHost', this.host, option)
.pipe( .pipe(
map((pingResult: PingResult) => { map((pingResult: PingResult) => {
this.healthResponse = 'aslkdfjas\nasdflskjdf';
if (pingResult) { if (pingResult) {
this.pingResult = pingResult; this.pingResult = pingResult;
} }

View File

@ -60,18 +60,27 @@
</p-tabPanel> </p-tabPanel>
<p-tabPanel header="Health"> <p-tabPanel header="Health">
<button type="button" pButton label="Ping" (click)="doPing()" class="ui-button-secondary ui-pingbn-position"></button>
<div *ngIf="pingWaiting"> <div class="ui-g-10 ui-g-offset-2">Retries :
Checking.... <input type="number" pInputText [(ngModel)]="retries" min="1" max="50">
</div> </div>
<div *ngIf="pingResult"> <div class="ui-g-10 ui-g-offset-2">Interval :
<input type="number" pInputText [(ngModel)]="interval" min="1" max="10">
</div>
<div class="ui-g-10 ui-g-offset-2">Deadline :
<input type="number" pInputText [(ngModel)]="deadline" min="1" max="10">
</div>
<button type="button" pButton label="Ping" (click)="doPing()" class="ui-button-secondary ui-pingbn-position"></button>
<p-progressSpinner *ngIf="pingWaiting"></p-progressSpinner>
<div *ngIf="!pingWaiting && pingResult">
<ul> <ul>
<li *ngFor="let key of pingResult.responses | objectKeys"> <li *ngFor="let key of pingResult.responses | objectKeys">
<span *ngIf="pingResult.responses[key].error else value"> <span *ngIf="pingResult.responses[key].error else value">
{{pingResult.responses[key].error}} {{pingResult.responses[key].error}}
</span> </span>
<ng-template #value> <ng-template #value>
{{pingResult.responses[key].time}}ms Response time {{key}} : {{pingResult.responses[key].time}}ms
</ng-template> </ng-template>
</li> </li>
</ul> </ul>

View File

@ -16,26 +16,33 @@ export class ServiceDetailComponent {
pingWaiting: boolean; pingWaiting: boolean;
pingResult: PingResult; pingResult: PingResult;
retries: number;
interval: number;
deadline: number;
constructor( constructor(
private probeService: ProbeService private probeService: ProbeService
) { ) {
this.pingWaiting = false; this.pingWaiting = false;
this.retries = 5;
this.interval = 1;
this.deadline = 1;
} }
doPing() { doPing() {
this.pingWaiting = true; this.pingWaiting = true;
const option = { const option = {
Retry: 3, Retry: this.retries,
Interval: 1, Interval: this.interval,
Deadline: 1, Deadline: this.deadline,
}; };
this.probeService this.probeService
.call<PingResult>('PingService.PingService', this.service, option) .call<PingResult>('PingService.PingService', this.service, option)
.pipe( .pipe(
map((pingResult: PingResult) => { map((pingResult: PingResult) => {
console.log(pingResult);
if (pingResult) { if (pingResult) {
this.pingResult = pingResult; this.pingResult = pingResult;
} }