ver: 1.1.21:
- Lista dei Cataloghi - Gestione Cataloghi in base alla configurazione
This commit is contained in:
@@ -4,12 +4,12 @@ import axios, {
|
||||
import { Api } from '@api'
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
|
||||
async function sendRequest(url: string, method: string, mydata: any, myformdata?: any, responsedata?: any) {
|
||||
async function sendRequest(url: string, method: string, mydata: any, myformdata?: any, responsedata?: any, options?: any) {
|
||||
console.log('sendRequest', method, url, mydata)
|
||||
|
||||
let request
|
||||
if (method === 'GET') request = Api.get(url, mydata, responsedata)
|
||||
else if (method === 'POST') request = Api.post(url, mydata, responsedata)
|
||||
else if (method === 'POST') request = Api.post(url, mydata, responsedata, options)
|
||||
else if (method === 'postFormData') request = Api.postFormData(url, myformdata, responsedata)
|
||||
else if (method === 'DELETE') request = Api.Delete(url, mydata, responsedata)
|
||||
else if (method === 'PUT') request = Api.put(url, mydata, responsedata)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios, { AxiosInstance, AxiosResponse } from 'axios'
|
||||
import axios, { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios'
|
||||
|
||||
// import LoginModule from '../Modules/Auth/LoginStore'
|
||||
import { toolsext } from '@src/store/Modules/toolsext'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
@@ -7,6 +8,9 @@ import { useUserStore } from '@store/UserStore'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
import * as Types from './ApiTypes'
|
||||
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { mergeMap, toArray } from 'rxjs/operators';
|
||||
|
||||
export let API_URL = ''
|
||||
export const axiosInstance: AxiosInstance = axios.create({
|
||||
baseURL: API_URL,
|
||||
@@ -15,6 +19,7 @@ export const axiosInstance: AxiosInstance = axios.create({
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
axiosInstance.interceptors.response.use(
|
||||
|
||||
(response) => {
|
||||
@@ -26,7 +31,7 @@ axiosInstance.interceptors.response.use(
|
||||
// console.log('error', error)
|
||||
if (error.response) {
|
||||
if (process.env.DEBUGGING === '1') console.log('Status = ', error.response.status)
|
||||
console.log('Request Error: ', error.response)
|
||||
console.log('Request Error: ', error.response)
|
||||
if (error.response.status !== 0) {
|
||||
globalStore.setStateConnection('online')
|
||||
} else {
|
||||
@@ -47,7 +52,64 @@ export const addAuthHeaders = () => {
|
||||
// delete axiosInstance.defaults.headers.Authorization
|
||||
//}
|
||||
|
||||
async function Request(type: string, path: string, payload: any, responsedata?: any): Promise<Types.AxiosSuccess | Types.AxiosError | undefined> {
|
||||
async function generateStream(path: string, payload: any, config?: RequestInit, options?: any): Promise<AsyncIterable<any>> {
|
||||
const userStore = useUserStore()
|
||||
|
||||
const mieiparam: any = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'x-auth': userStore.x_auth_token,
|
||||
'x-refrtok': userStore.refreshToken,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
signal: options?.signal,
|
||||
...config
|
||||
}
|
||||
|
||||
console.log('marams: ', mieiparam)
|
||||
|
||||
const response = await fetch(
|
||||
path,
|
||||
mieiparam,
|
||||
);
|
||||
console.log('USCITA DA FETCH... !!!!!')
|
||||
if (response.status !== 200) throw new Error(response.status.toString());
|
||||
return getIterableStream(response);
|
||||
}
|
||||
|
||||
function getIterableStream(stream: NodeJS.ReadableStream): AsyncIterable<any> {
|
||||
return {
|
||||
[Symbol.asyncIterator](): AsyncIterator<any> {
|
||||
let buffer = '';
|
||||
return {
|
||||
async next(): Promise<IteratorResult<any>> {
|
||||
while (true) {
|
||||
const chunk = await new Promise<string>((resolve, reject) => {
|
||||
stream.once('data', (data: Buffer) => resolve(data.toString()));
|
||||
stream.once('error', (err) => reject(err));
|
||||
stream.once('end', () => resolve(''));
|
||||
});
|
||||
buffer += chunk;
|
||||
if (buffer.includes('\n\n')) {
|
||||
const event = buffer.slice(0, buffer.indexOf('\n\n'));
|
||||
buffer = buffer.slice(buffer.indexOf('\n\n') + 2);
|
||||
try {
|
||||
return { value: JSON.parse(event.slice('data: '.length)), done: false };
|
||||
} catch (error) {
|
||||
console.error('Error parsing event data:', error);
|
||||
}
|
||||
} else if (chunk === '') {
|
||||
return { value: undefined, done: true };
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function Request(type: string, path: string, payload: any, responsedata?: any, options?: any): Promise<Types.AxiosSuccess | Types.AxiosError | undefined> {
|
||||
|
||||
let ricevuto = false
|
||||
const userStore = useUserStore()
|
||||
@@ -57,59 +119,108 @@ async function Request(type: string, path: string, payload: any, responsedata?:
|
||||
try {
|
||||
if (tools.isDebug()) console.log('Axios Request', path, type, tools.notshowPwd(payload))
|
||||
let response: AxiosResponse
|
||||
const config: AxiosRequestConfig = {
|
||||
baseURL: globalStore.getServerHost(),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'x-auth': userStore.x_auth_token,
|
||||
'x-refrtok': userStore.refreshToken,
|
||||
},
|
||||
...responsedata,
|
||||
}
|
||||
|
||||
if (options?.stream) {
|
||||
config.responseType = 'stream';
|
||||
}
|
||||
|
||||
if (type === 'post' || type === 'put' || type === 'patch') {
|
||||
response = await axiosInstance[type](path, payload, {
|
||||
baseURL: globalStore.getServerHost(),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'x-auth': userStore.x_auth_token,
|
||||
'x-refrtok': userStore.refreshToken,
|
||||
},
|
||||
...responsedata,
|
||||
})
|
||||
ricevuto = true
|
||||
// console.log('Request Response: ', response)
|
||||
// console.log(new Types.AxiosSuccess(response.data, response.status))
|
||||
|
||||
const setAuthToken = (path === '/updatepwd') || (path === '/users/login')
|
||||
if (options?.stream) {
|
||||
console.log('GENERATESTREAM...')
|
||||
const stream = await generateStream(path, payload, config, options);
|
||||
console.log('USCITOOOOOOOOOOOOOOOOOOOOO ------------------------')
|
||||
|
||||
// console.log('--------- 0 ')
|
||||
return new Promise((resolve, reject) => {
|
||||
const events$: Observable<any> = from(stream);
|
||||
events$
|
||||
.pipe(
|
||||
mergeMap((event) => from([event])),
|
||||
toArray()
|
||||
)
|
||||
.subscribe(
|
||||
(data) => {
|
||||
console.log('Received data:', data);
|
||||
// Elabora i dati ricevuti
|
||||
resolve({ data, status: response.status, statusText: response.statusText, headers: response.headers, config: response.config });
|
||||
},
|
||||
(error) => {
|
||||
console.error('Stream error:', error);
|
||||
reject(error);
|
||||
},
|
||||
() => {
|
||||
console.log('Stream completed');
|
||||
}
|
||||
);
|
||||
|
||||
if (response && (response.status === 200)) {
|
||||
let x_auth_token = ''
|
||||
let refreshToken = ''
|
||||
try {
|
||||
if (setAuthToken || (path === '/users/login')) {
|
||||
x_auth_token = String(response.headers['x-auth'])
|
||||
refreshToken = String(response.headers['x-refrtok'])
|
||||
});
|
||||
/*
|
||||
console.log('Stream response received, processing...');
|
||||
return handleStreamResponse(response, (data) => {
|
||||
console.log('data...' + data.content)
|
||||
// Aggiorna lo stato dell'applicazione qui
|
||||
// Ad esempio:
|
||||
// outputVisible.value += data.content;
|
||||
});
|
||||
*/
|
||||
|
||||
if (x_auth_token === '') {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION)
|
||||
}
|
||||
if (setAuthToken) {
|
||||
userStore.UpdatePwd(x_auth_token, refreshToken)
|
||||
} else {
|
||||
|
||||
response = await axiosInstance[type](path, payload, config)
|
||||
|
||||
ricevuto = true
|
||||
// console.log('Request Response: ', response)
|
||||
// console.log(new Types.AxiosSuccess(response.data, response.status))
|
||||
|
||||
const setAuthToken = (path === '/updatepwd') || (path === '/users/login')
|
||||
|
||||
// console.log('--------- 0 ')
|
||||
|
||||
if (response && (response.status === 200)) {
|
||||
let x_auth_token = ''
|
||||
let refreshToken = ''
|
||||
try {
|
||||
if (setAuthToken || (path === '/users/login')) {
|
||||
x_auth_token = String(response.headers['x-auth'])
|
||||
refreshToken = String(response.headers['x-refrtok'])
|
||||
|
||||
if (x_auth_token === '') {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION)
|
||||
}
|
||||
if (setAuthToken) {
|
||||
userStore.UpdatePwd(x_auth_token, refreshToken)
|
||||
localStorage.setItem(toolsext.localStorage.token, x_auth_token)
|
||||
localStorage.setItem(toolsext.localStorage.refreshToken, refreshToken)
|
||||
}
|
||||
|
||||
userStore.setAuth(x_auth_token, refreshToken)
|
||||
localStorage.setItem(toolsext.localStorage.token, x_auth_token)
|
||||
localStorage.setItem(toolsext.localStorage.refreshToken, refreshToken)
|
||||
}
|
||||
|
||||
userStore.setAuth(x_auth_token, refreshToken)
|
||||
localStorage.setItem(toolsext.localStorage.token, x_auth_token)
|
||||
localStorage.setItem(toolsext.localStorage.refreshToken, refreshToken)
|
||||
globalStore.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||
userStore.setServerCode(tools.OK)
|
||||
} catch (e) {
|
||||
if (setAuthToken) {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION)
|
||||
userStore.setAuth('', '')
|
||||
}
|
||||
globalStore.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||
return Promise.reject(new Types.AxiosError(serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN, null, toolsext.ERR_AUTHENTICATION))
|
||||
}
|
||||
|
||||
globalStore.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||
userStore.setServerCode(tools.OK)
|
||||
} catch (e) {
|
||||
if (setAuthToken) {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION)
|
||||
userStore.setAuth('', '')
|
||||
}
|
||||
globalStore.setStateConnection(ricevuto ? 'online' : 'offline')
|
||||
return Promise.reject(new Types.AxiosError(serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN, null, toolsext.ERR_AUTHENTICATION))
|
||||
}
|
||||
}
|
||||
|
||||
return new Types.AxiosSuccess(response.data, response.status)
|
||||
return new Types.AxiosSuccess(response.data, response.status)
|
||||
}
|
||||
} else if (type === 'get' || type === 'delete') {
|
||||
// @ts-ignore
|
||||
response = await axiosInstance[type](path, {
|
||||
@@ -172,4 +283,33 @@ async function Request(type: string, path: string, payload: any, responsedata?:
|
||||
}
|
||||
}
|
||||
|
||||
function handleStreamResponse(response: AxiosResponse, updateCallback: (data: any) => void): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// ... codice precedente ...
|
||||
|
||||
reader.on('data', (chunk: Buffer) => {
|
||||
// ... codice precedente ...
|
||||
if (line.startsWith('data: ')) {
|
||||
const eventData = line.slice(6);
|
||||
try {
|
||||
const parsedData = JSON.parse(eventData);
|
||||
console.log('Received data:', parsedData);
|
||||
updateCallback(parsedData); // Chiamata alla callback per aggiornare lo stato
|
||||
} catch (error) {
|
||||
console.error('Error parsing event data:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
reader.on('end', () => {
|
||||
console.log('Stream ended');
|
||||
resolve('Stream completed');
|
||||
});
|
||||
|
||||
reader.on('error', (error: Error) => {
|
||||
console.error('Stream error:', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
export default Request
|
||||
|
||||
@@ -37,11 +37,11 @@ function ReceiveResponsefromServer(tablesync: string, nametab: string, method: s
|
||||
|
||||
// const algoliaApi = new AlgoliaSearch()
|
||||
export const Api = {
|
||||
async post(path: string, payload?: any, responsedata?: any) {
|
||||
async post(path: string, payload?: any, responsedata?: any, options?: any) {
|
||||
const globalStore = useGlobalStore()
|
||||
globalStore.connData.downloading_server = 1
|
||||
globalStore.connData.uploading_server = 1
|
||||
return Request('post', path, payload, responsedata)
|
||||
return Request('post', path, payload, responsedata, options)
|
||||
},
|
||||
|
||||
async postFormData(path: string, payload?: any, responsedata?: any) {
|
||||
@@ -133,7 +133,6 @@ export const Api = {
|
||||
async checkTokenScaduto(status: number, evitaloop: boolean, resolve: any, reject: any, url: string, method: string, mydata: any, setAuthToken = false) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const $router = useRouter()
|
||||
|
||||
if (status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
try {
|
||||
@@ -146,6 +145,7 @@ export const Api = {
|
||||
return resolve(this.SendReq(url, method, mydata, setAuthToken, true));
|
||||
}
|
||||
} else {
|
||||
const $router = useRouter()
|
||||
$router.push('/signin')
|
||||
}
|
||||
} catch (err2: any) {
|
||||
@@ -162,7 +162,7 @@ export const Api = {
|
||||
|
||||
},
|
||||
|
||||
async SendReqBase(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, myformdata?: any, responsedata?: any): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
async SendReqBase(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, myformdata?: any, responsedata?: any, options?: any): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
const mydataout = {
|
||||
...mydata,
|
||||
keyappid: process.env.PAO_APP_ID,
|
||||
@@ -176,7 +176,7 @@ export const Api = {
|
||||
userStore.setServerCode(tools.EMPTY)
|
||||
userStore.setResStatus(0)
|
||||
|
||||
return new Promise((resolve, reject) => sendRequest(url, method, mydataout, myformdata, responsedata)
|
||||
return new Promise((resolve, reject) => sendRequest(url, method, mydataout, myformdata, responsedata, options)
|
||||
.then(async (res) => {
|
||||
setTimeout( () => {
|
||||
if (method === 'get') {
|
||||
@@ -268,9 +268,10 @@ export const Api = {
|
||||
retryDelay = 5000,
|
||||
myformdata?: any,
|
||||
responsedata?: any,
|
||||
options?: any,
|
||||
): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
try {
|
||||
const response = await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop, myformdata, responsedata);
|
||||
const response = await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop, myformdata, responsedata, options);
|
||||
return response;
|
||||
} catch (error: any) {
|
||||
let riprova = true
|
||||
|
||||
@@ -107,6 +107,10 @@ function AddCol(params: IColGridTable) {
|
||||
}
|
||||
}
|
||||
|
||||
export const colTablePublisher = [
|
||||
AddCol({ name: 'name', label_trans: 'reg.name' }),
|
||||
]
|
||||
|
||||
export const colmailinglist = [
|
||||
AddCol({ name: 'name', label_trans: 'reg.name' }),
|
||||
AddCol({ name: 'surname', label_trans: 'reg.surname' }),
|
||||
@@ -119,6 +123,7 @@ export const colmailinglist = [
|
||||
|
||||
export const colTableCatalogList = [
|
||||
AddCol({ name: 'active', label_trans: 'myelems.active', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'versione_perstampa', label_trans: 'cataloglist.versione_perstampa', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'title', label_trans: 'gallery.title' }),
|
||||
AddCol({
|
||||
name: 'foto_collana',
|
||||
@@ -134,6 +139,12 @@ export const colTableCatalogList = [
|
||||
fieldtype: costanti.FieldType.multiselect,
|
||||
jointable: 'collanas',
|
||||
}),
|
||||
AddCol({
|
||||
name: 'editore',
|
||||
label_trans: 'cataloglist.editore',
|
||||
fieldtype: costanti.FieldType.multiselect,
|
||||
jointable: 'publishers',
|
||||
}),
|
||||
|
||||
AddCol({
|
||||
name: 'idPageAssigned',
|
||||
@@ -146,21 +157,39 @@ export const colTableCatalogList = [
|
||||
name: 'referenti',
|
||||
label_trans: 'cataloglist.referenti',
|
||||
fieldtype: costanti.FieldType.multiselect,
|
||||
jointable: 'friendsandme',
|
||||
field_outtype: costanti.FieldType.object,
|
||||
showWhen: costanti.showWhen.InView_OnlyifExist,
|
||||
jointable: 'lista_editori',
|
||||
}),
|
||||
AddCol({ name: 'descr_introduttiva', label_trans: 'cataloglist.descr_introduttiva', fieldtype: costanti.FieldType.html }),
|
||||
AddCol({ name: 'descr_introduttiva', label_trans: 'cataloglist.descr_introduttiva', fieldtype: costanti.FieldType.html, maxlength: 1300 }),
|
||||
AddCol({ name: 'pagina_introduttiva_sfondo_nero', label_trans: 'cataloglist.pagina_introduttiva_sfondo_nero', fieldtype: costanti.FieldType.boolean }),
|
||||
|
||||
AddCol({
|
||||
name: 'img_bordata_web',
|
||||
label_trans: 'cataloglist.img_bordata_web',
|
||||
name: 'img_bordata',
|
||||
label_trans: 'cataloglist.img_bordata',
|
||||
fieldtype: costanti.FieldType.image,
|
||||
jointable: '',
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit,
|
||||
isadvanced_field: false,
|
||||
}),
|
||||
AddCol({
|
||||
name: 'img_intro',
|
||||
label_trans: 'cataloglist.img_intro',
|
||||
fieldtype: costanti.FieldType.image,
|
||||
jointable: '',
|
||||
showWhen: costanti.showWhen.NewRec + costanti.showWhen.InPage + costanti.showWhen.InEdit,
|
||||
isadvanced_field: false,
|
||||
}),
|
||||
|
||||
AddCol({
|
||||
name: 'pdf_generato',
|
||||
label_trans: 'cataloglist.pdf_generato',
|
||||
}),
|
||||
// AddCol({ name: 'data_generato', label_trans: 'dataloglist.data_generato', fieldtype: costanti.FieldType.date }),
|
||||
AddCol({
|
||||
name: 'pdf_online',
|
||||
label_trans: 'cataloglist.pdf_online',
|
||||
}),
|
||||
// AddCol({ name: 'data_online', label_trans: 'dataloglist.data_online', fieldtype: costanti.FieldType.date }),
|
||||
|
||||
AddCol(ModifRec),
|
||||
AddCol(DuplicateRec),
|
||||
AddCol(DeleteRec),
|
||||
@@ -225,6 +254,7 @@ export const colmyIImg = [
|
||||
export const colmyScheda = [
|
||||
AddCol({ name: 'name', label_trans: 'scheda.name', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'isTemplate', label_trans: 'scheda.isTemplate', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'isPagIntro', label_trans: 'scheda.isPagIntro', fieldtype: costanti.FieldType.boolean }),
|
||||
AddCol({ name: 'linkIdTemplate', label_trans: 'scheda.linkIdTemplate', fieldtype: costanti.FieldType.string }),
|
||||
AddCol({ name: 'widthscheda', label_trans: 'scheda.widthscheda', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'widthpag', label_trans: 'scheda.widthpag', fieldtype: costanti.FieldType.number }),
|
||||
@@ -573,8 +603,7 @@ export const colTableCatProd = [
|
||||
]
|
||||
export const colTableCollane = [
|
||||
AddCol({ name: 'idCollana', label_trans: 'collane.idCollana', fieldtype: costanti.FieldType.number }),
|
||||
AddCol({ name: 'descrizione', label_trans: 'collane.descrizione' }),
|
||||
AddCol({ name: 'descrizione_estesa', label_trans: 'collane.descrizione_estesa' }),
|
||||
AddCol({ name: 'title', label_trans: 'collane.title' }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec),
|
||||
]
|
||||
@@ -4301,6 +4330,13 @@ export const fieldsTable = {
|
||||
colkey: 'idCollana',
|
||||
collabel: 'title',
|
||||
},
|
||||
{
|
||||
value: 'publishers',
|
||||
label: 'Nome',
|
||||
columns: colTablePublisher,
|
||||
colkey: '_id',
|
||||
collabel: 'name',
|
||||
},
|
||||
{
|
||||
value: 'catais',
|
||||
label: 'Categorie AI',
|
||||
@@ -4874,6 +4910,13 @@ export const fieldsTable = {
|
||||
colkey: 'username',
|
||||
collabel: 'username',
|
||||
},
|
||||
{
|
||||
value: 'lista_editori',
|
||||
label: 'Editori',
|
||||
columns: colTableUsersGeneric,
|
||||
colkey: 'username',
|
||||
collabel: 'username',
|
||||
},
|
||||
{
|
||||
value: 'mygroups',
|
||||
label: 'Organizzazioni',
|
||||
|
||||
@@ -8438,7 +8438,7 @@ export const tools = {
|
||||
} else if (table === toolsext.TABCATALOGS) {
|
||||
return tools.getdefaultnewrec_Catalog()
|
||||
}
|
||||
return null
|
||||
return {}
|
||||
},
|
||||
|
||||
getNomeTabellaStrByTable(table: string, rec: any) {
|
||||
@@ -9632,7 +9632,11 @@ export const tools = {
|
||||
console.error('Errore durante l\'elaborazione dell\'URL:', error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isEmptyObject(obj: any) {
|
||||
return Object.keys(obj).length === 0;
|
||||
},
|
||||
|
||||
// FINE !
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo } from 'model'
|
||||
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog } from 'model'
|
||||
|
||||
import { Api } from '@api'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
@@ -13,6 +13,7 @@ import { useGlobalStore } from './globalStore'
|
||||
import { ref } from 'vue'
|
||||
|
||||
import translate from '@src/globalroutines/util'
|
||||
import { useCatalogStore } from './CatalogStore'
|
||||
|
||||
function getRecordOrdersCartEmpty(): IOrderCart {
|
||||
return {
|
||||
@@ -1295,7 +1296,7 @@ export const useProducts = defineStore('Products', {
|
||||
}
|
||||
},
|
||||
|
||||
replaceKeyWordsByProduct(optcatalogo: IOptCatalogo, myproduct: IProduct, testo: IText) {
|
||||
replaceKeyWordsByProduct(optcatalogo: IOptCatalogo, myproduct: IProduct, testo: IText, idPage?: string) {
|
||||
if (!myproduct || !testo.contenuto) {
|
||||
return testo.contenuto;
|
||||
}
|
||||
@@ -1363,11 +1364,10 @@ export const useProducts = defineStore('Products', {
|
||||
const prezzo_scontato = tools.arrotonda2Dec(myproduct.arrvariazioni![0].sale_price) || ''
|
||||
const categoria = this.getCatProdsStrByCatProds(myproduct.productInfo.catprods!)
|
||||
const sottocategoria = myproduct.productInfo.subcatprods && myproduct.productInfo.subcatprods.length > 0 ? myproduct.productInfo.subcatprods[0].name! : ''
|
||||
const descr_categoria = myproduct.productInfo.catprods ? this.getCatProdDescrStrByIdCatProd(myproduct.productInfo.catprods![0]) : ''
|
||||
const descr_categoria = myproduct.productInfo.catprods ? this.getCatProdDescrStrByIdCatProd(myproduct.productInfo.catprods![0].name) : ''
|
||||
const misure = myproduct.arrvariazioni![0].misure || ''
|
||||
const formato = myproduct.arrvariazioni![0].formato || ''
|
||||
const pagine = myproduct.arrvariazioni![0].pagine || ''
|
||||
|
||||
const pagine = myproduct.arrvariazioni![0].pagine || ''
|
||||
|
||||
const scale = optcatalogo.printable ? optcatalogo.areadistampa?.scale : 1
|
||||
// Crea una mappa di sostituzioni
|
||||
|
||||
@@ -39,7 +39,7 @@ import { Router } from 'vue-router'
|
||||
import { useProjectStore } from '@store/Projects'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { costanti } from '@costanti'
|
||||
import { IReaction, IBookmark, ISeen, IFavBook, IAttend, IFavorite, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
|
||||
import { IReaction, IBookmark, ISeen, IFavBook, IAttend, IFavorite, IGroupShort, IMyGroup, IUserAdmins, IUserShort } from '@model/UserStore'
|
||||
|
||||
import globalroutines from '../globalroutines/index'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
@@ -214,6 +214,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
countusers: 0,
|
||||
lastparamquery: {},
|
||||
updateTables: false,
|
||||
lista_editori: null,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
@@ -222,6 +223,10 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return (this.servercode === toolsext.ERR_SERVERFETCH)
|
||||
},
|
||||
|
||||
getListaEditori: (state: IUserState) => {
|
||||
return state.lista_editori
|
||||
},
|
||||
|
||||
getServerCode: (state: IUserState): number => (state.servercode ? state.servercode : 0),
|
||||
getMsg: (state: IUserState): string => (state.msg ? state.msg : ''),
|
||||
|
||||
@@ -2190,6 +2195,14 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
async loadListaEditori() {
|
||||
const globalStore = useGlobalStore();
|
||||
if (!this.lista_editori) {
|
||||
this.lista_editori = await globalStore.getObjOnServer('lista_editori');
|
||||
}
|
||||
return this.lista_editori
|
||||
},
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
@@ -339,7 +339,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return !!rec ? rec.name + ' ' + rec.surname : ''
|
||||
},
|
||||
|
||||
getSchedeOpt(): any [] {
|
||||
getSchedeOpt(): any[] {
|
||||
const arrschede: ISchedaSingola[] = this.myschedas
|
||||
|
||||
let arr: any = []
|
||||
@@ -432,7 +432,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return userStore.usersList
|
||||
else if (table === 'friends')
|
||||
return userStore.my.profile.friends
|
||||
else if (table === 'friendsandme')
|
||||
else if (table === 'lista_editori') {
|
||||
ris = userStore.getListaEditori
|
||||
} else if (table === 'friendsandme')
|
||||
return [{ username: userStore.my.username }, ...userStore.my.profile.friends]
|
||||
// else if (table === 'mygroups')
|
||||
// return userStore.groups
|
||||
@@ -1028,6 +1030,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
},
|
||||
|
||||
async loadAfterLogin() {
|
||||
const userStore = useUserStore()
|
||||
|
||||
// console.log('loadAfterLogin')
|
||||
this.clearDataAfterLoginOnlyIfActiveConnection()
|
||||
|
||||
@@ -1041,6 +1045,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
isok = true
|
||||
}
|
||||
|
||||
await userStore.loadListaEditori()
|
||||
|
||||
await globalroutines('readall', 'config', null)
|
||||
|
||||
if (tools.isLogged()) {
|
||||
@@ -1113,7 +1119,6 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
},
|
||||
|
||||
async loadTable(params: IParamsQuery) {
|
||||
// console.log('loadTable', params)
|
||||
const userStore = useUserStore()
|
||||
|
||||
return Api.SendReq('/gettable', 'POST', params)
|
||||
@@ -1132,6 +1137,23 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
})
|
||||
},
|
||||
|
||||
async getObjOnServer(cmd: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
return Api.SendReq('/getobj', 'POST', { cmd })
|
||||
.then((res) => {
|
||||
this.serverError = false
|
||||
return res.data.data
|
||||
})
|
||||
.catch((error) => {
|
||||
this.serverError = true
|
||||
this.serverMsgError = error
|
||||
console.log('error getObjOnServer', error)
|
||||
userStore.setErrorCatch(error)
|
||||
return null
|
||||
})
|
||||
},
|
||||
|
||||
async loadExp(params: any) {
|
||||
// console.log('loadTable', params)
|
||||
params.filtersearch2 = 'fdsgas1'
|
||||
@@ -2032,9 +2054,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
options,
|
||||
}
|
||||
|
||||
return Api.SendReq('/aitools/ds', 'POST', paramquery)
|
||||
return Api.SendReq('/aitools/ds', 'POST', paramquery, false, true, 1, 5000, null, null, options)
|
||||
.then((res) => {
|
||||
return res.data
|
||||
return res.data
|
||||
}).catch((error) => {
|
||||
return {}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user