- sistemato timeout corto

- corretto errori sulla generazione del PDF
- corretto alcune directory
- corretto fs.promise
- corretto CORS !
This commit is contained in:
Surya Paolo
2025-05-15 14:27:40 +02:00
parent 300b8434ef
commit 50015712f5
54 changed files with 1910 additions and 235 deletions

View File

@@ -77,8 +77,8 @@
'book-image-fixed': complete,
'cursor-pointer': !complete,
'shadow-4': !optcatalogo.pdf,
'border-box': optcatalogo.pdf,
}"
:img-class="optcatalogo.pdf ? 'border-box' : ''"
:style="{
zIndex: 2,
width:
@@ -99,7 +99,7 @@
</a>
<div class="q-ma-sm no-print">
<div
class="row absolute-top-left semi-transparent "
class="row absolute-top-left semi-transparent"
style="z-index: 10"
>
<q-btn-dropdown
@@ -179,12 +179,10 @@
</q-item-section>
</q-item>-->
<q-item
v-if="
!optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book)
"
v-if="!optcatalogo.generazionePDFInCorso && (editOn || options.show_edit_book)"
clickable
v-close-popup
@click="refreshSingleBookFromGM({usaDBGMLocale: false})"
@click="refreshSingleBookFromGM({ usaDBGMLocale: false })"
>
<q-item-section avatar>
<q-avatar
@@ -203,7 +201,7 @@
"
clickable
v-close-popup
@click="refreshSingleBookFromGM({usaDBGMLocale: true})"
@click="refreshSingleBookFromGM({ usaDBGMLocale: true })"
>
<q-item-section avatar>
<q-avatar
@@ -674,7 +672,6 @@
@updateproductmodif="updateproductmodif"
>
</CSchedaProdotto>
</q-dialog>
<q-dialog
v-if="myproduct && modifTrafiletto"
@@ -693,7 +690,6 @@
:maxlength="680"
>
</CModifTrafiletto>
</q-dialog>
<q-dialog
v-if="visufromgm && myproduct"
@@ -716,7 +712,8 @@
nameTable: 'T_Web_Articoli',
campispeciali: true,
numrec: 1,
where: 'T.IdArticolo =' + myproduct.productInfo.sku + ' AND T.Ean13 = \'' + myproduct.productInfo.code + '\'',
where:
'T.IdArticolo =' + myproduct.productInfo.sku + ' AND T.Ean13 = \'' + myproduct.productInfo.code + '\'',
showQtaDisponibile,
outhtml: true,
}"

View File

@@ -81,7 +81,7 @@ export default defineComponent({
watch(() => props.modelValue, (newVal) => {
optcatalogo.value = { ...newVal };
// updateCatalogoPadre()
}, { deep: true });
}, { deep: false });
function updateCatalogoPadre() {
emit('update:modelValue', optcatalogo.value);

View File

@@ -0,0 +1,27 @@
.json-container {
background-color: #f8f8f8;
padding: 15px;
border-radius: 6px;
font-family: monospace;
white-space: pre-wrap;
word-break: break-word;
}
.json-key {
color: brown;
}
.json-string {
color: green;
}
.json-boolean {
color: blue;
}
.json-number {
color: darkorange;
}
.json-null {
color: magenta;
}
.json-error {
color: red;
}

View File

@@ -0,0 +1,57 @@
import { computed, defineComponent, onBeforeMount, onBeforeUnmount, onMounted, ref, toRef, toRefs, watch } from 'vue';
import { tools } from '@tools';
import { costanti } from '@costanti';
import { useGlobalStore } from '@store/globalStore';
import { useUserStore } from '@store/UserStore';
import { useI18n } from 'vue-i18n';
export default defineComponent({
name: 'CJSONViewer',
props: {
json: {
type: [Object, Array, String, null],
required: true,
},
},
setup(props) {
const { t } = useI18n();
// Funzione di highlight della sintassi JSON
function syntaxHighlight(json: string): string {
return json
.replace(/&/g, '&amp;')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(
/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g,
(match) => {
let cls = 'json-value';
if (/^"/.test(match)) {
if (/:$/.test(match)) cls = 'json-key';
else cls = 'json-string';
} else if (/true|false/.test(match)) cls = 'json-boolean';
else if (/null/.test(match)) cls = 'json-null';
else if (/^-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(match)) cls = 'json-number';
return `<span class="${cls}">${match}</span>`;
}
);
}
// Formatta e applica la colorazione
const highlightedJson = () => {
try {
const data = typeof props.json === 'string' ? JSON.parse(props.json) : props.json;
const jsonString = JSON.stringify(data, null, 2);
return syntaxHighlight(jsonString);
} catch (e) {
return `<span class="json-error">${t('invalid_json')}</span>`;
}
};
return {
highlightedJson,
t,
};
},
});

View File

@@ -0,0 +1,9 @@
<template>
<div class="json-container" v-html="highlightedJson()"></div>
</template>
<script lang="ts" src="./CJSONViewer.ts">
</script>
<style lang="scss" scoped>
@import './CJSONViewer.scss';
</style>

View File

@@ -0,0 +1 @@
export { default as CJSONViewer } from './CJSONViewer.vue'

View File

@@ -366,7 +366,7 @@ export default defineComponent({
);
}
console.log('Area di stampa MOUNTED... ',myel.value.catalogo.areadistampa)
// console.log('Area di stampa MOUNTED... ',myel.value.catalogo.areadistampa)
} catch (error) {
console.log(error);
}

View File

@@ -0,0 +1,38 @@
.cltitlebg{
}
.titletext {
color: white;
font-size: 3rem;
font-weight: 500;
line-height: 3rem;
text-shadow: .25rem .25rem .5rem black;
letter-spacing: .00937em;
opacity: 0.9;
}
@media (max-width: 718px) {
// PER VERSIONE MOBILE
.titletext {
color: white;
font-size: 2rem;
font-weight: 500;
line-height: 2rem;
text-shadow: .25rem .25rem .5rem black;
}
}
.q-img__content > div{
background: rgba(0,0,0,0.17) !important;
}
pre {
background: #f4f4f4;
padding: 10px;
border-radius: 5px;
max-width: 100%;
overflow-x: auto;
}

View File

@@ -0,0 +1,106 @@
import { computed, defineComponent, onBeforeMount, onBeforeUnmount, onMounted, ref, toRef, toRefs, watch } from 'vue';
import { tools } from '@tools';
import { costanti } from '@costanti';
import { useGlobalStore } from '@store/globalStore';
import { useUserStore } from '@store/UserStore';
import { useI18n } from 'vue-i18n';
import { CJSONViewer } from '@src/components/CJSONViewer';
export default defineComponent({
name: 'CTestLungo',
props: {},
components: { CJSONViewer},
setup(props, { attrs, slots, emit }) {
const { t } = useI18n();
const globalStore = useGlobalStore();
const userStore = useUserStore();
const testServer = ref({});
const serverhost = ref('');
const loading = ref(false);
const error = ref('');
const callLog = ref<string[]>([]);
const myrecfiltertoggle = ref(0);
const SERVER_TEST = ref([
{ key: 1, label: 'Test (FreePlanet)', host: 'https://test.freeplanet.app:3001' },
{ key: 2, label: 'Produzione', host: tools.getServerHost() },
{ key: 3, label: 'Locale', host: 'https://localhost:3000' },
{ key: 4, label: 'Host IP', host: globalStore.site.host_ip },
{ key: 5, label: 'Host', host: globalStore.site.host },
{ key: 6, label: 'Host Api', host: globalStore.site.host_api },
{ key: 7, label: 'Host Api IP', host: globalStore.site.host_api_ip },
]);
watch(
() => myrecfiltertoggle.value,
(value: any, oldValue: any) => {
if (value) {
const trovato = SERVER_TEST.value.find((rec: any) => rec.key === value);
if (trovato) {
globalStore.serverHost = trovato.host;
ricarica();
}
}
}
);
const getoptions = computed(() => {
const arr = [];
for (const rec of SERVER_TEST.value) {
arr.push({ label: rec.label, value: rec.key });
}
return arr;
});
function mounted() {
// ricarica();
// globalStore.getStatSite();
}
async function ricarica(timeout?: number = 60000) {
loading.value = true;
error.value = null;
try {
testServer.value = {};
callLog.value.push(`${new Date().toISOString()}: Eseguo Chiamata... timeout: ${timeout}`);
testServer.value = await globalStore.loadPageTestLungo(timeout);
callLog.value.push(`${new Date().toISOString()}: Success: Called loadPageTestLungo (${timeout})`);
} catch (err) {
console.error('Errore nella richiesta:', err.message || err);
if (err.code === 'ECONNABORTED') {
error.value = 'Timeout: la richiesta ha superato il tempo massimo consentito.';
} else {
error.value = 'Errore nella comunicazione col server. Controlla la connessione.';
}
callLog.value.push(`${new Date().toISOString()}: Error: ${err instanceof Error ? err.message : JSON.stringify(err)}`);
} finally {
loading.value = false;
}
}
onMounted(mounted);
return {
t,
tools,
getoptions,
costanti,
testServer,
ricarica,
myrecfiltertoggle,
loading,
error,
serverhost,
callLog,
};
},
});

View File

@@ -0,0 +1,76 @@
<template>
<div class="bi-border-all">
<q-banner
rounded
class="bg-primary text-white"
color="primary q-title"
style="text-align: center;">
<p class="mybanner">Server: {{tools.getServerHost()}}</p>
</q-banner>
<div v-if="error" class="text-negative q-mt-md">
{{ error }}
</div>
<q-btn-toggle
class="column"
v-model="myrecfiltertoggle"
push
glossy
toggle-color="primary"
:options="getoptions"
/>
<div class="text-center q-ma-lg">
<q-btn push size="lg" color="primary" rounded @click="ricarica">
{{ loading ? 'Elaborazione in corso...' : 'Avvia Elaborazione' }}
</q-btn>
<q-btn v-if="!loading" push size="lg" color="primary" rounded @click="ricarica(10000)">
{{ !loading ? '10 sec' : '' }}
</q-btn>
<q-btn v-if="!loading" push size="lg" color="primary" rounded @click="ricarica(60000)">
{{ !loading ? '1 min' : '' }}
</q-btn>
<q-btn v-if="!loading" push size="lg" color="primary" rounded @click="ricarica(300000)">
{{ !loading ? '5 min' : '' }}
</q-btn>
<q-btn v-if="!loading" push size="lg" color="primary" rounded @click="ricarica(600000)">
{{ !loading ? '10 min' : '' }}
</q-btn>
<q-btn v-if="!loading" push size="lg" color="primary" rounded @click="ricarica(1200000)">
{{ !loading ? '20 min' : '' }}
</q-btn>
<q-linear-progress
v-if="loading"
indeterminate
color="primary"
class="q-my-md"
size="20px"
/>
</div>
<div class="json-wrapper">
<CJSONViewer :json="testServer" />
</div>
<div class="q-ma-lg">
Chiamate effettuate:
<ul>
<li v-for="c in callLog.slice().reverse()" :key="c">{{c}}</li>
</ul>
</div>
</div>
</template>
<script lang="ts" src="./CTestLungo.ts">
</script>
<style lang="scss" scoped>
@import './CTestLungo.scss';
</style>

View File

@@ -0,0 +1 @@
export { default as CTestLungo } from './CTestLungo.vue'