- Cataloghi: pagine, schede, formato
This commit is contained in:
@@ -180,16 +180,19 @@ export const Api = {
|
||||
|
||||
if (error.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
try {
|
||||
console.log('Token Scaduto.')
|
||||
const newAccessToken = await this.refreshToken();
|
||||
if (newAccessToken) {
|
||||
userStore.setAuth(newAccessToken, userStore.refreshToken);
|
||||
if (!evitaloop)
|
||||
if (!evitaloop) {
|
||||
console.log('uso il RefreshToken...')
|
||||
return resolve(this.SendReq(url, method, mydata, setAuthToken, true));
|
||||
}
|
||||
} else {
|
||||
$router.push('/signin')
|
||||
}
|
||||
} catch (err2: any) {
|
||||
console.error('err2', err2)
|
||||
console.error('err2, Token Invalido', err2)
|
||||
if (err2?.code === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION)
|
||||
userStore.setAuth('', '')
|
||||
@@ -241,7 +244,7 @@ export const Api = {
|
||||
mydata: any,
|
||||
setAuthToken = false,
|
||||
evitaloop = false,
|
||||
retryCount = 5,
|
||||
retryCount = 3,
|
||||
retryDelay = 5000
|
||||
): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
try {
|
||||
|
||||
@@ -27,25 +27,13 @@ export const costanti = {
|
||||
CATALOGO_FIELDS: [
|
||||
'productTypes',
|
||||
'excludeproductTypes',
|
||||
'formato',
|
||||
'misure',
|
||||
'Categoria',
|
||||
'Editore',
|
||||
'pdf',
|
||||
'printable',
|
||||
'backgroundimage',
|
||||
'backgroundimage_printable',
|
||||
'width',
|
||||
'widthscheda',
|
||||
'widthpag',
|
||||
'Printable',
|
||||
'height',
|
||||
'height_Printable',
|
||||
'numschede_perCol',
|
||||
'numschede_perRiga',
|
||||
'margine_pagina',
|
||||
'margine_riga',
|
||||
'margine_paginaPrintable',
|
||||
'margine_rigaPrintable',
|
||||
'first_page_img',
|
||||
'first_page_html',
|
||||
'first_page_height',
|
||||
@@ -56,10 +44,12 @@ export const costanti = {
|
||||
],
|
||||
|
||||
SCHEDA_FIELDS: [
|
||||
'bgimg',
|
||||
'bgimg_printable',
|
||||
'bgSize',
|
||||
'bgSize_printable',
|
||||
// 'imgsfondo',
|
||||
],
|
||||
|
||||
IMG_FIELDS: [
|
||||
'imgsfondo',
|
||||
'imgsfondo_def',
|
||||
],
|
||||
|
||||
TIPOFAVBOOK: {
|
||||
|
||||
@@ -158,6 +158,14 @@ export const colISize = [
|
||||
AddCol({ name: 'width', label_trans: 'size.width', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'height', label_trans: 'size.height', fieldtype: costanti.FieldType.string }),
|
||||
]
|
||||
export const colIText = [
|
||||
AddCol({ name: 'contenuto', label_trans: 'catalogo.contenuto', fieldtype: costanti.FieldType.html }),
|
||||
AddCol({ name: 'maxlength', label_trans: 'catalogo.maxlength', fieldtype: costanti.FieldType.number }),
|
||||
]
|
||||
export const colmyIImg = [
|
||||
AddCol({ name: 'filename', label_trans: 'iimg.filename', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'fit', label_trans: 'iimg.fit', fieldtype: costanti.FieldType.string }),
|
||||
]
|
||||
|
||||
export const colmyScheda = [
|
||||
AddCol({ name: 'name', label_trans: 'scheda.name', fieldtype: costanti.FieldType.string }),
|
||||
@@ -171,19 +179,10 @@ export const colmyScheda = [
|
||||
AddCol({ name: 'numschede_perRiga', label_trans: 'scheda.numschede_perRiga', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'margine_top', label_trans: 'scheda.margine_top', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'margine_pagina', label_trans: 'scheda.margine_pagina', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_paginaPrintable', label_trans: 'scheda.margine_paginaPrintable', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_riga', label_trans: 'scheda.margine_riga', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_rigaPrintable', label_trans: 'scheda.margine_rigaPrintable', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'text', label_trans: 'catalogo.text', fieldtype: costanti.FieldType.html }),
|
||||
AddCol({ name: 'posiz_text', label_trans: 'catalogo.posiz_text', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'line_height', label_trans: 'catalogo.line_height', fieldtype: costanti.FieldType.number }),
|
||||
|
||||
AddCol({ name: 'bgimg', label_trans: 'scheda.bgimg', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'bgimg_printable', label_trans: 'scheda.bgimg_printable', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'bgSize', label_trans: 'scheda.bgimg', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'bgSize_printable', label_trans: 'scheda.bgSize', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'widthPPrintable', label_trans: 'scheda.widthPPrintable', fieldtype: costanti.FieldType.number }),
|
||||
|
||||
AddCol({ name: 'productTypes', label_trans: 'productTypes', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'excludeproductTypes', label_trans: 'excludeproductTypes', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'Editore', label_trans: 'Editore' }),
|
||||
@@ -196,14 +195,13 @@ export const colmyelCatalogo = [
|
||||
AddCol({ name: 'productTypes', label_trans: 'productTypes', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'excludeproductTypes', label_trans: 'excludeproductTypes', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'pdf', label_trans: 'pdf' }),
|
||||
AddCol({ name: 'pdf_filename', label_trans: 'pdf_filename' }),
|
||||
AddCol({ name: 'Editore', label_trans: 'Editore' }),
|
||||
AddCol({ name: 'width', label_trans: 'width', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'height', label_trans: 'height', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'optcatalogo.', label_trans: 'catalogo.optcatalogo.', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'margine_pagina', label_trans: 'margine_pagina', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_paginaPrintable', label_trans: 'margine_paginaPrintable', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_riga', label_trans: 'margine_riga', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'margine_rigaPrintable', label_trans: 'margine_rigaPrintable', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'first_page_img', label_trans: 'catalogo.first_page_img', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'last_page_img', label_trans: 'catalogo.last_page_img', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'first_page_html', label_trans: 'catalogo.first_page_html', fieldtype: costanti.FieldType.html }),
|
||||
@@ -211,12 +209,8 @@ export const colmyelCatalogo = [
|
||||
AddCol({ name: 'last_page_height', label_trans: 'catalogo.last_page_html', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'last_page_html', label_trans: 'catalogo.last_page_html', fieldtype: costanti.FieldType.html }),
|
||||
|
||||
AddCol({ name: 'backgroundimage', label_trans: 'backgroundimage', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'backgroundimage_printable', label_trans: 'backgroundimage_printable', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'backgroundSize', label_trans: 'scheda.bgimg', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'backgroundSize_printable', label_trans: 'scheda.bgSize', fieldtype: costanti.FieldType.image }),
|
||||
AddCol({ name: 'widthpagPrintable', label_trans: 'widthpag', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'widthpagPrintable', label_trans: 'widthpagPrintable', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'imgsfondo_def', label_trans: 'catalogo.imgsfondo_def', fieldtype: costanti.FieldType.image }),
|
||||
|
||||
]
|
||||
|
||||
export const colmyelems = [
|
||||
@@ -2336,7 +2330,7 @@ export const colTableProductInfos = [
|
||||
AddCol({ name: 'collezione', label_trans: 'products.collezione', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'date_publishing', label_trans: 'products.date_publishing', fieldtype: costanti.FieldType.onlydate }),
|
||||
AddCol({ name: 'publisher', label_trans: 'products.publisher', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'numpages', label_trans: 'products.numpages', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'pagine', label_trans: 'products.pagine', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'note', label_trans: 'products.note', fieldtype: costanti.FieldType.html }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
@@ -3044,6 +3038,7 @@ export const colTableUsers = [
|
||||
titlepopupedit: 'Permessi'
|
||||
}),
|
||||
AddCol({ name: 'ipaddr', label_trans: 'reg.ipaddr' }),
|
||||
AddCol({ name: 'banIp', label_trans: 'reg.banIp', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
]
|
||||
@@ -3470,6 +3465,7 @@ export const colTableUsersISP = [
|
||||
titlepopupedit: 'Notifiche'
|
||||
}),
|
||||
AddCol({ name: 'ipaddr', label_trans: 'reg.ipaddr' }),
|
||||
AddCol({ name: 'banIp', label_trans: 'reg.banIp', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'deleted', label_trans: 'reg.deleted', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
@@ -4217,6 +4213,20 @@ export const fieldsTable = {
|
||||
colkey: '_id',
|
||||
collabel: 'name',
|
||||
},
|
||||
{
|
||||
value: 'text',
|
||||
label: 'Testo',
|
||||
columns: colIText,
|
||||
colkey: 'contenuto',
|
||||
collabel: 'contenuto',
|
||||
},
|
||||
{
|
||||
value: 'imgs',
|
||||
label: 'Immagini',
|
||||
columns: colmyIImg,
|
||||
colkey: 'filename',
|
||||
collabel: 'filename',
|
||||
},
|
||||
{
|
||||
value: 'listcards',
|
||||
label: 'Elementi',
|
||||
|
||||
@@ -227,7 +227,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
async updateNotifDataFromServer({ username, lastdataread }: { username: string, lastdataread: Date }) {
|
||||
console.log('updateNotifDataFromServer', username, lastdataread)
|
||||
|
||||
return Api.SendReq(`/sendnotif/${username}/${lastdataread}/${process.env.APP_ID}`, 'GET', null)
|
||||
return Api.SendReq(`/sendnotif/${username}/${lastdataread}/${process.env.APP_ID}`, 'GET', null, false, false, 0)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (!!res.data) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd } from 'model'
|
||||
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText } from 'model'
|
||||
|
||||
import { Api } from '@api'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
@@ -1267,32 +1267,46 @@ export const useProducts = defineStore('Products', {
|
||||
return authorString
|
||||
},
|
||||
|
||||
replaceKeyWordsByProduct(myproduct: IProduct, text_html: string) {
|
||||
if (!myproduct || !text_html) {
|
||||
return text_html;
|
||||
replaceKeyWordsByProduct(myproduct: IProduct, testo: IText) {
|
||||
if (!myproduct || !testo.contenuto) {
|
||||
return testo.contenuto;
|
||||
}
|
||||
|
||||
const autori = this.getAutoriByArrayAuthors(myproduct.productInfo.authors)
|
||||
|
||||
const maxDescriptionLength = 100;
|
||||
const maxDescriptionLength = testo.maxlength ?? 100;
|
||||
const description = myproduct.productInfo.short_descr || '';
|
||||
const long_descr = myproduct.productInfo.description || '';
|
||||
|
||||
const truncatedDescription = description.length > maxDescriptionLength
|
||||
? description.substring(0, description.lastIndexOf(' ', maxDescriptionLength)) + '...'
|
||||
: description;
|
||||
|
||||
const truncatedlongDescription = long_descr.length > maxDescriptionLength
|
||||
? long_descr.substring(0, long_descr.lastIndexOf(' ', maxDescriptionLength)) + '...'
|
||||
: long_descr;
|
||||
|
||||
const prezzo = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].price?.toFixed(2) : ''
|
||||
const prezzo_scontato = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].sale_price?.toFixed(2) : ''
|
||||
const misure = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].misure : ''
|
||||
const formato = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].formato : ''
|
||||
const pagine = myproduct.arrvariazioni ? myproduct.arrvariazioni[0].pagine : ''
|
||||
|
||||
// Crea una mappa di sostituzioni
|
||||
const replacements = {
|
||||
'{autore}': autori || '',
|
||||
'{titolo}': myproduct.productInfo.name || '',
|
||||
'{descrizione}': truncatedDescription || '',
|
||||
'{descrizione_estesa}': truncatedlongDescription || '',
|
||||
'{pagine}': pagine || '',
|
||||
'{misure}': misure || '',
|
||||
'{formato}': formato || '',
|
||||
'{prezzo}': prezzo || '',
|
||||
'{prezzo_scontato}': prezzo_scontato || '',
|
||||
};
|
||||
|
||||
// Esegue le sostituzioni
|
||||
let result = text_html;
|
||||
let result = testo.contenuto;
|
||||
for (const [key, value] of Object.entries(replacements)) {
|
||||
result = result.replace(new RegExp(key, 'g'), value);
|
||||
}
|
||||
|
||||
@@ -900,7 +900,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
mydata.repeatPassword = ''
|
||||
mydata.password = String(hashedPassword)
|
||||
|
||||
return Api.SendReq('/updatepwd', 'POST', mydata, true)
|
||||
return Api.SendReq('/updatepwd', 'POST', mydata, true, false, 1)
|
||||
.then((res) => {
|
||||
return { code: res.data.code, msg: res.data.msg }
|
||||
})
|
||||
@@ -1425,7 +1425,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
// console.log('executing login...')
|
||||
|
||||
return await Api.SendReq('/users/login', 'POST', usertosend, true)
|
||||
return await Api.SendReq('/users/login', 'POST', usertosend, true, false, 0)
|
||||
.then((res) => {
|
||||
|
||||
myres = res
|
||||
@@ -1867,7 +1867,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
},
|
||||
|
||||
async setCircuitCmd($q: any, t: any, usernameOrig: string, circuitname: string, cmd: number, value: any, extrarec?: any) {
|
||||
return await Api.SendReq('/users/circuits/cmd', 'POST', { usernameOrig, circuitname, cmd, value, extrarec })
|
||||
return await Api.SendReq('/users/circuits/cmd', 'POST', { usernameOrig, circuitname, cmd, value, extrarec }, false, false, 0)
|
||||
.then((res) => {
|
||||
this.updateTables = true
|
||||
const notifStore = useNotifStore()
|
||||
|
||||
@@ -2163,7 +2163,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
for (let i = 0; i < this.myelems.length; i++) {
|
||||
if (this.myelems[i]._id === newelem._id) {
|
||||
this.myelems[i] = newelem;
|
||||
|
||||
|
||||
console.log('SALVATO', this.myelems[i])
|
||||
break;
|
||||
}
|
||||
@@ -2239,7 +2239,13 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
Categoria: [],
|
||||
Editore: [],
|
||||
pdf: false,
|
||||
backgroundimage: '',
|
||||
dimensioni_def: {
|
||||
pagina: {
|
||||
size: { width: '', height: '' },
|
||||
margini: {left: '', top: '', right: '', bottom: ''},
|
||||
padding: {left: '', top: '', right: '', bottom: ''},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user