PASSAGGIO A VITE !
AGG. 1.1.23
This commit is contained in:
@@ -2,7 +2,7 @@ import axios, {
|
||||
AxiosInstance, AxiosPromise, AxiosResponse, AxiosInterceptorManager,
|
||||
} from 'axios'
|
||||
import { Api } from '@api'
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
import type * as Types from '@src/store/Api/ApiTypes'
|
||||
|
||||
async function sendRequest(url: string, method: string, mydata: any, myformdata?: any, responsedata?: any, options?: any) {
|
||||
console.log('sendRequest', method, url, mydata)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios, { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios'
|
||||
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios';
|
||||
import axios from 'axios'
|
||||
|
||||
// import LoginModule from '../Modules/Auth/LoginStore'
|
||||
import { toolsext } from '@src/store/Modules/toolsext'
|
||||
@@ -8,7 +9,8 @@ import { useUserStore } from '@store/UserStore'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
import * as Types from './ApiTypes'
|
||||
|
||||
import { from, Observable } from 'rxjs';
|
||||
import type { Observable } from 'rxjs';
|
||||
import { from } from 'rxjs';
|
||||
import { mergeMap, toArray } from 'rxjs/operators';
|
||||
|
||||
export let API_URL = ''
|
||||
@@ -23,14 +25,14 @@ export const axiosInstance: AxiosInstance = axios.create({
|
||||
axiosInstance.interceptors.response.use(
|
||||
|
||||
(response) => {
|
||||
if (process.env.DEBUGGING === '1') console.log(response)
|
||||
if (import.meta.env.DEBUGGING === '1') console.log(response)
|
||||
return response
|
||||
},
|
||||
(error) => {
|
||||
const globalStore = useGlobalStore()
|
||||
// console.log('error', error)
|
||||
if (error.response) {
|
||||
if (process.env.DEBUGGING === '1') console.log('Status = ', error.response.status)
|
||||
if (import.meta.env.DEBUGGING === '1') console.log('Status = ', error.response.status)
|
||||
console.log('Request Error: ', error.response)
|
||||
if (error.response.status !== 0) {
|
||||
globalStore.setStateConnection('online')
|
||||
@@ -163,16 +165,6 @@ async function Request(type: string, path: string, payload: any, responsedata?:
|
||||
);
|
||||
|
||||
});
|
||||
/*
|
||||
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;
|
||||
});
|
||||
*/
|
||||
|
||||
} else {
|
||||
|
||||
response = await axiosInstance[type](path, payload, config)
|
||||
@@ -255,7 +247,7 @@ async function Request(type: string, path: string, payload: any, responsedata?:
|
||||
globalStore.connData.downloading_server = (globalStore.connData.downloading_server === 1) ? -1 : globalStore.connData.downloading_server
|
||||
}, 1000)
|
||||
|
||||
if (process.env.DEV) {
|
||||
if (import.meta.env.DEV) {
|
||||
console.log('ERROR using', path)
|
||||
// console.log('Error received: ', error)
|
||||
// console.log('ricevuto=', ricevuto)
|
||||
@@ -282,34 +274,4 @@ async function Request(type: string, path: string, payload: any, responsedata?:
|
||||
return Promise.reject(new Types.AxiosError(0, null, mycode, error))
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -11,8 +11,8 @@ import { tools } from '@src/store/Modules/tools'
|
||||
import { toolsext } from '@src/store/Modules/toolsext'
|
||||
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
import router from '@router'
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
|
||||
import type * as Types from '@src/store/Api/ApiTypes'
|
||||
import { costanti } from '@src/store/Modules/costanti'
|
||||
import * as ApiTables from '@src/store/Modules/ApiTables'
|
||||
import sendRequest from './Inst-Pao'
|
||||
@@ -77,7 +77,7 @@ export const Api = {
|
||||
},
|
||||
|
||||
async checkSession({ token, refresh_token }: any) {
|
||||
return axios.post(process.env.API_URL + Paths.TOKEN_REFRESH, {
|
||||
return axios.post(import.meta.env.API_URL + Paths.TOKEN_REFRESH, {
|
||||
refresh_token,
|
||||
}, {
|
||||
headers: {
|
||||
@@ -145,8 +145,7 @@ export const Api = {
|
||||
return resolve(this.SendReq(url, method, mydata, setAuthToken, true));
|
||||
}
|
||||
} else {
|
||||
const $router = useRouter()
|
||||
$router.push('/signin')
|
||||
// $router.push('/signin')
|
||||
}
|
||||
} catch (err2: any) {
|
||||
console.error('err2, Token Invalido', err2)
|
||||
@@ -165,20 +164,20 @@ export const Api = {
|
||||
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,
|
||||
idapp: process.env.APP_ID,
|
||||
keyappid: import.meta.env.VITE_PAO_APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
}
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
const $router = useRouter()
|
||||
|
||||
|
||||
userStore.setServerCode(tools.EMPTY)
|
||||
userStore.setResStatus(0)
|
||||
|
||||
return new Promise((resolve, reject) => sendRequest(url, method, mydataout, myformdata, responsedata, options)
|
||||
.then(async (res) => {
|
||||
setTimeout( () => {
|
||||
setTimeout(() => {
|
||||
if (method === 'get') {
|
||||
globalStore.connData.downloading_server = 0
|
||||
} else {
|
||||
@@ -229,14 +228,14 @@ export const Api = {
|
||||
/**
|
||||
* Creates a Promise that resolves after a specified number of milliseconds.
|
||||
* Useful for creating delayed operations or pause in async functions.
|
||||
*
|
||||
*
|
||||
* @param ms - The number of milliseconds to delay
|
||||
* @returns A Promise that resolves after the specified delay
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // Basic usage
|
||||
* await delay(1000); // waits for 1 second
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // Usage in an async function
|
||||
* async function example() {
|
||||
@@ -244,7 +243,7 @@ export const Api = {
|
||||
* await delay(2000);
|
||||
* console.log('2 seconds later');
|
||||
* }
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // Usage with Promise chaining
|
||||
* delay(1000).then(() => console.log('1 second passed'));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Api } from '@api'
|
||||
import { IBookedEvent, ICalendarState, IEvents, IOperators } from 'model'
|
||||
import type { IBookedEvent, ICalendarState, IEvents, IOperators } from 'model'
|
||||
|
||||
import { serv_constants } from './Modules/serv_constants'
|
||||
import { tools } from './Modules/tools'
|
||||
@@ -217,7 +217,7 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
async CancelBookingEvent({ ideventbook, notify }: { ideventbook: string, notify: string }) {
|
||||
console.log('CALSTORE: CancelBookingEvent', ideventbook, notify)
|
||||
|
||||
return Api.SendReq('/booking/' + ideventbook + '/' + notify + '/' + process.env.APP_ID, 'DELETE', null)
|
||||
return Api.SendReq('/booking/' + ideventbook + '/' + notify + '/' + tools.getEnv('VITE_APP_ID'), 'DELETE', null)
|
||||
.then((res) => {
|
||||
if (res.status === 200) {
|
||||
if (res.data.code === serv_constants.RIS_CODE_OK) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import type {
|
||||
ICatalogState
|
||||
} from '@src/model';
|
||||
import {
|
||||
IAccount,
|
||||
ICircuit, ICatalog, IGlobalState, IGroupShort, IMyCircuit, IMyGroup, IUserFields,
|
||||
ICatalogState
|
||||
ICircuit, ICatalog, IGlobalState, IGroupShort, IMyCircuit, IMyGroup, IUserFields
|
||||
} from '@src/model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { tools } from '@tools'
|
||||
import translate from '@src/globalroutines/util'
|
||||
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
@@ -16,14 +18,14 @@ import { toolsext } from '@store/Modules/toolsext'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
|
||||
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { costanti } from '@costanti'
|
||||
|
||||
import globalroutines from '../globalroutines/index'
|
||||
|
||||
export const useCatalogStore = defineStore('CatalogStore', {
|
||||
state: (): ICatalogState => ({
|
||||
catalogs: [{ idapp: '', title: '' }]
|
||||
catalogs: [{ _id: '', idapp: '', title: '' }]
|
||||
}),
|
||||
|
||||
getters: {},
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import {
|
||||
import type {
|
||||
IAccount,
|
||||
ICircuit, ICircuitState, IGlobalState, IGroupShort, IMyCircuit, IMyGroup, IUserFields
|
||||
ICircuit, ICircuitState, IGroupShort, IMyCircuit, IMyGroup, IUserFields
|
||||
} from '@src/model';
|
||||
import { IGlobalState
|
||||
} from '@src/model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { tools } from '@tools'
|
||||
import translate from '@src/globalroutines/util'
|
||||
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
@@ -17,7 +19,7 @@ import { useUserStore } from '@store/UserStore'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
|
||||
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { costanti } from '@costanti'
|
||||
|
||||
import globalroutines from '../globalroutines/index'
|
||||
@@ -251,7 +253,7 @@ export const useCircuitStore = defineStore('CircuitStore', {
|
||||
getCircuitsListByGroup(mygrp: IMyGroup): ICircuit[] {
|
||||
if (mygrp.mycircuits)
|
||||
return this.listcircuits.filter((rec: ICircuit) => mygrp.mycircuits!.findIndex((circ: IMyCircuit) => circ.circuitname === rec.name) >= 0)
|
||||
|
||||
|
||||
return []
|
||||
},
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ import { Api } from '@api'
|
||||
|
||||
import { serv_constants } from './Modules/serv_constants'
|
||||
|
||||
import { IMessage, IMessageState, IMsgUsers, StatusMessage } from '../model'
|
||||
import type { IMessage, IMessageState, IMsgUsers} from '../model';
|
||||
import { StatusMessage } from '../model'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
import { MsgDefault } from '@src/model'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
@@ -74,10 +75,10 @@ export const useMessageStore = defineStore('MessageStore', {
|
||||
}
|
||||
},
|
||||
|
||||
async updateMsgDataFromServer({ username, lastdataread }: {username: string, lastdataread: Date}) {
|
||||
async updateMsgDataFromServer({ username, lastdataread }: { username: string, lastdataread: Date }) {
|
||||
// console.log('updateMsgDataFromServer', username, lastdataread)
|
||||
|
||||
return Api.SendReq(`/sendmsg/${username}/${lastdataread}/${process.env.APP_ID}`, 'GET', null)
|
||||
return Api.SendReq(`/sendmsg/${username}/${lastdataread}/${tools.getEnv('VITE_APP_ID')}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (res.status === 200) {
|
||||
@@ -100,7 +101,7 @@ export const useMessageStore = defineStore('MessageStore', {
|
||||
const userStore = useUserStore()
|
||||
|
||||
data.source!.page = ''
|
||||
data.idapp = process.env.APP_ID
|
||||
data.idapp = tools.getEnv('VITE_APP_ID')
|
||||
data.origin = userStore.my.username
|
||||
data.datemsg = tools.getDateNow()
|
||||
data.status = StatusMessage.WaitingToSend
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Api } from '@api'
|
||||
import { ITodo } from '@src/model'
|
||||
import type { ITodo } from '@src/model'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
import { toolsext } from '@src/store/Modules/toolsext'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
@@ -72,7 +72,6 @@ async function checkPendingMsg() {
|
||||
// ...
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
return new Promise((resolve, reject) => globalroutines('count', 'swmsg')
|
||||
.then((count) => {
|
||||
if (count > 0) {
|
||||
@@ -88,7 +87,6 @@ async function checkPendingNotif() {
|
||||
|
||||
const howmanybefore = notifStore.countNotif
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
return new Promise((resolve, reject) => globalroutines('count', 'notifications')
|
||||
.then((count) => {
|
||||
if (count !== howmanybefore) {
|
||||
@@ -170,7 +168,7 @@ export async function waitAndcheckPendingMsg() {
|
||||
return sendSwMsgIfAvailable()
|
||||
.then((something) => {
|
||||
if (something) {
|
||||
if (process.env.DEBUG === '1') {
|
||||
if (import.meta.env.VITE_DEBUG === '1') {
|
||||
console.log('something')
|
||||
}
|
||||
// Refresh data
|
||||
@@ -397,7 +395,7 @@ export function Sync_HideItem(nametab: string, item: any, id: string) {
|
||||
export async function aftercalling(ris: any, checkPending: boolean, nametabindex: string) {
|
||||
const userStore = useUserStore()
|
||||
if (ris.status !== 200) {
|
||||
if (process.env.DEBUG === '1') {
|
||||
if (import.meta.env.VITE_DEBUG === '1') {
|
||||
console.log('ris.status', ris.status)
|
||||
}
|
||||
if (ris.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { IColGridTable } from '@model'
|
||||
import type { IColGridTable } from '@model'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { lists } from './lists'
|
||||
import { costanti } from './costanti'
|
||||
import { tools } from '@tools'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { static_data } from '@/db/static_data'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
|
||||
const DeleteRec = {
|
||||
@@ -226,7 +227,7 @@ export const colTableCatalogList = [
|
||||
label_trans: 'cataloglist.pdf_online_stampa',
|
||||
}),
|
||||
// AddCol({ name: 'data_online', label_trans: 'dataloglist.data_online', fieldtype: costanti.FieldType.date }),
|
||||
|
||||
|
||||
AddCol(ModifRec),
|
||||
// AddCol(DuplicateRec),
|
||||
AddCol(DeleteRec),
|
||||
@@ -419,7 +420,7 @@ export const colmypage = [
|
||||
AddCol({
|
||||
name: '_id', label_trans: 'index', fieldtype: costanti.FieldType.string,
|
||||
showWhen: costanti.showWhen.InPage + costanti.showWhen.InEdit,
|
||||
}),
|
||||
}),
|
||||
AddCol({ name: 'path', label_trans: 'pages.path' }),
|
||||
AddCol({ name: 'icon', label_trans: 'pages.icon' }),
|
||||
AddCol({ name: 'order', label_trans: 'pages.order', fieldtype: costanti.FieldType.number }),
|
||||
@@ -2525,7 +2526,7 @@ export const colTableProductInfos = [
|
||||
AddCol({ name: 'name', label_trans: 'products.name' }),
|
||||
AddCol({ name: 'description', label_trans: 'products.description', fieldtype: costanti.FieldType.html }),
|
||||
AddCol({ name: 'icon', label_trans: 'products.icon' }),
|
||||
AddCol({ name: 'imagefile', label_trans: 'products.img', fieldtype: costanti.FieldType.image_and_filename, path: costanti.DIR_UPLOAD + 'products/' }),
|
||||
AddCol({ name: 'imagefile', label_trans: 'products.img', fieldtype: costanti.FieldType.image_and_filename, path: 'products/' }),
|
||||
AddCol({
|
||||
name: 'department',
|
||||
label_trans: 'products.department',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,11 @@
|
||||
import { date, useQuasar } from 'quasar'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
// import { useGlobalStore } from '@store/globalStore'
|
||||
import { static_data } from '@/db/static_data'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useTodoStore } from '@store/Todos'
|
||||
import { Router } from 'vue-router'
|
||||
import { ISpecialField } from 'model'
|
||||
import type { Router } from 'vue-router'
|
||||
import type { ISpecialField } from 'model'
|
||||
|
||||
export const func_tools = {
|
||||
getLocale(vero?: boolean): string {
|
||||
@@ -13,7 +13,7 @@ export const func_tools = {
|
||||
if (userStore) {
|
||||
return userStore.lang
|
||||
}
|
||||
if (!vero) return process.env.LANG_DEFAULT ? process.env.LANG_DEFAULT : 'it'
|
||||
if (!vero) return import.meta.env.VITE_LANG_DEFAULT ? import.meta.env.VITE_LANG_DEFAULT : 'it'
|
||||
return ''
|
||||
},
|
||||
|
||||
@@ -134,7 +134,7 @@ export const toolsext = {
|
||||
if (userStore) {
|
||||
return userStore.lang
|
||||
}
|
||||
return process.env.LANG_DEFAULT ? process.env.LANG_DEFAULT : 'it'
|
||||
return import.meta.env.VITE_LANG_DEFAULT ? import.meta.env.VITE_LANG_DEFAULT : 'it'
|
||||
},
|
||||
isLang(whichlang: string): boolean {
|
||||
const loc = func_tools.getLocale()
|
||||
@@ -144,26 +144,6 @@ export const toolsext = {
|
||||
if (mylang === 'enUs') return 'en-us'
|
||||
return mylang
|
||||
},
|
||||
setLangAtt($q: any, $router: Router, mylang: string) {
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
// console.log('setLangAtt =', mylang)
|
||||
// console.log('PRIMA this.$q.lang.isoName', this.$q.lang.isoName)
|
||||
|
||||
// dynamic import, so loading on demand only
|
||||
import(`quasar/lang/${this.getlangforQuasar(mylang)}`).then((lang) => {
|
||||
// console.log(' Import dinamically lang =', lang)
|
||||
|
||||
$q.lang.set(this.getlangforQuasar(lang.default.isoName))
|
||||
import('../../statics/i18n').then(() => {
|
||||
// console.log(' *** MY LANG DOPO=', $q.lang.isoName)
|
||||
})
|
||||
})
|
||||
|
||||
globalStore.addDynamicPages($router)
|
||||
|
||||
// this.$q.lang.set(mylang)
|
||||
},
|
||||
|
||||
getValDb(keystr: string, serv: boolean, def?: any, table?: string, subkey?: string, id?: any, idmain?: any, indrec?: number, subsubkey?: string, specialField?: ISpecialField): any {
|
||||
|
||||
@@ -285,7 +265,7 @@ export const toolsext = {
|
||||
}
|
||||
|
||||
if (!mylang) {
|
||||
if (process.env.LANG_DEFAULT) mylang = process.env.LANG_DEFAULT
|
||||
if (import.meta.env.VITE_LANG_DEFAULT) mylang = import.meta.env.VITE_LANG_DEFAULT
|
||||
console.log('LANG DEFAULT: ', mylang)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Api } from '@api'
|
||||
|
||||
import { serv_constants } from './Modules/serv_constants'
|
||||
|
||||
import { INotif, INotifState } from '../model'
|
||||
import type { INotif, INotifState } from '../model'
|
||||
import { tools } from '@src/store/Modules/tools'
|
||||
import { NotifDefault } from '@src/model'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
@@ -131,7 +131,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
},
|
||||
|
||||
setAllRead(username: string, qualinotif: number) {
|
||||
return Api.SendReq(`/sendnotif/setall/${username}/${qualinotif}/${process.env.APP_ID}`, 'GET', null)
|
||||
return Api.SendReq(`/sendnotif/setall/${username}/${qualinotif}/${tools.getEnv('VITE_APP_ID')}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
setTimeout(() => {
|
||||
@@ -157,7 +157,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
},
|
||||
|
||||
setRead(_id: string, notifcoins: boolean) {
|
||||
return Api.SendReq(`/sendnotif/set/${_id}/${process.env.APP_ID}`, 'GET', null)
|
||||
return Api.SendReq(`/sendnotif/set/${_id}/${tools.getEnv('VITE_APP_ID')}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (res) {
|
||||
@@ -181,7 +181,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
},
|
||||
|
||||
deleteRec(username: string, id: string, notifcoins: boolean) {
|
||||
return Api.SendReq(`/sendnotif/del/${username}/${id}/${process.env.APP_ID}`, 'GET', null)
|
||||
return Api.SendReq(`/sendnotif/del/${username}/${id}/${tools.getEnv('VITE_APP_ID')}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (res) {
|
||||
@@ -201,7 +201,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
},
|
||||
|
||||
deleteAll(username: string, qualinotif: number) {
|
||||
return Api.SendReq(`/sendnotif/delall/${username}/${qualinotif}/${process.env.APP_ID}`, 'GET', null)
|
||||
return Api.SendReq(`/sendnotif/delall/${username}/${qualinotif}/${tools.getEnv('VITE_APP_ID')}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (res) {
|
||||
@@ -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, false, false, 0)
|
||||
return Api.SendReq(`/sendnotif/${username}/${lastdataread}/${tools.getEnv('VITE_APP_ID')}`, 'GET', null, false, false, 0)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (!!res.data) {
|
||||
@@ -259,7 +259,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
|
||||
const data: INotif = { ...NotifDefault, ...notif }
|
||||
|
||||
data.idapp = process.env.APP_ID
|
||||
data.idapp = tools.getEnv('VITE_APP_ID')
|
||||
data.typedir = notif.typedir
|
||||
data.typeid = notif.typeid
|
||||
data.sender = notif.sender
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali } from 'model'
|
||||
import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatPrTotali } from 'model';
|
||||
import { ICatalog } from 'model'
|
||||
|
||||
import { Api } from '@api'
|
||||
import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { tools } from '@tools'
|
||||
import { defineStore } from 'pinia'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
@@ -119,7 +120,7 @@ export const useProducts = defineStore('Products', {
|
||||
getCatProds: (state: IProductsState) => (cosa: number): ICatProd[] => {
|
||||
if (cosa === shared_consts.PROD.GAS)
|
||||
return state.catprods_gas
|
||||
else if (cosa === shared_consts.PROD.GAS)
|
||||
else if (cosa === shared_consts.PROD.BOTTEGA)
|
||||
return state.catprods
|
||||
else
|
||||
return [...state.catprods, ...state.catprods_gas]
|
||||
@@ -468,12 +469,12 @@ export const useProducts = defineStore('Products', {
|
||||
const userStore = useUserStore()
|
||||
const myorder: IOrder = {
|
||||
userId: this.userActive._id,
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
status: shared_consts.OrderStatus.IN_CART,
|
||||
TotalPriceProduct: 0,
|
||||
TotalPriceProductCalc: 0,
|
||||
idProduct: product._id,
|
||||
product, // Copia tutto l'oggetto Product !
|
||||
product, // Copia tutto l'oggetto Product !
|
||||
|
||||
// Ordine:
|
||||
price: product.price,
|
||||
@@ -562,7 +563,7 @@ export const useProducts = defineStore('Products', {
|
||||
this.orders = []
|
||||
}
|
||||
|
||||
if (process.env.DEBUG === '1') {
|
||||
if (import.meta.env.VITE_DEBUG === '1') {
|
||||
}
|
||||
|
||||
return res
|
||||
@@ -817,14 +818,18 @@ export const useProducts = defineStore('Products', {
|
||||
if (product.storehouses.length === 1) {
|
||||
order.idStorehouse = product.storehouses[0]._id
|
||||
} else {
|
||||
order.idStorehouse = globalStore.storehouses ? globalStore.storehouses[0]._id : ''
|
||||
try {
|
||||
order.idStorehouse = globalStore.storehouses?.length ? globalStore.storehouses[0]._id : ''
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!order.idGasordine && order.quantitypreordered > 0) {
|
||||
if (product.gasordine && product.gasordine._id) {
|
||||
order.idGasordine = product.gasordine._id
|
||||
} else {
|
||||
order.idGasordine = globalStore.gasordines ? globalStore.gasordines[0]._id : ''
|
||||
order.idGasordine = globalStore.gasordines?.length ? globalStore.gasordines[0]._id : ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1374,7 +1379,7 @@ export const useProducts = defineStore('Products', {
|
||||
const descr_categoria = myproduct.productInfo.catprods && myproduct.productInfo.catprods.length > 0 ? 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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import {
|
||||
import type {
|
||||
ITodo,
|
||||
ITodosState,
|
||||
IParamTodo,
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from 'model'
|
||||
|
||||
import { Api } from '@api'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { tools } from '@tools'
|
||||
import { lists } from './Modules/lists'
|
||||
import * as ApiTables from './Modules/ApiTables'
|
||||
import globalroutines from './../globalroutines/index'
|
||||
@@ -25,7 +25,7 @@ const nametable = 'todos'
|
||||
|
||||
// import _ from 'lodash'
|
||||
|
||||
const listFieldsToChange: string [] = ['descr', 'statustodo', 'category', 'expiring_at', 'priority', 'pos', 'enableExpiring', 'progress', 'phase', 'assigned_to_userId', 'hoursplanned', 'hoursworked', 'start_date', 'completed_at', 'themecolor', 'themebgcolor', 'assignedToUsers']
|
||||
const listFieldsToChange: string[] = ['descr', 'statustodo', 'category', 'expiring_at', 'priority', 'pos', 'enableExpiring', 'progress', 'phase', 'assigned_to_userId', 'hoursplanned', 'hoursworked', 'start_date', 'completed_at', 'themecolor', 'themebgcolor', 'assignedToUsers']
|
||||
|
||||
export const useTodoStore = defineStore('Todos', {
|
||||
state: (): ITodosState => (
|
||||
@@ -92,9 +92,9 @@ export const useTodoStore = defineStore('Todos', {
|
||||
const indcat: number = this.getindexbycategory(cat)
|
||||
let arrout = []
|
||||
// console.log('items_dacompletare', 'indcat', indcat, state.todos[indcat])
|
||||
if (indcat >= 0 && state.todos) {
|
||||
if (indcat >= 0 && state.todos) {
|
||||
// @ts-ignore
|
||||
if (state.todos[indcat] ) {
|
||||
if (state.todos[indcat]) {
|
||||
// @ts-ignore
|
||||
arrout = state.todos[indcat].filter((todo: ITodo) => todo.statustodo !== tools.Status.COMPLETED)
|
||||
}
|
||||
@@ -283,7 +283,7 @@ export const useTodoStore = defineStore('Todos', {
|
||||
}), 10)
|
||||
|
||||
// console.log('ARRAY TODOS = ', this.todos)
|
||||
if (process.env.DEBUG === '1') {
|
||||
if (import.meta.env.VITE_DEBUG === '1') {
|
||||
// console.log('dbLoad', 'this.todos', this.todos, 'this.categories', this.categories)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import {
|
||||
import type {
|
||||
ICircuit,
|
||||
IMyCircuit,
|
||||
IFriends,
|
||||
IMsgGlobParam,
|
||||
ISigninOptions,
|
||||
ISignupOptions,
|
||||
@@ -15,16 +14,20 @@ import {
|
||||
IColGridTable,
|
||||
ISignupIscrizioneConacreisOptions,
|
||||
ISignupIscrizioneArcadeiOptions,
|
||||
ISettings,
|
||||
IMovQuery,
|
||||
IMovQuery
|
||||
} from '@src/model';
|
||||
import {
|
||||
IFriends,
|
||||
ISettings
|
||||
} from '@src/model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { tools } from '@tools'
|
||||
import translate from '@src/globalroutines/util'
|
||||
import { ICallResult, ILinkReg, IResult, IToken } from '@model/other'
|
||||
import type { ILinkReg, IToken } from '@model/other';
|
||||
import { ICallResult, IResult } from '@model/other'
|
||||
|
||||
import objectId from '@src/js/objectId'
|
||||
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
import type * as Types from '@src/store/Api/ApiTypes'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { serv_constants } from '@store/Modules/serv_constants'
|
||||
import { Api } from '@api'
|
||||
@@ -35,11 +38,12 @@ import { static_data } from '@src/db/static_data'
|
||||
import bcrypt from 'bcryptjs'
|
||||
|
||||
import { useTodoStore } from '@store/Todos'
|
||||
import { Router } from 'vue-router'
|
||||
import type { Router } from 'vue-router'
|
||||
import { useProjectStore } from '@store/Projects'
|
||||
import { shared_consts } from '@/common/shared_vuejs'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { costanti } from '@costanti'
|
||||
import { IReaction, IBookmark, ISeen, IFavBook, IAttend, IFavorite, IGroupShort, IMyGroup, IUserAdmins, IUserShort } from '@model/UserStore'
|
||||
import type { IReaction, IGroupShort, IMyGroup } from '@model/UserStore';
|
||||
import { IBookmark, ISeen, IFavBook, IAttend, IFavorite, IUserAdmins, IUserShort } from '@model/UserStore'
|
||||
|
||||
import globalroutines from '../globalroutines/index'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
@@ -129,7 +133,7 @@ export const DefaultProfile: IUserProfile = {
|
||||
img: '',
|
||||
nationality: '',
|
||||
intcode_cell: '',
|
||||
cell: process.env.TEST_CELL || '',
|
||||
cell: '',
|
||||
dateofbirth: null,
|
||||
sex: 0,
|
||||
country_pay: '',
|
||||
@@ -194,7 +198,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
my: { ...DefaultUser },
|
||||
userprofile: DefaultUser,
|
||||
groups: [],
|
||||
lang: process.env.LANG_DEFAULT ? process.env.LANG_DEFAULT : 'it',
|
||||
lang: import.meta.env.VITE_LANG_DEFAULT ? import.meta.env.VITE_LANG_DEFAULT : 'it',
|
||||
repeatPassword: '',
|
||||
categorySel: 'personal',
|
||||
servercode: 0,
|
||||
@@ -227,7 +231,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
getListaEditori: (state: IUserState) => {
|
||||
return state.lista_editori
|
||||
},
|
||||
|
||||
|
||||
getServerCode: (state: IUserState): number => (state.servercode ? state.servercode : 0),
|
||||
getMsg: (state: IUserState): string => (state.msg ? state.msg : ''),
|
||||
|
||||
@@ -409,7 +413,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
// Check if is this User!
|
||||
const myrec = this.getUserByUsername(username)
|
||||
if (myrec && myrec.profile && !!myrec.profile.img && myrec.profile.img !== '' && myrec.profile.img !== 'undefined') {
|
||||
return costanti.DIR_UPLOAD + 'profile/' + this.my.username + '/' + myrec.profile.img
|
||||
return tools.getDirUpload() + 'profile/' + this.my.username + '/' + myrec.profile.img
|
||||
}
|
||||
return ''
|
||||
},
|
||||
@@ -422,11 +426,11 @@ export const useUserStore = defineStore('UserStore', {
|
||||
getImgUserByRow(row: any, col: IColGridTable): string {
|
||||
let value = ''
|
||||
|
||||
if (row.hasOwnProperty(col.name)) {
|
||||
if (tools.existProp(row, col.name)) {
|
||||
value = row[col.name]
|
||||
}
|
||||
let tipoconto = shared_consts.AccountType.USER
|
||||
if (col.hasOwnProperty('tipoconto') && col.tipoconto) {
|
||||
if (tools.existProp(col, 'tipoconto') && col.tipoconto) {
|
||||
tipoconto = col.tipoconto
|
||||
}
|
||||
let img = ''
|
||||
@@ -440,7 +444,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
if (row) {
|
||||
const mycol = col.name + '.img'
|
||||
if (row.hasOwnProperty(mycol)) {
|
||||
if (tools.existProp(row, mycol)) {
|
||||
img = row[mycol]
|
||||
}
|
||||
}
|
||||
@@ -456,7 +460,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
img = 'images/noimg-user.svg'
|
||||
|
||||
let tipoconto = shared_consts.AccountType.USER
|
||||
if (col && col.hasOwnProperty('tipoconto') && col.tipoconto) {
|
||||
if (col && tools.existProp(col, 'tipoconto') && col.tipoconto) {
|
||||
tipoconto = col.tipoconto
|
||||
}
|
||||
|
||||
@@ -466,7 +470,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
img = this.getImgByCircuitpath(myrec.path)
|
||||
} else {
|
||||
if (myrec.profile && myrec.profile.img) {
|
||||
img = costanti.DIR_UPLOAD + 'profile/' + myrec.username + '/' + myrec.profile.img
|
||||
img = tools.getDirUpload() + 'profile/' + myrec.username + '/' + myrec.profile.img
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +499,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
} else {
|
||||
let myuser = from ? mov.userfrom : mov.userto
|
||||
if (myuser && myuser.profile.img) {
|
||||
img = costanti.DIR_UPLOAD + 'profile/' + myuser.username + '/' + myuser.profile.img
|
||||
img = tools.getDirUpload() + 'profile/' + myuser.username + '/' + myuser.profile.img
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,7 +651,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
try {
|
||||
if (circ && circ.photos && circ.photos.length > 0)
|
||||
return costanti.DIR_UPLOAD + 'circuits/' + circ.path + '/' + circ.photos[0].imagefile
|
||||
return tools.getDirUpload() + 'circuits/' + circ.path + '/' + circ.photos[0].imagefile
|
||||
} catch (e) {
|
||||
}
|
||||
return 'images/noimg.png'
|
||||
@@ -665,7 +669,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
try {
|
||||
// ++Todo: Sistemare!
|
||||
if (group) {
|
||||
return costanti.DIR_UPLOAD + 'mygroups/' + group.groupname + '/' + group.photos[0].imagefile
|
||||
return tools.getDirUpload() + 'mygroups/' + group.groupname + '/' + group.photos[0].imagefile
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
@@ -785,7 +789,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
let myrec = this.getRecByCol(user, col)
|
||||
|
||||
let tipoconto = shared_consts.AccountType.USER
|
||||
if (col && col.hasOwnProperty('tipoconto')) {
|
||||
if (col && tools.existProp(col, 'tipoconto')) {
|
||||
tipoconto = col.tipoconto
|
||||
}
|
||||
|
||||
@@ -802,21 +806,21 @@ export const useUserStore = defineStore('UserStore', {
|
||||
name = myrec.dest
|
||||
}
|
||||
} else if (tipoconto === shared_consts.AccountType.COLLECTIVE_ACCOUNT) {
|
||||
if (myrec.hasOwnProperty('descr'))
|
||||
if (tools.existProp(myrec, 'descr'))
|
||||
return myrec.descr
|
||||
else if (myrec.hasOwnProperty('groupname'))
|
||||
else if (tools.existProp(myrec, 'groupname'))
|
||||
return myrec.groupname
|
||||
else if (myrec.hasOwnProperty('grouporig'))
|
||||
else if (tools.existProp(myrec, 'grouporig'))
|
||||
return myrec.grouporig
|
||||
} else if (tipoconto === shared_consts.AccountType.COMMUNITY_ACCOUNT) {
|
||||
if (myrec.hasOwnProperty('name'))
|
||||
if (tools.existProp(myrec, 'name'))
|
||||
return myrec.name
|
||||
else if (myrec.hasOwnProperty('contocom'))
|
||||
else if (tools.existProp(myrec, 'contocom'))
|
||||
return myrec.contocom
|
||||
else if (myrec.hasOwnProperty('contoComDest'))
|
||||
else if (tools.existProp(myrec, 'contoComDest'))
|
||||
return myrec.contoComDest
|
||||
}
|
||||
if (!name && myrec.extrarec && myrec.extrarec.hasOwnProperty('contoComDest'))
|
||||
if (!name && tools.existProp(myrec.extrarec, 'contoComDest'))
|
||||
return myrec.extrarec.contoComDest
|
||||
|
||||
return name + (options && options.showprov ? this.getProvinceByUser(myrec, options ? options.html : false) : '')
|
||||
@@ -835,7 +839,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return mystr
|
||||
},
|
||||
|
||||
getUserNameOnlyIfToShow(user: any, col: any = null, options: any): string {
|
||||
getUserNameOnlyIfToShow(user: any, col: any = null, options: any = {}): string {
|
||||
let myrec = this.getRecByCol(user, col)
|
||||
|
||||
if (myrec.name || myrec.surname) {
|
||||
@@ -873,7 +877,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
msgerrore = translate('fetch.errore_generico')
|
||||
}
|
||||
|
||||
if (process.env.DEV) {
|
||||
if (import.meta.env.DEV) {
|
||||
console.log('ERROREEEEEEEEE: ', msgerrore, ' (', err, ')')
|
||||
}
|
||||
}
|
||||
@@ -1255,8 +1259,8 @@ export const useUserStore = defineStore('UserStore', {
|
||||
setlang($q: any, router: Router, newstr: string) {
|
||||
// console.log('SETLANG', newstr)
|
||||
this.lang = newstr
|
||||
toolsext.setLangAtt($q, router, newstr)
|
||||
toolsext.setLangAtt($q, router, newstr)
|
||||
tools.setLangAtt($q, router, newstr)
|
||||
tools.setLangAtt($q, router, newstr)
|
||||
tools.localStSetItem(toolsext.localStorage.lang, this.lang)
|
||||
},
|
||||
|
||||
@@ -1282,7 +1286,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
this.setServerCode(res.status)
|
||||
|
||||
if (res.status === 200) {
|
||||
if (process.env.DEV) {
|
||||
if (import.meta.env.DEV) {
|
||||
console.log('USERNAME = ' + newuser.username)
|
||||
console.log('IDUSER= ' + newuser._id)
|
||||
}
|
||||
@@ -1423,7 +1427,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
options,
|
||||
}
|
||||
|
||||
if (process.env.DEBUG === '1') {
|
||||
if (import.meta.env.VITE_DEBUG === '1') {
|
||||
console.log(usertosend)
|
||||
}
|
||||
|
||||
@@ -1541,10 +1545,12 @@ export const useUserStore = defineStore('UserStore', {
|
||||
await globalStore.checkUpdates()
|
||||
}
|
||||
|
||||
const isok = await globalStore.loadAfterLogin()
|
||||
const isok = await globalStore.loadLoginSite(router)
|
||||
|
||||
this.isLogged = isok && isLogged
|
||||
|
||||
await globalStore.loadAfterLogin()
|
||||
|
||||
// console.log('this.isLogged', this.isLogged, 'isok', isok, 'isLogged', isLogged)
|
||||
|
||||
if (globalStore.site.confpages && globalStore.site.confpages.enableTodos)
|
||||
@@ -2197,7 +2203,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
async loadListaEditori() {
|
||||
const globalStore = useGlobalStore();
|
||||
if (!this.lista_editori) {
|
||||
|
||||
@@ -1,32 +1,37 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import {
|
||||
ICfgServer, ICity, IProvince,
|
||||
import type {
|
||||
ICfgServer, IProvince,
|
||||
IColGridTable,
|
||||
IConfig,
|
||||
IDataToSet,
|
||||
IGlobalState,
|
||||
IListRoutes, IMyElem,
|
||||
IMyPage, IMySkill, IParamsPickup,
|
||||
IMyPage, IParamsPickup,
|
||||
IParamsQuery,
|
||||
ISettings,
|
||||
ISites,
|
||||
IStatusSkill,
|
||||
StateConnection,
|
||||
IMyScheda,
|
||||
ISchedaSingola,
|
||||
IOptQueryGM
|
||||
} from '@model';
|
||||
import {
|
||||
ICity, IMySkill,
|
||||
ISites,
|
||||
IMyScheda
|
||||
} from '@model'
|
||||
import { static_data } from '@src/db/static_data'
|
||||
import * as Types from '@src/store/Api/ApiTypes'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { serv_constants } from '@store/Modules/serv_constants'
|
||||
import * as ApiTables from '@src/store/Modules/ApiTables'
|
||||
import { Router, useRouter } from 'vue-router'
|
||||
import type { Router } from 'vue-router';
|
||||
import { useRouter } from 'vue-router'
|
||||
import { cfgrouter } from '@src/router/route-config'
|
||||
import { Api } from '@api'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
import { costanti } from '@costanti'
|
||||
import { fieldsTable } from '@store/Modules/fieldsTable'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { tools } from '@tools'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import globalroutines from '../globalroutines/index'
|
||||
import { useCalendarStore } from '@store/CalendarStore'
|
||||
@@ -243,11 +248,11 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
isNewVersionAvailable: (state: IGlobalState) => {
|
||||
// console.log('cfgServer', cfgServer)
|
||||
const serversrec = state.cfgServer.find((x) => (x.chiave === toolsext.SERVKEY_VERS) && (x.idapp === process.env.APP_ID))
|
||||
const serversrec = state.cfgServer.find((x) => (x.chiave === toolsext.SERVKEY_VERS) && (x.idapp === tools.getEnv('VITE_APP_ID')))
|
||||
// console.log('Record ', serversrec)
|
||||
if (serversrec) {
|
||||
console.log('Vers Server ', serversrec.valore, 'Vers locale:', process.env.APP_VERSION)
|
||||
return serversrec.valore !== process.env.APP_VERSION
|
||||
console.log('Vers Server ', serversrec.valore, 'Vers locale:', import.meta.env.VITE_APP_VERSION)
|
||||
return serversrec.valore !== import.meta.env.VITE_APP_VERSION
|
||||
}
|
||||
return false
|
||||
},
|
||||
@@ -879,7 +884,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('createPushSubscription')
|
||||
|
||||
let reg: any
|
||||
const mykey = process.env.PUBLICKEY_PUSH
|
||||
const mykey = import.meta.env.VITE_PUBLICKEY_PUSH
|
||||
return navigator.serviceWorker.ready
|
||||
.then((swreg) => {
|
||||
reg = swreg
|
||||
@@ -1029,31 +1034,32 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return prova
|
||||
},
|
||||
|
||||
async loadLoginSite(router: Router) {
|
||||
let isok = false
|
||||
|
||||
if (!await this.loadSite()) {
|
||||
router.push('/signin')
|
||||
} else {
|
||||
isok = true
|
||||
}
|
||||
|
||||
return isok
|
||||
},
|
||||
|
||||
async loadAfterLogin() {
|
||||
const userStore = useUserStore()
|
||||
|
||||
// console.log('loadAfterLogin')
|
||||
this.clearDataAfterLoginOnlyIfActiveConnection()
|
||||
|
||||
let isok = false
|
||||
|
||||
const $router = useRouter()
|
||||
|
||||
if (!await this.loadSite()) {
|
||||
$router.push('/signin')
|
||||
} else {
|
||||
isok = true
|
||||
}
|
||||
|
||||
await userStore.loadListaEditori()
|
||||
|
||||
await globalroutines('readall', 'config', null)
|
||||
|
||||
if (tools.isLogged()) {
|
||||
this.editOn = tools.getCookie('edn', '0') === '1'
|
||||
const pageKey = window.location.pathname
|
||||
this.editOn = tools.getCookie('edn_' + pageKey, '0') === '1'
|
||||
}
|
||||
|
||||
return isok
|
||||
},
|
||||
|
||||
async saveCfgServerKey(dataval: ICfgServer) {
|
||||
@@ -1356,6 +1362,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
// console.log('res', res)
|
||||
if (res && res.data) {
|
||||
tools.updateMyData(res.data.ris)
|
||||
|
||||
this.aggiornaRecordInLocaleDopoUpdateSulServer(mydata, res.data)
|
||||
if (res.data.rec) {
|
||||
return res.data.rec
|
||||
} else {
|
||||
@@ -1515,7 +1523,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('InviaMsgADonatori', msgobj)
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
msgextra: msgobj.msgextra,
|
||||
msgpar1: msgobj.msgpar1,
|
||||
username: msgobj.username,
|
||||
@@ -1544,7 +1552,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('InviaMsgAFlotta')
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
tipomsg,
|
||||
flotta,
|
||||
inviareale,
|
||||
@@ -1570,7 +1578,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('GetArrNavi')
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
}
|
||||
|
||||
return Api.SendReq('/dashboard/getnavi', 'POST', mydata)
|
||||
@@ -1592,7 +1600,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('GetMsgTemplates')
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
}
|
||||
|
||||
return Api.SendReq('/dashboard/getmsg_templates', 'POST', mydata)
|
||||
@@ -1614,7 +1622,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
// console.log('GetNave')
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
riga,
|
||||
col,
|
||||
riga1don,
|
||||
@@ -1641,7 +1649,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('GetData')
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
data,
|
||||
}
|
||||
|
||||
@@ -1664,7 +1672,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('GetArrDoniNavi')
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
ricalcola,
|
||||
showall,
|
||||
}
|
||||
@@ -1688,7 +1696,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('GetFlotte')
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
ricalcola,
|
||||
showall,
|
||||
}
|
||||
@@ -1712,7 +1720,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
console.log('GetFlotta')
|
||||
|
||||
const mydata = {
|
||||
idapp: process.env.APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
riga,
|
||||
col_prima,
|
||||
col_ultima,
|
||||
@@ -1748,7 +1756,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
// calendarStore.editable = false
|
||||
|
||||
return Api.SendReq(`/loadsite/${myuserid}/${process.env.APP_ID}/${process.env.APP_VERSION}`, 'GET', null)
|
||||
return Api.SendReq(`/loadsite/${myuserid}/${tools.getEnv('VITE_APP_ID')}/${import.meta.env.VITE_APP_VERSION}`, 'GET', null)
|
||||
.then((res) => {
|
||||
console.log('____________________________ res', res)
|
||||
this.serverError = false
|
||||
@@ -1852,7 +1860,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
// console.log('isLogged', isLogged)
|
||||
|
||||
// calendarStore.editable = userStore.isAdmin || userStore.isManager || userStore.isFacilitatore
|
||||
if (res.data.myuser === null || (res.data.myuser.idapp !== process.env.APP_ID)) {
|
||||
if (res.data.myuser === null || (res.data.myuser.idapp !== tools.getEnv('VITE_APP_ID'))) {
|
||||
if (isLogged) {
|
||||
// Fai Logout
|
||||
// console.log('Fai Logout', 'isLogged', isLogged)
|
||||
@@ -2161,11 +2169,16 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
myarr = newarr
|
||||
}
|
||||
|
||||
if (addall) {
|
||||
myarr = [costanti.FILTER_TUTTI, ...myarr]
|
||||
}
|
||||
|
||||
/* if (addall) {
|
||||
//myarr = [costanti.FILTER_TUTTI, ...myarr]
|
||||
const mykey = fieldsTable.getKeyByTable(table)
|
||||
const collab = fieldsTable.getLabelByTable(table)
|
||||
let obj: any = {}
|
||||
obj[mykey] = costanti.FILTER_TUTTI
|
||||
obj[collab] = costanti.FILTER_TUTTI_STR
|
||||
|
||||
myarr = [obj, ...myarr]
|
||||
}*/
|
||||
|
||||
if (addnone) {
|
||||
const mykey = fieldsTable.getKeyByTable(table)
|
||||
@@ -2238,9 +2251,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
getServerHost() {
|
||||
|
||||
try {
|
||||
let myserv = process.env.MONGODB_HOST!
|
||||
let myserv = import.meta.env.VITE_MONGODB_HOST!
|
||||
|
||||
if (!process.env.DEBUGGING) {
|
||||
if (!import.meta.env.DEBUGGING) {
|
||||
if (tools.isTest()) {
|
||||
if (this.site && this.site.host_testapi) {
|
||||
myserv = this.site.host_testapi
|
||||
@@ -2259,7 +2272,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
return myserv
|
||||
} catch (e) {
|
||||
return process.env.MONGODB_HOST
|
||||
return import.meta.env.VITE_MONGODB_HOST
|
||||
}
|
||||
|
||||
},
|
||||
@@ -2489,6 +2502,55 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
})
|
||||
},
|
||||
|
||||
async getGM_Tabella(options: IOptQueryGM) {
|
||||
const arrrec = await this.fetchTableContent(options);
|
||||
|
||||
return arrrec
|
||||
},
|
||||
async getGM_Lista_Argomenti(outhtml: boolean) {
|
||||
const arrrec = await this.fetchTableContent({ nameTable: 'T_Web_Argomenti', numrec: 200, outhtml });
|
||||
|
||||
return arrrec
|
||||
},
|
||||
|
||||
async getGM_FieldOf_T_Web_Articoli(sku: string, field: string, cmd: number) {
|
||||
|
||||
const options: IOptQueryGM = {
|
||||
nameTable: 'T_Web_Articoli',
|
||||
campispeciali: !field,
|
||||
numrec: 100,
|
||||
query: '',
|
||||
where: 'T.IdArticolo =' + sku,
|
||||
fieldGM: field,
|
||||
showQtaDisponibile: false,
|
||||
outhtml: false,
|
||||
cmd,
|
||||
}
|
||||
|
||||
const valueris = await this.fetchTableContent(options);
|
||||
if (valueris && valueris[field]) {
|
||||
console.log('valueris', valueris)
|
||||
return valueris[field]
|
||||
}
|
||||
|
||||
return null
|
||||
},
|
||||
|
||||
|
||||
async fetchTableContent(options: IOptQueryGM) {
|
||||
try {
|
||||
return Api.SendReq('/apisqlsrv/view-table', 'POST', { options })
|
||||
.then((res) => {
|
||||
return res.data.data
|
||||
}).catch((error: any) => {
|
||||
console.error('Error fetchTableContent: ', error)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Errore nel recupero della tabella:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
async getMailInABox(cmd: string, record: any = undefined) {
|
||||
|
||||
const mydata = {
|
||||
@@ -2521,5 +2583,26 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return this.getSchedeOpt
|
||||
},
|
||||
|
||||
}
|
||||
aggiornaRecordInLocaleDopoUpdateSulServer(datain: any, resdata: any) {
|
||||
|
||||
try {
|
||||
|
||||
if (datain.table) {
|
||||
const mytablerec = this.getListByTable(datain.table)
|
||||
|
||||
if (mytablerec && resdata && resdata.rec) {
|
||||
// Trova l'indice del record da aggiornare
|
||||
const index = mytablerec.findIndex((item: any) => item._id === resdata.rec._id)
|
||||
|
||||
if (index !== -1 && index !== undefined) {
|
||||
// Aggiorna il record mantenendo reattività
|
||||
mytablerec![index] = { ...mytablerec[index], ...resdata.rec }
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { createPinia } from 'pinia';
|
||||
|
||||
export default createPinia();
|
||||
|
||||
export { useUserStore } from './UserStore'
|
||||
export { useGlobalStore } from './globalStore'
|
||||
export { useTodoStore } from './Todos'
|
||||
export { useNotifStore } from './NotifStore'
|
||||
export { useCircuitStore } from './CircuitStore'
|
||||
export { useMessageStore } from './MessageStore'
|
||||
export { useProjectStore } from './Projects'
|
||||
export { useCalendarStore } from './CalendarStore'
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { tools } from '@tools'
|
||||
import { toolsext } from '@store/Modules/toolsext'
|
||||
|
||||
export interface ITest {
|
||||
finishLoading: boolean
|
||||
}
|
||||
|
||||
export const useTestStore = defineStore({
|
||||
id: 'TestStore',
|
||||
state: (): ITest => ({
|
||||
finishLoading: false,
|
||||
}),
|
||||
export const useTestStore = defineStore(
|
||||
'TestStore',
|
||||
{
|
||||
state: (): ITest => ({
|
||||
finishLoading: false,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
getters: {
|
||||
|
||||
isMyLang: (state: ITest) => (rec: { lang: string }): boolean => {
|
||||
if (!rec.lang) return true
|
||||
isMyLang: (state: ITest) => (rec: { lang: string }): boolean => {
|
||||
if (!rec.lang) return true
|
||||
|
||||
return (rec.lang === toolsext.getLocale(false) || toolsext.getLocale() === '')
|
||||
},
|
||||
|
||||
return (rec.lang === toolsext.getLocale(false) || toolsext.getLocale() === '')
|
||||
},
|
||||
|
||||
},
|
||||
actions: {
|
||||
testProva() {
|
||||
let arrpagesroute = null
|
||||
|
||||
actions: {
|
||||
testProva() {
|
||||
let arrpagesroute = null
|
||||
arrpagesroute = this.isMyLang({ lang: 'test' })
|
||||
},
|
||||
|
||||
arrpagesroute = this.isMyLang({ lang: 'test' })
|
||||
},
|
||||
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user