fleetmap-reports 1.0.228 → 1.0.232
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/.idea/runConfigurations.xml +10 -0
- package/.idea/workspace.xml +204 -0
- package/lang/enGB.js +1 -0
- package/lang/ptBR.js +1 -0
- package/lang/ptPT.js +1 -0
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/index.test.js +31 -14
- package/src/kms-report.js +26 -21
- package/.idea/codeStyles/Project.xml +0 -7
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/jsLibraryMappings.xml +0 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="RunConfigurationProducerService">
|
|
4
|
+
<option name="ignoredProducers">
|
|
5
|
+
<set>
|
|
6
|
+
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
|
7
|
+
</set>
|
|
8
|
+
</option>
|
|
9
|
+
</component>
|
|
10
|
+
</project>
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
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" />
|
|
8
|
+
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
9
|
+
<change beforePath="$PROJECT_DIR$/src/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.js" afterDir="false" />
|
|
10
|
+
<change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
|
|
11
|
+
<change beforePath="$PROJECT_DIR$/src/kms-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/kms-report.js" afterDir="false" />
|
|
12
|
+
</list>
|
|
13
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
14
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
15
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
16
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
17
|
+
</component>
|
|
18
|
+
<component name="Git.Settings">
|
|
19
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
20
|
+
</component>
|
|
21
|
+
<component name="ProjectId" id="20NIxbej0qfi8RaO3jr1XOU0xol" />
|
|
22
|
+
<component name="ProjectViewState">
|
|
23
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
24
|
+
<option name="showLibraryContents" value="true" />
|
|
25
|
+
</component>
|
|
26
|
+
<component name="PropertiesComponent">
|
|
27
|
+
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
|
28
|
+
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
|
29
|
+
<property name="WebServerToolWindowFactoryState" value="false" />
|
|
30
|
+
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
|
31
|
+
<property name="nodejs.mocha.mocha_node_package_dir" value="$PROJECT_DIR$/node_modules/mocha" />
|
|
32
|
+
<property name="nodejs_package_manager_path" value="npm" />
|
|
33
|
+
<property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
|
|
34
|
+
<property name="vue.rearranger.settings.migration" value="true" />
|
|
35
|
+
</component>
|
|
36
|
+
<component name="RunManager" selected="Mocha.test reports">
|
|
37
|
+
<configuration name="here" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
38
|
+
<node-interpreter>project</node-interpreter>
|
|
39
|
+
<node-options />
|
|
40
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
41
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
42
|
+
<pass-parent-env>true</pass-parent-env>
|
|
43
|
+
<ui>bdd</ui>
|
|
44
|
+
<extra-mocha-options />
|
|
45
|
+
<test-kind>SUITE</test-kind>
|
|
46
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
47
|
+
<test-names>
|
|
48
|
+
<name value="here" />
|
|
49
|
+
</test-names>
|
|
50
|
+
<method v="2" />
|
|
51
|
+
</configuration>
|
|
52
|
+
<configuration name="report" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
53
|
+
<node-interpreter>project</node-interpreter>
|
|
54
|
+
<node-options />
|
|
55
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
56
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
57
|
+
<pass-parent-env>true</pass-parent-env>
|
|
58
|
+
<ui>bdd</ui>
|
|
59
|
+
<extra-mocha-options />
|
|
60
|
+
<test-kind>SUITE</test-kind>
|
|
61
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
62
|
+
<test-names>
|
|
63
|
+
<name value="report" />
|
|
64
|
+
</test-names>
|
|
65
|
+
<method v="2" />
|
|
66
|
+
</configuration>
|
|
67
|
+
<configuration name="speedingReport" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
68
|
+
<node-interpreter>project</node-interpreter>
|
|
69
|
+
<node-options />
|
|
70
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
71
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
72
|
+
<pass-parent-env>true</pass-parent-env>
|
|
73
|
+
<ui>bdd</ui>
|
|
74
|
+
<extra-mocha-options />
|
|
75
|
+
<test-kind>TEST</test-kind>
|
|
76
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
77
|
+
<test-names>
|
|
78
|
+
<name value="speedingReport" />
|
|
79
|
+
</test-names>
|
|
80
|
+
<method v="2" />
|
|
81
|
+
</configuration>
|
|
82
|
+
<configuration name="test reports" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
83
|
+
<node-interpreter>project</node-interpreter>
|
|
84
|
+
<node-options />
|
|
85
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
86
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
87
|
+
<pass-parent-env>true</pass-parent-env>
|
|
88
|
+
<ui>bdd</ui>
|
|
89
|
+
<extra-mocha-options />
|
|
90
|
+
<test-kind>SUITE</test-kind>
|
|
91
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
92
|
+
<test-names>
|
|
93
|
+
<name value="test reports" />
|
|
94
|
+
</test-names>
|
|
95
|
+
<method v="2" />
|
|
96
|
+
</configuration>
|
|
97
|
+
<configuration name="test reports.test queue" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
98
|
+
<node-interpreter>project</node-interpreter>
|
|
99
|
+
<node-options />
|
|
100
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
101
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
102
|
+
<pass-parent-env>true</pass-parent-env>
|
|
103
|
+
<ui>bdd</ui>
|
|
104
|
+
<extra-mocha-options />
|
|
105
|
+
<test-kind>TEST</test-kind>
|
|
106
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
107
|
+
<test-names>
|
|
108
|
+
<name value="test reports" />
|
|
109
|
+
<name value="test queue" />
|
|
110
|
+
</test-names>
|
|
111
|
+
<method v="2" />
|
|
112
|
+
</configuration>
|
|
113
|
+
<recent_temporary>
|
|
114
|
+
<list>
|
|
115
|
+
<item itemvalue="Mocha.test reports" />
|
|
116
|
+
<item itemvalue="Mocha.test reports.test queue" />
|
|
117
|
+
<item itemvalue="Mocha.speedingReport" />
|
|
118
|
+
<item itemvalue="Mocha.report" />
|
|
119
|
+
<item itemvalue="Mocha.here" />
|
|
120
|
+
</list>
|
|
121
|
+
</recent_temporary>
|
|
122
|
+
</component>
|
|
123
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
124
|
+
<component name="TaskManager">
|
|
125
|
+
<task active="true" id="Default" summary="Default task">
|
|
126
|
+
<changelist id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="" />
|
|
127
|
+
<created>1635878866368</created>
|
|
128
|
+
<option name="number" value="Default" />
|
|
129
|
+
<option name="presentableId" value="Default" />
|
|
130
|
+
<updated>1635878866368</updated>
|
|
131
|
+
<workItem from="1635878870054" duration="105000" />
|
|
132
|
+
<workItem from="1635943211865" duration="371000" />
|
|
133
|
+
<workItem from="1636030918716" duration="808000" />
|
|
134
|
+
<workItem from="1636366400735" duration="3018000" />
|
|
135
|
+
<workItem from="1636371409243" duration="45000" />
|
|
136
|
+
<workItem from="1636371621773" duration="4750000" />
|
|
137
|
+
<workItem from="1636623371114" duration="675000" />
|
|
138
|
+
<workItem from="1636624396937" duration="1987000" />
|
|
139
|
+
<workItem from="1636627666406" duration="1616000" />
|
|
140
|
+
<workItem from="1636647112207" duration="1748000" />
|
|
141
|
+
<workItem from="1636981640447" duration="4315000" />
|
|
142
|
+
<workItem from="1637009407292" duration="1470000" />
|
|
143
|
+
<workItem from="1637012863006" duration="5376000" />
|
|
144
|
+
<workItem from="1637087797229" duration="5701000" />
|
|
145
|
+
<workItem from="1637227826845" duration="1275000" />
|
|
146
|
+
<workItem from="1637441942952" duration="4543000" />
|
|
147
|
+
<workItem from="1637670815688" duration="2973000" />
|
|
148
|
+
<workItem from="1637674107929" duration="13419000" />
|
|
149
|
+
<workItem from="1637756665591" duration="3093000" />
|
|
150
|
+
</task>
|
|
151
|
+
<task id="LOCAL-00001" summary="Fix getStyle">
|
|
152
|
+
<created>1636983717385</created>
|
|
153
|
+
<option name="number" value="00001" />
|
|
154
|
+
<option name="presentableId" value="LOCAL-00001" />
|
|
155
|
+
<option name="project" value="LOCAL" />
|
|
156
|
+
<updated>1636983717385</updated>
|
|
157
|
+
</task>
|
|
158
|
+
<task id="LOCAL-00002" summary="Fix getStyle in all reports">
|
|
159
|
+
<created>1637020728356</created>
|
|
160
|
+
<option name="number" value="00002" />
|
|
161
|
+
<option name="presentableId" value="LOCAL-00002" />
|
|
162
|
+
<option name="project" value="LOCAL" />
|
|
163
|
+
<updated>1637020728356</updated>
|
|
164
|
+
</task>
|
|
165
|
+
<task id="LOCAL-00003" summary="try catch on pdf addImage">
|
|
166
|
+
<created>1637247013210</created>
|
|
167
|
+
<option name="number" value="00003" />
|
|
168
|
+
<option name="presentableId" value="LOCAL-00003" />
|
|
169
|
+
<option name="project" value="LOCAL" />
|
|
170
|
+
<updated>1637247013211</updated>
|
|
171
|
+
</task>
|
|
172
|
+
<task id="LOCAL-00004" summary="Kms report grouped by day">
|
|
173
|
+
<created>1637715473148</created>
|
|
174
|
+
<option name="number" value="00004" />
|
|
175
|
+
<option name="presentableId" value="LOCAL-00004" />
|
|
176
|
+
<option name="project" value="LOCAL" />
|
|
177
|
+
<updated>1637715473149</updated>
|
|
178
|
+
</task>
|
|
179
|
+
<option name="localTasksCounter" value="5" />
|
|
180
|
+
<servers />
|
|
181
|
+
</component>
|
|
182
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
183
|
+
<option name="version" value="3" />
|
|
184
|
+
</component>
|
|
185
|
+
<component name="Vcs.Log.Tabs.Properties">
|
|
186
|
+
<option name="TAB_STATES">
|
|
187
|
+
<map>
|
|
188
|
+
<entry key="MAIN">
|
|
189
|
+
<value>
|
|
190
|
+
<State />
|
|
191
|
+
</value>
|
|
192
|
+
</entry>
|
|
193
|
+
</map>
|
|
194
|
+
</option>
|
|
195
|
+
<option name="oldMeFiltersMigrated" value="true" />
|
|
196
|
+
</component>
|
|
197
|
+
<component name="VcsManagerConfiguration">
|
|
198
|
+
<MESSAGE value="Fix getStyle" />
|
|
199
|
+
<MESSAGE value="Fix getStyle in all reports" />
|
|
200
|
+
<MESSAGE value="try catch on pdf addImage" />
|
|
201
|
+
<MESSAGE value="Kms report grouped by day" />
|
|
202
|
+
<option name="LAST_COMMIT_MESSAGE" value="Kms report grouped by day" />
|
|
203
|
+
</component>
|
|
204
|
+
</project>
|
package/lang/enGB.js
CHANGED
package/lang/ptBR.js
CHANGED
package/lang/ptPT.js
CHANGED
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -23,7 +23,7 @@ function Reports(config, axios) {
|
|
|
23
23
|
return require('./speeding-report').createSpeedingReport(from, to, userData, this.traccar, roadSpeedLimits)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
this.speedingReportToPDF = (userData, reportData) => {
|
|
26
|
+
this.speedingReportToPDF = async (userData, reportData) => {
|
|
27
27
|
return require('./speeding-report').exportSpeedingReportToPDF(userData, reportData)
|
|
28
28
|
}
|
|
29
29
|
|
package/src/index.test.js
CHANGED
|
@@ -3,25 +3,42 @@ const {SessionApi} = require("traccar-api");
|
|
|
3
3
|
const axios = require('axios')
|
|
4
4
|
const axiosCookieJarSupport = require('axios-cookiejar-support').default;
|
|
5
5
|
const tough = require('tough-cookie');
|
|
6
|
+
const style = require("./reportStyle");
|
|
6
7
|
const cookieJar = new tough.CookieJar();
|
|
7
8
|
|
|
8
9
|
axiosCookieJarSupport(axios)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
|
|
12
|
+
describe('test reports', function() {
|
|
13
|
+
this.timeout(9000000)
|
|
14
|
+
it('test queue', async () => {
|
|
15
|
+
const traccarConfig = {
|
|
16
|
+
basePath: 'https://api.fleetmap.io/api',
|
|
17
|
+
baseOptions: {
|
|
18
|
+
withCredentials: true,
|
|
19
|
+
jar: cookieJar
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
|
-
}
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
await new SessionApi(traccarConfig, null, axios).sessionPost('jppenas@gmail.com', 'penas46881')
|
|
24
|
+
const report = new Index(traccarConfig, axios)
|
|
25
|
+
const userData = await report.getUserData()
|
|
26
|
+
userData.groupByDay = true
|
|
27
|
+
const reportData = await report.kmsReport(new Date(2021, 10, 19, 0, 0, 0, 0),
|
|
28
|
+
new Date(2021, 10, 21, 23, 59, 59, 0),
|
|
29
|
+
userData)
|
|
30
|
+
|
|
31
|
+
const reportResult = reportData[0]
|
|
32
|
+
reportResult.devices.forEach(d => {
|
|
33
|
+
console.log(d.device.name)
|
|
34
|
+
d.days.forEach(day => {
|
|
35
|
+
console.log(day.date + ' - ' + day.kms)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
22
39
|
|
|
23
|
-
|
|
24
|
-
new Date(2021, 2, 30, 23, 59, 59, 0),
|
|
25
|
-
userData)
|
|
40
|
+
const pdf = report.kmsReportToPDF(userData, reportResult)
|
|
26
41
|
|
|
27
|
-
|
|
42
|
+
console.log(pdf)
|
|
43
|
+
})
|
|
44
|
+
})
|
package/src/kms-report.js
CHANGED
|
@@ -156,7 +156,7 @@ async function exportKmsReportToPDF(userData, reportData) {
|
|
|
156
156
|
const data = []
|
|
157
157
|
d.days.forEach(day => {
|
|
158
158
|
const temp = [
|
|
159
|
-
|
|
159
|
+
day.date,
|
|
160
160
|
(day.kms/1000).toFixed(0)
|
|
161
161
|
]
|
|
162
162
|
|
|
@@ -237,17 +237,22 @@ function exportKmsReportToExcel(userData, reportData) {
|
|
|
237
237
|
|
|
238
238
|
const headers = []
|
|
239
239
|
|
|
240
|
-
if(userData.groupByDay){
|
|
240
|
+
if(userData.groupByDay) {
|
|
241
241
|
headers.push(
|
|
242
242
|
{label: translations.report.vehicle, value: 'name'},
|
|
243
|
-
{label: translations.report.
|
|
243
|
+
{label: translations.report.licensePlate, value: 'licenseplate'},
|
|
244
244
|
{label: translations.report.group, value: 'group'},
|
|
245
245
|
{label: translations.report.date, value: 'date'},
|
|
246
246
|
{label: translations.report.distance, value: 'distance'})
|
|
247
247
|
} else if(userData.byDriver) {
|
|
248
248
|
headers.push(
|
|
249
249
|
{label: translations.report.driver, value: 'name'},
|
|
250
|
-
{label: translations.report.
|
|
250
|
+
{label: translations.report.group, value: 'group'},
|
|
251
|
+
{label: translations.report.distance, value: 'distance'})
|
|
252
|
+
} else {
|
|
253
|
+
headers.push(
|
|
254
|
+
{label: translations.report.vehicle, value: 'name'},
|
|
255
|
+
{label: translations.report.licensePlate, value: 'licenseplate'},
|
|
251
256
|
{label: translations.report.group, value: 'group'},
|
|
252
257
|
{label: translations.report.distance, value: 'distance'})
|
|
253
258
|
}
|
|
@@ -258,25 +263,25 @@ function exportKmsReportToExcel(userData, reportData) {
|
|
|
258
263
|
const group = userData.byDriver ? userData.groups.find(g => g.drivers.includes(d.driver.id)) :
|
|
259
264
|
userData.groups.find(g => d.device.groupId === g.id)
|
|
260
265
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
group: group ? group.name : '',
|
|
267
|
-
licenseplate: d.device.attributes.license_plate,
|
|
268
|
-
date: a.date,
|
|
269
|
-
distance: Number((a.kms / 1000).toFixed(0))
|
|
270
|
-
}
|
|
271
|
-
}))
|
|
272
|
-
} else {
|
|
273
|
-
data = data.concat([{
|
|
274
|
-
name: userData.byDriver ? d.driver.name : d.summary.deviceName,
|
|
266
|
+
if (userData.groupByDay) {
|
|
267
|
+
data = data.concat([{}])
|
|
268
|
+
data = data.concat(d.days.map(a => {
|
|
269
|
+
return {
|
|
270
|
+
name: d.device.name,
|
|
275
271
|
group: group ? group.name : '',
|
|
276
272
|
licenseplate: d.device.attributes.license_plate,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
273
|
+
date: a.date,
|
|
274
|
+
distance: Number((a.kms / 1000).toFixed(0))
|
|
275
|
+
}
|
|
276
|
+
}))
|
|
277
|
+
} else {
|
|
278
|
+
data = data.concat([{
|
|
279
|
+
name: userData.byDriver ? d.driver.name : d.summary.deviceName,
|
|
280
|
+
group: group ? group.name : '',
|
|
281
|
+
licenseplate: userData.byDriver ? '' : d.device.attributes.license_plate,
|
|
282
|
+
distance: Number((d.summary.distance / 1000).toFixed(0))
|
|
283
|
+
}])
|
|
284
|
+
}
|
|
280
285
|
})
|
|
281
286
|
|
|
282
287
|
return {
|