Adapt requests controller/front to new informations

pull/40/head
Chocobozzz 2017-01-19 22:38:34 +01:00
parent c625a9560b
commit 872a4c7cea
5 changed files with 49 additions and 25 deletions

View File

@ -1,23 +1,33 @@
<h3>Requests stats</h3>
<div *ngIf="stats !== null">
<div>
<span class="label-description">Interval seconds between requests:</span>
{{ stats.secondsInterval }}
<div class="requests-general">
<div>
<span class="label-description">Remaining requests:</span>
{{ stats.totalRequests }}
</div>
<div>
<span class="label-description">Interval seconds between requests:</span>
{{ stats.secondsInterval }}
</div>
<div>
<span class="label-description">Remaining time before the scheduled request:</span>
{{ stats.remainingSeconds }}
</div>
</div>
<div>
<span class="label-description">Remaining time before the scheduled request:</span>
{{ stats.remainingSeconds }}
<div class="requests-limit">
<div>
<span class="label-description">Maximum number of different pods for a scheduled request:</span>
{{ stats.requestsLimitPods }}
</div>
<div>
<span class="label-description">Maximum number of requests per pod for a scheduled request:</span>
{{ stats.requestsLimitPerPod }}
</div>
</div>
<div>
<span class="label-description">Maximum number of requests per interval:</span>
{{ stats.maxRequestsInParallel }}
</div>
<div>
<span class="label-description">Remaining requests:</span>
{{ stats.totalRequests }}
</div>
</div>

View File

@ -1,6 +1,19 @@
.label-description {
display: inline-block;
width: 350px;
font-weight: bold;
color: black;
}
.requests-general {
.label-description {
width: 320px;
}
}
.requests-limit {
margin-top: 20px;
.label-description {
width: 430px;
}
}

View File

@ -17,6 +17,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
ngOnInit() {
this.getStats();
this.runInterval();
}
ngOnDestroy() {
@ -27,10 +28,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
getStats() {
this.requestService.getStats().subscribe(
stats => {
this.stats = stats;
this.runInterval();
},
stats => this.stats = stats,
err => alert(err.text)
);
@ -42,7 +40,6 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
if (this.stats.remainingMilliSeconds <= 0) {
setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100);
clearInterval(this.interval);
}
}, 1000);
}

View File

@ -4,18 +4,21 @@ export interface Request {
}
export class RequestStats {
maxRequestsInParallel: number;
requestsLimitPods: number;
requestsLimitPerPod: number;
milliSecondsInterval: number;
remainingMilliSeconds: number;
totalRequests: number;
constructor(hash: {
maxRequestsInParallel: number,
requestsLimitPods: number,
requestsLimitPerPod: number,
milliSecondsInterval: number,
remainingMilliSeconds: number,
totalRequests: number;
}) {
this.maxRequestsInParallel = hash.maxRequestsInParallel;
this.requestsLimitPods = hash.requestsLimitPods;
this.requestsLimitPerPod = hash.requestsLimitPerPod;
this.milliSecondsInterval = hash.milliSecondsInterval;
this.remainingMilliSeconds = hash.remainingMilliSeconds;
this.totalRequests = hash.totalRequests;

View File

@ -28,7 +28,8 @@ function getStatsRequests (req, res, next) {
return res.json({
totalRequests: totalRequests,
maxRequestsInParallel: constants.REQUESTS_IN_PARALLEL,
requestsLimitPods: constants.REQUESTS_LIMIT_PODS,
requestsLimitPerPod: constants.REQUESTS_LIMIT_PER_POD,
remainingMilliSeconds: db.Request.remainingMilliSeconds(),
milliSecondsInterval: constants.REQUESTS_INTERVAL
})