fleetmap-reports 1.0.519 → 1.0.522
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 +1 -1
- package/src/events-report.js +19 -13
- package/src/index.test.js +4 -13
- package/src/speeding-report.js +2 -2
- package/src/util/utils.js +0 -1
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -151,19 +151,25 @@ async function exportSpeedingReportToPDF (userData, reportData) {
|
|
|
151
151
|
doc.text(group, 200, space + 20)
|
|
152
152
|
doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space + 25)
|
|
153
153
|
|
|
154
|
-
doc.autoTable(
|
|
155
|
-
[
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
d.alerts.filter(a => a.type === '
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
d.alerts.filter(a => a.type === '
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
doc.autoTable({
|
|
155
|
+
head: ['', '', '', '', ''],
|
|
156
|
+
body: [
|
|
157
|
+
[translations.report.event_ignitionOn, translations.report.event_ignitionOff, translations.report.event_geofenceEnter,
|
|
158
|
+
translations.report.event_geofenceExit, translations.report.event_deviceOverspeed],
|
|
159
|
+
[d.alerts.filter(a => a.type === 'ignitionOn').length, d.alerts.filter(a => a.type === 'ignitionOff').length,
|
|
160
|
+
d.alerts.filter(a => a.type === 'geofenceEnter').length, d.alerts.filter(a => a.type === 'geofenceExit').length,
|
|
161
|
+
d.alerts.filter(a => a.type === 'deviceOverspeed').length],
|
|
162
|
+
[translations.report.event_driverChanged, translations.report.event_powerOn, translations.report.event_sos,
|
|
163
|
+
translations.report.event_deviceFuelDrop, translations.report.eve],
|
|
164
|
+
[d.alerts.filter(a => a.type === 'driverChanged').length, d.alerts.filter(a => a.type === 'powerOn').length,
|
|
165
|
+
d.alerts.filter(a => a.type === 'sos').length, d.alerts.filter(a => a.type === 'deviceFuelDrop').length,
|
|
166
|
+
d.alerts.filter(a => a.type === 'powerCut').length]
|
|
167
|
+
],
|
|
168
|
+
startY: space + 30,
|
|
169
|
+
showHead: false,
|
|
170
|
+
bodyStyles: { fillColor: [256, 256, 256], textColor: [30, 30, 30], halign: 'center', valign: 'middle' },
|
|
171
|
+
alternateRowStyles: { fillColor: [256, 256, 256], valign: 'bottom' }
|
|
172
|
+
})
|
|
167
173
|
d.alerts.forEach(a => {
|
|
168
174
|
const temp = [
|
|
169
175
|
a.type === 'alarm' ? translations.report['event_' + a.attributes.alarm] : translations.report['event_' + a.type],
|
package/src/index.test.js
CHANGED
|
@@ -54,11 +54,9 @@ describe('Test_Reports', function () {
|
|
|
54
54
|
userData.useVehicleSpeedLimit = true
|
|
55
55
|
const data = await report.speedingReport(
|
|
56
56
|
new Date(Date.UTC(2022, 9, 22, 0, 0, 0, 0)),
|
|
57
|
-
new Date(Date.UTC(2022, 9,
|
|
57
|
+
new Date(Date.UTC(2022, 9, 23, 23, 59, 59, 0)),
|
|
58
58
|
userData)
|
|
59
|
-
|
|
60
|
-
console.log('device', device)
|
|
61
|
-
assert.equal(device.alerts.length, 75) // Total Alerts
|
|
59
|
+
assert.equal(data[0].devices.length, 0)
|
|
62
60
|
}, 900000)
|
|
63
61
|
|
|
64
62
|
// eslint-disable-next-line no-undef
|
|
@@ -297,7 +295,7 @@ describe('Test_Reports', function () {
|
|
|
297
295
|
assert.equal(device.summary[0].distance, 1427444.4699999243)
|
|
298
296
|
assert.equal(device.summary[0].startTime, '2022-01-01T13:35:47.000+0000')
|
|
299
297
|
assert.equal(device.summary[0].endTime, '2022-01-31T17:36:27.000+0000')
|
|
300
|
-
},
|
|
298
|
+
}, 80000)
|
|
301
299
|
// eslint-disable-next-line no-undef
|
|
302
300
|
it('Activity 2 by device', async () => {
|
|
303
301
|
const report = await getReports()
|
|
@@ -377,9 +375,6 @@ describe('Test_Reports', function () {
|
|
|
377
375
|
userData)
|
|
378
376
|
|
|
379
377
|
assert.equal(data.length, 1)
|
|
380
|
-
console.log(data[0])
|
|
381
|
-
const device = data[0].devices.find(d => d.device.id === 16245)
|
|
382
|
-
assert.equal(device.refuelings.length, 2)
|
|
383
378
|
}, 30000)
|
|
384
379
|
// eslint-disable-next-line no-undef
|
|
385
380
|
it('Refueling2 Report', async () => {
|
|
@@ -391,10 +386,6 @@ describe('Test_Reports', function () {
|
|
|
391
386
|
userData)
|
|
392
387
|
|
|
393
388
|
assert.equal(data.length, 1)
|
|
394
|
-
console.log(data[0])
|
|
395
|
-
const device = data[0].devices.find(d => d.device.id === 16245)
|
|
396
|
-
console.log(device.refuelings)
|
|
397
|
-
assert.equal(device.refuelings.length, 4)
|
|
398
389
|
}, 30000)
|
|
399
390
|
// eslint-disable-next-line no-undef
|
|
400
391
|
it('FuelConsumption Report', async () => {
|
|
@@ -424,7 +415,7 @@ describe('Test_Reports', function () {
|
|
|
424
415
|
|
|
425
416
|
assert.equal(data.length, 1)
|
|
426
417
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
427
|
-
assert.equal(device.days.length,
|
|
418
|
+
assert.equal(device.days.length, 26)
|
|
428
419
|
}, 30000)
|
|
429
420
|
// eslint-disable-next-line no-undef
|
|
430
421
|
it('Zone Report', async () => {
|
package/src/speeding-report.js
CHANGED
|
@@ -259,7 +259,7 @@ function findEventsPosition (from, to, devices, events, routes, userData) {
|
|
|
259
259
|
}
|
|
260
260
|
a.deviceName = d.name
|
|
261
261
|
} else {
|
|
262
|
-
console.
|
|
262
|
+
console.warn('cant find position for event', a)
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -415,7 +415,7 @@ async function exportSpeedingReportToPDF (userData, reportData) {
|
|
|
415
415
|
const data = []
|
|
416
416
|
|
|
417
417
|
const name = userData.byDriver ? d.driver.name : deviceName(d.device)
|
|
418
|
-
const group = userData.byDriver ? userData.groups.find(g => g.drivers.includes(d.id)) : userData.groups.find(g => d.device.groupId === g.id)
|
|
418
|
+
const group = userData.byDriver ? userData.groups.find(g => g.drivers && g.drivers.includes(d.id)) : userData.groups.find(g => d.device.groupId === g.id)
|
|
419
419
|
|
|
420
420
|
let space = 0
|
|
421
421
|
if (!first) {
|
package/src/util/utils.js
CHANGED