fleetmap-reports 1.0.237 → 1.0.238

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.
@@ -1,21 +1,24 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
- <list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="Kms report grouped by day">
5
- <change beforePath="$PROJECT_DIR$/lang/enGB.js" beforeDir="false" afterPath="$PROJECT_DIR$/lang/enGB.js" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/lang/ptBR.js" beforeDir="false" afterPath="$PROJECT_DIR$/lang/ptBR.js" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/lang/ptPT.js" beforeDir="false" afterPath="$PROJECT_DIR$/lang/ptPT.js" afterDir="false" />
4
+ <list default="true" id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="Fix pdf logo">
8
5
  <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
9
6
  <change beforePath="$PROJECT_DIR$/src/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.js" afterDir="false" />
10
7
  <change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
11
8
  <change beforePath="$PROJECT_DIR$/src/kms-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/kms-report.js" afterDir="false" />
12
- <change beforePath="$PROJECT_DIR$/src/util/pdfDocument.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/pdfDocument.js" afterDir="false" />
13
9
  </list>
14
10
  <option name="SHOW_DIALOG" value="false" />
15
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
16
12
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
17
13
  <option name="LAST_RESOLUTION" value="IGNORE" />
18
14
  </component>
15
+ <component name="FileTemplateManagerImpl">
16
+ <option name="RECENT_TEMPLATES">
17
+ <list>
18
+ <option value="JavaScript File" />
19
+ </list>
20
+ </option>
21
+ </component>
19
22
  <component name="Git.Settings">
20
23
  <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
21
24
  </component>
@@ -164,7 +167,7 @@
164
167
  <workItem from="1637670815688" duration="2973000" />
165
168
  <workItem from="1637674107929" duration="13419000" />
166
169
  <workItem from="1637756665591" duration="4742000" />
167
- <workItem from="1637841765985" duration="4644000" />
170
+ <workItem from="1637841765985" duration="8842000" />
168
171
  </task>
169
172
  <task id="LOCAL-00001" summary="Fix getStyle">
170
173
  <created>1636983717385</created>
@@ -194,7 +197,14 @@
194
197
  <option name="project" value="LOCAL" />
195
198
  <updated>1637715473149</updated>
196
199
  </task>
197
- <option name="localTasksCounter" value="5" />
200
+ <task id="LOCAL-00005" summary="Fix pdf logo">
201
+ <created>1637849206762</created>
202
+ <option name="number" value="00005" />
203
+ <option name="presentableId" value="LOCAL-00005" />
204
+ <option name="project" value="LOCAL" />
205
+ <updated>1637849206762</updated>
206
+ </task>
207
+ <option name="localTasksCounter" value="6" />
198
208
  <servers />
199
209
  </component>
200
210
  <component name="TypeScriptGeneratedFilesManager">
@@ -217,6 +227,7 @@
217
227
  <MESSAGE value="Fix getStyle in all reports" />
218
228
  <MESSAGE value="try catch on pdf addImage" />
219
229
  <MESSAGE value="Kms report grouped by day" />
220
- <option name="LAST_COMMIT_MESSAGE" value="Kms report grouped by day" />
230
+ <MESSAGE value="Fix pdf logo" />
231
+ <option name="LAST_COMMIT_MESSAGE" value="Fix pdf logo" />
221
232
  </component>
222
233
  </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.237",
3
+ "version": "1.0.238",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/kms-report.js CHANGED
@@ -6,7 +6,7 @@ const {getStyle} = require("./reportStyle");
6
6
  const {headerFromUser,addTable} = require("./util/pdfDocument");
7
7
  const {getUserPartner} = require("fleetmap-partners");
8
8
  const automaticReports = require("./automaticReports");
9
- const {jsPDFOptions} = require("jspdf");
9
+ const traccar = require("./util/traccar");
10
10
 
11
11
 
12
12
  let traccarInstance
@@ -24,16 +24,7 @@ async function createKmsReportByDevice(from, to, userData) {
24
24
  }
25
25
 
26
26
  devicesToProcess.sort((a, b) => (a.name > b.name) ? 1 : -1)
27
- const devicesToSlice = devicesToProcess.slice()
28
-
29
- const arrayOfArrays = automaticReports.sliceArray(devicesToSlice)
30
- let data = []
31
- for (const a of arrayOfArrays) {
32
- console.log('getting',from,to,a.map(a => a.id))
33
- const response = await traccarInstance.reports.reportsRouteGet(from, to, a.map(d => d.id))
34
- console.log('concat', response.data.length)
35
- data = data.concat(response.data)
36
- }
27
+ const data = await traccar.getRoute(traccarInstance, from, to, devicesToProcess)
37
28
 
38
29
  console.log('locations:' + data.length)
39
30
 
@@ -159,7 +150,7 @@ async function exportKmsReportToPDF(userData, reportData) {
159
150
  const data = []
160
151
  d.days.forEach(day => {
161
152
  const temp = [
162
- day.date,
153
+ new Date(day.date).toLocaleDateString(),
163
154
  (day.kms/1000).toFixed(0)
164
155
  ]
165
156
 
@@ -255,7 +246,7 @@ function exportKmsReportToExcel(userData, reportData) {
255
246
  } else {
256
247
  headers.push(
257
248
  {label: translations.report.vehicle, value: 'name'},
258
- {label: translations.report.licensePlate, value: 'licenseplate'},
249
+ {label: translations.settings.vehicle_licenseplate, value: 'licenseplate'},
259
250
  {label: translations.report.group, value: 'group'},
260
251
  {label: translations.report.distance, value: 'distance'})
261
252
  }
@@ -0,0 +1,17 @@
1
+ const automaticReports = require("../automaticReports");
2
+
3
+ async function getRoute(traccar, from, to, devices){
4
+ const devicesToSlice = devices.slice()
5
+
6
+ const arrayOfArrays = automaticReports.sliceArray(devicesToSlice)
7
+ let requests = []
8
+ for (const a of arrayOfArrays) {
9
+ const promise = traccar.reports.reportsRouteGet(from, to, a.map(d => d.id))
10
+ requests = requests.concat(promise)
11
+ }
12
+
13
+ const result = await Promise.all(requests)
14
+ return result.map(r => r.data).flat()
15
+ }
16
+
17
+ exports.getRoute = getRoute