- piuchebuono: possiblità di modificare l'immagine dalla scheda direttamente

- migliorata di poco la grafica dell'immagine.
This commit is contained in:
Surya Paolo
2024-10-03 03:55:05 +02:00
parent f9e0175f9b
commit d438867e3a
7 changed files with 85 additions and 15 deletions

View File

@@ -1,12 +1,12 @@
DATABASE=test_PiuCheBuono
DATABASE=test_FreePlanet
UDB=paofreeplanet
PDB=mypassword@1A
SEND_EMAIL=0
SEND_EMAIL_ORDERS=1
PORT=3000
appTelegram_TEST=["1","17","18"]
appTelegram=["1","17","18"]
appTelegram_DEVELOP=["17"]
appTelegram_TEST=["1","13"]
appTelegram=["1","13"]
appTelegram_DEVELOP=["13"]
DOMAIN=mongodb://localhost:27017/
AUTH_MONGODB=1
MONGODB_USER=admin
@@ -42,6 +42,3 @@ FTPSERVER_PWD=ftpmypwd@1A_
AUTH_NEW_SITES=123123123
SCRIPTS_DIR=admin_scripts
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
MIAB_HOST=box.lamiaposta.org
MIAB_ADMIN_EMAIL=admin@lamiaposta.org
MIAB_ADMIN_PASSWORD=passpao1pabox@1A

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 KiB

View File

@@ -230,7 +230,7 @@ module.exports.getProductByCode = function (idapp, code) {
module.exports.replaceProductImgToImageFile = async function () {
const ProductInfo = this;
let abilitaserver = false;
let abilitaserver = true;
if (abilitaserver) {
// const result = await ProductInfo.updateMany({ "img": { $exists: true } }, { $rename: { 'img': 'imagefile' } });
@@ -240,9 +240,9 @@ module.exports.replaceProductImgToImageFile = async function () {
// Aggiorna ciascun documento
for (let doc of documents) {
if (doc.img && doc.img.startsWith('/upload/products/')) {
if (doc.img && doc.img.startsWith('upload/products/')) {
// Rimuovi il prefisso '/upload/products' dal campo `img`
doc.imagefile = doc.img.replace(/^\/upload\/products\//, '');
doc.imagefile = doc.img.replace(/^\upload\/products\//, '');
doc.img = undefined; // Può anche rimuovere il campo img corrente se desiderato
await doc.save(); // Salva il documento aggiornato
}

View File

@@ -1919,8 +1919,15 @@ function uploadFile(req, res, version) {
let mydircurrent = process.cwd() + '/src/server/router/upload/' + dir;
fromfile = mydircurrent + '/' + oldpath;
tofile = mydir + '/' + file.originalFilename;
// ------------
// ++TODO: Questo non funziona perché dovrei passargli il nomefile aggiornato a Vue.js
// tofile = tools.cleanFileName(tofile)
// ------------
let newname = tofile;
file.path = newname;
console.log('fromfile', fromfile, 'tofile', tofile)

View File

@@ -169,6 +169,12 @@ myLoad().then(ris => {
},
});
// Serve il tuo service worker da una certa directory
/*app.get('/service-worker.js', (req, res) => {
res.set('Cache-Control', 'no-cache'); // Aggiunge l'intestazione
// res.sendFile(path.join(__dirname, 'service-worker.js')); // Modifica il percorso secondo la tua struttura
});*/
app.use(cors({
exposedHeaders: ['x-auth', 'x-refrtok'],
}));
@@ -806,6 +812,54 @@ function startServer(app, port) {
console.log('isProduction', isProduction);
/*
const CORS_ENABLE_FOR_ALL_SITES = true;
let corsOptions = {};
if (CORS_ENABLE_FOR_ALL_SITES) {
corsOptions = {
exposedHeaders: ['x-auth', 'x-refrtok'], // Intestazioni da esporre al client
};
} else {
let myhosts = [];
for (let i = 0; i < domains.length; i++) {
myhosts.push('https://' + domains[i].hostname);
myhosts.push('https://' + 'api.' + domains[i].hostname);
myhosts.push('https://' + 'test.' + domains[i].hostname);
myhosts.push('https://' + 'testapi.' + domains[i].hostname);
}
console.log('myhosts', myhosts);
console.log('CORS');
corsOptions = {
origin: (origin, callback) => {
if (myhosts.indexOf(origin) !== -1 || !origin) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
},
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'x-auth', 'x-refrtok'], // Intestazioni consentite
exposedHeaders: ['x-auth', 'x-refrtok'], // Intestazioni da esporre al client
credentials: true, // Consenti l'invio di cookie
preflightContinue: false,
optionsSuccessStatus: 204,
};
app.use(cors(corsOptions));
}*/
if (isProduction) {
for (let i = 0; i < domains.length; i++) {
const credentials = getCredentials(domains[i].hostname);

View File

@@ -5707,4 +5707,16 @@ module.exports = {
return annunciFields;
},
// Funzione per pulire il nome del file
cleanFileName(filePath) {
// Ottieni solo il nome del file dall'intero percorso
// const fileName = filePath.split('/').pop();
// Rimuovi apostrofi e sostituisci gli spazi con underscore
const cleanedName = fileName.replace(/'/g, '').replace(/\s+/g, '_');
// Restituisci il percorso chiaro; puoi decidere di mantenere il resto del percorso
return cleanedName;
},
};

View File

@@ -1 +1 @@
1.1.0
1.1.3