fleetmap-reports 1.0.518 → 1.0.520
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 +38 -13
- package/src/util/utils.js +1 -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
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
1
2
|
const { getReports } = require('./tests')
|
|
2
3
|
const assert = require('assert')
|
|
4
|
+
const utils = require('./util/utils')
|
|
3
5
|
|
|
4
6
|
async function getSpeedingReport (report, userData) {
|
|
5
7
|
const data = await report.speedingReport(
|
|
@@ -15,7 +17,24 @@ async function getSpeedingReport (report, userData) {
|
|
|
15
17
|
|
|
16
18
|
// eslint-disable-next-line no-undef
|
|
17
19
|
describe('Test_Reports', function () {
|
|
18
|
-
|
|
20
|
+
it('converts to pdf', async () => {
|
|
21
|
+
const report = await getReports()
|
|
22
|
+
const userData = await report.getUserData()
|
|
23
|
+
userData.roadSpeedLimits = false
|
|
24
|
+
userData.customSpeed = false
|
|
25
|
+
userData.useVehicleSpeedLimit = true
|
|
26
|
+
const data = await report.speedingReport(
|
|
27
|
+
new Date(Date.UTC(2022, 9, 22, 0, 0, 0, 0)),
|
|
28
|
+
new Date(Date.UTC(2022, 9, 22, 23, 59, 59, 0)),
|
|
29
|
+
userData)
|
|
30
|
+
console.log(await report.speedingReportToPDF(userData, data))
|
|
31
|
+
}, 20000)
|
|
32
|
+
|
|
33
|
+
it('converts madrid time', async () => {
|
|
34
|
+
assert.equal(false, utils.isClientSide())
|
|
35
|
+
console.log(utils.convertToLocaleString(new Date(), 'es-CL', 'Europe/Madrid'))
|
|
36
|
+
})
|
|
37
|
+
|
|
19
38
|
// eslint-disable-next-line no-undef
|
|
20
39
|
it('works with road speed limits', async () => {
|
|
21
40
|
const report = await getReports()
|
|
@@ -35,11 +54,9 @@ describe('Test_Reports', function () {
|
|
|
35
54
|
userData.useVehicleSpeedLimit = true
|
|
36
55
|
const data = await report.speedingReport(
|
|
37
56
|
new Date(Date.UTC(2022, 9, 22, 0, 0, 0, 0)),
|
|
38
|
-
new Date(Date.UTC(2022, 9,
|
|
57
|
+
new Date(Date.UTC(2022, 9, 23, 23, 59, 59, 0)),
|
|
39
58
|
userData)
|
|
40
|
-
|
|
41
|
-
console.log('device', device)
|
|
42
|
-
assert.equal(device.alerts.length, 75) // Total Alerts
|
|
59
|
+
assert.equal(data[0].devices.length, 0)
|
|
43
60
|
}, 900000)
|
|
44
61
|
|
|
45
62
|
// eslint-disable-next-line no-undef
|
|
@@ -351,16 +368,24 @@ describe('Test_Reports', function () {
|
|
|
351
368
|
it('Refueling Report', async () => {
|
|
352
369
|
const report = await getReports()
|
|
353
370
|
const userData = await report.getUserData()
|
|
354
|
-
|
|
371
|
+
|
|
355
372
|
const data = await report.refuelingReport(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
373
|
+
new Date(Date.UTC(2022, 1, 2, 0, 0, 0, 0)),
|
|
374
|
+
new Date(Date.UTC(2022, 1, 2, 23, 59, 59, 0)),
|
|
375
|
+
userData)
|
|
376
|
+
|
|
377
|
+
assert.equal(data.length, 1)
|
|
378
|
+
}, 30000)
|
|
379
|
+
// eslint-disable-next-line no-undef
|
|
380
|
+
it('Refueling2 Report', async () => {
|
|
381
|
+
const report = await getReports()
|
|
382
|
+
const userData = await report.getUserData()
|
|
383
|
+
|
|
384
|
+
const data = await report.refuelingReport(new Date(2022, 1, 21, 0, 0, 0, 0),
|
|
385
|
+
new Date(2022, 1, 25, 23, 59, 59, 0),
|
|
386
|
+
userData)
|
|
359
387
|
|
|
360
388
|
assert.equal(data.length, 1)
|
|
361
|
-
console.log(data[0])
|
|
362
|
-
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
363
|
-
assert.equal(device.refuelings.length, 2)
|
|
364
389
|
}, 30000)
|
|
365
390
|
// eslint-disable-next-line no-undef
|
|
366
391
|
it('FuelConsumption Report', async () => {
|
|
@@ -390,7 +415,7 @@ describe('Test_Reports', function () {
|
|
|
390
415
|
|
|
391
416
|
assert.equal(data.length, 1)
|
|
392
417
|
const device = data[0].devices.find(d => d.device.id === 22326)
|
|
393
|
-
assert.equal(device.days.length,
|
|
418
|
+
assert.equal(device.days.length, 25)
|
|
394
419
|
}, 30000)
|
|
395
420
|
// eslint-disable-next-line no-undef
|
|
396
421
|
it('Zone Report', async () => {
|
package/src/util/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ const messages = require('../../lang')
|
|
|
5
5
|
const distance = require('@turf/distance')
|
|
6
6
|
|
|
7
7
|
exports.getTranslations = (userData) => {
|
|
8
|
-
const lang =
|
|
8
|
+
const lang = this.getLanguage(userData)
|
|
9
9
|
if (!messages[lang]) {
|
|
10
10
|
console.warn('no lang found for', userData.user, userData.user.attributes.lang, navigator && navigator.language)
|
|
11
11
|
}
|