fleetmap-reports 2.0.152 → 2.0.154

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/lang/frFR.json CHANGED
@@ -254,6 +254,7 @@
254
254
  "event_geofenceExit": "Sortir en zone",
255
255
  "event_deviceFuelDrop": "Perte de carburant",
256
256
  "event_driverChanged": "Changement de pilote",
257
+ "event_maintenance": "Maintenance",
257
258
  "event_sos": "SOS",
258
259
  "event_powerOn": "prise de force",
259
260
  "event_powerCut": "Coupure de courant",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "2.0.152",
3
+ "version": "2.0.154",
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.toString()))
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