fleetmap-reports 1.0.611 → 1.0.613
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 +20 -19
- package/src/speeding-report.js +1 -1
- package/src/tests/index.test.js +0 -1
- package/src/tests/speeding.test.js +1 -1
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -152,19 +152,20 @@ async function exportSpeedingReportToPDF (userData, reportData) {
|
|
|
152
152
|
doc.text(group, 200, space + 20)
|
|
153
153
|
doc.text(convertToLocaleString(d.from, lang, timezone) + ' - ' + convertToLocaleString(d.to, lang, timezone), 20, space + 25)
|
|
154
154
|
|
|
155
|
+
const headerEventTypes = []
|
|
156
|
+
userData.eventTypes.forEach(e => {
|
|
157
|
+
const data = e.startsWith('alarm') ? { type: 'alarm', attributes: { alarm: e.slice(6) } } : { type: e }
|
|
158
|
+
const value = e.startsWith('alarm') ? d.alerts.filter(a => a.attributes.alarm === data.attributes.alarm).length : d.alerts.filter(a => a.type === e).length
|
|
159
|
+
headerEventTypes.push([getEventType(data, translations, d.device), value])
|
|
160
|
+
})
|
|
161
|
+
|
|
155
162
|
doc.autoTable({
|
|
156
163
|
head: ['', '', '', '', ''],
|
|
157
164
|
body: [
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
d.alerts.filter(a => a.type === 'deviceOverspeed').length],
|
|
163
|
-
[translations.report.event_driverChanged, translations.report.event_powerOn, translations.report.event_sos,
|
|
164
|
-
translations.report.event_deviceFuelDrop, translations.report.eve],
|
|
165
|
-
[d.alerts.filter(a => a.type === 'driverChanged').length, d.alerts.filter(a => a.type === 'powerOn').length,
|
|
166
|
-
d.alerts.filter(a => a.type === 'sos').length, d.alerts.filter(a => a.type === 'deviceFuelDrop').length,
|
|
167
|
-
d.alerts.filter(a => a.type === 'powerCut').length]
|
|
165
|
+
headerEventTypes.slice(0, 6).map(a => a[0]),
|
|
166
|
+
headerEventTypes.slice(0, 6).map(a => a[1]),
|
|
167
|
+
headerEventTypes.slice(7).map(a => a[0]),
|
|
168
|
+
headerEventTypes.slice(7).map(a => a[1])
|
|
168
169
|
],
|
|
169
170
|
startY: space + 30,
|
|
170
171
|
showHead: false,
|
|
@@ -173,9 +174,7 @@ async function exportSpeedingReportToPDF (userData, reportData) {
|
|
|
173
174
|
})
|
|
174
175
|
d.alerts.forEach(a => {
|
|
175
176
|
const temp = [
|
|
176
|
-
a
|
|
177
|
-
? getEventType(a, translations, d.device)
|
|
178
|
-
: translations.report['event_' + a.type],
|
|
177
|
+
getEventType(a, translations, d.device),
|
|
179
178
|
getAlertDate(userData.user, a),
|
|
180
179
|
a.geofenceName || (a.position ? a.position.address : ''),
|
|
181
180
|
getAlertInfo(userData.drivers, a, d.device, translations)
|
|
@@ -217,9 +216,13 @@ async function exportSpeedingReportToPDF (userData, reportData) {
|
|
|
217
216
|
}
|
|
218
217
|
|
|
219
218
|
function getEventType (a, translations, device) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
if (a.type === 'alarm') {
|
|
220
|
+
let sensor
|
|
221
|
+
if (a.attributes.alarm === 'sensor') { sensor = device.attributes.sensor1 }
|
|
222
|
+
return sensor || translations.report['event_' + a.attributes.alarm] || a.attributes.alarm
|
|
223
|
+
} else {
|
|
224
|
+
return translations.report['event_' + a.type]
|
|
225
|
+
}
|
|
223
226
|
}
|
|
224
227
|
|
|
225
228
|
function exportSpeedingReportToExcel (userData, reportData) {
|
|
@@ -247,9 +250,7 @@ function exportSpeedingReportToExcel (userData, reportData) {
|
|
|
247
250
|
data = data.concat(d.alerts.map(a => {
|
|
248
251
|
return {
|
|
249
252
|
name: d.device.name,
|
|
250
|
-
eventType: a
|
|
251
|
-
? getEventType(a, translations, d.device)
|
|
252
|
-
: translations.report['event_' + a.type],
|
|
253
|
+
eventType: getEventType(a, translations, d.device),
|
|
253
254
|
fixTime: getAlertDate(userData.user, a),
|
|
254
255
|
address: a.geofenceName || (a.position ? a.position.address : ''),
|
|
255
256
|
info: getAlertInfo(userData.drivers, a, d.device, translations),
|
package/src/speeding-report.js
CHANGED
|
@@ -135,7 +135,7 @@ async function getEvents (traccarInstance, from, to, devices, userData, deviceCo
|
|
|
135
135
|
|
|
136
136
|
const events = []
|
|
137
137
|
if (userData.roadSpeedLimits) {
|
|
138
|
-
const hereResults = await getHereEvents(devices, routes, userData.maxSpeedThreshold, userData.
|
|
138
|
+
const hereResults = await getHereEvents(devices, routes, userData.maxSpeedThreshold, userData.minimumIdleMinutes)
|
|
139
139
|
console.log('got', hereResults.length, 'from here')
|
|
140
140
|
events.push(...hereResults)
|
|
141
141
|
} else if (!userData.useVehicleSpeedLimit && userData.customSpeed) {
|
package/src/tests/index.test.js
CHANGED
|
@@ -23,7 +23,7 @@ describe('speeding tests', function () {
|
|
|
23
23
|
assert.equal(device.alerts.length, 104) // Total Alerts
|
|
24
24
|
console.log(device.alerts)
|
|
25
25
|
|
|
26
|
-
userData.
|
|
26
|
+
userData.minimumIdleMinutes = 1
|
|
27
27
|
const r = await getSpeedingReport(report, userData)
|
|
28
28
|
r.device.alerts.forEach(a => assert.equal(true, a.eventTime >= 60000))
|
|
29
29
|
assert.equal(r.device.alerts.length, 6) // Total Alerts
|