fleetmap-reports 1.0.816 → 1.0.817
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/generated.pdf +0 -0
- package/package.json +2 -2
- package/src/tests/index.test.js +4 -3
- package/src/util/pdfDocument.js +4 -3
- package/src/util/utils.js +1 -1
- package/report.pdf +0 -286585
package/generated.pdf
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetmap-reports",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.817",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"fleetmap-partners": "^1.0.76",
|
|
22
22
|
"json-as-xlsx": "^1.2.1",
|
|
23
23
|
"jspdf": "^2.5.1",
|
|
24
|
-
"jspdf-autotable": "
|
|
24
|
+
"jspdf-autotable": "3.6.0",
|
|
25
25
|
"moment": "^2.29.4",
|
|
26
26
|
"tough-cookie": "^4.0.0",
|
|
27
27
|
"traccar-api": "^1.0.5",
|
package/src/tests/index.test.js
CHANGED
|
@@ -12,10 +12,11 @@ describe('Test_Reports', function () {
|
|
|
12
12
|
userData.customSpeed = false
|
|
13
13
|
userData.useVehicleSpeedLimit = true
|
|
14
14
|
const data = await report.speedingReport(
|
|
15
|
-
new Date(Date.UTC(
|
|
16
|
-
new Date(Date.UTC(
|
|
15
|
+
new Date(Date.UTC(2023, 7, 1, 0, 0, 0, 0)),
|
|
16
|
+
new Date(Date.UTC(2023, 7, 2, 23, 59, 59, 0)),
|
|
17
17
|
userData)
|
|
18
|
-
await report.speedingReportToPDF(userData, data)
|
|
18
|
+
const pdf = await report.speedingReportToPDF(userData, data[0])
|
|
19
|
+
pdf.save()
|
|
19
20
|
}, 40000)
|
|
20
21
|
|
|
21
22
|
it('converts madrid time', async () => {
|
package/src/util/pdfDocument.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
require('jspdf-autotable')
|
|
2
2
|
const { getStyle } = require('../reportStyle')
|
|
3
3
|
const { getUserPartner } = require('fleetmap-partners')
|
|
4
|
-
const {
|
|
4
|
+
const { getImgFromUrl } = require('./utils')
|
|
5
5
|
|
|
6
|
-
function header (doc, title, hostname, style, orientation) {
|
|
6
|
+
async function header (doc, title, hostname, style, orientation) {
|
|
7
7
|
doc.setFontSize(16)
|
|
8
8
|
doc.setFont('helvetica', 'bold')
|
|
9
9
|
doc.text(title, 15, 15)
|
|
10
10
|
|
|
11
11
|
if (style.imgWidth && style.imgHeight) {
|
|
12
12
|
try {
|
|
13
|
-
const image =
|
|
13
|
+
const image = await getImgFromUrl(hostname)
|
|
14
14
|
if (image) {
|
|
15
15
|
doc.addImage(image, 'PNG', (orientation === 'l' ? 220 : 135) + (style.imgWidth < 50 ? 25 : 0), 5, style.imgWidth, style.imgHeight)
|
|
16
16
|
}
|
|
17
17
|
} catch (e) {
|
|
18
|
+
console.error(e)
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
doc.setFont('helvetica', 'normal')
|
package/src/util/utils.js
CHANGED
|
@@ -136,7 +136,7 @@ async function getImageBase64 (url) {
|
|
|
136
136
|
|
|
137
137
|
function getLogoUrl (hostname) {
|
|
138
138
|
const path = `/img/logos/${hostname}.png`
|
|
139
|
-
return
|
|
139
|
+
return isClientSide() ? path : `https://${hostname}${path}`
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
async function getImgFromUrl (hostname) {
|