fleetmap-reports 1.0.559 → 1.0.561

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": "1.0.559",
3
+ "version": "1.0.561",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -7,6 +7,7 @@ const { getUserPartner } = require('fleetmap-partners')
7
7
  const { convertToLocaleString, getTranslations } = require('./util/utils')
8
8
  const { devicesToProcess } = require('./util/device')
9
9
  const { isInside } = require('./util/timetable')
10
+ const { getDigitalPortValue } = require('./location-report')
10
11
 
11
12
  const fileName = 'EventReport'
12
13
 
@@ -175,7 +176,7 @@ async function exportSpeedingReportToPDF (userData, reportData) {
175
176
  a.type === 'alarm' ? translations.report['event_' + a.attributes.alarm] : translations.report['event_' + a.type],
176
177
  getAlertDate(userData.user, a),
177
178
  a.geofenceName || (a.position ? a.position.address : ''),
178
- getAlertInfo(userData.drivers, a)
179
+ getAlertInfo(userData.drivers, a, d.device, translations)
179
180
  ]
180
181
  data.push(temp)
181
182
  })
@@ -264,7 +265,10 @@ function deviceName (device) {
264
265
  return device.name + (device.attributes.license_plate ? ', ' + device.attributes.license_plate : '') + (device.model ? ', ' + device.model : '')
265
266
  }
266
267
 
267
- function getAlertInfo (drivers, alert) {
268
+ function getAlertInfo (drivers, alert, device, translations) {
269
+ if (alert.type === 'alarm' && alert.position) {
270
+ getDigitalPortValue(alert.position, 1, translations, device.attributes)
271
+ }
268
272
  if (alert.type === 'deviceOverspeed') {
269
273
  return Math.round(alert.attributes.speed * 1.85200) + ' Km/h'
270
274
  }
@@ -313,8 +313,7 @@ function getDigitalPort2Label (row, translations) {
313
313
  return row.attributes.door2 || translations.report.digital_ports2
314
314
  }
315
315
 
316
- function getDigitalPortValue (row, index, translations, dAttributes) {
317
- console.log('getDigitalPortValue', row, index, dAttributes)
316
+ export function getDigitalPortValue (row, index, translations, dAttributes) {
318
317
  switch (index) {
319
318
  case 1:
320
319
  if (row.attributes && row.attributes.door1 !== undefined) {
@@ -394,8 +393,8 @@ function exportLocationReportToExcel (userData, reportData) {
394
393
  ignition: a.attributes.ignition ? translations.report.ignitionOn : translations.report.ignitionOff,
395
394
  driver: userData.byDriver ? d.driver.name : getDriverName(a, userData.drivers),
396
395
  temperature: getTempValue(a),
397
- digitalport1: getDigitalPortValue(a, 1, translations),
398
- digitalport2: getDigitalPortValue(a, 2, translations),
396
+ digitalport1: getDigitalPortValue(a, 1, translations, d.device.attributes),
397
+ digitalport2: getDigitalPortValue(a, 2, translations, d.device.attributes),
399
398
  latitude: a.latitude,
400
399
  longitude: a.longitude
401
400
  }