|
|
@ -1,6 +1,7 @@
|
|
|
|
import { Component, OnInit, Input } from "@angular/core";
|
|
|
|
import { IRemainingRequests } from "../interfaces/IRemainingRequests";
|
|
|
|
import { RequestService } from "../services";
|
|
|
|
import { RequestService } from "../services";
|
|
|
|
import { IRemainingRequests } from "../interfaces/IRemainingRequests";
|
|
|
|
|
|
|
|
|
|
|
|
import { Component, Input, OnInit } from "@angular/core";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: "remaining-requests",
|
|
|
|
selector: "remaining-requests",
|
|
|
@ -14,29 +15,29 @@ export class RemainingRequestsComponent implements OnInit {
|
|
|
|
public hoursUntil: number;
|
|
|
|
public hoursUntil: number;
|
|
|
|
public minutesUntil: number;
|
|
|
|
public minutesUntil: number;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private requestService: RequestService)
|
|
|
|
constructor(private requestService: RequestService) {
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
public ngOnInit() {
|
|
|
|
var self = this;
|
|
|
|
const self = this;
|
|
|
|
|
|
|
|
|
|
|
|
this.update();
|
|
|
|
this.update();
|
|
|
|
|
|
|
|
|
|
|
|
this.requestService.onRequested().subscribe(m => {
|
|
|
|
this.requestService.onRequested().subscribe(m => {
|
|
|
|
this.update();
|
|
|
|
this.update();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
setInterval(function(){
|
|
|
|
setInterval(() => {
|
|
|
|
self.calculateTime();
|
|
|
|
self.calculateTime();
|
|
|
|
}, 10000)
|
|
|
|
}, 10000);
|
|
|
|
|
|
|
|
|
|
|
|
setInterval(function(){
|
|
|
|
setInterval(() => {
|
|
|
|
self.update()
|
|
|
|
self.update();
|
|
|
|
}, 60000)
|
|
|
|
}, 60000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
update(): void {
|
|
|
|
public update(): void {
|
|
|
|
var callback = (remaining => {
|
|
|
|
const callback = (remaining => {
|
|
|
|
this.remaining = remaining;
|
|
|
|
this.remaining = remaining;
|
|
|
|
this.calculateTime();
|
|
|
|
this.calculateTime();
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -48,21 +49,21 @@ export class RemainingRequestsComponent implements OnInit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
calculateTime(): void {
|
|
|
|
private calculateTime(): void {
|
|
|
|
this.daysUntil = Math.ceil(this.daysUntilNextRequest());
|
|
|
|
this.daysUntil = Math.ceil(this.daysUntilNextRequest());
|
|
|
|
this.hoursUntil = Math.ceil(this.hoursUntilNextRequest());
|
|
|
|
this.hoursUntil = Math.ceil(this.hoursUntilNextRequest());
|
|
|
|
this.minutesUntil = Math.ceil(this.minutesUntilNextRequest())
|
|
|
|
this.minutesUntil = Math.ceil(this.minutesUntilNextRequest());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
daysUntilNextRequest(): number {
|
|
|
|
private daysUntilNextRequest(): number {
|
|
|
|
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60 / 60 / 24;
|
|
|
|
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60 / 60 / 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
hoursUntilNextRequest(): number {
|
|
|
|
private hoursUntilNextRequest(): number {
|
|
|
|
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60 / 60;
|
|
|
|
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60 / 60;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
minutesUntilNextRequest(): number {
|
|
|
|
private minutesUntilNextRequest(): number {
|
|
|
|
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60;
|
|
|
|
return (new Date(this.remaining.nextRequest).getTime() - new Date().getTime()) / 1000 / 60;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|