. esportazione lista catalogo direttamente in EXCEL, e scelta dei campi.
This commit is contained in:
@@ -70,6 +70,7 @@
|
|||||||
"validator": "^13.12.0",
|
"validator": "^13.12.0",
|
||||||
"vhost": "^3.0.2",
|
"vhost": "^3.0.2",
|
||||||
"web-push": "^3.6.7",
|
"web-push": "^3.6.7",
|
||||||
|
"xlsx": "^0.18.5",
|
||||||
"xml2js": "^0.6.2",
|
"xml2js": "^0.6.2",
|
||||||
"xoauth2": "^1.2.0"
|
"xoauth2": "^1.2.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const PageViewSchema = new mongoose.Schema({
|
|||||||
userAgent: {
|
userAgent: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
referrer: String,
|
||||||
timestamp: {
|
timestamp: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: Date.now
|
default: Date.now
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ const { authenticate, authenticate_noerror } = require('../middleware/authentica
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const PageView = require('../models/PageView');
|
const PageView = require('../models/PageView');
|
||||||
|
|
||||||
|
const multer = require('multer');
|
||||||
|
const XLSX = require('xlsx');
|
||||||
|
|
||||||
|
const upload = multer({ dest: 'uploads/' });
|
||||||
|
|
||||||
|
|
||||||
router.post('/test-lungo', authenticate, (req, res) => {
|
router.post('/test-lungo', authenticate, (req, res) => {
|
||||||
const timeout = req.body.timeout;
|
const timeout = req.body.timeout;
|
||||||
|
|
||||||
@@ -25,7 +31,7 @@ router.post('/test-lungo', authenticate, (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post('/track-pageview', authenticate_noerror, async (req, res) => {
|
router.post('/track-pageview', authenticate_noerror, async (req, res) => {
|
||||||
const { url, userAgent, idapp } = req.body;
|
const { url, userAgent, idapp, referrer } = req.body;
|
||||||
const ip = req.ip || req.headers['x-forwarded-for'] || 'unknown';
|
const ip = req.ip || req.headers['x-forwarded-for'] || 'unknown';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -33,6 +39,7 @@ router.post('/track-pageview', authenticate_noerror, async (req, res) => {
|
|||||||
url,
|
url,
|
||||||
ip,
|
ip,
|
||||||
idapp,
|
idapp,
|
||||||
|
referrer,
|
||||||
userId: req.user ? req.user._id : '',
|
userId: req.user ? req.user._id : '',
|
||||||
username: req.user ? req.user.username : '',
|
username: req.user ? req.user.username : '',
|
||||||
userAgent,
|
userAgent,
|
||||||
@@ -294,4 +301,37 @@ router.get('/pageviews/weekly-top-pages', authenticate_noerror, async (req, res)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/api/convert-csv-to-xls', upload.single('csv'), (req, res) => {
|
||||||
|
try {
|
||||||
|
const csvFilePath = req.file.path;
|
||||||
|
|
||||||
|
// Leggi il CSV con SheetJS
|
||||||
|
const csvData = fs.readFileSync(csvFilePath, 'utf-8');
|
||||||
|
const worksheet = XLSX.utils.csv_to_sheet(csvData);
|
||||||
|
|
||||||
|
// Crea un file Excel
|
||||||
|
const workbook = XLSX.utils.book_new();
|
||||||
|
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
|
||||||
|
|
||||||
|
// Imposta la risposta come file XLS
|
||||||
|
const xlsFilePath = path.join(__dirname, 'converted', 'output.xls');
|
||||||
|
XLSX.writeFile(workbook, xlsFilePath);
|
||||||
|
|
||||||
|
// Restituisci il file XLS al frontend come risposta
|
||||||
|
res.download(xlsFilePath, 'converted-file.xls', (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error('Errore nel download del file:', err);
|
||||||
|
res.status(500).send('Errore nel download del file');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pulisci il file temporaneo
|
||||||
|
fs.unlinkSync(csvFilePath);
|
||||||
|
fs.unlinkSync(xlsFilePath);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Errore nella conversione del file:", error);
|
||||||
|
res.status(500).send('Errore nella conversione del file');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -2950,7 +2950,8 @@ module.exports = {
|
|||||||
if (qa1) query = [...query, ...qa1];
|
if (qa1) query = [...query, ...qa1];
|
||||||
query.push({ $unwind: '$group' });
|
query.push({ $unwind: '$group' });
|
||||||
|
|
||||||
if (true) {
|
if (false) {
|
||||||
|
//##++Todo: Query per i limiti GPS!
|
||||||
query.push({
|
query.push({
|
||||||
$match: {
|
$match: {
|
||||||
$and: [{ 'group.idapp': params.idapp }],
|
$and: [{ 'group.idapp': params.idapp }],
|
||||||
|
|||||||
58
yarn.lock
58
yarn.lock
@@ -1260,6 +1260,11 @@ acorn@^7.1.1:
|
|||||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
|
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
|
||||||
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
|
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
|
||||||
|
|
||||||
|
adler-32@~1.3.0:
|
||||||
|
version "1.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/adler-32/-/adler-32-1.3.1.tgz#1dbf0b36dda0012189a32b3679061932df1821e2"
|
||||||
|
integrity sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==
|
||||||
|
|
||||||
agent-base@^7.1.0, agent-base@^7.1.2:
|
agent-base@^7.1.0, agent-base@^7.1.2:
|
||||||
version "7.1.3"
|
version "7.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.3.tgz#29435eb821bc4194633a5b89e5bc4703bafc25a1"
|
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.3.tgz#29435eb821bc4194633a5b89e5bc4703bafc25a1"
|
||||||
@@ -2082,6 +2087,14 @@ centra@^2.7.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
follow-redirects "^1.15.6"
|
follow-redirects "^1.15.6"
|
||||||
|
|
||||||
|
cfb@~1.2.1:
|
||||||
|
version "1.2.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/cfb/-/cfb-1.2.2.tgz#94e687628c700e5155436dac05f74e08df23bc44"
|
||||||
|
integrity sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==
|
||||||
|
dependencies:
|
||||||
|
adler-32 "~1.3.0"
|
||||||
|
crc-32 "~1.2.0"
|
||||||
|
|
||||||
chalk@4.1.2, chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.2:
|
chalk@4.1.2, chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.2:
|
||||||
version "4.1.2"
|
version "4.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
|
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
|
||||||
@@ -2291,6 +2304,11 @@ code-point-at@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
|
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
|
||||||
integrity sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==
|
integrity sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==
|
||||||
|
|
||||||
|
codepage@~1.15.0:
|
||||||
|
version "1.15.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/codepage/-/codepage-1.15.0.tgz#2e00519024b39424ec66eeb3ec07227e692618ab"
|
||||||
|
integrity sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==
|
||||||
|
|
||||||
collect-v8-coverage@^1.0.0:
|
collect-v8-coverage@^1.0.0:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9"
|
resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9"
|
||||||
@@ -2512,6 +2530,11 @@ country-codes-list@^2.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/country-codes-list/-/country-codes-list-2.0.0.tgz#162c49028a0a9fe64503ed146980e0bb8529c170"
|
resolved "https://registry.yarnpkg.com/country-codes-list/-/country-codes-list-2.0.0.tgz#162c49028a0a9fe64503ed146980e0bb8529c170"
|
||||||
integrity sha512-KZqq/LBdCD76hQCa6nOx0bA/nIjYly1OtV8+Bbt/4SW+mJEqGk7oZHjUj7PRrV0gXJJKs6Tv2cIntFdofBByvA==
|
integrity sha512-KZqq/LBdCD76hQCa6nOx0bA/nIjYly1OtV8+Bbt/4SW+mJEqGk7oZHjUj7PRrV0gXJJKs6Tv2cIntFdofBByvA==
|
||||||
|
|
||||||
|
crc-32@~1.2.0, crc-32@~1.2.1:
|
||||||
|
version "1.2.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff"
|
||||||
|
integrity sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==
|
||||||
|
|
||||||
create-jest@^29.7.0:
|
create-jest@^29.7.0:
|
||||||
version "29.7.0"
|
version "29.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320"
|
resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320"
|
||||||
@@ -3849,6 +3872,11 @@ forwarded@0.2.0:
|
|||||||
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
|
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
|
||||||
integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==
|
integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==
|
||||||
|
|
||||||
|
frac@~1.1.2:
|
||||||
|
version "1.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/frac/-/frac-1.1.2.tgz#3d74f7f6478c88a1b5020306d747dc6313c74d0b"
|
||||||
|
integrity sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==
|
||||||
|
|
||||||
fresh@0.5.2, fresh@^0.5.2:
|
fresh@0.5.2, fresh@^0.5.2:
|
||||||
version "0.5.2"
|
version "0.5.2"
|
||||||
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
|
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
|
||||||
@@ -8305,6 +8333,13 @@ sqlstring@2.3.1:
|
|||||||
resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.1.tgz#475393ff9e91479aea62dcaf0ca3d14983a7fb40"
|
resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.1.tgz#475393ff9e91479aea62dcaf0ca3d14983a7fb40"
|
||||||
integrity sha512-ooAzh/7dxIG5+uDik1z/Rd1vli0+38izZhGzSa34FwR7IbelPWCCKSNIl8jlL/F7ERvy8CB2jNeM1E9i9mXMAQ==
|
integrity sha512-ooAzh/7dxIG5+uDik1z/Rd1vli0+38izZhGzSa34FwR7IbelPWCCKSNIl8jlL/F7ERvy8CB2jNeM1E9i9mXMAQ==
|
||||||
|
|
||||||
|
ssf@~0.11.2:
|
||||||
|
version "0.11.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/ssf/-/ssf-0.11.2.tgz#0b99698b237548d088fc43cdf2b70c1a7512c06c"
|
||||||
|
integrity sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==
|
||||||
|
dependencies:
|
||||||
|
frac "~1.1.2"
|
||||||
|
|
||||||
sshpk@^1.18.0, sshpk@^1.7.0:
|
sshpk@^1.18.0, sshpk@^1.7.0:
|
||||||
version "1.18.0"
|
version "1.18.0"
|
||||||
resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.18.0.tgz#1663e55cddf4d688b86a46b77f0d5fe363aba028"
|
resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.18.0.tgz#1663e55cddf4d688b86a46b77f0d5fe363aba028"
|
||||||
@@ -9434,6 +9469,16 @@ with@~4.0.0:
|
|||||||
acorn "^1.0.1"
|
acorn "^1.0.1"
|
||||||
acorn-globals "^1.0.3"
|
acorn-globals "^1.0.3"
|
||||||
|
|
||||||
|
wmf@~1.0.1:
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/wmf/-/wmf-1.0.2.tgz#7d19d621071a08c2bdc6b7e688a9c435298cc2da"
|
||||||
|
integrity sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==
|
||||||
|
|
||||||
|
word@~0.3.0:
|
||||||
|
version "0.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/word/-/word-0.3.0.tgz#8542157e4f8e849f4a363a288992d47612db9961"
|
||||||
|
integrity sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==
|
||||||
|
|
||||||
wordwrap@0.0.2:
|
wordwrap@0.0.2:
|
||||||
version "0.0.2"
|
version "0.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
|
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
|
||||||
@@ -9514,6 +9559,19 @@ xhr@^2.0.1:
|
|||||||
parse-headers "^2.0.0"
|
parse-headers "^2.0.0"
|
||||||
xtend "^4.0.0"
|
xtend "^4.0.0"
|
||||||
|
|
||||||
|
xlsx@^0.18.5:
|
||||||
|
version "0.18.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/xlsx/-/xlsx-0.18.5.tgz#16711b9113c848076b8a177022799ad356eba7d0"
|
||||||
|
integrity sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==
|
||||||
|
dependencies:
|
||||||
|
adler-32 "~1.3.0"
|
||||||
|
cfb "~1.2.1"
|
||||||
|
codepage "~1.15.0"
|
||||||
|
crc-32 "~1.2.1"
|
||||||
|
ssf "~0.11.2"
|
||||||
|
wmf "~1.0.1"
|
||||||
|
word "~0.3.0"
|
||||||
|
|
||||||
xml-name-validator@^5.0.0:
|
xml-name-validator@^5.0.0:
|
||||||
version "5.0.0"
|
version "5.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-5.0.0.tgz#82be9b957f7afdacf961e5980f1bf227c0bf7673"
|
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-5.0.0.tgz#82be9b957f7afdacf961e5980f1bf227c0bf7673"
|
||||||
|
|||||||
Reference in New Issue
Block a user