fleetmap-reports 1.0.612 → 1.0.614
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 +25 -19
package/package.json
CHANGED
package/src/events-report.js
CHANGED
|
@@ -152,19 +152,22 @@ 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
|
+
if (value > 0) {
|
|
160
|
+
headerEventTypes.push([getEventType(data, translations, d.device), value])
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
|
|
155
164
|
doc.autoTable({
|
|
156
165
|
head: ['', '', '', '', ''],
|
|
157
166
|
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]
|
|
167
|
+
headerEventTypes.slice(0, 6).map(a => a[0]),
|
|
168
|
+
headerEventTypes.slice(0, 6).map(a => a[1]),
|
|
169
|
+
headerEventTypes.slice(7).map(a => a[0]),
|
|
170
|
+
headerEventTypes.slice(7).map(a => a[1])
|
|
168
171
|
],
|
|
169
172
|
startY: space + 30,
|
|
170
173
|
showHead: false,
|
|
@@ -173,9 +176,7 @@ async function exportSpeedingReportToPDF (userData, reportData) {
|
|
|
173
176
|
})
|
|
174
177
|
d.alerts.forEach(a => {
|
|
175
178
|
const temp = [
|
|
176
|
-
a
|
|
177
|
-
? getEventType(a, translations, d.device)
|
|
178
|
-
: translations.report['event_' + a.type],
|
|
179
|
+
getEventType(a, translations, d.device),
|
|
179
180
|
getAlertDate(userData.user, a),
|
|
180
181
|
a.geofenceName || (a.position ? a.position.address : ''),
|
|
181
182
|
getAlertInfo(userData.drivers, a, d.device, translations)
|
|
@@ -217,9 +218,13 @@ async function exportSpeedingReportToPDF (userData, reportData) {
|
|
|
217
218
|
}
|
|
218
219
|
|
|
219
220
|
function getEventType (a, translations, device) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
if (a.type === 'alarm') {
|
|
222
|
+
let sensor
|
|
223
|
+
if (a.attributes.alarm === 'sensor') { sensor = device.attributes.sensor1 }
|
|
224
|
+
return sensor || translations.report['event_' + a.attributes.alarm] || a.attributes.alarm
|
|
225
|
+
} else {
|
|
226
|
+
return translations.report['event_' + a.type]
|
|
227
|
+
}
|
|
223
228
|
}
|
|
224
229
|
|
|
225
230
|
function exportSpeedingReportToExcel (userData, reportData) {
|
|
@@ -247,9 +252,7 @@ function exportSpeedingReportToExcel (userData, reportData) {
|
|
|
247
252
|
data = data.concat(d.alerts.map(a => {
|
|
248
253
|
return {
|
|
249
254
|
name: d.device.name,
|
|
250
|
-
eventType: a
|
|
251
|
-
? getEventType(a, translations, d.device)
|
|
252
|
-
: translations.report['event_' + a.type],
|
|
255
|
+
eventType: getEventType(a, translations, d.device),
|
|
253
256
|
fixTime: getAlertDate(userData.user, a),
|
|
254
257
|
address: a.geofenceName || (a.position ? a.position.address : ''),
|
|
255
258
|
info: getAlertInfo(userData.drivers, a, d.device, translations),
|
|
@@ -280,6 +283,9 @@ function deviceName (device) {
|
|
|
280
283
|
}
|
|
281
284
|
|
|
282
285
|
function getAlertInfo (drivers, alert, device, translations) {
|
|
286
|
+
if (alert.type === 'alarm' && alert.attributes.alarm === 'sensor') {
|
|
287
|
+
return device ? device.attributes.sensor1on : ''
|
|
288
|
+
}
|
|
283
289
|
if (alert.type === 'alarm' && alert.position) {
|
|
284
290
|
return getDigitalPortValue(alert.position, 1, translations, device.attributes)
|
|
285
291
|
}
|