Added eta on dashboard

This commit is contained in:
simon987 2019-03-02 20:36:51 -05:00
parent 82b91867f2
commit f085560494
5 changed files with 21 additions and 4 deletions

View File

@ -6,7 +6,8 @@ import {Credentials} from "./models/credentials";
@Injectable()
export class ApiService {
public url: string = window.location.protocol + "//" + window.location.hostname + "/api";
// public url: string = window.location.protocol + "//" + window.location.hostname + "/api";
public url = "https://tt.simon987.net/api";
private options: {
withCredentials: true,
responseType: "json"

View File

@ -19,7 +19,8 @@
<pre *ngIf="project">{{project.motd}}</pre>
<p>{{"project.task_per_second" | translate}}:
<span class="text-mono" *ngIf="project">{{avgTask | number}}/s</span>
<span class="text-mono" *ngIf="project">{{avgTask | number}}/s</span>,
{{"project.eta"|translate}}: <span class="text-mono">{{eta}}</span>
</p>
<div style="display: flex; align-items: center; justify-content: center">

View File

@ -11,6 +11,8 @@ import {AuthService} from "../auth.service";
import {MatDialog} from "@angular/material";
import {AreYouSureComponent} from "../are-you-sure/are-you-sure.component";
import * as moment from "moment"
@Component({
selector: 'app-project-dashboard',
@ -27,6 +29,7 @@ export class ProjectDashboardComponent implements OnInit {
private statusPie: Chart;
private assigneesPie: Chart;
private avgTask: number;
eta: string;
private colors = {
@ -74,6 +77,7 @@ export class ProjectDashboardComponent implements OnInit {
.subscribe((data: any) => {
this.snapshots = data.content.snapshots;
this.averageTaskPerSecond();
this.calculateEta();
this.lastSnapshot = this.snapshots ? this.snapshots.sort((a, b) => {
return b.time_stamp - a.time_stamp
})[0] : null;
@ -340,6 +344,7 @@ export class ProjectDashboardComponent implements OnInit {
});
this.averageTaskPerSecond();
this.calculateEta();
})
},
error => {
@ -396,6 +401,14 @@ export class ProjectDashboardComponent implements OnInit {
}
}
private calculateEta() {
if (this.snapshots.length > 0) {
this.eta = moment.utc(this.snapshots[0].new_task_count / this.avgTask * 1000).format("D[d] HH[h]mm[m]ss[s]")
} else {
this.eta = "N/A"
}
}
private setPaused(paused: boolean) {
this.dialog.open(AreYouSureComponent, {
width: '250px',

View File

@ -74,7 +74,8 @@
"assign_rate": "Task assign rate limit",
"submit_rate": "Task submit rate limit",
"rate": "per second",
"task_per_second": "Completed tasks per second"
"task_per_second": "Tasks per second",
"eta": "ETA"
},
"dashboard": {
"title": "Dashboard for",

View File

@ -74,7 +74,8 @@
"assign_rate": "Taux d'assignation de tâches",
"submit_rate": "Taux de soumission de tâches",
"rate": "par seconde",
"task_per_second": "Tâches par seconde"
"task_per_second": "Tâches par seconde",
"eta": "Temps estimé"
},
"dashboard": {
"title": "Tableau de bord pour ",