fleetmap-reports 1.0.436 → 1.0.437

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/index.js CHANGED
@@ -1,22 +1,22 @@
1
- const enGBLocale = require('./enGB');
2
- const ptBRLocale = require('./ptBR');
3
- const esCLLocale = require('./esCL');
4
- const ptPTLocale = require('./ptPT');
1
+ const enGBLocale = require('./enGB')
2
+ const ptBRLocale = require('./ptBR')
3
+ const esCLLocale = require('./esCL')
4
+ const ptPTLocale = require('./ptPT')
5
5
 
6
6
  module.exports = {
7
- "en-GB": {
7
+ 'en-GB': {
8
8
  ...enGBLocale
9
9
  },
10
- "pt-BR": {
10
+ 'pt-BR': {
11
11
  ...ptBRLocale
12
12
  },
13
- "pt-PT": {
13
+ 'pt-PT': {
14
14
  ...ptPTLocale
15
15
  },
16
- "es-CL": {
16
+ 'es-CL': {
17
17
  ...esCLLocale
18
18
  },
19
- "pt": {
19
+ pt: {
20
20
  ...ptPTLocale
21
21
  }
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.436",
3
+ "version": "1.0.437",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -296,11 +296,11 @@ function exportIdleReportToExcel (userData, reportData) {
296
296
  fileName // The name of the spreadsheet
297
297
  }
298
298
  const headers = [
299
- userData.byDriver ? { label: translations.report.driver, value: 'name' } : { label: translations.report.vehicle, value: 'name' },
299
+ { label: userData.byDriver ? translations.report.driver : translations.report.vehicle, value: 'name' },
300
300
  { label: translations.report.date, value: 'fixTime' },
301
301
  { label: translations.report.address, value: 'address' },
302
302
  { label: translations.report.duration, value: 'duration' },
303
- userData.byDriver ? { label: translations.report.vehicle, value: 'subname' } : { label: translations.report.driver, value: 'subname' }
303
+ { label: userData.byDriver ? translations.report.vehicle : translations.report.driver, value: 'subname' }
304
304
  ]
305
305
 
306
306
  let data = []
@@ -312,7 +312,7 @@ function exportIdleReportToExcel (userData, reportData) {
312
312
  name: userData.byDriver ? d.driver.name : d.device.name,
313
313
  duration: convertMS(a.idleTime, true),
314
314
  fixTime: getIdleEventDate(a, userData.user),
315
- subname: userData.byDriver ? a.driver : a.deviceName,
315
+ subname: userData.byDriver ? a.deviceName : a.driver,
316
316
  address: a.position.address + (a.geofenceName ? ' - ' + a.geofenceName : '')
317
317
  }
318
318
  }))
@@ -1,350 +1,354 @@
1
1
  const jsPDF = require('jspdf')
2
2
  require('jspdf-autotable')
3
- const {headerFromUser} = require("./util/pdfDocument");
4
- const {getStyle} = require("./reportStyle")
5
- const {getUserPartner} = require("fleetmap-partners");
6
- const {convertToLocaleString, getTranslations} = require("./util/utils");
7
- const traccarHelper = require("./util/traccar");
8
- const {devicesToProcess} = require("./util/device");
3
+ const { headerFromUser } = require('./util/pdfDocument')
4
+ const { getStyle } = require('./reportStyle')
5
+ const { getUserPartner } = require('fleetmap-partners')
6
+ const { convertToLocaleString, getTranslations } = require('./util/utils')
7
+ const traccarHelper = require('./util/traccar')
8
+ const { devicesToProcess } = require('./util/device')
9
9
 
10
10
  const fileName = 'LocationReport'
11
11
 
12
- async function createLocationReport(from, to, userData, traccar) {
13
- console.log('Create LocationReport')
14
- const reportData = []
15
-
16
- if (userData.byDriver) {
17
- console.log("ByDriver")
18
- const report = await createLocationReportByDriver(from, to, userData, traccar)
19
- reportData.push(report)
20
- }
21
- else if (userData.byGroup) {
22
- console.log("ByGroup")
23
- const allData = await createLocationReportByGroup(from, to, userData, traccar)
24
- reportData.push(...allData)
25
- } else {
26
- console.log("ByDevice")
27
- const report = await createLocationReportByDevice(from, to, userData, traccar)
28
- reportData.push(report)
29
- }
30
-
31
- return reportData
12
+ async function createLocationReport (from, to, userData, traccar) {
13
+ console.log('Create LocationReport')
14
+ const reportData = []
15
+
16
+ if (userData.byDriver) {
17
+ console.log('ByDriver')
18
+ const report = await createLocationReportByDriver(from, to, userData, traccar)
19
+ reportData.push(report)
20
+ } else if (userData.byGroup) {
21
+ console.log('ByGroup')
22
+ const allData = await createLocationReportByGroup(from, to, userData, traccar)
23
+ reportData.push(...allData)
24
+ } else {
25
+ console.log('ByDevice')
26
+ const report = await createLocationReportByDevice(from, to, userData, traccar)
27
+ reportData.push(report)
28
+ }
29
+
30
+ return reportData
32
31
  }
33
32
 
34
- async function createLocationReportByDriver(from, to, userData, traccar) {
35
- const devices = await traccar.devices.devicesGet().then(d => d.data)
36
- console.log(devices.length)
33
+ async function createLocationReportByDriver (from, to, userData, traccar) {
34
+ const devices = await traccar.devices.devicesGet().then(d => d.data)
35
+ console.log(devices.length)
37
36
 
38
- if(!devices.length){
39
- //Empty report
40
- return { drivers:[] }
41
- }
37
+ if (!devices.length) {
38
+ // Empty report
39
+ return { drivers: [] }
40
+ }
42
41
 
43
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, false, false, false)
44
- const routeData = allInOne.route
42
+ const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, false, false, false)
43
+ const routeData = allInOne.route
45
44
 
46
- return { drivers: processDrivers(from, to, userData, routeData)}
45
+ return { drivers: processDrivers(from, to, userData, routeData) }
47
46
  }
48
47
 
49
- async function createLocationReportByGroup(from, to, userData, traccar) {
50
- const reportData = []
48
+ async function createLocationReportByGroup (from, to, userData, traccar) {
49
+ const reportData = []
51
50
 
52
- for (const g of userData.groups) {
53
- const devices = userData.devices.filter(d => d.groupId === g.id)
51
+ for (const g of userData.groups) {
52
+ const devices = userData.devices.filter(d => d.groupId === g.id)
54
53
 
55
- if(devices.length > 0) {
56
- const groupData = {
57
- devices: [],
58
- group: g,
59
- xpert: devices.filter(d => d.attributes.xpert).length > 0
60
- }
54
+ if (devices.length > 0) {
55
+ const groupData = {
56
+ devices: [],
57
+ group: g,
58
+ xpert: devices.filter(d => d.attributes.xpert).length > 0
59
+ }
61
60
 
62
- const response = await traccar.reports.reportsRouteGet(from, to, null, [g.id])
63
- const data = response.data
61
+ const response = await traccar.reports.reportsRouteGet(from, to, null, [g.id])
62
+ const data = response.data
64
63
 
65
- devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
64
+ devices.sort((a, b) => (a.name > b.name) ? 1 : -1)
66
65
 
67
- if (data.length > 0) {
68
- console.log('Locations:'+data.length)
69
- groupData.devices = processDevices(from, to, devices, userData.drivers, data)
66
+ if (data.length > 0) {
67
+ console.log('Locations:' + data.length)
68
+ groupData.devices = processDevices(from, to, devices, userData.drivers, data)
70
69
 
71
- reportData.push(groupData)
72
- }
73
- }
70
+ reportData.push(groupData)
71
+ }
74
72
  }
73
+ }
75
74
 
76
- const allData = await createLocationReportByDevice(from, to, userData, traccar)
77
- reportData.push(allData)
75
+ const allData = await createLocationReportByDevice(from, to, userData, traccar)
76
+ reportData.push(allData)
78
77
 
79
- return reportData
78
+ return reportData
80
79
  }
81
80
 
82
- async function createLocationReportByDevice(from, to, userData, traccar) {
83
- const devices = devicesToProcess(userData)
81
+ async function createLocationReportByDevice (from, to, userData, traccar) {
82
+ const devices = devicesToProcess(userData)
84
83
 
85
- const allData = {
86
- devices: [],
87
- xpert: devices.filter(d => d.attributes.xpert).length > 0
88
- }
84
+ const allData = {
85
+ devices: [],
86
+ xpert: devices.filter(d => d.attributes.xpert).length > 0
87
+ }
89
88
 
90
- const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, false, false, false)
91
- const routeData = allInOne.route
89
+ const allInOne = await traccarHelper.getAllInOne(traccar, from, to, devices, true, false, false, false)
90
+ const routeData = allInOne.route
92
91
 
93
- console.log('Locations:'+routeData.length)
92
+ console.log('Locations:' + routeData.length)
94
93
 
95
- if(routeData.length > 0) {
96
- allData.devices = processDevices(from, to, devices, userData.drivers, routeData)
97
- }
94
+ if (routeData.length > 0) {
95
+ allData.devices = processDevices(from, to, devices, userData.drivers, routeData)
96
+ }
98
97
 
99
- return allData
98
+ return allData
100
99
  }
101
100
 
102
- function processDevices(from, to, devices, drivers, data) {
103
- const devicesResult = []
101
+ function processDevices (from, to, devices, drivers, data) {
102
+ const devicesResult = []
104
103
 
105
- for (const d of devices) {
106
- const positions = data.filter(t => t.deviceId===d.id)
104
+ for (const d of devices) {
105
+ const positions = data.filter(t => t.deviceId === d.id)
107
106
 
108
- if(drivers.length > 0) {
109
- positions.forEach(p => {
110
- const driver = drivers.find(d => d.uniqueId === p.attributes.driverUniqueId)
111
- if(driver){
112
- p.driverName = driver.name
113
- }
114
- })
107
+ if (drivers.length > 0) {
108
+ positions.forEach(p => {
109
+ const driver = drivers.find(d => d.uniqueId === p.attributes.driverUniqueId)
110
+ if (driver) {
111
+ p.driverName = driver.name
115
112
  }
113
+ })
114
+ }
116
115
 
117
- if(positions.length > 0) {
118
- devicesResult.push({
119
- device: d,
120
- from: from,
121
- to: to,
122
- positions: positions,
123
- })
124
- }
116
+ if (positions.length > 0) {
117
+ devicesResult.push({
118
+ device: d,
119
+ from,
120
+ to,
121
+ positions
122
+ })
125
123
  }
124
+ }
126
125
 
127
- return devicesResult
126
+ return devicesResult
128
127
  }
129
128
 
130
- function processDrivers(from, to, userData, route) {
131
- const driversResult = []
132
- userData.drivers.forEach(d => {
133
- const positions = route.filter(p => p.attributes.driverUniqueId === d.uniqueId)
134
- if (positions.length > 0) {
135
- positions.sort((a,b)=>new Date(a.fixTime).getTime()-new Date(b.fixTime).getTime());
136
-
137
- positions.forEach(p => {
138
- const device = userData.devices.find(d => d.id === p.deviceId)
139
- if(device){
140
- p.vehicleName = device.name
141
- }
142
- })
143
-
144
- const driverData = {
145
- driver: d,
146
- from: from,
147
- to: to,
148
- positions: positions,
149
- }
150
- driversResult.push(driverData)
129
+ function processDrivers (from, to, userData, route) {
130
+ const driversResult = []
131
+ userData.drivers.forEach(d => {
132
+ const positions = route.filter(p => p.attributes.driverUniqueId === d.uniqueId)
133
+ if (positions.length > 0) {
134
+ positions.sort((a, b) => new Date(a.fixTime).getTime() - new Date(b.fixTime).getTime())
135
+
136
+ positions.forEach(p => {
137
+ const device = userData.devices.find(d => d.id === p.deviceId)
138
+ if (device) {
139
+ p.vehicleName = device.name
151
140
  }
152
- })
153
- console.log(driversResult)
141
+ })
142
+
143
+ const driverData = {
144
+ driver: d,
145
+ from,
146
+ to,
147
+ positions
148
+ }
149
+ driversResult.push(driverData)
150
+ }
151
+ })
152
+ console.log(driversResult)
154
153
 
155
- return driversResult
154
+ return driversResult
156
155
  }
157
156
 
158
- async function exportLocationReportToPDF(userData, reportData) {
159
- console.log('Export to PDF')
157
+ async function exportLocationReportToPDF (userData, reportData) {
158
+ console.log('Export to PDF')
160
159
 
161
- const translations = getTranslations(userData)
162
- const lang = userData.user.attributes.lang || (navigator && navigator.language)
163
- const timezone = userData.user.attributes.timezone
160
+ const translations = getTranslations(userData)
161
+ const lang = userData.user.attributes.lang || (navigator && navigator.language)
162
+ const timezone = userData.user.attributes.timezone
164
163
 
165
- const positionsData = userData.byDriver ? reportData.drivers : reportData.devices
164
+ const positionsData = userData.byDriver ? reportData.drivers : reportData.devices
166
165
 
167
- const headers = userData.byDriver ? [
166
+ const headers = userData.byDriver
167
+ ? [
168
168
  translations.report.date,
169
169
  translations.report.address,
170
170
  translations.report.speed,
171
171
  translations.report.ignition,
172
172
  translations.report.vehicle,
173
173
  translations.report.temperature
174
- ] : [
174
+ ]
175
+ : [
175
176
  translations.report.date,
176
177
  translations.report.address,
177
178
  translations.report.speed,
178
179
  translations.report.ignition,
179
180
  translations.report.driver,
180
181
  translations.report.temperature
181
- ]
182
-
183
- if (positionsData) {
184
- let first = true
185
- const doc = new jsPDF.jsPDF('l');
186
- await headerFromUser(doc, translations.report.titleLocationReport, userData.user)
187
-
188
- positionsData.forEach(d => {
189
- let data = []
190
- const name = userData.byDriver ? d.driver.name : deviceName(d.device)
191
- const group = userData.byDriver ? '' : deviceGroupName(userData.groups, d.device, translations)
192
-
193
- let space = 0
194
- if (!first) {
195
- doc.addPage()
196
- } else {
197
- first = false
198
- space = 10
199
- }
200
- doc.setFontSize(13)
201
- doc.text(name, 20, space + 20)
202
- doc.setFontSize(11)
203
- doc.text(group, 200, space + 20)
204
- doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space + 25)
205
- d.positions.map(a => {
206
- const temp = [
207
- getLocationDate(a, userData.user),
208
- a.address,
209
- Math.round(a.speed * 1.85200),
210
- a.attributes.ignition ? translations.report.ignitionOn : translations.report.ignitionOff,
211
- userData.byDriver ? a.vehicleName : getDriverName(a, userData.drivers),
212
- getTempValue(a)
213
- ]
214
- data.push(temp)
215
- })
216
-
217
- const footValues = [
218
- 'Total:' + d.positions.length,
219
- '', getMaxSpeed(d.positions)
220
- ]
221
-
222
- const style = getStyle(getUserPartner(userData.user))
223
- doc.autoTable({
224
- head: [headers],
225
- body: data,
226
- foot: [footValues],
227
- showFoot: 'lastPage',
228
- headStyles: {
229
- fillColor: style.pdfHeaderColor,
230
- textColor: style.pdfHeaderTextColor,
231
- fontSize: 10
232
- },
233
- bodyStyles: {
234
- fillColor: style.pdfBodyColor,
235
- textColor: style.pdfBodyTextColor,
236
- fontSize: 8
237
- },
238
- footStyles: {
239
- fillColor: style.pdfFooterColor,
240
- textColor: style.pdfFooterTextColor,
241
- fontSize: 9
242
- },
243
- startY: space + 35
244
- });
245
- });
246
-
247
- return doc
248
- }
249
- }
182
+ ]
183
+
184
+ if (positionsData) {
185
+ let first = true
186
+ // eslint-disable-next-line new-cap
187
+ const doc = new jsPDF.jsPDF('l')
188
+ await headerFromUser(doc, translations.report.titleLocationReport, userData.user)
189
+
190
+ positionsData.forEach(d => {
191
+ const data = []
192
+ const name = userData.byDriver ? d.driver.name : deviceName(d.device)
193
+ const group = userData.byDriver ? '' : deviceGroupName(userData.groups, d.device, translations)
194
+
195
+ let space = 0
196
+ if (!first) {
197
+ doc.addPage()
198
+ } else {
199
+ first = false
200
+ space = 10
201
+ }
202
+ doc.setFontSize(13)
203
+ doc.text(name, 20, space + 20)
204
+ doc.setFontSize(11)
205
+ doc.text(group, 200, space + 20)
206
+ doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space + 25)
207
+ d.positions.forEach(a => {
208
+ const temp = [
209
+ getLocationDate(a, userData.user),
210
+ a.address,
211
+ Math.round(a.speed * 1.85200),
212
+ a.attributes.ignition ? translations.report.ignitionOn : translations.report.ignitionOff,
213
+ userData.byDriver ? a.vehicleName : getDriverName(a, userData.drivers),
214
+ getTempValue(a)
215
+ ]
216
+ data.push(temp)
217
+ })
218
+
219
+ const footValues = [
220
+ 'Total:' + d.positions.length,
221
+ '', getMaxSpeed(d.positions)
222
+ ]
223
+
224
+ const style = getStyle(getUserPartner(userData.user))
225
+ doc.autoTable({
226
+ head: [headers],
227
+ body: data,
228
+ foot: [footValues],
229
+ showFoot: 'lastPage',
230
+ headStyles: {
231
+ fillColor: style.pdfHeaderColor,
232
+ textColor: style.pdfHeaderTextColor,
233
+ fontSize: 10
234
+ },
235
+ bodyStyles: {
236
+ fillColor: style.pdfBodyColor,
237
+ textColor: style.pdfBodyTextColor,
238
+ fontSize: 8
239
+ },
240
+ footStyles: {
241
+ fillColor: style.pdfFooterColor,
242
+ textColor: style.pdfFooterTextColor,
243
+ fontSize: 9
244
+ },
245
+ startY: space + 35
246
+ })
247
+ })
250
248
 
251
- function getTempValue(row) {
252
- return row.attributes && (
253
- row.attributes.temp1 !== 175 && row.attributes.temp1
254
- || row.attributes.temp2 !== 175 && row.attributes.temp2
255
- ) || ''
249
+ return doc
250
+ }
256
251
  }
257
252
 
258
- function exportLocationReportToExcel(userData, reportData) {
259
- console.log('Export to Excel')
260
-
261
- const translations = getTranslations(userData)
262
-
263
- const positionsData = userData.byDriver ? reportData.drivers : reportData.devices
253
+ function getTempValue (row) {
254
+ return (row.attributes && (
255
+ (row.attributes.temp1 !== 175 && row.attributes.temp1) ||
256
+ (row.attributes.temp2 !== 175 && row.attributes.temp2)
257
+ )) || ''
258
+ }
264
259
 
265
- const settings = {
266
- sheetName: translations.report.titleLocationReport, // The name of the sheet
267
- fileName: fileName, // The name of the spreadsheet
268
- }
269
- const headers = userData.byDriver ? [
270
- {label: translations.report.driver, value:'driver'},
271
- {label: translations.report.date, value:'date'},
272
- {label: translations.report.address, value:'address'},
273
- {label: translations.report.speed, value:'speed'},
274
- {label: translations.report.ignition, value:'ignition'},
275
- {label: translations.report.vehicle, value:'name'},
276
- {label: translations.report.temperature, value:'temperature'}
277
- ] : [
278
- {label: translations.report.vehicle, value:'name'},
279
- {label: translations.report.group, value:'group'},
280
- {label: translations.report.date, value:'date'},
281
- {label: translations.report.address, value:'address'},
282
- {label: translations.report.speed, value:'speed'},
283
- {label: translations.report.ignition, value:'ignition'},
284
- {label: translations.report.driver, value:'driver'},
285
- {label: translations.report.temperature, value:'temperature'}
286
- ]
287
- let data = []
288
- if (positionsData) {
289
- positionsData.forEach(d => {
290
- data = data.concat(d.positions.map(a => {
291
- return {
292
- name: userData.byDriver ? a.vehicleName : d.device.name,
293
- group: userData.byDriver ? '' : deviceGroupName(userData.groups, d.device),
294
- date: getLocationDate(a, userData.user),
295
- address: a.address,
296
- speed: Math.round(a.speed * 1.85200),
297
- ignition: a.attributes.ignition ? translations.report.ignitionOn : translations.report.ignitionOff,
298
- driver: userData.byDriver ? d.driver.name : getDriverName(a, userData.drivers),
299
- temperature: getTempValue(a)
300
- }
301
- }))
302
- })
260
+ function exportLocationReportToExcel (userData, reportData) {
261
+ console.log('Export to Excel')
262
+
263
+ const translations = getTranslations(userData)
264
+
265
+ const positionsData = userData.byDriver ? reportData.drivers : reportData.devices
266
+
267
+ const settings = {
268
+ sheetName: translations.report.titleLocationReport, // The name of the sheet
269
+ fileName // The name of the spreadsheet
270
+ }
271
+ const headers = userData.byDriver
272
+ ? [
273
+ { label: translations.report.driver, value: 'driver' },
274
+ { label: translations.report.date, value: 'date' },
275
+ { label: translations.report.address, value: 'address' },
276
+ { label: translations.report.speed, value: 'speed' },
277
+ { label: translations.report.ignition, value: 'ignition' },
278
+ { label: translations.report.vehicle, value: 'name' },
279
+ { label: translations.report.temperature, value: 'temperature' }
280
+ ]
281
+ : [
282
+ { label: translations.report.vehicle, value: 'name' },
283
+ { label: translations.report.group, value: 'group' },
284
+ { label: translations.report.date, value: 'date' },
285
+ { label: translations.report.address, value: 'address' },
286
+ { label: translations.report.speed, value: 'speed' },
287
+ { label: translations.report.ignition, value: 'ignition' },
288
+ { label: translations.report.driver, value: 'driver' },
289
+ { label: translations.report.temperature, value: 'temperature' }
290
+ ]
291
+ let data = []
292
+ if (positionsData) {
293
+ positionsData.forEach(d => {
294
+ data = data.concat(d.positions.map(a => {
303
295
  return {
304
- headers,
305
- data,
306
- settings
296
+ name: userData.byDriver ? a.vehicleName : d.device.name,
297
+ group: userData.byDriver ? '' : deviceGroupName(userData.groups, d.device),
298
+ date: getLocationDate(a, userData.user),
299
+ address: a.address,
300
+ speed: Math.round(a.speed * 1.85200),
301
+ ignition: a.attributes.ignition ? translations.report.ignitionOn : translations.report.ignitionOff,
302
+ driver: userData.byDriver ? d.driver.name : getDriverName(a, userData.drivers),
303
+ temperature: getTempValue(a)
307
304
  }
305
+ }))
306
+ })
307
+ return {
308
+ headers,
309
+ data,
310
+ settings
308
311
  }
312
+ }
309
313
  }
310
314
 
311
- function deviceGroupName(groups, device, translation){
312
- const group = groups.find(g => device.groupId === g.id)
313
- if(group) {
314
- if(translation) {
315
- return translation.report.group + ': ' + group.name
316
- } else {
317
- return group.name
318
- }
315
+ function deviceGroupName (groups, device, translation) {
316
+ const group = groups.find(g => device.groupId === g.id)
317
+ if (group) {
318
+ if (translation) {
319
+ return translation.report.group + ': ' + group.name
320
+ } else {
321
+ return group.name
319
322
  }
320
- return ''
323
+ }
324
+ return ''
321
325
  }
322
326
 
323
- function deviceName(device){
324
- return device.name + (device.attributes.license_plate ? ', ' +device.attributes.license_plate : '') + (device.model ? ', ' + device.model : '')
327
+ function deviceName (device) {
328
+ return device.name + (device.attributes.license_plate ? ', ' + device.attributes.license_plate : '') + (device.model ? ', ' + device.model : '')
325
329
  }
326
330
 
327
- function getLocationDate(location, user){
328
- return convertToLocaleString(location.fixTime, user.attributes.lang, user.attributes.timezone)
331
+ function getLocationDate (location, user) {
332
+ return convertToLocaleString(location.fixTime, user.attributes.lang, user.attributes.timezone)
329
333
  }
330
334
 
331
- function getDriverName(location, drivers) {
332
- if(location.attributes.driverUniqueId) {
333
- const driver = drivers.find(d => d.uniqueId === location.attributes.driverUniqueId)
334
- return driver ? driver.name : location.attributes.driverUniqueId
335
- }
335
+ function getDriverName (location, drivers) {
336
+ if (location.attributes.driverUniqueId) {
337
+ const driver = drivers.find(d => d.uniqueId === location.attributes.driverUniqueId)
338
+ return driver ? driver.name : location.attributes.driverUniqueId
339
+ }
336
340
 
337
- return ''
341
+ return ''
338
342
  }
339
343
 
340
- function getMaxSpeed(data) {
341
- const values = data.map(item => {
342
- return item.speed
343
- })
344
- const max = values.reduce(function(a, b) {
345
- return Math.max(a, b);
346
- });
347
- return Math.round(max * 1.85200)
344
+ function getMaxSpeed (data) {
345
+ const values = data.map(item => {
346
+ return item.speed
347
+ })
348
+ const max = values.reduce(function (a, b) {
349
+ return Math.max(a, b)
350
+ })
351
+ return Math.round(max * 1.85200)
348
352
  }
349
353
 
350
354
  exports.createLocationReport = createLocationReport