fleetmap-reports 1.0.512 → 1.0.513

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.512",
3
+ "version": "1.0.513",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  const jsPDF = require('jspdf')
2
- const { convertMS, convertToLocaleString, convertToFeature, convertPositionToFeature, getTranslations } = require('./util/utils')
2
+ const { convertMS, convertToLocaleString, convertToFeature, convertPositionToFeature, getTranslations, getLanguage } = require('./util/utils')
3
3
  const { headerFromUser, AmiriRegular } = require('./util/pdfDocument')
4
4
  require('jspdf-autotable')
5
5
  const { getStyle } = require('./reportStyle')
@@ -378,7 +378,7 @@ function calculateEventData (positions, pIndex, alert, device, geofence, userDat
378
378
 
379
379
  async function exportSpeedingReportToPDF (userData, reportData) {
380
380
  console.log('Export to PDF')
381
- const lang = userData.user.attributes.lang || (navigator && navigator.language)
381
+ const lang = getLanguage(userData)
382
382
 
383
383
  const timezone = userData.user.attributes.timezone
384
384
  const translations = getTranslations(userData)
package/src/util/utils.js CHANGED
@@ -12,6 +12,10 @@ exports.getTranslations = (userData) => {
12
12
  return messages[lang] ? messages[lang] : messages['en-GB']
13
13
  }
14
14
 
15
+ exports.getLanguage = (userData) => {
16
+ return userData.user.attributes.lang || ((typeof navigator !== 'undefined') && navigator.language) || 'en-GB'
17
+ }
18
+
15
19
  function convertMS (duration, withSeconds) {
16
20
  if (!duration || duration < 0) {
17
21
  return '00:00'