fleetmap-reports 1.0.230 → 1.0.231
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 +202 -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 +21 -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,202 @@
|
|
|
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$/src/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.js" afterDir="false" />
|
|
9
|
+
<change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
|
|
10
|
+
</list>
|
|
11
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
12
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
13
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
14
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
15
|
+
</component>
|
|
16
|
+
<component name="Git.Settings">
|
|
17
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
18
|
+
</component>
|
|
19
|
+
<component name="ProjectId" id="20NIxbej0qfi8RaO3jr1XOU0xol" />
|
|
20
|
+
<component name="ProjectViewState">
|
|
21
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
22
|
+
<option name="showLibraryContents" value="true" />
|
|
23
|
+
</component>
|
|
24
|
+
<component name="PropertiesComponent">
|
|
25
|
+
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
|
26
|
+
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
|
27
|
+
<property name="WebServerToolWindowFactoryState" value="false" />
|
|
28
|
+
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
|
29
|
+
<property name="nodejs.mocha.mocha_node_package_dir" value="$PROJECT_DIR$/node_modules/mocha" />
|
|
30
|
+
<property name="nodejs_package_manager_path" value="npm" />
|
|
31
|
+
<property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
|
|
32
|
+
<property name="vue.rearranger.settings.migration" value="true" />
|
|
33
|
+
</component>
|
|
34
|
+
<component name="RunManager" selected="Mocha.test reports">
|
|
35
|
+
<configuration name="here" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
36
|
+
<node-interpreter>project</node-interpreter>
|
|
37
|
+
<node-options />
|
|
38
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
39
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
40
|
+
<pass-parent-env>true</pass-parent-env>
|
|
41
|
+
<ui>bdd</ui>
|
|
42
|
+
<extra-mocha-options />
|
|
43
|
+
<test-kind>SUITE</test-kind>
|
|
44
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
45
|
+
<test-names>
|
|
46
|
+
<name value="here" />
|
|
47
|
+
</test-names>
|
|
48
|
+
<method v="2" />
|
|
49
|
+
</configuration>
|
|
50
|
+
<configuration name="report" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
51
|
+
<node-interpreter>project</node-interpreter>
|
|
52
|
+
<node-options />
|
|
53
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
54
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
55
|
+
<pass-parent-env>true</pass-parent-env>
|
|
56
|
+
<ui>bdd</ui>
|
|
57
|
+
<extra-mocha-options />
|
|
58
|
+
<test-kind>SUITE</test-kind>
|
|
59
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
60
|
+
<test-names>
|
|
61
|
+
<name value="report" />
|
|
62
|
+
</test-names>
|
|
63
|
+
<method v="2" />
|
|
64
|
+
</configuration>
|
|
65
|
+
<configuration name="speedingReport" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
66
|
+
<node-interpreter>project</node-interpreter>
|
|
67
|
+
<node-options />
|
|
68
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
69
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
70
|
+
<pass-parent-env>true</pass-parent-env>
|
|
71
|
+
<ui>bdd</ui>
|
|
72
|
+
<extra-mocha-options />
|
|
73
|
+
<test-kind>TEST</test-kind>
|
|
74
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
75
|
+
<test-names>
|
|
76
|
+
<name value="speedingReport" />
|
|
77
|
+
</test-names>
|
|
78
|
+
<method v="2" />
|
|
79
|
+
</configuration>
|
|
80
|
+
<configuration name="test reports" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
81
|
+
<node-interpreter>project</node-interpreter>
|
|
82
|
+
<node-options />
|
|
83
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
84
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
85
|
+
<pass-parent-env>true</pass-parent-env>
|
|
86
|
+
<ui>bdd</ui>
|
|
87
|
+
<extra-mocha-options />
|
|
88
|
+
<test-kind>SUITE</test-kind>
|
|
89
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
90
|
+
<test-names>
|
|
91
|
+
<name value="test reports" />
|
|
92
|
+
</test-names>
|
|
93
|
+
<method v="2" />
|
|
94
|
+
</configuration>
|
|
95
|
+
<configuration name="test reports.test queue" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
96
|
+
<node-interpreter>project</node-interpreter>
|
|
97
|
+
<node-options />
|
|
98
|
+
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
99
|
+
<working-directory>$PROJECT_DIR$</working-directory>
|
|
100
|
+
<pass-parent-env>true</pass-parent-env>
|
|
101
|
+
<ui>bdd</ui>
|
|
102
|
+
<extra-mocha-options />
|
|
103
|
+
<test-kind>TEST</test-kind>
|
|
104
|
+
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
105
|
+
<test-names>
|
|
106
|
+
<name value="test reports" />
|
|
107
|
+
<name value="test queue" />
|
|
108
|
+
</test-names>
|
|
109
|
+
<method v="2" />
|
|
110
|
+
</configuration>
|
|
111
|
+
<recent_temporary>
|
|
112
|
+
<list>
|
|
113
|
+
<item itemvalue="Mocha.test reports" />
|
|
114
|
+
<item itemvalue="Mocha.test reports.test queue" />
|
|
115
|
+
<item itemvalue="Mocha.speedingReport" />
|
|
116
|
+
<item itemvalue="Mocha.report" />
|
|
117
|
+
<item itemvalue="Mocha.here" />
|
|
118
|
+
</list>
|
|
119
|
+
</recent_temporary>
|
|
120
|
+
</component>
|
|
121
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
122
|
+
<component name="TaskManager">
|
|
123
|
+
<task active="true" id="Default" summary="Default task">
|
|
124
|
+
<changelist id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="" />
|
|
125
|
+
<created>1635878866368</created>
|
|
126
|
+
<option name="number" value="Default" />
|
|
127
|
+
<option name="presentableId" value="Default" />
|
|
128
|
+
<updated>1635878866368</updated>
|
|
129
|
+
<workItem from="1635878870054" duration="105000" />
|
|
130
|
+
<workItem from="1635943211865" duration="371000" />
|
|
131
|
+
<workItem from="1636030918716" duration="808000" />
|
|
132
|
+
<workItem from="1636366400735" duration="3018000" />
|
|
133
|
+
<workItem from="1636371409243" duration="45000" />
|
|
134
|
+
<workItem from="1636371621773" duration="4750000" />
|
|
135
|
+
<workItem from="1636623371114" duration="675000" />
|
|
136
|
+
<workItem from="1636624396937" duration="1987000" />
|
|
137
|
+
<workItem from="1636627666406" duration="1616000" />
|
|
138
|
+
<workItem from="1636647112207" duration="1748000" />
|
|
139
|
+
<workItem from="1636981640447" duration="4315000" />
|
|
140
|
+
<workItem from="1637009407292" duration="1470000" />
|
|
141
|
+
<workItem from="1637012863006" duration="5376000" />
|
|
142
|
+
<workItem from="1637087797229" duration="5701000" />
|
|
143
|
+
<workItem from="1637227826845" duration="1275000" />
|
|
144
|
+
<workItem from="1637441942952" duration="4543000" />
|
|
145
|
+
<workItem from="1637670815688" duration="2973000" />
|
|
146
|
+
<workItem from="1637674107929" duration="13419000" />
|
|
147
|
+
<workItem from="1637756665591" duration="1260000" />
|
|
148
|
+
</task>
|
|
149
|
+
<task id="LOCAL-00001" summary="Fix getStyle">
|
|
150
|
+
<created>1636983717385</created>
|
|
151
|
+
<option name="number" value="00001" />
|
|
152
|
+
<option name="presentableId" value="LOCAL-00001" />
|
|
153
|
+
<option name="project" value="LOCAL" />
|
|
154
|
+
<updated>1636983717385</updated>
|
|
155
|
+
</task>
|
|
156
|
+
<task id="LOCAL-00002" summary="Fix getStyle in all reports">
|
|
157
|
+
<created>1637020728356</created>
|
|
158
|
+
<option name="number" value="00002" />
|
|
159
|
+
<option name="presentableId" value="LOCAL-00002" />
|
|
160
|
+
<option name="project" value="LOCAL" />
|
|
161
|
+
<updated>1637020728356</updated>
|
|
162
|
+
</task>
|
|
163
|
+
<task id="LOCAL-00003" summary="try catch on pdf addImage">
|
|
164
|
+
<created>1637247013210</created>
|
|
165
|
+
<option name="number" value="00003" />
|
|
166
|
+
<option name="presentableId" value="LOCAL-00003" />
|
|
167
|
+
<option name="project" value="LOCAL" />
|
|
168
|
+
<updated>1637247013211</updated>
|
|
169
|
+
</task>
|
|
170
|
+
<task id="LOCAL-00004" summary="Kms report grouped by day">
|
|
171
|
+
<created>1637715473148</created>
|
|
172
|
+
<option name="number" value="00004" />
|
|
173
|
+
<option name="presentableId" value="LOCAL-00004" />
|
|
174
|
+
<option name="project" value="LOCAL" />
|
|
175
|
+
<updated>1637715473149</updated>
|
|
176
|
+
</task>
|
|
177
|
+
<option name="localTasksCounter" value="5" />
|
|
178
|
+
<servers />
|
|
179
|
+
</component>
|
|
180
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
181
|
+
<option name="version" value="3" />
|
|
182
|
+
</component>
|
|
183
|
+
<component name="Vcs.Log.Tabs.Properties">
|
|
184
|
+
<option name="TAB_STATES">
|
|
185
|
+
<map>
|
|
186
|
+
<entry key="MAIN">
|
|
187
|
+
<value>
|
|
188
|
+
<State />
|
|
189
|
+
</value>
|
|
190
|
+
</entry>
|
|
191
|
+
</map>
|
|
192
|
+
</option>
|
|
193
|
+
<option name="oldMeFiltersMigrated" value="true" />
|
|
194
|
+
</component>
|
|
195
|
+
<component name="VcsManagerConfiguration">
|
|
196
|
+
<MESSAGE value="Fix getStyle" />
|
|
197
|
+
<MESSAGE value="Fix getStyle in all reports" />
|
|
198
|
+
<MESSAGE value="try catch on pdf addImage" />
|
|
199
|
+
<MESSAGE value="Kms report grouped by day" />
|
|
200
|
+
<option name="LAST_COMMIT_MESSAGE" value="Kms report grouped by day" />
|
|
201
|
+
</component>
|
|
202
|
+
</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
|
@@ -237,10 +237,10 @@ 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
|
-
|
|
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'})
|
|
@@ -251,8 +251,8 @@ function exportKmsReportToExcel(userData, reportData) {
|
|
|
251
251
|
{label: translations.report.distance, value: 'distance'})
|
|
252
252
|
} else {
|
|
253
253
|
headers.push(
|
|
254
|
-
{label: translations.report.
|
|
255
|
-
{label: translations.
|
|
254
|
+
{label: translations.report.vehicle, value: 'name'},
|
|
255
|
+
{label: translations.report.licensePlate, value: 'licenseplate'},
|
|
256
256
|
{label: translations.report.group, value: 'group'},
|
|
257
257
|
{label: translations.report.distance, value: 'distance'})
|
|
258
258
|
}
|
|
@@ -263,25 +263,25 @@ function exportKmsReportToExcel(userData, reportData) {
|
|
|
263
263
|
const group = userData.byDriver ? userData.groups.find(g => g.drivers.includes(d.driver.id)) :
|
|
264
264
|
userData.groups.find(g => d.device.groupId === g.id)
|
|
265
265
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
group: group ? group.name : '',
|
|
272
|
-
licenseplate: d.device.attributes.license_plate,
|
|
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,
|
|
266
|
+
if (userData.groupByDay) {
|
|
267
|
+
data = data.concat([{}])
|
|
268
|
+
data = data.concat(d.days.map(a => {
|
|
269
|
+
return {
|
|
270
|
+
name: d.device.name,
|
|
280
271
|
group: group ? group.name : '',
|
|
281
272
|
licenseplate: d.device.attributes.license_plate,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
+
}
|
|
285
285
|
})
|
|
286
286
|
|
|
287
287
|
return {
|