Browse Source

fix: Display correct displayed/ommited points stats

master
Konstantinos Kamaropoulos 5 years ago
parent
commit
2843819217
  1. 14
      src/app/map/map.component.ts

14
src/app/map/map.component.ts

@ -15,6 +15,8 @@ import { interval } from 'rxjs';
export class MapComponent implements OnInit { export class MapComponent implements OnInit {
version: string | null = environment.version; version: string | null = environment.version;
pointsToDisplay = 10;
// data: Array<Object>; // data: Array<Object>;
map: mapboxgl.Map; map: mapboxgl.Map;
@ -26,8 +28,8 @@ export class MapComponent implements OnInit {
lastPoint: number[]; lastPoint: number[];
ommitedPoints: Number; ommitedPoints: number = 0;
displayedPoints: Number; displayedPoints: number = 0;
constructor(private logsService: LogsService) {} constructor(private logsService: LogsService) {}
@ -50,15 +52,15 @@ export class MapComponent implements OnInit {
if (firstRun) { if (firstRun) {
data = await this.logsService.getLogsFirstRun(); data = await this.logsService.getLogsFirstRun();
firstRun = false; firstRun = false;
if (data.length > 100) { if (data.length > this.pointsToDisplay) {
this.ommitedPoints = data.length; this.ommitedPoints = data.length - this.pointsToDisplay;
data = data.slice(data.length - 100, data.length); data = data.slice(data.length - this.pointsToDisplay, data.length);
} }
this.displayedPoints = data.length;
} else { } else {
data = await this.logsService.getUpdates(); data = await this.logsService.getUpdates();
} }
let newPointsCount = 0; let newPointsCount = 0;
this.displayedPoints = this.displayedPoints + data.length;
for (let log of data) { for (let log of data) {
if (log['gps_data']['status'] == 'A') { if (log['gps_data']['status'] == 'A') {
newPointsCount++; newPointsCount++;

Loading…
Cancel
Save