fleetmap-reports 2.0.151 → 2.0.153

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "2.0.151",
3
+ "version": "2.0.153",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -196,7 +196,7 @@ async function exportSpeedingReportToPDF (userData, reportData) {
196
196
  })
197
197
  d.alerts.forEach(a => {
198
198
  const temp = [
199
- getEventType(a, translations, d.device),
199
+ getEventType(a, translations, d.device, userData),
200
200
  getAlertDate(userData.user, a.position),
201
201
  getAlertDate(userData.user, a.endPosition),
202
202
  a.geofenceName || (a.position ? a.position.address : ''),
@@ -239,13 +239,28 @@ async function exportSpeedingReportToPDF (userData, reportData) {
239
239
  }
240
240
  }
241
241
 
242
- function getEventType (a, translations, device) {
242
+ function getEventType (a, translations, device, userData) {
243
243
  if (a.type === 'alarm') {
244
244
  let sensor
245
245
  if (a.attributes.alarm === 'sensor') { sensor = device.attributes.sensor1 }
246
246
  return sensor || translations.report['event_' + a.attributes.alarm] || a.attributes.alarm
247
247
  } else {
248
- return translations.report['event_' + a.type] || a.type
248
+ const result = translations.report['event_' + a.type] || a.type
249
+ try {
250
+ if (userData &&
251
+ userData.notifications &&
252
+ userData.notifications.length &&
253
+ a.type === 'maintenance' &&
254
+ a.attributes.notifications) {
255
+ const notification = userData.notifications.find(n => a.attributes.notifications.split(',').includes(n.id))
256
+ if (notification) {
257
+ return `${result} ${notification.attributes.name}`
258
+ }
259
+ }
260
+ } catch (e) {
261
+ console.error(e)
262
+ }
263
+ return result
249
264
  }
250
265
  }
251
266
 
@@ -310,7 +310,6 @@ async function getCustomSpeedLimitEvents (devices, routes, customSpeed) {
310
310
  async function getRoadSpeedLimits (devices, routes, threshold, minimumMinutes = 0) {
311
311
  const position = routes.find(p => getCountry(p))
312
312
  const country = position && getCountry(position)
313
- console.log('getRoadSpeedLimits', position.address, country)
314
313
  const config = {
315
314
  Chile: getOSMSpeedingEvents,
316
315
  CL: getOSMSpeedingEvents,