mirror of https://github.com/Chocobozzz/PeerTube
Client: move some methods in the requestStats model
parent
b539c9b34c
commit
bed3143eb9
|
@ -3,12 +3,12 @@
|
|||
<div *ngIf="stats !== null">
|
||||
<div>
|
||||
<span class="label-description">Interval seconds between requests:</span>
|
||||
{{ secondsInterval }}
|
||||
{{ stats.secondsInterval }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span class="label-description">Remaining time before the scheduled request:</span>
|
||||
{{ remainingSeconds }}
|
||||
{{ stats.remainingSeconds }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
|
|
@ -19,19 +19,11 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.secondsInterval !== null) {
|
||||
if (this.stats.secondsInterval !== null) {
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
}
|
||||
|
||||
get remainingSeconds() {
|
||||
return Math.floor(this.stats.remainingMilliSeconds / 1000);
|
||||
}
|
||||
|
||||
get secondsInterval() {
|
||||
return Math.floor(this.stats.milliSecondsInterval / 1000);
|
||||
}
|
||||
|
||||
getStats() {
|
||||
this.requestService.getStats().subscribe(
|
||||
stats => {
|
||||
|
|
|
@ -1,8 +1,29 @@
|
|||
export interface RequestStats {
|
||||
export interface Request {
|
||||
request: any;
|
||||
to: any;
|
||||
}
|
||||
|
||||
export class RequestStats {
|
||||
milliSecondsInterval: number;
|
||||
remainingMilliSeconds: number;
|
||||
requests: {
|
||||
request: any,
|
||||
to: any
|
||||
}[];
|
||||
requests: Request[];
|
||||
|
||||
constructor(hash: {
|
||||
milliSecondsInterval: number,
|
||||
remainingMilliSeconds: number,
|
||||
requests: Request[];
|
||||
}) {
|
||||
this.milliSecondsInterval = hash.milliSecondsInterval;
|
||||
this.remainingMilliSeconds = hash.remainingMilliSeconds;
|
||||
this.requests = hash.requests;
|
||||
}
|
||||
|
||||
get remainingSeconds() {
|
||||
return Math.floor(this.remainingMilliSeconds / 1000);
|
||||
}
|
||||
|
||||
get secondsInterval() {
|
||||
return Math.floor(this.milliSecondsInterval / 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ export class RequestService {
|
|||
getStats(): Observable<RequestStats> {
|
||||
return this.authHttp.get(RequestService.BASE_REQUEST_URL + 'stats')
|
||||
.map(this.restExtractor.extractDataGet)
|
||||
.map((data) => new RequestStats(data))
|
||||
.catch((res) => this.restExtractor.handleError(res));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue