fleetmap-reports 1.0.259 → 1.0.260
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/.idea/workspace.xml +17 -4
- package/package.json +1 -1
- package/src/events-report.js +4 -5
- package/src/location-report.js +4 -11
- package/src/speeding-report.js +4 -6
- package/src/trip-report.js +14 -16
- package/src/util/utils.js +38 -0
- package/src/zone-report.js +5 -10
package/.idea/workspace.xml
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ChangeListManager">
|
|
4
|
-
<list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="
|
|
4
|
+
<list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="location report - check if it's running on client side">
|
|
5
5
|
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
|
6
6
|
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
7
|
+
<change beforePath="$PROJECT_DIR$/src/events-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/events-report.js" afterDir="false" />
|
|
7
8
|
<change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
|
|
8
9
|
<change beforePath="$PROJECT_DIR$/src/location-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/location-report.js" afterDir="false" />
|
|
10
|
+
<change beforePath="$PROJECT_DIR$/src/speeding-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/speeding-report.js" afterDir="false" />
|
|
11
|
+
<change beforePath="$PROJECT_DIR$/src/trip-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/trip-report.js" afterDir="false" />
|
|
12
|
+
<change beforePath="$PROJECT_DIR$/src/util/utils.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/utils.js" afterDir="false" />
|
|
13
|
+
<change beforePath="$PROJECT_DIR$/src/zone-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/zone-report.js" afterDir="false" />
|
|
9
14
|
</list>
|
|
10
15
|
<option name="SHOW_DIALOG" value="false" />
|
|
11
16
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -215,7 +220,7 @@
|
|
|
215
220
|
<workItem from="1639954341221" duration="11986000" />
|
|
216
221
|
<workItem from="1640272520380" duration="2253000" />
|
|
217
222
|
<workItem from="1640789226071" duration="1935000" />
|
|
218
|
-
<workItem from="1640794844118" duration="
|
|
223
|
+
<workItem from="1640794844118" duration="8847000" />
|
|
219
224
|
</task>
|
|
220
225
|
<task id="LOCAL-00001" summary="Fix getStyle">
|
|
221
226
|
<created>1636983717385</created>
|
|
@@ -329,7 +334,14 @@
|
|
|
329
334
|
<option name="project" value="LOCAL" />
|
|
330
335
|
<updated>1640274171902</updated>
|
|
331
336
|
</task>
|
|
332
|
-
<
|
|
337
|
+
<task id="LOCAL-00017" summary="location report - check if it's running on client side">
|
|
338
|
+
<created>1640795243287</created>
|
|
339
|
+
<option name="number" value="00017" />
|
|
340
|
+
<option name="presentableId" value="LOCAL-00017" />
|
|
341
|
+
<option name="project" value="LOCAL" />
|
|
342
|
+
<updated>1640795243288</updated>
|
|
343
|
+
</task>
|
|
344
|
+
<option name="localTasksCounter" value="18" />
|
|
333
345
|
<servers />
|
|
334
346
|
</component>
|
|
335
347
|
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -363,6 +375,7 @@
|
|
|
363
375
|
<MESSAGE value="Trip and activity report with time period" />
|
|
364
376
|
<MESSAGE value="Fix trips distance because imported positions generate trips with 0 kms" />
|
|
365
377
|
<MESSAGE value="Fix reports by driver" />
|
|
366
|
-
<
|
|
378
|
+
<MESSAGE value="location report - check if it's running on client side" />
|
|
379
|
+
<option name="LAST_COMMIT_MESSAGE" value="location report - check if it's running on client side" />
|
|
367
380
|
</component>
|
|
368
381
|
</project>
|
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -5,6 +5,7 @@ require('jspdf-autotable')
|
|
|
5
5
|
const {getStyle} = require("./reportStyle");
|
|
6
6
|
const {headerFromUser} = require("./util/pdfDocument");
|
|
7
7
|
const {getUserPartner} = require("fleetmap-partners");
|
|
8
|
+
const {convertToLocaleString} = require("./util/utils");
|
|
8
9
|
|
|
9
10
|
const fileName = 'EventReport'
|
|
10
11
|
|
|
@@ -120,6 +121,7 @@ async function exportSpeedingReportToPDF(userData, reportData) {
|
|
|
120
121
|
console.log('Export to PDF')
|
|
121
122
|
|
|
122
123
|
const lang = userData.user.attributes.lang
|
|
124
|
+
const timezone = userData.user.attributes.timezone
|
|
123
125
|
const translations = messages[lang] ? messages[lang] : messages['en-GB']
|
|
124
126
|
|
|
125
127
|
const headers = [
|
|
@@ -149,7 +151,7 @@ async function exportSpeedingReportToPDF(userData, reportData) {
|
|
|
149
151
|
doc.text(name, 20, space+20 )
|
|
150
152
|
doc.setFontSize(11)
|
|
151
153
|
doc.text(group, 200, space+20 )
|
|
152
|
-
doc.text(
|
|
154
|
+
doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space+25 )
|
|
153
155
|
|
|
154
156
|
doc.autoTable(['','','','',''], [
|
|
155
157
|
[translations.report.event_ignitionOn,translations.report.event_ignitionOff, translations.report.event_geofenceEnter,
|
|
@@ -270,10 +272,7 @@ function getAlertInfo(drivers, alert) {
|
|
|
270
272
|
|
|
271
273
|
function getAlertDate(user, alert) {
|
|
272
274
|
if(alert.position) {
|
|
273
|
-
return
|
|
274
|
-
timeZone: user.attributes.timezone,
|
|
275
|
-
hour12: false
|
|
276
|
-
})
|
|
275
|
+
return convertToLocaleString(alert.position.fixTime, user.attributes.lang, user.attributes.timezone)
|
|
277
276
|
}
|
|
278
277
|
}
|
|
279
278
|
|
package/src/location-report.js
CHANGED
|
@@ -5,11 +5,10 @@ require('jspdf-autotable')
|
|
|
5
5
|
const {headerFromUser} = require("./util/pdfDocument");
|
|
6
6
|
const {getStyle} = require("./reportStyle")
|
|
7
7
|
const {getUserPartner} = require("fleetmap-partners");
|
|
8
|
+
const {convertToLocaleString} = require("./util/utils");
|
|
8
9
|
|
|
9
10
|
const fileName = 'LocationReport'
|
|
10
11
|
|
|
11
|
-
const clientSide = typeof window !== "undefined"
|
|
12
|
-
|
|
13
12
|
async function createLocationReport(from, to, userData, traccar) {
|
|
14
13
|
console.log('Create LocationReport')
|
|
15
14
|
|
|
@@ -106,6 +105,7 @@ async function exportLocationReportToPDF(userData, reportData) {
|
|
|
106
105
|
console.log('Export to PDF')
|
|
107
106
|
|
|
108
107
|
const lang = userData.user.attributes.lang
|
|
108
|
+
const timezone = userData.user.attributes.timezone
|
|
109
109
|
const translations = messages[lang] ? messages[lang] : messages['en-GB']
|
|
110
110
|
|
|
111
111
|
const headers = [
|
|
@@ -138,7 +138,7 @@ async function exportLocationReportToPDF(userData, reportData) {
|
|
|
138
138
|
doc.text(name, 20, space + 20)
|
|
139
139
|
doc.setFontSize(11)
|
|
140
140
|
doc.text(group, 200, space + 20)
|
|
141
|
-
doc.text(
|
|
141
|
+
doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space + 25)
|
|
142
142
|
d.positions.map(a => {
|
|
143
143
|
const temp = [
|
|
144
144
|
getLocationDate(a, userData.user),
|
|
@@ -253,14 +253,7 @@ function deviceName(device){
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
function getLocationDate(location, user){
|
|
256
|
-
|
|
257
|
-
return new Date(location.fixTime).toLocaleString()
|
|
258
|
-
} else {
|
|
259
|
-
return new Date(location.fixTime).toLocaleString(user.attributes.lang, {
|
|
260
|
-
timeZone: user.attributes.timezone,
|
|
261
|
-
hour12: false
|
|
262
|
-
})
|
|
263
|
-
}
|
|
256
|
+
return convertToLocaleString(location.fixTime, user.attributes.lang, user.attributes.timezone)
|
|
264
257
|
}
|
|
265
258
|
|
|
266
259
|
function getDriverName(location, drivers) {
|
package/src/speeding-report.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const messages = require('../lang')
|
|
2
2
|
const jsPDF = require('jspdf')
|
|
3
|
-
const {convertMS} = require("./util/utils")
|
|
3
|
+
const {convertMS, convertToLocaleString} = require("./util/utils")
|
|
4
4
|
const {headerFromUser} = require("./util/pdfDocument")
|
|
5
5
|
require('jspdf-autotable')
|
|
6
6
|
const { parse } = require('wkt')
|
|
@@ -318,6 +318,7 @@ async function exportSpeedingReportToPDF(userData, reportData) {
|
|
|
318
318
|
console.log('Export to PDF')
|
|
319
319
|
|
|
320
320
|
const lang = userData.user.attributes.lang
|
|
321
|
+
const timezone = userData.user.attributes.timezone
|
|
321
322
|
const translations = messages[lang] ? messages[lang] : messages['en-GB']
|
|
322
323
|
|
|
323
324
|
const overspeedData = userData.byDriver ? reportData.drivers : reportData.devices
|
|
@@ -364,7 +365,7 @@ async function exportSpeedingReportToPDF(userData, reportData) {
|
|
|
364
365
|
doc.text(name, 20, space+20 )
|
|
365
366
|
doc.setFontSize(11)
|
|
366
367
|
doc.text(group ? translations.report.group + ': ' + group.name : '', 150, space+20 )
|
|
367
|
-
doc.text(
|
|
368
|
+
doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space+25 )
|
|
368
369
|
if (d.alerts[0] && !userData.byDriver) {
|
|
369
370
|
doc.text(translations.report.speedLimit + ": " + (userData.useVehicleSpeedLimit ? Math.round(d.alerts[0].attributes.speedLimit * 1.85200) : userData.customSpeed) + ' Km/h', 20, space + 30)
|
|
370
371
|
}
|
|
@@ -490,10 +491,7 @@ function deviceName(device){
|
|
|
490
491
|
}
|
|
491
492
|
|
|
492
493
|
function getAlertDate(row, user) {
|
|
493
|
-
return
|
|
494
|
-
timeZone: user.attributes.timezone,
|
|
495
|
-
hour12: false
|
|
496
|
-
})
|
|
494
|
+
return convertToLocaleString(row.position.fixTime, user.attributes.lang, user.attributes.timezone)
|
|
497
495
|
}
|
|
498
496
|
|
|
499
497
|
function getMaxSpeed(data) {
|
package/src/trip-report.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const automaticReports = require("./automaticReports")
|
|
2
2
|
const messages = require('../lang')
|
|
3
3
|
const jsPDF = require('jspdf')
|
|
4
|
-
const {convertMS} = require("./util/utils")
|
|
4
|
+
const {convertMS, convertToLocaleString, convertToLocaleDateString, convertToLocaleTimeString} = require("./util/utils")
|
|
5
5
|
require('jspdf-autotable')
|
|
6
6
|
const {coordsDistance} = require("./util/utils")
|
|
7
7
|
const drivers = require("./util/driver")
|
|
@@ -217,6 +217,7 @@ async function exportTripReportToPDF(userData, reportData) {
|
|
|
217
217
|
console.log('Export to PDF')
|
|
218
218
|
|
|
219
219
|
const lang = userData.user.attributes.lang
|
|
220
|
+
const timezone = userData.user.attributes.timezone
|
|
220
221
|
const translations = messages[lang] ? messages[lang] : messages['en-GB']
|
|
221
222
|
const tripsData = userData.byDriver ? reportData.drivers : reportData.devices
|
|
222
223
|
|
|
@@ -260,7 +261,7 @@ async function exportTripReportToPDF(userData, reportData) {
|
|
|
260
261
|
doc.text(name, 20, space+20 )
|
|
261
262
|
doc.setFontSize(11)
|
|
262
263
|
doc.text(group ? translations.report.group + ': ' + group.name : '', 200, space+20 )
|
|
263
|
-
doc.text(
|
|
264
|
+
doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space+25 )
|
|
264
265
|
if(!userData.allWeek) {
|
|
265
266
|
doc.text((userData.weekDays.monday ? ' ' + translations.report.monday + ',' : '')
|
|
266
267
|
+ (userData.weekDays.tuesday ? ' ' + translations.report.tuesday + ',' : '')
|
|
@@ -398,23 +399,17 @@ function deviceName(device){
|
|
|
398
399
|
}
|
|
399
400
|
|
|
400
401
|
function getTripDate(user, trip){
|
|
401
|
-
return
|
|
402
|
-
timeZone: user.attributes.timezone,
|
|
403
|
-
hour12: false
|
|
404
|
-
})
|
|
402
|
+
return convertToLocaleDateString(trip.startTime, user.attributes.lang, user.attributes.timezone)
|
|
405
403
|
}
|
|
404
|
+
|
|
406
405
|
function getTripStart(user, trip){
|
|
407
|
-
return
|
|
408
|
-
timeZone: user.attributes.timezone,
|
|
409
|
-
hour12: false
|
|
410
|
-
})
|
|
406
|
+
return convertToLocaleTimeString(trip.startTime, user.attributes.lang, user.attributes.timezone)
|
|
411
407
|
}
|
|
408
|
+
|
|
412
409
|
function getTripEnd(user, trip){
|
|
413
|
-
return
|
|
414
|
-
timeZone: user.attributes.timezone,
|
|
415
|
-
hour12: false
|
|
416
|
-
})
|
|
410
|
+
return convertToLocaleTimeString(trip.endTime, user.attributes.lang, user.attributes.timezone)
|
|
417
411
|
}
|
|
412
|
+
|
|
418
413
|
function getDriverName(drivers, driverUniqueId) {
|
|
419
414
|
if(driverUniqueId) {
|
|
420
415
|
const driver = drivers.find(d => d.uniqueId === driverUniqueId)
|
|
@@ -423,18 +418,21 @@ function getDriverName(drivers, driverUniqueId) {
|
|
|
423
418
|
|
|
424
419
|
return ''
|
|
425
420
|
}
|
|
421
|
+
|
|
426
422
|
function getSumTotalKms(user, data) {
|
|
427
423
|
const values = data.map(item => {
|
|
428
424
|
return item.totalKms ? parseFloat(item.totalKms) : 0
|
|
429
425
|
})
|
|
430
426
|
return Intl.NumberFormat(user.attributes.lang, {maximumFractionDigits: 2}).format(values.reduce((a, b) => a + b, 0))
|
|
431
427
|
}
|
|
428
|
+
|
|
432
429
|
function getSumAvgSpeed(data) {
|
|
433
430
|
const values = data.map(item => {
|
|
434
|
-
return Math.round(item.averageSpeed * 1.85200)
|
|
431
|
+
return Math.round(item.averageSpeed * 1.85200) * item.totalKms
|
|
435
432
|
})
|
|
436
|
-
return Math.round((values.reduce((a, b) => a + b, 0)) / data.
|
|
433
|
+
return Math.round((values.reduce((a, b) => a + b, 0)) / data.reduce((a, b) => a + b.totalKms, 0))
|
|
437
434
|
}
|
|
435
|
+
|
|
438
436
|
function getMaxSpeed(data) {
|
|
439
437
|
const values = data.map(item => {
|
|
440
438
|
return item.maxSpeed
|
package/src/util/utils.js
CHANGED
|
@@ -55,8 +55,46 @@ async function getImgFromUrl(hostname) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
function isClientSide() { typeof window !== "undefined" }
|
|
59
|
+
|
|
60
|
+
function convertToLocaleString(value, lang, timezone){
|
|
61
|
+
if(isClientSide){
|
|
62
|
+
return new Date(value).toLocaleString()
|
|
63
|
+
} else {
|
|
64
|
+
return new Date(value).toLocaleString(lang, {
|
|
65
|
+
timeZone: timezone,
|
|
66
|
+
hour12: false
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function convertToLocaleDateString(value, lang, timezone){
|
|
72
|
+
if(isClientSide){
|
|
73
|
+
return new Date(value).toLocaleDateString()
|
|
74
|
+
} else {
|
|
75
|
+
return new Date(value).toLocaleDateString(lang, {
|
|
76
|
+
timeZone: timezone,
|
|
77
|
+
hour12: false
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function convertToLocaleTimeString(value, lang, timezone){
|
|
83
|
+
if(isClientSide){
|
|
84
|
+
return new Date(value).toLocaleTimeString()
|
|
85
|
+
} else {
|
|
86
|
+
return new Date(value).toLocaleTimeString(lang, {
|
|
87
|
+
timeZone: timezone,
|
|
88
|
+
hour12: false
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
58
93
|
exports.getImgFromUrl = getImgFromUrl
|
|
59
94
|
exports.convertMS = convertMS
|
|
60
95
|
exports.coordsDistance = coordsDistance
|
|
61
96
|
exports.getDates = getDates
|
|
97
|
+
exports.convertToLocaleString = convertToLocaleString
|
|
98
|
+
exports.convertToLocaleDateString = convertToLocaleDateString
|
|
99
|
+
exports.convertToLocaleTimeString = convertToLocaleTimeString
|
|
62
100
|
|
package/src/zone-report.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const moment = require('moment')
|
|
2
2
|
const messages = require('../lang')
|
|
3
3
|
const automaticReports = require("./automaticReports");
|
|
4
|
-
const {convertMS} = require("./util/utils")
|
|
4
|
+
const {convertMS, convertToLocaleString} = require("./util/utils")
|
|
5
5
|
const jsPDF = require('jspdf')
|
|
6
6
|
require('jspdf-autotable')
|
|
7
7
|
const {headerFromUser} = require("./util/pdfDocument");
|
|
@@ -150,6 +150,7 @@ async function exportZoneReportToPDF(userData, reportData) {
|
|
|
150
150
|
console.log('Export to PDF')
|
|
151
151
|
|
|
152
152
|
const lang = userData.user.attributes.lang
|
|
153
|
+
const timezone = userData.user.attributes.timezone
|
|
153
154
|
const translations = messages[lang] ? messages[lang] : messages['en-GB']
|
|
154
155
|
|
|
155
156
|
const headers = [
|
|
@@ -180,7 +181,7 @@ async function exportZoneReportToPDF(userData, reportData) {
|
|
|
180
181
|
doc.text(name, 20, space+20 )
|
|
181
182
|
doc.setFontSize(11)
|
|
182
183
|
doc.text(group ? translations.report.group + ': ' + group.name : '', 200, space+20 )
|
|
183
|
-
doc.text(
|
|
184
|
+
doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space+25 )
|
|
184
185
|
d.geofences.map(a => {
|
|
185
186
|
const temp = [
|
|
186
187
|
geofenceEnter(userData.user, a),
|
|
@@ -271,16 +272,10 @@ function deviceName(device){
|
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
function geofenceEnter(user, row){
|
|
274
|
-
return row.inTime ?
|
|
275
|
-
timeZone: user.attributes.timezone,
|
|
276
|
-
hour12: false
|
|
277
|
-
}) : ''
|
|
275
|
+
return row.inTime ? convertToLocaleString(row.inTime.fixTime, user.attributes.lang, user.attributes.timezone) : ''
|
|
278
276
|
}
|
|
279
277
|
function geofenceExit(user, row){
|
|
280
|
-
return row.outTime ?
|
|
281
|
-
timeZone: user.attributes.timezone,
|
|
282
|
-
hour12: false
|
|
283
|
-
}) : ''
|
|
278
|
+
return row.outTime ? convertToLocaleString(row.outTime.fixTime, user.attributes.lang, user.attributes.timezone) : ''
|
|
284
279
|
}
|
|
285
280
|
|
|
286
281
|
exports.createZoneReport = createZoneReport
|