fleetmap-reports 1.0.447 → 1.0.448
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/lang/enGB.js +4 -0
- package/lang/ptBR.js +6 -0
- package/lang/ptPT.js +6 -0
- package/package.json +1 -1
- package/src/index.test.js +2 -0
- package/src/location-report.js +58 -9
- package/src/util/odoo.js +9 -7
package/lang/enGB.js
CHANGED
|
@@ -161,6 +161,10 @@ module.exports = {
|
|
|
161
161
|
delete_geofence: 'Delete'
|
|
162
162
|
},
|
|
163
163
|
report: {
|
|
164
|
+
closed: 'Door Closed',
|
|
165
|
+
opened: 'Door Opened',
|
|
166
|
+
sun: 'Sun',
|
|
167
|
+
rain: 'Rain',
|
|
164
168
|
temperature: 'Temperatura',
|
|
165
169
|
select_vehicles: 'Select vehicles',
|
|
166
170
|
select_vehicles_placeholder: 'Vehicles',
|
package/lang/ptBR.js
CHANGED
|
@@ -153,6 +153,12 @@ module.exports = {
|
|
|
153
153
|
delete_geofence: 'Apagar'
|
|
154
154
|
},
|
|
155
155
|
report: {
|
|
156
|
+
closed: 'Porta fechada',
|
|
157
|
+
opened: 'Porta aberta',
|
|
158
|
+
sun: 'Sol',
|
|
159
|
+
rain: 'Chuva',
|
|
160
|
+
digital_ports1: 'Portas Digitais 1',
|
|
161
|
+
digital_ports2: 'Portas Digitais 2',
|
|
156
162
|
temperature: 'Temperatura',
|
|
157
163
|
select_vehicles: 'Seleccionar veículos',
|
|
158
164
|
select_vehicles_placeholder: 'Veículos',
|
package/lang/ptPT.js
CHANGED
|
@@ -157,6 +157,12 @@ module.exports = {
|
|
|
157
157
|
delete_geofence: 'Apagar'
|
|
158
158
|
},
|
|
159
159
|
report: {
|
|
160
|
+
closed: 'Porta fechada',
|
|
161
|
+
opened: 'Porta aberta',
|
|
162
|
+
sun: 'Sol',
|
|
163
|
+
rain: 'Chuva',
|
|
164
|
+
digital_ports1: 'Portas Digitais 1',
|
|
165
|
+
digital_ports2: 'Portas Digitais 2',
|
|
160
166
|
temperature: 'Temperatura',
|
|
161
167
|
select_vehicles: 'Seleccionar veículos',
|
|
162
168
|
select_vehicles_placeholder: 'Veículos',
|
package/package.json
CHANGED
package/src/index.test.js
CHANGED
|
@@ -15,10 +15,12 @@ async function getSpeedingReport (report, userData) {
|
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line no-undef
|
|
17
17
|
describe('Test_Reports', function () {
|
|
18
|
+
this.timeout(500000)
|
|
18
19
|
// eslint-disable-next-line no-undef
|
|
19
20
|
it('Speeding by device', async () => {
|
|
20
21
|
const report = await getReports()
|
|
21
22
|
const userData = await report.getUserData()
|
|
23
|
+
userData.roadSpeedLimit = true
|
|
22
24
|
const { device, totalDistance, totalEventTime } = await getSpeedingReport(report, userData)
|
|
23
25
|
assert.equal(device.alerts.length, 15) // Total Alerts
|
|
24
26
|
assert.equal(totalDistance, 19.59984677533689) // Total Kms
|
package/src/location-report.js
CHANGED
|
@@ -169,19 +169,26 @@ async function exportLocationReportToPDF (userData, reportData) {
|
|
|
169
169
|
translations.report.address,
|
|
170
170
|
translations.report.speed,
|
|
171
171
|
translations.report.ignition,
|
|
172
|
-
translations.report.vehicle
|
|
173
|
-
translations.report.temperature
|
|
172
|
+
translations.report.vehicle
|
|
174
173
|
]
|
|
175
174
|
: [
|
|
176
175
|
translations.report.date,
|
|
177
176
|
translations.report.address,
|
|
178
177
|
translations.report.speed,
|
|
179
178
|
translations.report.ignition,
|
|
180
|
-
translations.report.driver
|
|
181
|
-
translations.report.temperature
|
|
179
|
+
translations.report.driver
|
|
182
180
|
]
|
|
183
181
|
|
|
182
|
+
if (userData.includeTemperature) {
|
|
183
|
+
headers.push(translations.report.temperature)
|
|
184
|
+
}
|
|
185
|
+
|
|
184
186
|
if (positionsData) {
|
|
187
|
+
if (userData.includeDigitalPorts) {
|
|
188
|
+
headers.push(getDigitalPort1Label(userData.byDriver ? positionsData[0].driver : positionsData[0].device, translations))
|
|
189
|
+
headers.push(getDigitalPort2Label(userData.byDriver ? positionsData[0].driver : positionsData[0].device, translations))
|
|
190
|
+
}
|
|
191
|
+
|
|
185
192
|
let first = true
|
|
186
193
|
// eslint-disable-next-line new-cap
|
|
187
194
|
const doc = new jsPDF.jsPDF('l')
|
|
@@ -210,9 +217,18 @@ async function exportLocationReportToPDF (userData, reportData) {
|
|
|
210
217
|
a.address,
|
|
211
218
|
Math.round(a.speed * 1.85200),
|
|
212
219
|
a.attributes.ignition ? translations.report.ignitionOn : translations.report.ignitionOff,
|
|
213
|
-
userData.byDriver ? a.vehicleName : getDriverName(a, userData.drivers)
|
|
214
|
-
getTempValue(a)
|
|
220
|
+
userData.byDriver ? a.vehicleName : getDriverName(a, userData.drivers)
|
|
215
221
|
]
|
|
222
|
+
|
|
223
|
+
if (userData.includeTemperature) {
|
|
224
|
+
temp.push(getTempValue(a))
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (userData.includeDigitalPorts) {
|
|
228
|
+
temp.push(getDigitalPortValue(a, 1, translations))
|
|
229
|
+
temp.push(getDigitalPortValue(a, 2, translations))
|
|
230
|
+
}
|
|
231
|
+
|
|
216
232
|
data.push(temp)
|
|
217
233
|
})
|
|
218
234
|
|
|
@@ -257,6 +273,28 @@ function getTempValue (row) {
|
|
|
257
273
|
)) || ''
|
|
258
274
|
}
|
|
259
275
|
|
|
276
|
+
function getDigitalPort1Label (row, translations) {
|
|
277
|
+
return row.attributes.door1 || translations.report.digital_ports1
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function getDigitalPort2Label (row, translations) {
|
|
281
|
+
return row.attributes.door2 || translations.report.digital_ports2
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function getDigitalPortValue (row, index, translations) {
|
|
285
|
+
switch (index) {
|
|
286
|
+
case 1:
|
|
287
|
+
return row.attributes && row.attributes.door1 ? translations.report[row.attributes.door1] : ''
|
|
288
|
+
case 2:
|
|
289
|
+
if (row.attributes && row.attributes.door2) {
|
|
290
|
+
return translations.report[row.attributes.door2]
|
|
291
|
+
}
|
|
292
|
+
return row.attributes && row.attributes.rain ? translations.report[row.attributes.rain] : ''
|
|
293
|
+
default:
|
|
294
|
+
return ''
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
260
298
|
function exportLocationReportToExcel (userData, reportData) {
|
|
261
299
|
console.log('Export to Excel')
|
|
262
300
|
|
|
@@ -285,11 +323,20 @@ function exportLocationReportToExcel (userData, reportData) {
|
|
|
285
323
|
{ label: translations.report.address, value: 'address' },
|
|
286
324
|
{ label: translations.report.speed, value: 'speed' },
|
|
287
325
|
{ label: translations.report.ignition, value: 'ignition' },
|
|
288
|
-
{ label: translations.report.driver, value: 'driver' }
|
|
289
|
-
{ label: translations.report.temperature, value: 'temperature' }
|
|
326
|
+
{ label: translations.report.driver, value: 'driver' }
|
|
290
327
|
]
|
|
328
|
+
|
|
329
|
+
if (userData.includeTemperature) {
|
|
330
|
+
headers.push({ label: translations.report.temperature, value: 'temperature' })
|
|
331
|
+
}
|
|
332
|
+
|
|
291
333
|
let data = []
|
|
292
334
|
if (positionsData) {
|
|
335
|
+
if (userData.includeDigitalPorts) {
|
|
336
|
+
headers.push({ label: getDigitalPort1Label(userData.byDriver ? positionsData[0].driver : positionsData[0].device, translations), value: 'digitalport1' })
|
|
337
|
+
headers.push({ label: getDigitalPort2Label(userData.byDriver ? positionsData[0].driver : positionsData[0].device, translations), value: 'digitalport2' })
|
|
338
|
+
}
|
|
339
|
+
|
|
293
340
|
positionsData.forEach(d => {
|
|
294
341
|
data = data.concat(d.positions.map(a => {
|
|
295
342
|
return {
|
|
@@ -300,7 +347,9 @@ function exportLocationReportToExcel (userData, reportData) {
|
|
|
300
347
|
speed: Math.round(a.speed * 1.85200),
|
|
301
348
|
ignition: a.attributes.ignition ? translations.report.ignitionOn : translations.report.ignitionOff,
|
|
302
349
|
driver: userData.byDriver ? d.driver.name : getDriverName(a, userData.drivers),
|
|
303
|
-
temperature: getTempValue(a)
|
|
350
|
+
temperature: getTempValue(a),
|
|
351
|
+
digitalport1: getDigitalPortValue(a, 1, translations),
|
|
352
|
+
digitalport2: getDigitalPortValue(a, 2, translations)
|
|
304
353
|
}
|
|
305
354
|
}))
|
|
306
355
|
})
|
package/src/util/odoo.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
async function getOdooFuelServices(traccar, from, to) {
|
|
3
|
-
|
|
2
|
+
async function getOdooFuelServices (traccar, from, to) {
|
|
3
|
+
const url = `/odoo/reports/refuelingServices?startDate=${from.toDateString()}&endDate=${to.toDateString()}`
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
console.log('LOADING_MESSAGE:' + url)
|
|
6
|
+
const { data } = await traccar.axios.get(url, {
|
|
7
|
+
jar: traccar.cookieJar,
|
|
8
|
+
withCredentials: true
|
|
9
|
+
})
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
console.log(data)
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
return data
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
exports.getOdooFuelServices = getOdooFuelServices
|