ping in progress

This commit is contained in:
insanity 2018-09-19 21:00:54 +09:00
parent 57cda87632
commit 3cc60d0cac
4 changed files with 44 additions and 50 deletions

View File

@ -80,46 +80,22 @@
<p-tabPanel header="Health">
<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="text" pInputText placeholder="3" style="width:100px;" [(ngModel)]="interval" (ngModelChange)="validateIP($event, 0)"
(keypress)="ipPressed($event)">
<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="text" pInputText placeholder="3" style="width:100px;" [(ngModel)]="deadline" (ngModelChange)="validateIP($event, 0)"
(keypress)="ipPressed($event)">
</div> -->
<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>
<br />
<textarea style="width: 100%; height: 200px" pInputTextarea autoResize="autoResize" [(ngModel)]="healthResponse"></textarea>
<p-progressSpinner *ngIf="pingWaiting"></p-progressSpinner>
<div *ngIf="pingWaiting">
Checking....
</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>
<textarea style="width: 100%; height: 200px; background-color: black; color:#fff;" *ngIf="!pingWaiting && pingResult"
pInputTextarea autoResize="autoResize" [(ngModel)]="pingResult.raw"></textarea>
<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-tabView>

View File

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

View File

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

View File

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