fleetmap-reports 1.0.216 → 1.0.220
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/codeStyles/Project.xml +7 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/index.test.js +14 -31
- package/src/kms-report.js +9 -7
- package/.idea/runConfigurations.xml +0 -10
- package/.idea/workspace.xml +0 -194
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 =
|
|
26
|
+
this.speedingReportToPDF = (userData, reportData) => {
|
|
27
27
|
return require('./speeding-report').exportSpeedingReportToPDF(userData, reportData)
|
|
28
28
|
}
|
|
29
29
|
|
package/src/index.test.js
CHANGED
|
@@ -3,42 +3,25 @@ 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");
|
|
7
6
|
const cookieJar = new tough.CookieJar();
|
|
8
7
|
|
|
9
8
|
axiosCookieJarSupport(axios)
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
baseOptions: {
|
|
18
|
-
withCredentials: true,
|
|
19
|
-
jar: cookieJar
|
|
20
|
-
}
|
|
10
|
+
test('speedingReport', async () => {
|
|
11
|
+
const traccarConfig = {
|
|
12
|
+
basePath: 'https://api.pinme.io/api',
|
|
13
|
+
baseOptions: {
|
|
14
|
+
withCredentials: true,
|
|
15
|
+
jar: cookieJar
|
|
21
16
|
}
|
|
17
|
+
}
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
19
|
+
await new SessionApi(traccarConfig, null, axios).sessionPost('-','-')
|
|
20
|
+
const report = new Index(traccarConfig, axios)
|
|
21
|
+
const userData = await report.getUserData()
|
|
39
22
|
|
|
40
|
-
|
|
23
|
+
await report.speedingReport(new Date(2021, 2, 30, 0, 0, 0, 0),
|
|
24
|
+
new Date(2021, 2, 30, 23, 59, 59, 0),
|
|
25
|
+
userData)
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
})
|
|
27
|
+
}, 10000)
|
package/src/kms-report.js
CHANGED
|
@@ -6,7 +6,6 @@ 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 {convertMS} = require("./util/utils");
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
let traccarInstance
|
|
@@ -18,7 +17,9 @@ async function createKmsReportByDevice(from, to, userData) {
|
|
|
18
17
|
const devicesToProcess = userData.byGroup ? userData.devices.filter(d => !groupIds.includes(d.groupId)) : userData.devices
|
|
19
18
|
|
|
20
19
|
const allData = {
|
|
21
|
-
devices: []
|
|
20
|
+
devices: [],
|
|
21
|
+
from: from,
|
|
22
|
+
to: to
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
devicesToProcess.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
|
@@ -132,7 +133,7 @@ async function exportKmsReportToPDF(userData, reportData) {
|
|
|
132
133
|
if (kmsData) {
|
|
133
134
|
let first = true
|
|
134
135
|
const doc = userData.groupByDay ? new jsPDF.jsPDF() : new jsPDF.jsPDF('l')
|
|
135
|
-
await headerFromUser(doc, translations.report.
|
|
136
|
+
await headerFromUser(doc, translations.report.titleKmsReport, userData.user)
|
|
136
137
|
|
|
137
138
|
if (userData.groupByDay) {
|
|
138
139
|
for (const d of kmsData) {
|
|
@@ -149,14 +150,14 @@ async function exportKmsReportToPDF(userData, reportData) {
|
|
|
149
150
|
doc.setFontSize(13)
|
|
150
151
|
doc.text(name, 20, space + 20)
|
|
151
152
|
doc.setFontSize(11)
|
|
152
|
-
doc.text(group ? translations.report.group + ': ' + group.name : '',
|
|
153
|
-
doc.text(new Date(
|
|
153
|
+
doc.text(group ? translations.report.group + ': ' + group.name : '', 150, space + 20)
|
|
154
|
+
doc.text(new Date(reportData.from).toLocaleString() + ' - ' + new Date(reportData.to).toLocaleString(), 20, space + 25)
|
|
154
155
|
|
|
155
156
|
const data = []
|
|
156
157
|
d.days.forEach(day => {
|
|
157
158
|
const temp = [
|
|
158
|
-
new Date(day).toLocaleDateString(),
|
|
159
|
-
(day.kms/1000).toFixed(0)
|
|
159
|
+
new Date(day.date).toLocaleDateString(),
|
|
160
|
+
day.kms ? (day.kms/1000).toFixed(0) : 0
|
|
160
161
|
]
|
|
161
162
|
|
|
162
163
|
data.push(temp)
|
|
@@ -173,6 +174,7 @@ async function exportKmsReportToPDF(userData, reportData) {
|
|
|
173
174
|
addTable(doc, headers, data, footValues, style, 35)
|
|
174
175
|
}
|
|
175
176
|
} else {
|
|
177
|
+
const data = []
|
|
176
178
|
if (userData.byDriver) {
|
|
177
179
|
reportData.drivers.forEach(d => {
|
|
178
180
|
const group = userData.groups.find(g => g.drivers.includes(d.driver.id))
|
|
@@ -1,10 +0,0 @@
|
|
|
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>
|
package/.idea/workspace.xml
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
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="try catch on pdf addImage">
|
|
5
|
-
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
6
|
-
<change beforePath="$PROJECT_DIR$/src/activity-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/activity-report.js" afterDir="false" />
|
|
7
|
-
<change beforePath="$PROJECT_DIR$/src/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.js" afterDir="false" />
|
|
8
|
-
<change beforePath="$PROJECT_DIR$/src/index.test.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.test.js" afterDir="false" />
|
|
9
|
-
<change beforePath="$PROJECT_DIR$/src/kms-report.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/kms-report.js" afterDir="false" />
|
|
10
|
-
<change beforePath="$PROJECT_DIR$/src/util/pdfDocument.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/util/pdfDocument.js" afterDir="false" />
|
|
11
|
-
</list>
|
|
12
|
-
<option name="SHOW_DIALOG" value="false" />
|
|
13
|
-
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
14
|
-
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
15
|
-
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
16
|
-
</component>
|
|
17
|
-
<component name="Git.Settings">
|
|
18
|
-
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
19
|
-
</component>
|
|
20
|
-
<component name="ProjectId" id="20NIxbej0qfi8RaO3jr1XOU0xol" />
|
|
21
|
-
<component name="ProjectViewState">
|
|
22
|
-
<option name="hideEmptyMiddlePackages" value="true" />
|
|
23
|
-
<option name="showLibraryContents" value="true" />
|
|
24
|
-
</component>
|
|
25
|
-
<component name="PropertiesComponent">
|
|
26
|
-
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
|
27
|
-
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
|
28
|
-
<property name="WebServerToolWindowFactoryState" value="false" />
|
|
29
|
-
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
|
30
|
-
<property name="nodejs.mocha.mocha_node_package_dir" value="$PROJECT_DIR$/node_modules/mocha" />
|
|
31
|
-
<property name="nodejs_package_manager_path" value="npm" />
|
|
32
|
-
<property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
|
|
33
|
-
<property name="vue.rearranger.settings.migration" value="true" />
|
|
34
|
-
</component>
|
|
35
|
-
<component name="RunManager" selected="Mocha.test reports">
|
|
36
|
-
<configuration name="here" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
37
|
-
<node-interpreter>project</node-interpreter>
|
|
38
|
-
<node-options />
|
|
39
|
-
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
40
|
-
<working-directory>$PROJECT_DIR$</working-directory>
|
|
41
|
-
<pass-parent-env>true</pass-parent-env>
|
|
42
|
-
<ui>bdd</ui>
|
|
43
|
-
<extra-mocha-options />
|
|
44
|
-
<test-kind>SUITE</test-kind>
|
|
45
|
-
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
46
|
-
<test-names>
|
|
47
|
-
<name value="here" />
|
|
48
|
-
</test-names>
|
|
49
|
-
<method v="2" />
|
|
50
|
-
</configuration>
|
|
51
|
-
<configuration name="report" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
52
|
-
<node-interpreter>project</node-interpreter>
|
|
53
|
-
<node-options />
|
|
54
|
-
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
55
|
-
<working-directory>$PROJECT_DIR$</working-directory>
|
|
56
|
-
<pass-parent-env>true</pass-parent-env>
|
|
57
|
-
<ui>bdd</ui>
|
|
58
|
-
<extra-mocha-options />
|
|
59
|
-
<test-kind>SUITE</test-kind>
|
|
60
|
-
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
61
|
-
<test-names>
|
|
62
|
-
<name value="report" />
|
|
63
|
-
</test-names>
|
|
64
|
-
<method v="2" />
|
|
65
|
-
</configuration>
|
|
66
|
-
<configuration name="speedingReport" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
67
|
-
<node-interpreter>project</node-interpreter>
|
|
68
|
-
<node-options />
|
|
69
|
-
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
70
|
-
<working-directory>$PROJECT_DIR$</working-directory>
|
|
71
|
-
<pass-parent-env>true</pass-parent-env>
|
|
72
|
-
<ui>bdd</ui>
|
|
73
|
-
<extra-mocha-options />
|
|
74
|
-
<test-kind>TEST</test-kind>
|
|
75
|
-
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
76
|
-
<test-names>
|
|
77
|
-
<name value="speedingReport" />
|
|
78
|
-
</test-names>
|
|
79
|
-
<method v="2" />
|
|
80
|
-
</configuration>
|
|
81
|
-
<configuration name="test reports" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
82
|
-
<node-interpreter>project</node-interpreter>
|
|
83
|
-
<node-options />
|
|
84
|
-
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
85
|
-
<working-directory>$PROJECT_DIR$</working-directory>
|
|
86
|
-
<pass-parent-env>true</pass-parent-env>
|
|
87
|
-
<ui>bdd</ui>
|
|
88
|
-
<extra-mocha-options />
|
|
89
|
-
<test-kind>SUITE</test-kind>
|
|
90
|
-
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
91
|
-
<test-names>
|
|
92
|
-
<name value="test reports" />
|
|
93
|
-
</test-names>
|
|
94
|
-
<method v="2" />
|
|
95
|
-
</configuration>
|
|
96
|
-
<configuration name="test reports.test queue" type="mocha-javascript-test-runner" temporary="true" nameIsGenerated="true">
|
|
97
|
-
<node-interpreter>project</node-interpreter>
|
|
98
|
-
<node-options />
|
|
99
|
-
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
|
|
100
|
-
<working-directory>$PROJECT_DIR$</working-directory>
|
|
101
|
-
<pass-parent-env>true</pass-parent-env>
|
|
102
|
-
<ui>bdd</ui>
|
|
103
|
-
<extra-mocha-options />
|
|
104
|
-
<test-kind>TEST</test-kind>
|
|
105
|
-
<test-file>$PROJECT_DIR$/src/index.test.js</test-file>
|
|
106
|
-
<test-names>
|
|
107
|
-
<name value="test reports" />
|
|
108
|
-
<name value="test queue" />
|
|
109
|
-
</test-names>
|
|
110
|
-
<method v="2" />
|
|
111
|
-
</configuration>
|
|
112
|
-
<recent_temporary>
|
|
113
|
-
<list>
|
|
114
|
-
<item itemvalue="Mocha.test reports" />
|
|
115
|
-
<item itemvalue="Mocha.test reports.test queue" />
|
|
116
|
-
<item itemvalue="Mocha.speedingReport" />
|
|
117
|
-
<item itemvalue="Mocha.report" />
|
|
118
|
-
<item itemvalue="Mocha.here" />
|
|
119
|
-
</list>
|
|
120
|
-
</recent_temporary>
|
|
121
|
-
</component>
|
|
122
|
-
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
123
|
-
<component name="TaskManager">
|
|
124
|
-
<task active="true" id="Default" summary="Default task">
|
|
125
|
-
<changelist id="eb665c86-c893-4333-bd2a-721dc27980b9" name="Changes" comment="" />
|
|
126
|
-
<created>1635878866368</created>
|
|
127
|
-
<option name="number" value="Default" />
|
|
128
|
-
<option name="presentableId" value="Default" />
|
|
129
|
-
<updated>1635878866368</updated>
|
|
130
|
-
<workItem from="1635878870054" duration="105000" />
|
|
131
|
-
<workItem from="1635943211865" duration="371000" />
|
|
132
|
-
<workItem from="1636030918716" duration="808000" />
|
|
133
|
-
<workItem from="1636366400735" duration="3018000" />
|
|
134
|
-
<workItem from="1636371409243" duration="45000" />
|
|
135
|
-
<workItem from="1636371621773" duration="4750000" />
|
|
136
|
-
<workItem from="1636623371114" duration="675000" />
|
|
137
|
-
<workItem from="1636624396937" duration="1987000" />
|
|
138
|
-
<workItem from="1636627666406" duration="1616000" />
|
|
139
|
-
<workItem from="1636647112207" duration="1748000" />
|
|
140
|
-
<workItem from="1636981640447" duration="4315000" />
|
|
141
|
-
<workItem from="1637009407292" duration="1470000" />
|
|
142
|
-
<workItem from="1637012863006" duration="5376000" />
|
|
143
|
-
<workItem from="1637087797229" duration="5701000" />
|
|
144
|
-
<workItem from="1637227826845" duration="1275000" />
|
|
145
|
-
<workItem from="1637441942952" duration="4543000" />
|
|
146
|
-
<workItem from="1637670815688" duration="2973000" />
|
|
147
|
-
<workItem from="1637674107929" duration="12171000" />
|
|
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
|
-
<option name="localTasksCounter" value="4" />
|
|
171
|
-
<servers />
|
|
172
|
-
</component>
|
|
173
|
-
<component name="TypeScriptGeneratedFilesManager">
|
|
174
|
-
<option name="version" value="3" />
|
|
175
|
-
</component>
|
|
176
|
-
<component name="Vcs.Log.Tabs.Properties">
|
|
177
|
-
<option name="TAB_STATES">
|
|
178
|
-
<map>
|
|
179
|
-
<entry key="MAIN">
|
|
180
|
-
<value>
|
|
181
|
-
<State />
|
|
182
|
-
</value>
|
|
183
|
-
</entry>
|
|
184
|
-
</map>
|
|
185
|
-
</option>
|
|
186
|
-
<option name="oldMeFiltersMigrated" value="true" />
|
|
187
|
-
</component>
|
|
188
|
-
<component name="VcsManagerConfiguration">
|
|
189
|
-
<MESSAGE value="Fix getStyle" />
|
|
190
|
-
<MESSAGE value="Fix getStyle in all reports" />
|
|
191
|
-
<MESSAGE value="try catch on pdf addImage" />
|
|
192
|
-
<option name="LAST_COMMIT_MESSAGE" value="try catch on pdf addImage" />
|
|
193
|
-
</component>
|
|
194
|
-
</project>
|