- creato editor di Pagine (iniziato)
- fix: mancano i "t," su alcuni componenti...
This commit is contained in:
@@ -30,8 +30,8 @@ SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
|||||||
TOKEN_LIFE=2h
|
TOKEN_LIFE=2h
|
||||||
REFRESH_TOKEN_LIFE=14d
|
REFRESH_TOKEN_LIFE=14d
|
||||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
||||||
DOMAINS=[{"hostname":"riso.app","port":"3006"},{"hostname":"freeplanet.app","port":"3000"}]
|
DOMAINS=[{"hostname":"riso.app","port":"3006"},{"hostname":"freeplanet.app","port":"3000"},{"hostname":"nuovomondo.app","port":"3032"}]
|
||||||
DOMAINS_ALLOWED=["comunitanuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"]
|
DOMAINS_ALLOWED=["comunitanuovomondo.app","nuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"]
|
||||||
#DOMAINS=[{"hostname":"abitaregliiblei.it","port":"3021"},{"hostname":"riso.app","port":"3005"}]
|
#DOMAINS=[{"hostname":"abitaregliiblei.it","port":"3021"},{"hostname":"riso.app","port":"3005"}]
|
||||||
SCRIPTS_DIR=admin_scripts
|
SCRIPTS_DIR=admin_scripts
|
||||||
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
|
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
|||||||
TOKEN_LIFE=2h
|
TOKEN_LIFE=2h
|
||||||
REFRESH_TOKEN_LIFE=14d
|
REFRESH_TOKEN_LIFE=14d
|
||||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
||||||
DOMAINS=[{"hostname":"riso.app","port":"3005"}]
|
DOMAINS=[{"hostname":"riso.app","port":"3005"},{"hostname":"nuovomondo.app","port":"3033"}]
|
||||||
DOMAINS_ALLOWED=["comunitanuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"]
|
DOMAINS_ALLOWED=["comunitanuovomondo.app","kolibrilab.it","artenergetica.org","freeplanet.app","www.freeplanet.app","freeplanet.app:3000","freeplanet.app:3001","www.freeplanet.app:3000","www.freeplanet.app:3001"]
|
||||||
SCRIPTS_DIR=admin_scripts
|
SCRIPTS_DIR=admin_scripts
|
||||||
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
|
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Define MIODOMINIO riso.app
|
||||||
|
Define MIODOMINIO_COMPLETO test.riso.app
|
||||||
|
Define MIOURL_API testapi.riso.app
|
||||||
|
Define PORTA 3005
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<VirtualHost 65.108.222.97:80>
|
||||||
|
ServerName ${MIODOMINIO_COMPLETO}
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# Forza la connessione HTTPS
|
||||||
|
RewriteCond %{HTTPS} off
|
||||||
|
RewriteRule ^ https://${MIODOMINIO_COMPLETO}%{REQUEST_URI} [L,R=301]
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
<VirtualHost 65.108.222.97:443>
|
||||||
|
ServerName ${MIODOMINIO_COMPLETO}
|
||||||
|
DocumentRoot /var/www/${MIODOMINIO_COMPLETO}
|
||||||
|
ServerAdmin surya@riso.app
|
||||||
|
SSLEngine On
|
||||||
|
SSLProtocol -ALL +TLSv1.2
|
||||||
|
SSLCompression Off
|
||||||
|
SSLHonorCipherOrder off
|
||||||
|
SSLCipherSuite ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128
|
||||||
|
SSLVerifyDepth 10
|
||||||
|
SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/cert.pem
|
||||||
|
SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
|
||||||
|
<Directory /var/www/${MIODOMINIO_COMPLETO}/>
|
||||||
|
CGIPassAuth On
|
||||||
|
Require all granted
|
||||||
|
AllowOverride All
|
||||||
|
</Directory>
|
||||||
|
LogLevel warn
|
||||||
|
ErrorLog "/var/www/${MIODOMINIO_COMPLETO}/logs/error.log"
|
||||||
|
CustomLog "/var/www/${MIODOMINIO_COMPLETO}/logs/access.log" combined
|
||||||
|
</VirtualHost>
|
||||||
11
docs/apache2/sites-available/000-default-ssl.conf
Normal file
11
docs/apache2/sites-available/000-default-ssl.conf
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<VirtualHost *:443>
|
||||||
|
ServerName _default_
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile /etc/letsencrypt/live/riso.app/fullchain.pem
|
||||||
|
SSLCertificateKeyFile /etc/letsencrypt/live/riso.app/privkey.pem
|
||||||
|
Include /etc/letsencrypt/options-ssl-apache.conf
|
||||||
|
Protocols h2 http/1.1
|
||||||
|
|
||||||
|
# Puoi anche fare un 403:
|
||||||
|
Redirect 403 /
|
||||||
|
</VirtualHost>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
Define MIODOMINIO riso.app
|
||||||
|
Define MIODOMINIO_COMPLETO riso.app
|
||||||
|
Define MIOURL_API api.riso.app
|
||||||
|
Define PORTA 3006
|
||||||
3
docs/apache2/sites-available/websites_ssl.riso.app.conf
Normal file
3
docs/apache2/sites-available/websites_ssl.riso.app.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Include /etc/apache2/sites-available/dominioinclude.riso.app.conf
|
||||||
|
|
||||||
|
Include /etc/apache2/sites-available/websites_ssl_virtualhost.conf
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Include /etc/apache2/sites-available/dominioinclude_test.riso.app.conf
|
||||||
|
|
||||||
|
Include /etc/apache2/sites-available/websites_ssl_virtualhost_sottodomini.conf
|
||||||
@@ -1,30 +1,94 @@
|
|||||||
<VirtualHost 65.108.222.97:80>
|
# ==================== APEX (SITO) ====================
|
||||||
ServerName ${MIODOMINIO_COMPLETO}
|
# HTTP -> HTTPS
|
||||||
RewriteEngine On
|
<VirtualHost *:80>
|
||||||
|
ServerName ${MIODOMINIO}
|
||||||
|
ServerAlias www.${MIODOMINIO}
|
||||||
|
|
||||||
# Forza la connessione HTTPS
|
RewriteEngine On
|
||||||
RewriteCond %{HTTPS} off
|
RewriteRule ^ https://${MIODOMINIO}%{REQUEST_URI} [R=301,L]
|
||||||
RewriteRule ^ https://${MIODOMINIO_COMPLETO}%{REQUEST_URI} [L,R=301]
|
|
||||||
|
ErrorLog /var/log/apache2/${MIODOMINIO}-error.log
|
||||||
|
CustomLog /var/log/apache2/${MIODOMINIO}-access.log combined
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
||||||
<VirtualHost 65.108.222.97:443>
|
# HTTPS (servizio sito - NO proxy qui)
|
||||||
ServerName ${MIODOMINIO_COMPLETO}
|
<VirtualHost *:443>
|
||||||
DocumentRoot /var/www/${MIODOMINIO_COMPLETO}
|
ServerName ${MIODOMINIO}
|
||||||
ServerAdmin surya@riso.app
|
ServerAlias www.${MIODOMINIO}
|
||||||
SSLEngine On
|
|
||||||
SSLProtocol -ALL +TLSv1.2
|
DocumentRoot /var/www/${MIODOMINIO_COMPLETO}
|
||||||
SSLCompression Off
|
|
||||||
SSLHonorCipherOrder off
|
SSLEngine on
|
||||||
SSLCipherSuite ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128
|
SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/fullchain.pem
|
||||||
SSLVerifyDepth 10
|
SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
|
||||||
SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/cert.pem
|
Include /etc/letsencrypt/options-ssl-apache.conf
|
||||||
SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
|
Protocols h2 http/1.1
|
||||||
<Directory /var/www/${MIODOMINIO_COMPLETO}/>
|
|
||||||
CGIPassAuth On
|
<Directory "/var/www/${MIODOMINIO_COMPLETO}">
|
||||||
Require all granted
|
Options Indexes FollowSymLinks
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
</Directory>
|
Require all granted
|
||||||
LogLevel warn
|
</Directory>
|
||||||
ErrorLog "/var/www/${MIODOMINIO_COMPLETO}/logs/error.log"
|
|
||||||
CustomLog "/var/www/${MIODOMINIO_COMPLETO}/logs/access.log" combined
|
DirectoryIndex index.html
|
||||||
|
|
||||||
|
# (Opzionale per SPA Quasar/Vue)
|
||||||
|
# RewriteEngine On
|
||||||
|
# RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
# RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
# RewriteRule ^ /index.html [L]
|
||||||
|
|
||||||
|
ErrorLog /var/log/apache2/${MIODOMINIO}-error.log
|
||||||
|
CustomLog /var/log/apache2/${MIODOMINIO}-access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== API ====================
|
||||||
|
# HTTP -> HTTPS
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName ${MIOURL_API}
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteRule ^ https://${MIOURL_API}%{REQUEST_URI} [R=301,L]
|
||||||
|
|
||||||
|
ErrorLog /var/log/apache2/${MIOURL_API}-error.log
|
||||||
|
CustomLog /var/log/apache2/${MIOURL_API}-access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
# HTTPS (proxy verso backend)
|
||||||
|
<VirtualHost *:443>
|
||||||
|
ServerName ${MIOURL_API}
|
||||||
|
ServerAdmin surya@riso.app
|
||||||
|
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/fullchain.pem
|
||||||
|
SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
|
||||||
|
Include /etc/letsencrypt/options-ssl-apache.conf
|
||||||
|
Protocols h2 http/1.1
|
||||||
|
|
||||||
|
ProxyPreserveHost On
|
||||||
|
|
||||||
|
# ===== SCEGLI UNO DEI DUE BLOCCHI, in base al TUO backend su ${PORTA} =====
|
||||||
|
# --- Backend HTTP (più comune) ---
|
||||||
|
# ProxyPass / http://127.0.0.1:${PORTA}/ retry=0 timeout=310 connectiontimeout=30
|
||||||
|
# ProxyPassReverse / http://127.0.0.1:${PORTA}/
|
||||||
|
|
||||||
|
# --- Backend HTTPS (nel tuo caso probabile, visto l’“Empty reply” via HTTP) ---
|
||||||
|
SSLProxyEngine On
|
||||||
|
SSLProxyVerify none
|
||||||
|
SSLProxyCheckPeerName off
|
||||||
|
ProxyPass / https://127.0.0.1:${PORTA}/ retry=0 timeout=310 connectiontimeout=30
|
||||||
|
ProxyPassReverse / https://127.0.0.1:${PORTA}/
|
||||||
|
# ==========================================================================
|
||||||
|
|
||||||
|
<Proxy *>
|
||||||
|
Require all granted
|
||||||
|
</Proxy>
|
||||||
|
|
||||||
|
ProxyTimeout 310
|
||||||
|
Timeout 310
|
||||||
|
ProxyBadHeader Ignore
|
||||||
|
|
||||||
|
ErrorLog /var/log/apache2/${MIOURL_API}-error.log
|
||||||
|
CustomLog /var/log/apache2/${MIOURL_API}-access.log combined
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
# ==================== APEX (SITO) ====================
|
||||||
|
# HTTP -> HTTPS
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName ${MIODOMINIO_COMPLETO}
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteRule ^ https://${MIODOMINIO_COMPLETO}%{REQUEST_URI} [R=301,L]
|
||||||
|
|
||||||
|
ErrorLog /var/log/apache2/${MIODOMINIO_COMPLETO}-error.log
|
||||||
|
CustomLog /var/log/apache2/${MIODOMINIO_COMPLETO}-access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
# HTTPS (servizio sito - NO proxy qui)
|
||||||
|
<VirtualHost *:443>
|
||||||
|
ServerName ${MIODOMINIO_COMPLETO}
|
||||||
|
|
||||||
|
DocumentRoot /var/www/${MIODOMINIO_COMPLETO}
|
||||||
|
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/fullchain.pem
|
||||||
|
SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
|
||||||
|
Include /etc/letsencrypt/options-ssl-apache.conf
|
||||||
|
Protocols h2 http/1.1
|
||||||
|
|
||||||
|
<Directory "/var/www/${MIODOMINIO_COMPLETO}">
|
||||||
|
Options Indexes FollowSymLinks
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
DirectoryIndex index.html
|
||||||
|
|
||||||
|
# (Opzionale per SPA Quasar/Vue)
|
||||||
|
# RewriteEngine On
|
||||||
|
# RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
# RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
# RewriteRule ^ /index.html [L]
|
||||||
|
|
||||||
|
ErrorLog /var/log/apache2/${MIODOMINIO_COMPLETO}-error.log
|
||||||
|
CustomLog /var/log/apache2/${MIODOMINIO_COMPLETO}-access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
|
||||||
|
# ==================== API ====================
|
||||||
|
# HTTP -> HTTPS
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName ${MIOURL_API}
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteRule ^ https://${MIOURL_API}%{REQUEST_URI} [R=301,L]
|
||||||
|
|
||||||
|
ErrorLog /var/log/apache2/${MIOURL_API}-error.log
|
||||||
|
CustomLog /var/log/apache2/${MIOURL_API}-access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
# HTTPS (proxy verso backend)
|
||||||
|
<VirtualHost *:443>
|
||||||
|
ServerName ${MIOURL_API}
|
||||||
|
ServerAdmin surya@riso.app
|
||||||
|
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile /etc/letsencrypt/live/${MIODOMINIO}/fullchain.pem
|
||||||
|
SSLCertificateKeyFile /etc/letsencrypt/live/${MIODOMINIO}/privkey.pem
|
||||||
|
Include /etc/letsencrypt/options-ssl-apache.conf
|
||||||
|
Protocols h2 http/1.1
|
||||||
|
|
||||||
|
ProxyPreserveHost On
|
||||||
|
|
||||||
|
# ===== SCEGLI UNO DEI DUE BLOCCHI, in base al TUO backend su ${PORTA} =====
|
||||||
|
# --- Backend HTTP (più comune) ---
|
||||||
|
# ProxyPass / http://127.0.0.1:${PORTA}/ retry=0 timeout=310 connectiontimeout=30
|
||||||
|
# ProxyPassReverse / http://127.0.0.1:${PORTA}/
|
||||||
|
|
||||||
|
# --- Backend HTTPS (nel tuo caso probabile, visto l’“Empty reply” via HTTP) ---
|
||||||
|
SSLProxyEngine On
|
||||||
|
SSLProxyVerify none
|
||||||
|
SSLProxyCheckPeerName off
|
||||||
|
ProxyPass / https://127.0.0.1:${PORTA}/ retry=0 timeout=310 connectiontimeout=30
|
||||||
|
ProxyPassReverse / https://127.0.0.1:${PORTA}/
|
||||||
|
# ==========================================================================
|
||||||
|
|
||||||
|
<Proxy *>
|
||||||
|
Require all granted
|
||||||
|
</Proxy>
|
||||||
|
|
||||||
|
ProxyTimeout 310
|
||||||
|
Timeout 310
|
||||||
|
ProxyBadHeader Ignore
|
||||||
|
|
||||||
|
ErrorLog /var/log/apache2/${MIOURL_API}-error.log
|
||||||
|
CustomLog /var/log/apache2/${MIOURL_API}-access.log combined
|
||||||
|
</VirtualHost>
|
||||||
@@ -690,3 +690,6 @@ function generateCSV(data, outputPath) {
|
|||||||
// const Order = mongoose.model('Order', OrderSchema);
|
// const Order = mongoose.model('Order', OrderSchema);
|
||||||
|
|
||||||
// module.exports = { Order };
|
// module.exports = { Order };
|
||||||
|
|
||||||
|
|
||||||
|
// **** TOTALPRICE !!!
|
||||||
@@ -495,36 +495,38 @@ class CronMod {
|
|||||||
await MyBot.generateBotMenuRecords(idapp);
|
await MyBot.generateBotMenuRecords(idapp);
|
||||||
} else if (mydata.dbop === 'GenerateVapiKey') {
|
} else if (mydata.dbop === 'GenerateVapiKey') {
|
||||||
await tools.generateVapiKey();
|
await tools.generateVapiKey();
|
||||||
|
} else if (mydata.dbop === 'convertProductInfos') {
|
||||||
|
const products = await Product.find({ idProductInfo: { $exists: true } });
|
||||||
|
console.log(
|
||||||
|
'eseguiDbOpUser: convertProductInfos - TrovaticonvertProductInfos ',
|
||||||
|
products.length,
|
||||||
|
' prodotti con idProductInfo'
|
||||||
|
);
|
||||||
|
|
||||||
/*} else if (mydata.dbop === 'visuNave') {
|
let aggiornati = 0;
|
||||||
mystr = await Nave.getNavePos(idapp, parseInt(mydata.riga), parseInt(mydata.col));
|
for (const product of products) {
|
||||||
|
const productInfo = await ProductInfo.findById(product.idProductInfo);
|
||||||
const visu_nave_Bot = await Settings.getValDbSettings(idapp, 'VISU_NAVE_BOT');
|
if (productInfo) {
|
||||||
if (visu_nave_Bot)
|
const productInfoObj = productInfo.toObject();
|
||||||
telegrambot.sendMsgTelegramToTheAdmin(idapp, mystr, true);
|
delete productInfoObj._id;
|
||||||
|
delete productInfoObj.__v;
|
||||||
ris = { mystr };
|
await Product.updateOne(
|
||||||
} else if (mydata.dbop === 'getnavibyuser') {
|
{ _id: product._id },
|
||||||
|
{
|
||||||
let arrnavi = null;
|
$set: { productInfo: productInfoObj },
|
||||||
|
$unset: { idProductInfo: 1 },
|
||||||
const user = await User.getUserShortDataByUsername(idapp, mydata.username);
|
}
|
||||||
if (user) {
|
);
|
||||||
arrnavi = await Nave.getArrPosizioniByUsername(idapp, user.username);
|
|
||||||
|
aggiornati++;
|
||||||
for (let mynave of arrnavi) {
|
|
||||||
mynave._doc.rec = await Nave.getNaveByRigaCol(idapp, mynave.riga, mynave.col);
|
// ✅ Cancella il record ProductInfo ora che è stato copiato
|
||||||
}
|
await ProductInfo.deleteOne({ _id: productInfo._id });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ris = { data: arrnavi };
|
console.log('eseguiDbOpUser - Aggiornati ', aggiornati, ' prodotti');
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('ris', ris);
|
|
||||||
|
|
||||||
return ris;
|
return ris;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
|
|||||||
@@ -1316,193 +1316,6 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return res.status(200).send({ updated, imported, errors });
|
return res.status(200).send({ updated, imported, errors });
|
||||||
} else if (cmd === shared_consts.Cmd.MACRO_RANKING) {
|
|
||||||
/*
|
|
||||||
let updated = 0;
|
|
||||||
let imported = 0;
|
|
||||||
let errors = 0;
|
|
||||||
|
|
||||||
const ripopola = true; // SETTARE su TRUE
|
|
||||||
|
|
||||||
if (ripopola) {
|
|
||||||
dataObjects = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
dataObjects = JSON.parse(`[${data.arrdata}]`);
|
|
||||||
} catch (e) {
|
|
||||||
dataObjects = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dataObjects && dataObjects[0]) {
|
|
||||||
// Cancella la collection ImportaIsbn
|
|
||||||
await ImportaIsbn.deleteMany({ idapp });
|
|
||||||
|
|
||||||
const numtot = dataObjects[0].length
|
|
||||||
|
|
||||||
console.log('Numero di RECORD da Importare = ', numtot);
|
|
||||||
|
|
||||||
// Aggiungi i record su ImportaIsbn
|
|
||||||
for (const recinv of dataObjects[0]) {
|
|
||||||
let recmacro = recinv;
|
|
||||||
|
|
||||||
recmacro.idapp = idapp;
|
|
||||||
|
|
||||||
//recmacro._id = recmacro.id;
|
|
||||||
recmacro.sku = recmacro.IdArticolo;
|
|
||||||
|
|
||||||
if (recmacro.DataPubblicazione) {
|
|
||||||
|
|
||||||
// delete recmacro.id;
|
|
||||||
|
|
||||||
let queryprod = { idapp, sku: recmacro.sku };
|
|
||||||
|
|
||||||
// 13872
|
|
||||||
|
|
||||||
try {
|
|
||||||
let risrec = await ImportaIsbn.findOneAndUpdate(queryprod, { $set: recmacro }, { new: true, upsert: true, strict: false });
|
|
||||||
if (risrec) {
|
|
||||||
imported++;
|
|
||||||
if ((imported % 100) === 0)
|
|
||||||
console.log('Importati dir TEMPORANEA ... ', imported + '/' + numtot);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
errors++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rileggi tutti i record di ImportaIsbn
|
|
||||||
dataObjects = await ImportaIsbn.find({ idapp }).lean();
|
|
||||||
|
|
||||||
let numprod = dataObjects.length;
|
|
||||||
|
|
||||||
console.log('*** INIZIO IMPORT RANKING ... NUMRECORD = ', numprod);
|
|
||||||
|
|
||||||
let indprod = 0;
|
|
||||||
let newprod = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if (numprod) {
|
|
||||||
// Rimuove prima tutti i valori precedenti
|
|
||||||
let risupdate = await ProductInfo.updateMany({ idapp }, {
|
|
||||||
$set: {
|
|
||||||
totVen: 0,
|
|
||||||
totFat: 0,
|
|
||||||
vLast3M: 0,
|
|
||||||
vLast6M: 0,
|
|
||||||
vLast1Y: 0,
|
|
||||||
vLast2Y: 0,
|
|
||||||
rank3M: 0,
|
|
||||||
rank6M: 0,
|
|
||||||
rank1Y: 0,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
imported = 0;
|
|
||||||
|
|
||||||
for (const product of dataObjects) {
|
|
||||||
let isnuovo = false
|
|
||||||
let setta = false
|
|
||||||
|
|
||||||
let importa = true;
|
|
||||||
|
|
||||||
//if (!product.title || !product.isbn)
|
|
||||||
if (!product.sku || !product.DataPubblicazione)
|
|
||||||
importa = false;
|
|
||||||
|
|
||||||
if (importa) {
|
|
||||||
let versGM = product.Versione ? product.Versione : '';
|
|
||||||
|
|
||||||
// split versioneGM in array with separated ","
|
|
||||||
let arrversGM = versGM.split(",").map(x => x.trim());
|
|
||||||
|
|
||||||
const recproductInfoAttuale = await ProductInfo.findOne({ idapp, code: product.isbn });
|
|
||||||
|
|
||||||
let productInfo = {
|
|
||||||
idapp: product.idapp,
|
|
||||||
code: product.isbn ? product.isbn : product.code,
|
|
||||||
sku: product.sku,
|
|
||||||
idCatProds: recproductInfoAttuale?.idCatProds,
|
|
||||||
|
|
||||||
// id_wp: product._id,
|
|
||||||
|
|
||||||
// name: product.title,
|
|
||||||
totVen: product.totVen || 0,
|
|
||||||
totFat: product.totFat || 0,
|
|
||||||
vLast3M: product.vLast3M || 0,
|
|
||||||
fatLast3M: product.fatLast3M || 0,
|
|
||||||
fatLast6M: product.fatLast6M || 0,
|
|
||||||
vLast6M: product.vLast6M || 0,
|
|
||||||
vLast1Y: product.vLast1Y || 0,
|
|
||||||
vLast2Y: product.vLast2Y || 0,
|
|
||||||
rank3M: product.rank3M || 0,
|
|
||||||
rank6M: product.rank6M || 0,
|
|
||||||
rank1Y: product.rank1Y || 0,
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!productInfo.idCatProds) {
|
|
||||||
productInfo.idCatProds = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Aggiorna la collana solo se non è stata già impostata nel record attuale
|
|
||||||
//if (recproductInfoAttuale && !recproductInfoAttuale.idCollana && product.DescrizioneCollana) {
|
|
||||||
if (recproductInfoAttuale && product.DescrizioneCollana) {
|
|
||||||
const idCollanaNum = parseInt(product.IdCollana)
|
|
||||||
|
|
||||||
reccollana = await Collana.findOne({ idapp, idCollana: idCollanaNum }).lean();
|
|
||||||
if (!reccollana) {
|
|
||||||
try {
|
|
||||||
// Non esiste questa collana, quindi la creo !
|
|
||||||
reccollana = new Collana({ idapp, idCollana: idCollanaNum, title: product.DescrizioneCollana });
|
|
||||||
ris = await reccoll.save();
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Err', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reccollana)
|
|
||||||
productInfo.idCollana = reccollana._id;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (recproductInfoAttuale && product.DescrArgomento) {
|
|
||||||
|
|
||||||
productInfo = await updateProductInfo(productInfo, product, idapp, product.DescrArgomento);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (product.DataPubblicazione) {
|
|
||||||
productInfo.date_pub = new Date(product.DataPubblicazione);
|
|
||||||
// convert data to timestamp
|
|
||||||
productInfo.date_pub_ts = productInfo.date_pub.getTime();
|
|
||||||
}
|
|
||||||
if (product.dataUltimoOrdine) {
|
|
||||||
productInfo.dataUltimoOrdine = new Date(product.dataUltimoOrdine);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update ProductInfo
|
|
||||||
let risrecInfo = await ProductInfo.findOneAndUpdate({ idapp, code: productInfo.code }, { $set: productInfo }, { new: true, upsert: false });
|
|
||||||
if (risrecInfo) {
|
|
||||||
imported++;
|
|
||||||
if (imported % 100 === 0)
|
|
||||||
console.log('Importati... ', imported + '/' + numprod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('*** IMPORTATI: ', imported, ' [Prodotti = ' + indprod + '] *** NUOVI: ', newprod, 'AGGIORNATI = ' + updated + ' (su ' + dataObjects.length + ' RECORD)');
|
|
||||||
|
|
||||||
return res.status(200).send({ updated, imported, errors });
|
|
||||||
*/
|
|
||||||
} else if (cmd === shared_consts.Cmd.MACRO_CATALOGO_JSON) {
|
} else if (cmd === shared_consts.Cmd.MACRO_CATALOGO_JSON) {
|
||||||
try {
|
try {
|
||||||
const macro = new Macro(idapp, { importadaFDV: true }); // Crea un'istanza della classe Macro
|
const macro = new Macro(idapp, { importadaFDV: true }); // Crea un'istanza della classe Macro
|
||||||
@@ -1598,6 +1411,7 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// .... ANDARE AVANTI DA QUI... .productInfo.... SISTEMARE!
|
// .... ANDARE AVANTI DA QUI... .productInfo.... SISTEMARE!
|
||||||
|
|
||||||
if (risrecInfo) {
|
if (risrecInfo) {
|
||||||
productImported.productInfo = risrecInfo._id;
|
productImported.productInfo = risrecInfo._id;
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,26 @@ function subDays(date, days) {
|
|||||||
return newDate;
|
return newDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
router.delete('/mypage/:id', authenticate, async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Trova il record di MyPage da cancellare
|
||||||
|
const pageToDelete = await MyPage.findByIdAndRemove(id);
|
||||||
|
|
||||||
|
if (!pageToDelete) {
|
||||||
|
return res.status(404).json({ error: 'Pagina non trovata' });
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({ message: `Pagina eliminata con successo: ${pageToDelete.path}` });
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
res.status(500).json({ error: 'Errore durante l\'eliminazione della pagina' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
router.get('/pageviews/users', authenticate_noerror, async (req, res) => {
|
router.get('/pageviews/users', authenticate_noerror, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { idapp } = req.query;
|
const { idapp } = req.query;
|
||||||
|
|||||||
@@ -900,6 +900,30 @@ router.post('/getpage', async (req, res) => {
|
|||||||
return found;
|
return found;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/savepage', authenticate, async (req, res) => {
|
||||||
|
const params = req.body;
|
||||||
|
const idapp = req.body.idapp;
|
||||||
|
const mypage = params.page;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (mypage?._id) {
|
||||||
|
let found = await MyPage.findOneAndUpdate({ idapp, _id: mypage._id }, mypage, { upsert: true, new: true })
|
||||||
|
.then((ris) => {
|
||||||
|
if (ris) {
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_OK, mypage: ris });
|
||||||
|
}
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_ERR, msg: '' });
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e.message);
|
||||||
|
res.status(400).send(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error', e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
async function exportPage(idapp, pageId) {
|
async function exportPage(idapp, pageId) {
|
||||||
try {
|
try {
|
||||||
const myexp = {
|
const myexp = {
|
||||||
|
|||||||
@@ -1126,23 +1126,6 @@ async function eseguiDbOpUser(idapp, mydata, locale, req, res) {
|
|||||||
await User.findOneAndUpdate({ _id: mydata._id }, { $set: { 'profile.noCircIta': mydata.value } });
|
await User.findOneAndUpdate({ _id: mydata._id }, { $set: { 'profile.noCircIta': mydata.value } });
|
||||||
} else if (mydata.dbop === 'noFoto') {
|
} else if (mydata.dbop === 'noFoto') {
|
||||||
await User.findOneAndUpdate({ _id: mydata._id }, { $set: { 'profile.noFoto': mydata.value } });
|
await User.findOneAndUpdate({ _id: mydata._id }, { $set: { 'profile.noFoto': mydata.value } });
|
||||||
} else if (mydata.dbop === 'convertProductInfos') {
|
|
||||||
const products = await Product.find({ idProductInfo: { $exists: true } });
|
|
||||||
for (const product of products) {
|
|
||||||
const productInfo = await ProductInfo.findById(product.idProductInfo);
|
|
||||||
if (productInfo) {
|
|
||||||
const productInfoObj = productInfo.toObject();
|
|
||||||
delete productInfoObj._id;
|
|
||||||
delete productInfoObj.__v;
|
|
||||||
await Product.updateOne(
|
|
||||||
{ _id: product._id },
|
|
||||||
{
|
|
||||||
$set: { productInfo: productInfoObj },
|
|
||||||
$unset: { idProductInfo: 1 },
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
|
|||||||
@@ -791,7 +791,10 @@ connectToDatabase(connectionUrl, options)
|
|||||||
return [
|
return [
|
||||||
'https://localhost:3000',
|
'https://localhost:3000',
|
||||||
'https://localhost:8089',
|
'https://localhost:8089',
|
||||||
|
'https://localhost:8082',
|
||||||
|
'https://localhost:8083',
|
||||||
'https://localhost:8084',
|
'https://localhost:8084',
|
||||||
|
'https://localhost:8085',
|
||||||
'https://localhost:8088',
|
'https://localhost:8088',
|
||||||
'https://localhost:8099',
|
'https://localhost:8099',
|
||||||
];
|
];
|
||||||
@@ -864,6 +867,7 @@ connectToDatabase(connectionUrl, options)
|
|||||||
|
|
||||||
function setupMiddleware(app, corsOptions, isDebug = false) {
|
function setupMiddleware(app, corsOptions, isDebug = false) {
|
||||||
app.use(cors(corsOptions));
|
app.use(cors(corsOptions));
|
||||||
|
app.set('trust proxy', true);
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.options('*', cors(corsOptions));
|
app.options('*', cors(corsOptions));
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.2.67
|
1.2.68
|
||||||
Reference in New Issue
Block a user