|
@ -48,49 +48,51 @@ export class MapComponent implements OnInit { |
|
|
var firstRun: Boolean = true; |
|
|
var firstRun: Boolean = true; |
|
|
|
|
|
|
|
|
this.sub = interval(1000).subscribe(async val => { |
|
|
this.sub = interval(1000).subscribe(async val => { |
|
|
let data: Array<Object>; |
|
|
if (this.logsService.liveUpdate || firstRun) { |
|
|
if (firstRun) { |
|
|
let data: Array<Object>; |
|
|
data = await this.logsService.getLogsFirstRun(); |
|
|
if (firstRun) { |
|
|
firstRun = false; |
|
|
data = await this.logsService.getLogsFirstRun(); |
|
|
if (data.length > this.pointsToDisplay) { |
|
|
firstRun = false; |
|
|
this.ommitedPoints = data.length - this.pointsToDisplay; |
|
|
if (data.length > this.pointsToDisplay) { |
|
|
data = data.slice(data.length - this.pointsToDisplay, data.length); |
|
|
this.ommitedPoints = data.length - this.pointsToDisplay; |
|
|
|
|
|
data = data.slice(data.length - this.pointsToDisplay, data.length); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
data = await this.logsService.getUpdates(); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
let newPointsCount = 0; |
|
|
data = await this.logsService.getUpdates(); |
|
|
this.displayedPoints = this.displayedPoints + data.length; |
|
|
} |
|
|
for (let log of data) { |
|
|
let newPointsCount = 0; |
|
|
if (log['gps_data']['status'] == 'A') { |
|
|
this.displayedPoints = this.displayedPoints + data.length; |
|
|
newPointsCount++; |
|
|
for (let log of data) { |
|
|
let html = |
|
|
if (log['gps_data']['status'] == 'A') { |
|
|
log['gps_data']['datestamp'] + |
|
|
newPointsCount++; |
|
|
' ' + |
|
|
let html = |
|
|
log['gps_data']['timestamp'] + |
|
|
log['gps_data']['datestamp'] + |
|
|
'<br><table><tr><th>Sensor </th><th>Reading</th></tr>'; |
|
|
' ' + |
|
|
for (let record in log['sensorReadings']) { |
|
|
log['gps_data']['timestamp'] + |
|
|
if (Object.prototype.hasOwnProperty.call(log['sensorReadings'], record)) { |
|
|
'<br><table><tr><th>Sensor </th><th>Reading</th></tr>'; |
|
|
html += '<tr><td>' + record + '</td>' + '<td>' + log['sensorReadings'][record] + '</td></tr>'; |
|
|
for (let record in log['sensorReadings']) { |
|
|
} |
|
|
if (Object.prototype.hasOwnProperty.call(log['sensorReadings'], record)) { |
|
|
|
|
|
html += '<tr><td>' + record + '</td>' + '<td>' + log['sensorReadings'][record] + '</td></tr>'; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
html += '</table>'; |
|
|
|
|
|
var popup = new mapboxgl.Popup({ offset: 25 }).setHTML(html); |
|
|
|
|
|
var marker = new mapboxgl.Marker({ |
|
|
|
|
|
draggable: false |
|
|
|
|
|
}) |
|
|
|
|
|
.setLngLat([log['gps_data']['longitude'], log['gps_data']['latitude']]) |
|
|
|
|
|
.setPopup(popup) |
|
|
|
|
|
.addTo(this.map); |
|
|
} |
|
|
} |
|
|
html += '</table>'; |
|
|
this.lastPoint = [log['gps_data']['longitude'], log['gps_data']['latitude']]; |
|
|
var popup = new mapboxgl.Popup({ offset: 25 }).setHTML(html); |
|
|
} |
|
|
var marker = new mapboxgl.Marker({ |
|
|
if (newPointsCount) { |
|
|
draggable: false |
|
|
this.map.flyTo({ |
|
|
}) |
|
|
center: [this.lastPoint[0], this.lastPoint[1]], |
|
|
.setLngLat([log['gps_data']['longitude'], log['gps_data']['latitude']]) |
|
|
essential: true, // this animation is considered essential with respect to prefers-reduced-motion
|
|
|
.setPopup(popup) |
|
|
zoom: 22 |
|
|
.addTo(this.map); |
|
|
}); |
|
|
} |
|
|
} |
|
|
this.lastPoint = [log['gps_data']['longitude'], log['gps_data']['latitude']]; |
|
|
|
|
|
} |
|
|
|
|
|
if (newPointsCount) { |
|
|
|
|
|
this.map.flyTo({ |
|
|
|
|
|
center: [this.lastPoint[0], this.lastPoint[1]], |
|
|
|
|
|
essential: true, // this animation is considered essential with respect to prefers-reduced-motion
|
|
|
|
|
|
zoom: 22 |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|