Adapt requests controller/front to new informations

This commit is contained in:
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> <h3>Requests stats</h3>
<div *ngIf="stats !== null"> <div *ngIf="stats !== null">
<div> <div class="requests-general">
<span class="label-description">Interval seconds between requests:</span> <div>
{{ stats.secondsInterval }} <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>
<div> <div class="requests-limit">
<span class="label-description">Remaining time before the scheduled request:</span> <div>
{{ stats.remainingSeconds }} <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>
<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> </div>

View File

@ -1,6 +1,19 @@
.label-description { .label-description {
display: inline-block; display: inline-block;
width: 350px;
font-weight: bold; font-weight: bold;
color: black; 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() { ngOnInit() {
this.getStats(); this.getStats();
this.runInterval();
} }
ngOnDestroy() { ngOnDestroy() {
@ -27,10 +28,7 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
getStats() { getStats() {
this.requestService.getStats().subscribe( this.requestService.getStats().subscribe(
stats => { stats => this.stats = stats,
this.stats = stats;
this.runInterval();
},
err => alert(err.text) err => alert(err.text)
); );
@ -42,7 +40,6 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
if (this.stats.remainingMilliSeconds <= 0) { if (this.stats.remainingMilliSeconds <= 0) {
setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100); setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100);
clearInterval(this.interval);
} }
}, 1000); }, 1000);
} }

View File

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

View File

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