- attivita

- gestione degli script sul server
 - creato websocket per interagire con gli script del server.
This commit is contained in:
Surya Paolo
2024-08-29 23:31:54 +02:00
parent 79e874e3e0
commit 8f4ff8ff9c
39 changed files with 1373 additions and 303 deletions

View File

@@ -14,7 +14,9 @@ import {
ISearchList,
IPagination,
IParamDialog,
IMySkill
IMySkill,
ICoordLatLng,
ICoordGPS
} from 'model'
import { lists } from '@store/Modules/lists'
import { IParamsQuery } from 'model'
@@ -41,15 +43,18 @@ import { CMyCardPopup } from '@/components/CMyCardPopup'
import { CMyCardService } from '@/components/CMyCardService'
import { CMyCardGrpPopup } from '@/components/CMyCardGrpPopup'
import { CMyCardCircuitPopup } from '@/components/CMyCardCircuitPopup'
import { onBeforeRouteLeave, onBeforeRouteUpdate, beforeRouteEnter, useRouter } from 'vue-router'
import { onBeforeRouteLeave, onBeforeRouteUpdate, useRouter } from 'vue-router'
import { useRoute } from 'vue-router'
import { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
import { Dialog } from 'quasar'; // Assicurati di importare correttamente Dialog da Quasar.
import { getMapBoundaries } from '@src/store/Modules/geocodingmap'
import { isMap } from 'util/types'
export default defineComponent({
name: 'CGridTableRec',
emits: ['clickButtBar', 'savefilter'],
props: {
prop_mytitle: {
type: String,
@@ -329,6 +334,8 @@ export default defineComponent({
const drawmonth = ref(true)
const showMap = ref(false)
const showMapAtLeast1 = ref(false)
const mapInitialized = ref(false)
const newRecordBool = ref(false)
@@ -344,6 +351,8 @@ export default defineComponent({
const mycolumns = ref([] as any[])
const colkey = ref('')
const search = ref('')
const showSearchDialog = ref(false)
const myMapComp = ref(<any>null)
const tablesel = ref('')
const showSpin = ref(false)
@@ -361,6 +370,9 @@ export default defineComponent({
},
})
const boundariesMap = ref({ ne: 0, sw: 0 } as any)
const precboundariesMap = ref({ ne: 0, sw: 0 } as any)
const visupagedialog = ref(false)
const myrecdialog = ref(null)
const myIdRecDialog = ref(null)
@@ -412,6 +424,8 @@ export default defineComponent({
const ordinam = ref('')
const ordinam_desc = ref(false)
const autoaggiornaMappaSeMuovi = ref(true)
/*onBeforeRouteUpdate((to: any, from: any, next: any) => {
console.log('onBeforeRouteUpdate', 'to', to, 'from', from, 'next', next)
next()
@@ -419,7 +433,7 @@ export default defineComponent({
onBeforeRouteLeave((to: any, from: any, next: any) => {
console.log('onBeforeRouteLeave', 'to', to, 'from', from, 'next', next)
if (checkForChanges()) {
if ((editRecordBool.value || newRecordBool.value) && checkForChanges()) {
const answer = window.confirm(t('dialog.uscire'))
if (answer) {
next()
@@ -542,7 +556,7 @@ export default defineComponent({
watch(() => props.filtercustom, (to: any, from: any) => {
// console.log('filtercustom', to)
if (JSON.stringify(to) !== JSON.stringify(from)) {
console.log('REFRR props.filtercustom', to, from)
// console.log('REFRR props.filtercustom', to, from)
refresh()
}
})
@@ -1066,7 +1080,18 @@ export default defineComponent({
// console.log('params', params)
// console.log('props.extraparams', props.extraparams)
let paramsMap = null
if (showMap.value) {
paramsMap = {
searchByBoundariesMap: boundariesMap.value
}
}
params = { ...params, ...props.extraparams }
if (paramsMap) {
params = { ...params, ...paramsMap }
}
const data = await globalStore.loadTable(params)
@@ -1606,51 +1631,57 @@ export default defineComponent({
function mounted() {
console.log('mounted...')
searchList.value = props.prop_searchList
try {
searchList.value = props.prop_searchList
showMap.value = props.prop_showMap
boundariesMap.value = getMapBoundaries()
showMap.value = props.prop_showMap
showMapAtLeast1.value = props.prop_showMap
// console.log('GridTable mounted', tablesel.value)
// console.log('props.filtercustom', props.filtercustom)
// console.log('GridTable mounted', tablesel.value)
if (!!props.tablesList) {
canEdit.value = tools.getCookie(tools.CAN_EDIT, canEdit) === 'true'
tablesel.value = tools.getCookie('tablesel', tablesel.value)
}
// console.log('props.filtercustom', props.filtercustom)
myfilterand.value = props.filterdef
// myfiltercustom.value = props.filtercustom
// console.log('tablesel', tablesel)
if (tablesel.value === '') {
if (!!props.tablesList)
tablesel.value = props.tablesList[0].value
else
tablesel.value = mytable.value
}
if (!!props.tablesList) {
canEdit.value = tools.getCookie(tools.CAN_EDIT, canEdit) === 'true'
tablesel.value = tools.getCookie('tablesel', tablesel.value)
if (!shared_consts.TABLES_ORDER_DATE_UPDATED.includes(tablesel.value) &&
!shared_consts.TABLES_ORDER_DESCR.includes(tablesel.value)) {
// console.log('get cookie)')
let v1 = tools.getCookie('s_ordinamnew_' + tablesel.value, null)
if (v1)
ordinam.value = v1
let v2 = tools.getCookie('s_ordinamnew_des_' + tablesel.value, null)
if (v2)
ordinam_desc.value = v2
}
// console.log('2) tablesel', tablesel.value)
changeTable(tablesel.value, true)
// Aggiungi gli listener agli eventi della tastiera
document.addEventListener('keydown', onEscapeKey);
// window.addEventListener('popstate', onBackButton);
} catch (error) {
console.error('Err mounted', error)
}
myfilterand.value = props.filterdef
// myfiltercustom.value = props.filtercustom
// console.log('tablesel', tablesel)
if (tablesel.value === '') {
if (!!props.tablesList)
tablesel.value = props.tablesList[0].value
else
tablesel.value = mytable.value
}
if (!shared_consts.TABLES_ORDER_DATE_UPDATED.includes(tablesel.value) &&
!shared_consts.TABLES_ORDER_DESCR.includes(tablesel.value)) {
// console.log('get cookie)')
let v1 = tools.getCookie('s_ordinamnew_' + tablesel.value, null)
if (v1)
ordinam.value = v1
let v2 = tools.getCookie('s_ordinamnew_des_' + tablesel.value, null)
if (v2)
ordinam_desc.value = v2
}
// console.log('2) tablesel', tablesel.value)
changeTable(tablesel.value, true)
// Aggiungi gli listener agli eventi della tastiera
document.addEventListener('keydown', onEscapeKey);
// window.addEventListener('popstate', onBackButton);
}
function exec_func_table(table: string, func: number, par: IParamDialog) {
@@ -2396,6 +2427,7 @@ export default defineComponent({
// Questa funzione viene chiamata quando il dialogo cerca di chiudersi
const onEscapeKey = (event: KeyboardEvent) => {
// console.log('onEscapeKey', event.key)
if (event.key === 'Escape') {
event.preventDefault(); // Previene la chiusura da ESC
}
@@ -2420,6 +2452,91 @@ export default defineComponent({
cmdExt(costanti.CMD_SHOW_PAGE, id, null)
}
function updateMapBoundaries(ne: any, sw: any, updatedata: boolean) {
if (ne && sw) {
// console.log('updateMapBoundaries', ne, sw)
mapInitialized.value = true
boundariesMap.value = { ne, sw }
// Verifica se boundariesMap è variato da precedente valore,
// ma solo se ci sono nuovi pezzi delle mappa in più mostrati, quindi se è stato fatto un zoom in, non includerlo
const percrange = 0.15 //15%
const percrange_ne_lat = ne.lat - ((ne.lat - sw.lat) * percrange)
const percrange_ne_lng = ne.lng - ((ne.lng - sw.lng) * percrange)
const percrange_sw_lat = sw.lat + ((ne.lat - sw.lat) * percrange)
const percrange_sw_lng = sw.lng + ((ne.lng - sw.lng) * percrange)
if (precboundariesMap.value) {
if (precboundariesMap.value.ne.lat > percrange_ne_lat && precboundariesMap.value.ne.lng > percrange_ne_lng &&
precboundariesMap.value.sw.lat < percrange_sw_lat && precboundariesMap.value.sw.lng < percrange_sw_lng) {
updatedata = false
// console.log('updateMapBoundaries', 'updatedata', updatedata)
} else {
// updatedata = false
}
}
if (updatedata) {
precboundariesMap.value = boundariesMap.value
// console.log(' doSearch in updateMapBoundaries... ', ne, sw)
if (autoaggiornaMappaSeMuovi.value) {
doSearch()
} else {
}
}
}
}
function updateMapZoomOut() {
// console.log('updateMapZoomOut')
doSearch()
}
function clickButtBar(idbutt: any) {
if (idbutt === tools.BUTT_ADDREC) {
createNewRecord()
}
}
function getLabelAreaMap(conHtml: boolean = true) {
if (showMap.value) {
if (conHtml) {
return '<span class="hint_search">' + translate('grid.intheareamap') + '</span>'
} else {
return translate('grid.intheareamap')
}
}
return ''
}
function gotoCurrentLocation() {
myMapComp.value.gotoCurrentLocation()
}
function showInMap(rec: any) {
visupagedialog.value = false
if (!showMap.value) {
showMapAtLeast1.value = true
showMap.value = true
}
if (myMapComp.value && mapInitialized.value) {
myMapComp.value.showInMap(rec)
}
}
created()
return {
@@ -2533,6 +2650,15 @@ export default defineComponent({
ifShowMonth,
showMap,
clickMarker,
updateMapBoundaries,
updateMapZoomOut,
clickButtBar,
showSearchDialog,
getLabelAreaMap,
myMapComp,
gotoCurrentLocation,
showInMap,
showMapAtLeast1,
}
}
})