PASSAGGIO A VITE !

AGG. 1.1.23
This commit is contained in:
Surya Paolo
2025-03-01 14:14:43 +01:00
parent f0098e57b2
commit bc960d38a1
1044 changed files with 5323 additions and 10823777 deletions

View File

@@ -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) {
}
},
},
})