From f12fdf23bcd2f94b9e3853787ecfd672433bfa71 Mon Sep 17 00:00:00 2001 From: bisbaldi Date: Mon, 15 Jan 2018 10:02:32 +0100 Subject: [PATCH 1/3] Update query to include only 100 items --- src/app/dashboard/dashboard.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 8f4f686..185cf54 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -90,7 +90,7 @@ export class DashboardComponent implements OnInit, OnDestroy { } loadTimeBasedPrivateData(start: Date, end: Date) { - const query = 'startTime=' + start.toISOString() + '&endTime=' + end.toISOString(); + const query = 'startTime=' + start.toISOString() + '&endTime=' + end.toISOString() + '&numberOfItems=100'; console.log(start.toISOString()); this.privateStatisticsService.query(query) .subscribe( From 06b885e870ce77ae04eb8c257ff9503ca72399b1 Mon Sep 17 00:00:00 2001 From: bisbaldi Date: Mon, 15 Jan 2018 10:11:14 +0100 Subject: [PATCH 2/3] Remove helper arrays and frontend limitation to 50 items --- .../charts/linechart/linechart.component.ts | 29 +++++-------------- src/app/dashboard/dashboard.component.ts | 1 + 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/app/dashboard/charts/linechart/linechart.component.ts b/src/app/dashboard/charts/linechart/linechart.component.ts index 15a514b..7542990 100644 --- a/src/app/dashboard/charts/linechart/linechart.component.ts +++ b/src/app/dashboard/charts/linechart/linechart.component.ts @@ -1,12 +1,12 @@ import {Component, Input, OnChanges, OnInit} from '@angular/core'; -import {DatePipe} from "@angular/common"; +import {DatePipe} from '@angular/common'; @Component({ selector: 'app-linechart', templateUrl: './linechart.component.html', styleUrls: ['./linechart.component.css'] }) -export class LinechartComponent implements OnInit, OnChanges{ +export class LinechartComponent implements OnInit, OnChanges { @Input() labels: string[]; @Input() statistics: any; @@ -18,7 +18,7 @@ export class LinechartComponent implements OnInit, OnChanges{ private lineChartLabels = []; private lineChartData: Array; - constructor(private datePipe: DatePipe){ + constructor(private datePipe: DatePipe) { } @@ -46,8 +46,6 @@ export class LinechartComponent implements OnInit, OnChanges{ this.lineChartData = []; this.lineChartLabels.length = 0; - let dataHelperArray = []; - let dateHelperArray = []; let dataArray = []; let dates = []; dataArray = this.statistics.map(record => { @@ -57,32 +55,21 @@ export class LinechartComponent implements OnInit, OnChanges{ return this.datePipe.transform(record.timeStamp, 'short'); }); - // TODO remove once backend is fixed - let size = dataArray.length - for(let j = 1; j <= 50; j++){ - let index = (Math.floor(size/50)) * j; - dataHelperArray[j-1]=dataArray[index]; - dateHelperArray[j-1]=dates[index]; - } - - for (let i = 0; i < dateHelperArray.length; i++) { - this.lineChartLabels.push(dateHelperArray[i]); + for (let i = 0; i < dates.length; i++) { + this.lineChartLabels.push(dates[i]); } this.lineChartData = [ - {data: dataHelperArray, label: this.labels[0], borderWidth: [1]}, + {data: dataArray, label: this.labels[0], borderWidth: [1]}, ]; - - - } // events - public chartClicked(e:any):void { + public chartClicked(e: any): void { console.log(e); } - public chartHovered(e:any):void { + public chartHovered(e: any): void { console.log(e); } } diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 185cf54..d6dd2be 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -85,6 +85,7 @@ export class DashboardComponent implements OnInit, OnDestroy { .subscribe( response => { this.timeBasedPublicStatistics = response; + console.log(response); } ); } From b725bd9439bad133764d940c75a99b942b7ff154 Mon Sep 17 00:00:00 2001 From: bisbaldi Date: Tue, 16 Jan 2018 10:32:33 +0100 Subject: [PATCH 3/3] Update query to only get 100 items as a response --- src/app/dashboard/dashboard.component.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index d6dd2be..e2f2d00 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -80,22 +80,21 @@ export class DashboardComponent implements OnInit, OnDestroy { } loadTimeBasedPublicData(start: Date, end: Date) { - const query = 'startTime=' + start.toISOString() + '&endTime=' + end.toISOString(); - this.publicStatisticsService.query(query) + const query = 'startTime=' + start.toISOString() + '&endTime=' + end.toISOString() + '&numberOfItems=100'; + this.publicStatisticsService.query(query) .subscribe( response => { this.timeBasedPublicStatistics = response; - console.log(response); } ); } loadTimeBasedPrivateData(start: Date, end: Date) { const query = 'startTime=' + start.toISOString() + '&endTime=' + end.toISOString() + '&numberOfItems=100'; - console.log(start.toISOString()); this.privateStatisticsService.query(query) .subscribe( response => { + console.log(response); this.timeBasedPrivateStatistics = response; } );