fleetmap-reports 2.0.80 → 2.0.82

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "2.0.80",
3
+ "version": "2.0.82",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -126,7 +126,7 @@ async function createSpeedingReportByDriver (from, to, userData, traccarInstance
126
126
 
127
127
  async function getEvents (traccarInstance, from, to, devices, userData, deviceCount, totalDevices, sliceSize) {
128
128
  if (processServerSide()) {
129
- const url = `https://${getServerHost()}/reports/speeding-report/getEvents`
129
+ const url = `https://${getServerHost()}/pinmeapi/reports/speeding-report/getEvents`
130
130
  return axios.post(url, { from, to, devices, userData, deviceCount, totalDevices, sliceSize }, { withCredentials: true }).then(d => d.data)
131
131
  } else {
132
132
  const geofencesFeatures = userData.geofences.filter(g => g.area.startsWith('POLYGON') &&
package/src/util/utils.js CHANGED
@@ -1,7 +1,6 @@
1
1
  const turf = require('@turf/helpers')
2
2
  const {
3
- getUserPartner,
4
- newDomains
3
+ getUserPartner
5
4
  } = require('fleetmap-partners')
6
5
  const messages = require('../../lang')
7
6
  const distance = require('@turf/distance')
@@ -238,7 +237,7 @@ async function executeServerSide (type, sliced, from, to, userData, totalItems,
238
237
  for (let i = 0; i < sliced.length; i += maxRequests) {
239
238
  const _sliced = sliced.slice(i, i + maxRequests)
240
239
  await Promise.all(_sliced.map(async items => {
241
- const url = `https://${getServerHost()}/reports/${type}`
240
+ const url = `https://${getServerHost()}/pinmeapi/reports/${type}`
242
241
  try {
243
242
  await axios.post(url, {
244
243
  from,
@@ -325,8 +324,5 @@ exports.processServerSide = (userData) => {
325
324
  return devices.length > 100 && isClientSide()
326
325
  }
327
326
 
328
- const getServerHost = () =>
329
- newDomains.includes(window.location.hostname)
330
- ? `${window.location.hostname}/pinmeapi`
331
- : process.env.SERVER_HOST
327
+ const getServerHost = () => process.env.SERVER_HOST
332
328
  exports.getServerHost = getServerHost
@@ -4,8 +4,7 @@ const {
4
4
  calculateDistance,
5
5
  sortPositions, getDates, convertToLocaleDateString, convertToLocaleTimeString,
6
6
  isClientSide,
7
- getLanguage, convertFromUTC, convertFromLocal,
8
- getServerHost
7
+ getLanguage, convertFromUTC, convertFromLocal
9
8
  } = require('./util/utils')
10
9
  const jsPDF = require('jspdf')
11
10
  require('jspdf-autotable')
@@ -23,7 +22,7 @@ const {
23
22
  const { checkGeofenceIn } = require('./util/geofence')
24
23
  const { parallel } = require('./util/parallel')
25
24
  const { getDataByDay } = require('./util/trips')
26
- const axios = require('axios')
25
+ const axios = require('axios').default
27
26
  const sliceSize = 100
28
27
  const deviceChunk = 5
29
28
  const fileName = 'ZoneReport'
@@ -37,10 +36,9 @@ async function createZoneReport (from, to, userData, traccar) {
37
36
  }
38
37
 
39
38
  if (isClientSide()) {
40
- const url = 'https://alb.fleetmap.pt/reports/zone-report/'
41
39
  const cookie = await axios.get('/pinmeapi/cookie/get', { withCredentials: true }).then(d => d.data)
42
- return traccar.axios.post(url, { from, to, userData }, { headers: {cookie} })
43
- .then(d => d.data)
40
+ const url = `https://${process.env.SERVER_HOST}/pinmeapi/reports/zone-report?cookie=${cookie}`
41
+ return axios.post(url, { from, to, userData }).then(d => d.data)
44
42
  }
45
43
  const types = ['geofenceEnter', 'geofenceExit']
46
44