- risolto problema della non attesa della PWA durante la chiamata a Node.js.
- risolto problema dell'ambiente in Locale HTTPS certificato installato aggiornato.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
VITE_APP_ID="13"
|
||||
VITE_APP_URL="https://test.riso.app"
|
||||
VITE_MONGODB_HOST="https://testapi.riso.app"
|
||||
VITE_LOGO_REG="riso-logo-full.png"
|
||||
VITE_APP_URL="https://riso.app"
|
||||
VITE_MONGODB_HOST="https://api.riso.app"
|
||||
VITE_LOGO_REG='riso-logo-full.png'
|
||||
VITE_PUBLICKEY_PUSH="BGXRf1TgcqocqD6J7qnRgCG7AvM2lxAoW7peb7UEzB4SxBb6DxGRdJ0UvD9ewnrB9KrSrh0-aDCODXBm7sZ1DDs"
|
||||
VITE_DEBUG="1"
|
||||
VITE_VUE_APP_ISTEST="1"
|
||||
DIRECTORY_LOCAL="myprojplanet_vite"
|
||||
DIRECTORY_SERVER="/var/www/nodejs_test.riso_server"
|
||||
SERVERDIR_WEBSITE="/var/www/test.riso.app"
|
||||
VITE_DEBUG="0"
|
||||
VITE_VUE_APP_ISTEST="0"
|
||||
DIRECTORY_LOCAL=myprojplanet_vite
|
||||
DIRECTORY_SERVER=/var/www/nodejs_riso_server
|
||||
SERVERDIR_WEBSITE="/var/www/riso.app"
|
||||
SERVERPW_WEBSITE="pwdadmin@1AOK"
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -34,3 +34,5 @@ upload/
|
||||
._yarn.lock
|
||||
.gitignore
|
||||
._upload
|
||||
scripts/localhost.pem
|
||||
scripts/localhost-key.pem
|
||||
|
||||
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -10,5 +10,8 @@
|
||||
"typescript",
|
||||
"vue"
|
||||
],
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"[vue]": {
|
||||
"editor.defaultFormatter": "Vue.volar"
|
||||
}
|
||||
}
|
||||
28
localhost-key.pem
Normal file
28
localhost-key.pem
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDMj4l7a8snvjVf
|
||||
3kj1WqOJPm5JV54l/GSOi6WQvjMfiW+nQoDgUINBbq7NrVgfdCMtDFmCInBxKQ6y
|
||||
fD/jmOMfAjchr0xqkKil6JD6xU3IO5vTmn7wbnC3av5iwRrM8EoAQs2QqQCdCj8v
|
||||
8ykxVzr2LxgEXIvtBaJLzq6KR4fHs7QHxDA6hF45MTzB+Ea8T2NKuoTLEfZKY7VA
|
||||
oVYz2i+q5Elc+9w8LrZvp+6j3feSS3QlTj9IezblXj7dTApfkniwPuG756IzuaYo
|
||||
ko7mnwxxruADI/4mXn/9K/KVFsUQ7I0vQ5SAB+YHHM/JMxTykfJCPjlM3BfblfXE
|
||||
xhayCcLlAgMBAAECggEAPXPBcXpohX/2uN4mPM8F4e0HZLEVqYOxEcGR83GwGgFH
|
||||
sY+g98I4LCf8C33Pw2M4Tggvu5BtBxG2gJgi+VSsplwcA9qNslXS1ESRiURMoaKG
|
||||
pYL8L25+HhveX/xy+K4XDQ0EhDjBHmw9n0IFVfVGmT58kJLc1k+i+fMVLCVg/PTN
|
||||
hmjp04tFEBQz8jZCkYBwX7bOiZ15A6rrQtvvafaM4AcYn9cJIEi1SPUEC5HuWvpY
|
||||
JrqBP3MW1OBVj/XE3dEOaO0jt8E4Mhbef/VQzFatdgw7/NlJCFMpqgqzSYRmpz9i
|
||||
riQhipnorrz7E63qzR5XbkpKcWN9d+xZJvtWmBS64QKBgQD1MOZqtouCVac5xduY
|
||||
Ah/AzqlTi2IuX4Gv3xCYu7a1CCxpWFEGeI1pVD3SiADS7wf6rGSWrES6dLdHfPNn
|
||||
OM7pK0tJL9xhIn3c6qWuJTWNE6MQoc4CIEBSJVqwVqLBsIToNHV2GuU6S2UXNkpu
|
||||
f+mga0XcWEq+e5sgEKEXEgVQCwKBgQDVlBqfLVvhdmccmFNWGl42ZytTJ5rxMyCo
|
||||
GgIYaZoUgPaXodmh+D3jFhRUe0dt6PMg1Lrz5bNV87tStFpybBHwVrgjdTLjMh3s
|
||||
hVbeB4e+p+FXos042zS55N4WmoRyUkiEPqS4yAQmQ39ry+Z8R3kjYqZ8160jV70I
|
||||
AeUo+05ezwKBgQCBU/G1h+O+M3+pMXvKihRFlrwpnPOEkkvNgFM4vIp6on0Kc9MJ
|
||||
Hr04OX8CdUo5+Gq1BglokCUQVE/4HSgl4gkBZByp1dzgP1k0FXCeknHUn+767t3C
|
||||
sVA8BAf5yzi+AWWZNVJfoYAXZ31C6RgJgN6yBuMqfkeugXQpTZwqlw7GUQKBgGku
|
||||
Ven8OZqQZ/lSHwBxXeJm7pQ2Ff0hE70VieCh6Qqd9FL6lyZIDZpPHlX4nFXJeiq5
|
||||
+RPyFF6I+MCjJ0Pgavk0i9ySdCwlW01G4V/Yz4YaQUSaXXzZn17JEoKJOB7g3Oub
|
||||
uh1yC3EYnqDkuq6LuGGvzJQA1zhnliViYYvML21LAoGBAJ5JOztBX/6vXpBF0/JJ
|
||||
BNuKr9CPQ5qjyThX0lJF0+o8ZVD/tttwAgA/FfmePqKSrrWs5RJfbjt5NUFXYykx
|
||||
7UF9bitWfSVqERkZcOp4NgRjx/A6l27T5e6+zu0Ze7es1oUzR3Ov2FUDUt9skpdC
|
||||
O8iSMszloFwh/gOG9F1vLLAz
|
||||
-----END PRIVATE KEY-----
|
||||
26
localhost.pem
Normal file
26
localhost.pem
Normal file
@@ -0,0 +1,26 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEczCCAtugAwIBAgIQPkGxv6Tr58lKZlWBrK31KzANBgkqhkiG9w0BAQsFADCB
|
||||
ozEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMTwwOgYDVQQLDDNzdXJ5
|
||||
YXBhb2xvQE1hY0Jvb2stQWlyLWRpLVN1cnlhLmxvY2FsIChTdXJ5YSBQYW9sbykx
|
||||
QzBBBgNVBAMMOm1rY2VydCBzdXJ5YXBhb2xvQE1hY0Jvb2stQWlyLWRpLVN1cnlh
|
||||
LmxvY2FsIChTdXJ5YSBQYW9sbykwHhcNMjUwMzEzMDgxODIxWhcNMjcwNjEzMDcx
|
||||
ODIxWjBnMScwJQYDVQQKEx5ta2NlcnQgZGV2ZWxvcG1lbnQgY2VydGlmaWNhdGUx
|
||||
PDA6BgNVBAsMM3N1cnlhcGFvbG9ATWFjQm9vay1BaXItZGktU3VyeWEubG9jYWwg
|
||||
KFN1cnlhIFBhb2xvKTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyP
|
||||
iXtryye+NV/eSPVao4k+bklXniX8ZI6LpZC+Mx+Jb6dCgOBQg0Furs2tWB90Iy0M
|
||||
WYIicHEpDrJ8P+OY4x8CNyGvTGqQqKXokPrFTcg7m9OafvBucLdq/mLBGszwSgBC
|
||||
zZCpAJ0KPy/zKTFXOvYvGARci+0FokvOropHh8eztAfEMDqEXjkxPMH4RrxPY0q6
|
||||
hMsR9kpjtUChVjPaL6rkSVz73Dwutm+n7qPd95JLdCVOP0h7NuVePt1MCl+SeLA+
|
||||
4bvnojO5piiSjuafDHGu4AMj/iZef/0r8pUWxRDsjS9DlIAH5gccz8kzFPKR8kI+
|
||||
OUzcF9uV9cTGFrIJwuUCAwEAAaNeMFwwDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQM
|
||||
MAoGCCsGAQUFBwMBMB8GA1UdIwQYMBaAFLFuWFq/xnNJeprfAy5ACMa9SjguMBQG
|
||||
A1UdEQQNMAuCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQsFAAOCAYEAtstXoeWi9WY/
|
||||
4URXA4uUSFItGhmWmVkNI1Ak+iM4w7OgerohZ1bfDY/0vVDmX8aGtacnU9cwnz+H
|
||||
y7yxrA42pJjk9GF1cKO+AKGr5oj6LJ8MQ7XfHhJ7Phv+QJHFo6sMBb0P5qR/TI4r
|
||||
UNmzda8jBDpSE9vCe0XdM89R2UB/G0UBu4Gc2+tTpcG+2/B3P+L6dNrDbHcFHU6W
|
||||
L/UpFiHUaKqFvTz62oYqCicgftXPrGy6RNd4tWj+YETxdYRRlUkLHgAQaj8QAs1g
|
||||
9Krj0KOfyk3Kmxeis7XW7O3FglI3D/PDyOwWTN76EIzjGteNj3OZ49Ys4jt9V0pr
|
||||
CeCnjq3lbSvX8xj139fc2fb/bvd3vzGjv39rRDQ3BDHwaWZrlyHhSGy/mLKQC/SH
|
||||
FGhr/v+NcMe9uGh8aDM60Hm+wQEM+WOWCJkDG3Ajv+Rf0V8N03foS0ngAO0PQlDp
|
||||
ZlhOlMNxkUSQkwMawOX33mzEaVALTQ6/OKMWbR8K5bjAIWUtG1AN
|
||||
-----END CERTIFICATE-----
|
||||
@@ -215,7 +215,10 @@ export default defineConfig((ctx) => {
|
||||
|
||||
// Full list of options: https://v2.quasar.dev/quasar-cli/quasar-conf-js#Property%3A-devServer
|
||||
devServer: {
|
||||
https: false,
|
||||
https: {
|
||||
key: path.resolve(__dirname, 'localhost-key.pem'),
|
||||
cert: path.resolve(__dirname, 'localhost.pem'),
|
||||
},
|
||||
port: ctx.mode.spa ? 8084 : 8094,
|
||||
vueDevtools: false, // automatically opening remote Vue Devtools
|
||||
open: false, // opens browser window automatically
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
import { CacheableResponsePlugin } from 'workbox-cacheable-response';
|
||||
import { ExpirationPlugin } from 'workbox-expiration';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const debug = false; //process.env.NODE_ENV !== 'production';
|
||||
|
||||
if (workbox) {
|
||||
|
||||
@@ -122,14 +122,14 @@ async function deleteItemFromData(table, id) {
|
||||
if (workbox) {
|
||||
|
||||
|
||||
if (process.env.MODE !== 'ssr' || process.env.PROD) {
|
||||
/*if (process.env.MODE !== 'ssr' || process.env.PROD) {
|
||||
registerRoute(
|
||||
new NavigationRoute(
|
||||
createHandlerBoundToURL(process.env.PWA_FALLBACK_HTML),
|
||||
{ denylist: [new RegExp(process.env.PWA_SERVICE_WORKER_REGEX), /workbox\workbox-(.)*\.js$/] }
|
||||
)
|
||||
)
|
||||
}
|
||||
}*/
|
||||
|
||||
// Cache strategy registrations
|
||||
registerRoute(
|
||||
@@ -256,9 +256,13 @@ if (workbox) {
|
||||
let API_DOMAIN = '';
|
||||
if (ISTEST) {
|
||||
API_DOMAIN = 'testapi.' + removeTestPrefix(APP_DOMAIN);
|
||||
} else {
|
||||
if (APP_DOMAIN.includes('localhost')) {
|
||||
API_DOMAIN = 'localhost:3000';
|
||||
} else {
|
||||
API_DOMAIN = 'api.' + APP_DOMAIN;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('API_DOMAIN', API_DOMAIN);
|
||||
|
||||
@@ -304,19 +308,19 @@ if (workbox) {
|
||||
}
|
||||
|
||||
// Strategia di caching: stale-while-revalidate
|
||||
async function cacheWithStaleWhileRevalidate(request) {
|
||||
async function cacheWithStaleWhileRevalidate(request, event) {
|
||||
const cache = await caches.open(CACHE_NAME);
|
||||
|
||||
// Prova a recuperare la risorsa dalla cache
|
||||
const cachedResponse = await cache.match(request);
|
||||
if (cachedResponse) {
|
||||
// Restituisci la risposta in cache mentre aggiorni in background
|
||||
fetchAndCache(request);
|
||||
event.waitUntil(fetchAndCache(request));
|
||||
return cachedResponse;
|
||||
}
|
||||
|
||||
// Se non è in cache, fai la richiesta di rete
|
||||
return fetchAndCache(request);
|
||||
return await fetchAndCache(request);
|
||||
}
|
||||
|
||||
// Funzione per fare la richiesta di rete e aggiornare la cache
|
||||
@@ -357,7 +361,7 @@ if (workbox) {
|
||||
console.log('E\' una RICHIESTA statica...')
|
||||
}
|
||||
// Gestione risorse statiche e altre richieste
|
||||
event.respondWith(cacheWithStaleWhileRevalidate(request));
|
||||
event.respondWith(cacheWithStaleWhileRevalidate(request, event));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ export default defineComponent({
|
||||
const globalStore = useGlobalStore()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const NUMSEC_TO_POLLING = ref(60)
|
||||
// const NUMSEC_TO_POLLING = ref(60)
|
||||
const MAXNUM_POLLING = ref(1000)
|
||||
|
||||
const myloadingload = ref(false)
|
||||
const eseguipolling = ref(false)
|
||||
const polling = ref(<any>null)
|
||||
const numpolled = ref(0)
|
||||
// const numpolled = ref(0)
|
||||
|
||||
const mytab = ref('reg')
|
||||
|
||||
@@ -127,7 +127,8 @@ export default defineComponent({
|
||||
|
||||
if (eseguipolling.value) {
|
||||
beforeDestroy()
|
||||
if (numpolled.value > 200) {
|
||||
|
||||
/*if (numpolled.value > 200) {
|
||||
NUMSEC_TO_POLLING.value = 60 * 5
|
||||
}
|
||||
if (numpolled.value < MAXNUM_POLLING.value) {
|
||||
@@ -137,7 +138,7 @@ export default defineComponent({
|
||||
numpolled.value++
|
||||
}, NUMSEC_TO_POLLING.value * 1000)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,83 +1,32 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="visustat">
|
||||
<CTitleBanner
|
||||
class="q-pa-xs"
|
||||
:title="$t('pages.status')"
|
||||
bgcolor="bg-primary"
|
||||
clcolor="text-white"
|
||||
mystyle=""
|
||||
myclass="sfondo_gradiente_blu myshad"
|
||||
:canopen="true"
|
||||
>
|
||||
<CTitleBanner class="q-pa-xs" :title="$t('pages.status')" bgcolor="bg-primary" clcolor="text-white" mystyle=""
|
||||
myclass="sfondo_gradiente_blu myshad" :canopen="true">
|
||||
<div class="flex flex-center">
|
||||
<CElemStat
|
||||
myclass="fixed-size"
|
||||
:title="$t('statusreg.reg')"
|
||||
icon="fas fa-users"
|
||||
:value_today="datastat.num_reg_today"
|
||||
:mytextval="
|
||||
datastat.activeusers + ' su ' + tools.numtostr(datastat.num_reg)
|
||||
"
|
||||
classColor="text-red"
|
||||
colBack="green"
|
||||
>
|
||||
<CElemStat myclass="fixed-size" :title="$t('statusreg.reg')" icon="fas fa-users"
|
||||
:value_today="datastat.num_reg_today" :mytextval="datastat.activeusers + ' su ' + tools.numtostr(datastat.num_reg)
|
||||
" classColor="text-red" colBack="green">
|
||||
</CElemStat>
|
||||
<CElemStat
|
||||
v-if="true"
|
||||
myclass="fixed-size"
|
||||
:title="$t('statusreg.online_today')"
|
||||
icon="fas fa-wifi"
|
||||
:mytextval="tools.numtostr(datastat.online_today)"
|
||||
classColor="text-orange"
|
||||
colBack="yellow"
|
||||
>
|
||||
<CElemStat v-if="true" myclass="fixed-size" :title="$t('statusreg.online_today')" icon="fas fa-wifi"
|
||||
:mytextval="tools.numtostr(datastat.online_today)" classColor="text-orange" colBack="yellow">
|
||||
</CElemStat>
|
||||
<CElemStat
|
||||
myclass="fixed-size"
|
||||
v-f="datastat.num_annunci > 0"
|
||||
:title="$t('statusreg.num_annunci')"
|
||||
icon="fas fa-tshirt"
|
||||
:value_today="0"
|
||||
:mytextval="tools.numtostr(datastat.num_annunci)"
|
||||
classColor="text-green"
|
||||
colBack="orange"
|
||||
>
|
||||
<CElemStat myclass="fixed-size" v-f="datastat.num_annunci > 0" :title="$t('statusreg.num_annunci')"
|
||||
icon="fas fa-tshirt" :value_today="0" :mytextval="tools.numtostr(datastat.num_annunci)"
|
||||
classColor="text-green" colBack="orange">
|
||||
</CElemStat>
|
||||
<CElemStat
|
||||
myclass="fixed-size"
|
||||
v-f="datastat.num_circuiti_attivi > 0"
|
||||
:title="$t('statusreg.num_circuiti_attivi')"
|
||||
icon="fas fa-map-marker-alt"
|
||||
:value_today="0"
|
||||
:mytextval="
|
||||
datastat.num_circuiti_attivi + ' su ' + datastat.num_circuiti
|
||||
"
|
||||
classColor="text-blue"
|
||||
colBack="red"
|
||||
>
|
||||
<CElemStat myclass="fixed-size" v-f="datastat.num_circuiti_attivi > 0"
|
||||
:title="$t('statusreg.num_circuiti_attivi')" icon="fas fa-map-marker-alt" :value_today="0" :mytextval="datastat.num_circuiti_attivi + ' su ' + datastat.num_circuiti
|
||||
" classColor="text-blue" colBack="red">
|
||||
</CElemStat>
|
||||
<CElemStat
|
||||
myclass="fixed-size"
|
||||
v-f="datastat.num_transaz_tot > 0"
|
||||
:title="$t('statusreg.numtransazioni')"
|
||||
icon="fas fa-sync-alt"
|
||||
:value_today="0"
|
||||
:mytextval="tools.numtostr(datastat.num_transaz_tot)"
|
||||
classColor="text-indigo"
|
||||
colBack="green"
|
||||
>
|
||||
<CElemStat myclass="fixed-size" v-f="datastat.num_transaz_tot > 0" :title="$t('statusreg.numtransazioni')"
|
||||
icon="fas fa-sync-alt" :value_today="0" :mytextval="tools.numtostr(datastat.num_transaz_tot)"
|
||||
classColor="text-indigo" colBack="green">
|
||||
</CElemStat>
|
||||
<CElemStat
|
||||
myclass="fixed-size"
|
||||
v-f="datastat.tot_RIS_transati > 0"
|
||||
:title="$t('statusreg.totristransati')"
|
||||
icon="img: /images/1ris_rosso_100.png"
|
||||
:value_today="0"
|
||||
:mytextval="tools.numtostr(datastat.tot_RIS_transati) + ' RIS'"
|
||||
classColor="text-blueviolet"
|
||||
colBack="green"
|
||||
>
|
||||
<CElemStat myclass="fixed-size" v-f="datastat.tot_RIS_transati > 0" :title="$t('statusreg.totristransati')"
|
||||
icon="img: /images/1ris_rosso_100.png" :value_today="0"
|
||||
:mytextval="tools.numtostr(datastat.tot_RIS_transati) + ' RIS'" classColor="text-blueviolet"
|
||||
colBack="green">
|
||||
</CElemStat>
|
||||
|
||||
<!--<CCardState :mytext="$t('statusreg.autorizzare')" :myval="datastat.num_autorizzare"
|
||||
@@ -85,10 +34,7 @@
|
||||
-->
|
||||
|
||||
<div class="q-pa-xs" v-if="datastat.num_part_accepted > 1">
|
||||
<CCardStat
|
||||
:mytext="$t('stat.accepted')"
|
||||
:myval="datastat.num_part_accepted"
|
||||
></CCardStat>
|
||||
<CCardStat :mytext="$t('stat.accepted')" :myval="datastat.num_part_accepted"></CCardStat>
|
||||
<!--<CCardStat :mytext="$t('stat.modalita_pagamento')"
|
||||
:myval="datastat.num_modalita_pagamento"></CCardStat>-->
|
||||
<!--<CCardStat :mytext="$t('stat.requisiti')" :myval="datastat.num_requisiti"></CCardStat>-->
|
||||
@@ -103,58 +49,35 @@
|
||||
</div>
|
||||
|
||||
<q-list bordered>
|
||||
<q-expansion-item
|
||||
group="somegroup"
|
||||
icon="fas fa-user-plus"
|
||||
:label="$t('statusreg.newreg')"
|
||||
default-opened
|
||||
header-class="text-primary"
|
||||
>
|
||||
<q-expansion-item group="somegroup" icon="fas fa-user-plus" :label="$t('statusreg.newreg')" default-opened
|
||||
header-class="text-primary">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<div class="q-pa-md" style="max-width: 350px; margin: auto">
|
||||
<transition-group
|
||||
name="fade"
|
||||
mode="out-in"
|
||||
appear
|
||||
enter-active-class="animazione fadeIn"
|
||||
leave-active-class="animazione fadeOut"
|
||||
>
|
||||
<q-item
|
||||
v-for="(user, index) in lastsreg"
|
||||
:key="index"
|
||||
class="animated chip_shadow q-ma-sm"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="gotoPage(`/my/${user.username}`)"
|
||||
>
|
||||
<transition-group name="fade" mode="out-in" appear enter-active-class="animazione fadeIn"
|
||||
leave-active-class="animazione fadeOut">
|
||||
<q-item v-for="(user, index) in lastsreg" :key="index" class="animated chip_shadow q-ma-sm"
|
||||
v-ripple clickable @click="gotoPage(`/my/${user.username}`)">
|
||||
<q-item-section avatar>
|
||||
<q-avatar round size="48px">
|
||||
<img :src="userStore.getImgByProfile(user)" />
|
||||
<q-badge
|
||||
v-if="tools.isUserOnline(user)"
|
||||
align="top"
|
||||
floating
|
||||
color="green"
|
||||
>online</q-badge
|
||||
>
|
||||
<q-badge v-if="tools.isUserOnline(user)" align="top" floating color="green">online</q-badge>
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section class="">
|
||||
<q-item-label>
|
||||
{{
|
||||
tools.getNameToShow(user, null, {
|
||||
<span v-html="tools.getNameToShow(user, null, {
|
||||
showprov: true,
|
||||
html: true,
|
||||
})
|
||||
}}
|
||||
"></span>
|
||||
</q-item-label>
|
||||
<q-item-label caption>{{
|
||||
tools.getUserNameOnlyIfToShow(user, null, {
|
||||
showprov: true,
|
||||
<q-item-label caption>
|
||||
<span v-html="tools.getUserNameOnlyIfToShow(user, null, {
|
||||
showprov: false,
|
||||
html: true,
|
||||
})
|
||||
}}</q-item-label>
|
||||
})"></span>
|
||||
</q-item-label>
|
||||
<q-item-label class="iscritto_da">
|
||||
{{ t("statusreg.invite_by") }}:
|
||||
<span class="iscritto_da_name">{{
|
||||
@@ -176,13 +99,8 @@
|
||||
|
||||
<q-separator />
|
||||
|
||||
<q-expansion-item
|
||||
expand-separator
|
||||
group="somegroup"
|
||||
icon="fas fa-medal"
|
||||
:label="$t('statusreg.lastsharedlink')"
|
||||
header-class="text-purple"
|
||||
>
|
||||
<q-expansion-item expand-separator group="somegroup" icon="fas fa-medal"
|
||||
:label="$t('statusreg.lastsharedlink')" header-class="text-purple">
|
||||
<div>
|
||||
<div class="text-center text-bold text-h6">Unisciti a RISO</div>
|
||||
<div class="text-center">
|
||||
@@ -192,36 +110,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<q-item
|
||||
v-for="(user, index) in lastssharedlink"
|
||||
:key="index"
|
||||
class="animated chip_shadow q-ma-sm"
|
||||
clickable
|
||||
v-ripple
|
||||
@click="gotoPage(`/registrati/${user.user_aportador.username}`)"
|
||||
>
|
||||
<q-item v-for="(user, index) in lastssharedlink" :key="index" class="animated chip_shadow q-ma-sm"
|
||||
clickable v-ripple @click="gotoPage(`/registrati/${user.user_aportador.username}`)">
|
||||
<q-item-section avatar>
|
||||
<q-avatar round size="48px">
|
||||
<img
|
||||
:src="userStore.getImgByProfile(user.user_aportador)"
|
||||
/>
|
||||
<img :src="userStore.getImgByProfile(user.user_aportador)" />
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section class="">
|
||||
<q-item-label>
|
||||
{{
|
||||
tools.getNameToShow(user.user_aportador, null, {
|
||||
<span v-html="tools.getNameToShow(user.user_aportador, null, {
|
||||
showprov: true,
|
||||
html: true,
|
||||
})
|
||||
}}
|
||||
"></span>
|
||||
</q-item-label>
|
||||
<q-item-label caption>{{
|
||||
tools.getUserNameOnlyIfToShow(user.user_aportador, null, {
|
||||
showprov: true,
|
||||
<q-item-label caption>
|
||||
<span v-html="tools.getUserNameOnlyIfToShow(user.user_aportador, null, {
|
||||
showprov: false,
|
||||
html: true,
|
||||
})
|
||||
}}</q-item-label>
|
||||
})">
|
||||
</span></q-item-label>
|
||||
<q-item-label class="iscritto_da">
|
||||
{{ t("statusreg.has_invited") }}:
|
||||
<span class="iscritto_da_name">{{
|
||||
@@ -229,75 +138,47 @@
|
||||
}}</span>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side
|
||||
><span class="text-h6 q-mr-sm"></span
|
||||
></q-item-section>
|
||||
<q-item-section side><span class="text-h6 q-mr-sm"></span></q-item-section>
|
||||
</q-item>
|
||||
</q-expansion-item>
|
||||
|
||||
<q-expansion-item
|
||||
group="somegroup"
|
||||
icon="fas fa-wifi"
|
||||
:label="
|
||||
$t('statusreg.onlineusers', { today: datastat.online_today })
|
||||
"
|
||||
header-class="text-teal"
|
||||
>
|
||||
<q-expansion-item group="somegroup" icon="fas fa-wifi" :label="$t('statusreg.onlineusers', { today: datastat.online_today })
|
||||
" header-class="text-teal">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<div class="q-pa-md" style="max-width: 350px; margin: auto">
|
||||
<q-list bordered>
|
||||
<transition-group
|
||||
name="fade"
|
||||
mode="out-in"
|
||||
appear
|
||||
enter-active-class="animazione fadeIn"
|
||||
leave-active-class="animazione fadeOut"
|
||||
>
|
||||
<q-item
|
||||
v-for="(user, index) in lastsonline"
|
||||
:key="index"
|
||||
class="animated chip_shadow q-ma-sm"
|
||||
clickable
|
||||
v-ripple
|
||||
@click="gotoPage(`/my/${user.username}`)"
|
||||
>
|
||||
<transition-group name="fade" mode="out-in" appear enter-active-class="animazione fadeIn"
|
||||
leave-active-class="animazione fadeOut">
|
||||
<q-item v-for="(user, index) in lastsonline" :key="index" class="animated chip_shadow q-ma-sm"
|
||||
clickable v-ripple @click="gotoPage(`/my/${user.username}`)">
|
||||
<q-item-section avatar>
|
||||
<q-avatar round size="48px">
|
||||
<img :src="userStore.getImgByProfile(user)" />
|
||||
<q-badge
|
||||
v-if="tools.isUserOnline(user)"
|
||||
align="top"
|
||||
floating
|
||||
color="green"
|
||||
>online</q-badge
|
||||
>
|
||||
<q-badge v-if="tools.isUserOnline(user)" align="top" floating
|
||||
color="green">online</q-badge>
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section class="">
|
||||
<q-item-label
|
||||
>{{
|
||||
tools.getNameToShow(user, null, {
|
||||
<q-item-label>
|
||||
<span v-html="tools.getNameToShow(user, null, {
|
||||
showprov: true,
|
||||
html: true,
|
||||
})
|
||||
}}
|
||||
"></span>
|
||||
</q-item-label>
|
||||
<q-item-label caption>{{
|
||||
tools.getUserNameOnlyIfToShow(user, null, {
|
||||
showprov: true,
|
||||
showprov: false,
|
||||
html: true,
|
||||
})
|
||||
}}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<div
|
||||
:class="
|
||||
`text-h6 q-mr-sm text-bold ` + $q.dark.isActive
|
||||
<div :class="`text-h6 q-mr-sm text-bold ` + $q.dark.isActive
|
||||
? `text-white`
|
||||
: `text-black`
|
||||
"
|
||||
>
|
||||
">
|
||||
<CTimeAgo :datetime="user.lasttimeonline" />
|
||||
</div>
|
||||
</q-item-section>
|
||||
@@ -311,14 +192,8 @@
|
||||
|
||||
<q-separator />
|
||||
|
||||
<q-expansion-item
|
||||
v-if="false"
|
||||
expand-separator
|
||||
group="somegroup"
|
||||
icon="fas fa-medal"
|
||||
:label="$t('statusreg.diffusori')"
|
||||
header-class="text-purple"
|
||||
>
|
||||
<q-expansion-item v-if="false" expand-separator group="somegroup" icon="fas fa-medal"
|
||||
:label="$t('statusreg.diffusori')" header-class="text-purple">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<div class="q-pa-md" style="max-width: 350px; margin: auto">
|
||||
@@ -330,31 +205,15 @@
|
||||
alla RETE Solidale di RISO.
|
||||
</div>
|
||||
<q-list bordered>
|
||||
<transition-group
|
||||
name="fade"
|
||||
mode="out-in"
|
||||
appear
|
||||
enter-active-class="animazione fadeIn"
|
||||
leave-active-class="animazione fadeOut"
|
||||
>
|
||||
<q-item
|
||||
v-for="(user, index) in diffusorilist"
|
||||
:key="index"
|
||||
class="animated chip_shadow q-ma-sm"
|
||||
clickable
|
||||
v-ripple
|
||||
@click="gotoPage(`/my/${user.username}`)"
|
||||
>
|
||||
<transition-group name="fade" mode="out-in" appear enter-active-class="animazione fadeIn"
|
||||
leave-active-class="animazione fadeOut">
|
||||
<q-item v-for="(user, index) in diffusorilist" :key="index" class="animated chip_shadow q-ma-sm"
|
||||
clickable v-ripple @click="gotoPage(`/my/${user.username}`)">
|
||||
<q-item-section avatar>
|
||||
<q-avatar round size="48px">
|
||||
<img :src="userStore.getImgByProfile(user)" />
|
||||
<q-badge
|
||||
v-if="tools.isUserOnline(user)"
|
||||
align="top"
|
||||
floating
|
||||
color="green"
|
||||
>online</q-badge
|
||||
>
|
||||
<q-badge v-if="tools.isUserOnline(user)" align="top" floating
|
||||
color="green">online</q-badge>
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section class="">
|
||||
@@ -364,30 +223,26 @@
|
||||
</div>
|
||||
</q-item-label>
|
||||
<q-item-label>
|
||||
{{
|
||||
tools.getNameToShow(user, null, {
|
||||
<span v-html="tools.getNameToShow(user, null, {
|
||||
showprov: true,
|
||||
html: true,
|
||||
})
|
||||
}}
|
||||
"></span>
|
||||
</q-item-label>
|
||||
<q-item-label caption>{{
|
||||
tools.getUserNameOnlyIfToShow(user, null, {
|
||||
showprov: true,
|
||||
showprov: false,
|
||||
html: true,
|
||||
})
|
||||
}}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side
|
||||
><div
|
||||
:class="
|
||||
`text-h6 q-mx-sm q-px-sm text-bold ` +
|
||||
<q-item-section side>
|
||||
<div :class="`text-h6 q-mx-sm q-px-sm text-bold ` +
|
||||
($q.dark.isActive ? `text-white` : `text-black`)
|
||||
"
|
||||
>
|
||||
">
|
||||
{{ user.count }}
|
||||
</div></q-item-section
|
||||
>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</transition-group>
|
||||
</q-list>
|
||||
@@ -398,13 +253,8 @@
|
||||
|
||||
<q-separator />
|
||||
|
||||
<q-expansion-item
|
||||
group="somegroup"
|
||||
icon="fas fa-handshake"
|
||||
:label="$t('handshake.last_strettedimano')"
|
||||
header-class="bg-teal text-white"
|
||||
expand-icon-class="text-white"
|
||||
>
|
||||
<q-expansion-item group="somegroup" icon="fas fa-handshake" :label="$t('handshake.last_strettedimano')"
|
||||
header-class="bg-teal text-white" expand-icon-class="text-white">
|
||||
<q-card class="bg-teal-2">
|
||||
<q-card-section>
|
||||
<div class="q-pa-md" style="max-width: 350px; margin: auto">
|
||||
@@ -416,34 +266,15 @@
|
||||
Rete di fiducia.
|
||||
</div>
|
||||
<q-list bordered>
|
||||
<transition-group
|
||||
name="fade"
|
||||
mode="out-in"
|
||||
appear
|
||||
enter-active-class="animazione fadeIn"
|
||||
leave-active-class="animazione fadeOut"
|
||||
>
|
||||
<q-item
|
||||
v-for="(user, index) in strettelist"
|
||||
:key="index"
|
||||
class="animated chip_shadow q-ma-sm"
|
||||
clickable
|
||||
v-ripple
|
||||
>
|
||||
<transition-group name="fade" mode="out-in" appear enter-active-class="animazione fadeIn"
|
||||
leave-active-class="animazione fadeOut">
|
||||
<q-item v-for="(user, index) in strettelist" :key="index" class="animated chip_shadow q-ma-sm"
|
||||
clickable v-ripple>
|
||||
<q-item-section avatar>
|
||||
<q-avatar
|
||||
round
|
||||
size="48px"
|
||||
@click="gotoPage(`/my/${user.username}`)"
|
||||
>
|
||||
<q-avatar round size="48px" @click="gotoPage(`/my/${user.username}`)">
|
||||
<img :src="userStore.getImgByProfile(user)" />
|
||||
<q-badge
|
||||
v-if="tools.isUserOnline(user)"
|
||||
align="top"
|
||||
floating
|
||||
color="green"
|
||||
>online</q-badge
|
||||
>
|
||||
<q-badge v-if="tools.isUserOnline(user)" align="top" floating
|
||||
color="green">online</q-badge>
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section class="">
|
||||
@@ -452,46 +283,31 @@
|
||||
tools.getstrDateTimeLong(
|
||||
user.profile.handshake.date
|
||||
)
|
||||
}}</q-item-label
|
||||
>
|
||||
}}</q-item-label>
|
||||
<q-item-label>
|
||||
{{
|
||||
tools.getNameToShow(user, null, {
|
||||
<span v-html="tools.getNameToShow(user, null, {
|
||||
showprov: true,
|
||||
html: true,
|
||||
})
|
||||
}}
|
||||
"></span>
|
||||
</q-item-label>
|
||||
|
||||
<q-item-label style="text-align: right">
|
||||
{{
|
||||
tools.getNameToShow(user.userfriend, null, {
|
||||
<span v-html="tools.getNameToShow(user.userfriend, null, {
|
||||
showprov: true,
|
||||
html: true,
|
||||
})
|
||||
}}
|
||||
"></span>
|
||||
</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-avatar
|
||||
round
|
||||
size="48px"
|
||||
@click="
|
||||
<q-avatar round size="48px" @click="
|
||||
gotoPage(`/my/${user.userfriend.username}`)
|
||||
"
|
||||
>
|
||||
<img
|
||||
:src="
|
||||
userStore.getImgByProfile(user.userfriend)
|
||||
"
|
||||
/>
|
||||
<q-badge
|
||||
v-if="tools.isUserOnline(user.userfriend)"
|
||||
align="top"
|
||||
floating
|
||||
color="green"
|
||||
>online</q-badge
|
||||
>
|
||||
">
|
||||
<img :src="userStore.getImgByProfile(user.userfriend)
|
||||
" />
|
||||
<q-badge v-if="tools.isUserOnline(user.userfriend)" align="top" floating
|
||||
color="green">online</q-badge>
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
@@ -515,14 +331,8 @@
|
||||
</CListNationality>
|
||||
</div>-->
|
||||
<div class="clBorderTutor">
|
||||
<CLineChart
|
||||
:mydata="datastat.reg_daily"
|
||||
:title="$t('stat.reg_daily')"
|
||||
color="blue"
|
||||
bordercolor="blue"
|
||||
:sum="true"
|
||||
:showMedia="true"
|
||||
>
|
||||
<CLineChart :mydata="datastat.reg_daily" :title="$t('stat.reg_daily')" color="blue" bordercolor="blue"
|
||||
:sum="true" :showMedia="true">
|
||||
</CLineChart>
|
||||
|
||||
<!--<CLineChart :mydata="datastat.reg_daily" :title="$t('stat.reg_total')"
|
||||
|
||||
@@ -4,20 +4,20 @@ import axios, {
|
||||
import { Api } from '@api'
|
||||
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)
|
||||
|
||||
let request
|
||||
if (method === 'GET') request = Api.get(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)
|
||||
else if (method === 'PATCH') request = Api.patch(url, mydata, responsedata)
|
||||
|
||||
// @ts-ignore
|
||||
const req: Promise<Types.AxiosSuccess | Types.AxiosError> = request
|
||||
return req
|
||||
// Funzione che smista la richiesta in base al metodo
|
||||
async function sendRequest(url, method, mydata, myformdata, responsedata, options) {
|
||||
const actions = {
|
||||
get: () => Api.get(url, mydata, responsedata),
|
||||
post: () => Api.post(url, mydata, responsedata, options),
|
||||
postformdata: () => Api.postFormData(url, myformdata, responsedata),
|
||||
delete: () => Api.Delete(url, mydata, responsedata),
|
||||
put: () => Api.put(url, mydata, responsedata),
|
||||
patch: () => Api.patch(url, mydata, responsedata),
|
||||
};
|
||||
const key = method.toLowerCase();
|
||||
if (actions[key]) return await actions[key]();
|
||||
throw new Error(`Metodo non supportato: ${method}`);
|
||||
}
|
||||
|
||||
export default sendRequest
|
||||
|
||||
@@ -111,113 +111,65 @@ function getIterableStream(stream: NodeJS.ReadableStream): AsyncIterable<any> {
|
||||
};
|
||||
}
|
||||
|
||||
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()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
const baseURL = globalStore.getServerHost()
|
||||
|
||||
// Funzione helper per inviare la richiesta HTTP
|
||||
async function Request(type, path, payload, responsedata = {}, options = {}) {
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
const baseURL = globalStore.getServerHost();
|
||||
|
||||
try {
|
||||
if (tools.isDebug()) console.log('Axios Request', path, type, tools.notshowPwd(payload))
|
||||
let response: AxiosResponse
|
||||
const config: AxiosRequestConfig = {
|
||||
if (tools.isDebug()) console.log('Axios Request', path, type, tools.notshowPwd(payload));
|
||||
|
||||
const isFormData = type === 'postFormData';
|
||||
const config = {
|
||||
baseURL,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Type': isFormData ? 'multipart/form-data' : 'application/json',
|
||||
'x-auth': userStore.x_auth_token,
|
||||
'x-refrtok': userStore.refreshToken,
|
||||
},
|
||||
...responsedata,
|
||||
}
|
||||
};
|
||||
|
||||
if (options?.stream) config.responseType = 'stream';
|
||||
|
||||
let response;
|
||||
const method = type.toLowerCase();
|
||||
|
||||
// Gestione dinamica del metodo HTTP
|
||||
if (['post', 'put', 'patch'].includes(method)) {
|
||||
if (options?.stream) {
|
||||
config.responseType = 'stream';
|
||||
}
|
||||
|
||||
if (type === 'post' || type === 'put' || type === 'patch') {
|
||||
|
||||
if (options?.stream) {
|
||||
console.log('GENERATESTREAM...')
|
||||
// Gestione stream (riconosciuta come promise)
|
||||
const stream = await generateStream(path, payload, config, options);
|
||||
console.log('USCITOOOOOOOOOOOOOOOOOOOOO ------------------------')
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const events$: Observable<any> = from(stream);
|
||||
events$
|
||||
from(stream)
|
||||
.pipe(
|
||||
mergeMap((event) => from([event])),
|
||||
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 });
|
||||
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');
|
||||
}
|
||||
() => console.log('Stream completed')
|
||||
);
|
||||
|
||||
});
|
||||
} 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)
|
||||
response = await axiosInstance[method](path, payload, config);
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
} else if (type === 'get' || type === 'delete') {
|
||||
// @ts-ignore
|
||||
response = await axiosInstance[type](path, {
|
||||
} else if (['get', 'delete'].includes(method)) {
|
||||
response = await axiosInstance[method](path, {
|
||||
baseURL,
|
||||
params: payload,
|
||||
headers: {
|
||||
@@ -226,54 +178,58 @@ async function Request(type: string, path: string, payload: any, responsedata?:
|
||||
'x-refrtok': userStore.refreshToken,
|
||||
},
|
||||
...responsedata,
|
||||
})
|
||||
ricevuto = true
|
||||
return new Types.AxiosSuccess(response.data, response.status)
|
||||
});
|
||||
} else if (type === 'postFormData') {
|
||||
console.log('postFormData', payload)
|
||||
response = await axiosInstance.post(path, payload, {
|
||||
baseURL,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
'x-auth': userStore.x_auth_token,
|
||||
'x-refrtok': userStore.refreshToken,
|
||||
},
|
||||
...responsedata,
|
||||
})
|
||||
ricevuto = true
|
||||
return new Types.AxiosSuccess(response.data, response.status)
|
||||
response = await axiosInstance.post(path, payload, config);
|
||||
} else {
|
||||
throw new Error(`Unsupported request type: ${type}`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
|
||||
// Gestione aggiornamento token se necessario
|
||||
const setAuthToken = (path === '/updatepwd' || path === '/users/login');
|
||||
if (response && response.status === 200 && (setAuthToken || path === '/users/login')) {
|
||||
const x_auth_token = String(response.headers['x-auth'] || '');
|
||||
const 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);
|
||||
}
|
||||
|
||||
globalStore.setStateConnection('online');
|
||||
userStore.setServerCode(tools.OK);
|
||||
return new Types.AxiosSuccess(response.data, response.status);
|
||||
} catch (error) {
|
||||
// Aggiornamento asincrono dello stato di connessione (setTimeout per dare tempo a eventuali animazioni)
|
||||
setTimeout(() => {
|
||||
globalStore.connData.uploading_server = (globalStore.connData.uploading_server === 1) ? -1 : globalStore.connData.uploading_server
|
||||
globalStore.connData.downloading_server = (globalStore.connData.downloading_server === 1) ? -1 : globalStore.connData.downloading_server
|
||||
}, 1000)
|
||||
if (['get'].includes(type.toLowerCase())) {
|
||||
globalStore.connData.downloading_server = (globalStore.connData.downloading_server === 1) ? -1 : globalStore.connData.downloading_server;
|
||||
} else {
|
||||
globalStore.connData.uploading_server = (globalStore.connData.uploading_server === 1) ? -1 : globalStore.connData.uploading_server;
|
||||
globalStore.connData.downloading_server = (globalStore.connData.downloading_server === 1) ? -1 : globalStore.connData.downloading_server;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
console.log('ERROR using', path)
|
||||
// console.log('Error received: ', error)
|
||||
// console.log('ricevuto=', ricevuto)
|
||||
console.log('error.response=', error.response)
|
||||
console.log('ERROR using', path);
|
||||
console.log('error.response=', error.response);
|
||||
}
|
||||
let mycode = 0;
|
||||
if (error.response) {
|
||||
const code = error.response.data?.code || 0;
|
||||
mycode = code;
|
||||
userStore.setServerCode(mycode);
|
||||
return Promise.reject(new Types.AxiosError(error.response.status, error.response.data, code));
|
||||
}
|
||||
return Promise.reject(new Types.AxiosError(0, null, mycode, error));
|
||||
}
|
||||
let mycode = 0
|
||||
if (!ricevuto) {
|
||||
mycode = toolsext.ERR_SERVERFETCH
|
||||
userStore.setServerCode(toolsext.ERR_SERVERFETCH)
|
||||
} else {
|
||||
mycode = toolsext.ERR_GENERICO
|
||||
userStore.setServerCode(toolsext.ERR_GENERICO)
|
||||
}
|
||||
|
||||
if (error.response) {
|
||||
let code = 0
|
||||
if (error.response.data && error.response.data.code) {
|
||||
code = error.response.data.code
|
||||
mycode = error.response.data.code
|
||||
userStore.setServerCode(mycode)
|
||||
}
|
||||
return Promise.reject(new Types.AxiosError(error.response.status, error.response.data, code))
|
||||
}
|
||||
return Promise.reject(new Types.AxiosError(0, null, mycode, error))
|
||||
}
|
||||
}
|
||||
export default Request
|
||||
|
||||
@@ -41,43 +41,43 @@ export const Api = {
|
||||
const globalStore = useGlobalStore()
|
||||
globalStore.connData.downloading_server = 1
|
||||
globalStore.connData.uploading_server = 1
|
||||
return Request('post', path, payload, responsedata, options)
|
||||
return await Request('post', path, payload, responsedata, options)
|
||||
},
|
||||
|
||||
async postFormData(path: string, payload?: any, responsedata?: any) {
|
||||
const globalStore = useGlobalStore()
|
||||
globalStore.connData.uploading_server = 1
|
||||
globalStore.connData.downloading_server = 1
|
||||
return Request('postFormData', path, payload, responsedata)
|
||||
return await Request('postFormData', path, payload, responsedata)
|
||||
},
|
||||
|
||||
async get(path: string, payload?: any, responsedata?: any) {
|
||||
const globalStore = useGlobalStore()
|
||||
globalStore.connData.downloading_server = 1
|
||||
globalStore.connData.uploading_server = 0
|
||||
return Request('get', path, payload, responsedata)
|
||||
return await Request('get', path, payload, responsedata)
|
||||
},
|
||||
|
||||
async put(path: string, payload?: any, responsedata?: any) {
|
||||
const globalStore = useGlobalStore()
|
||||
globalStore.connData.uploading_server = 1
|
||||
return Request('put', path, payload, responsedata)
|
||||
return await Request('put', path, payload, responsedata)
|
||||
},
|
||||
|
||||
async patch(path: string, payload?: any, responsedata?: any) {
|
||||
const globalStore = useGlobalStore()
|
||||
globalStore.connData.uploading_server = 1
|
||||
return Request('patch', path, payload, responsedata)
|
||||
return await Request('patch', path, payload, responsedata)
|
||||
},
|
||||
|
||||
async Delete(path: string, payload: any, responsedata?: any) {
|
||||
const globalStore = useGlobalStore()
|
||||
globalStore.connData.uploading_server = 1
|
||||
return Request('delete', path, payload, responsedata)
|
||||
return await Request('delete', path, payload, responsedata)
|
||||
},
|
||||
|
||||
async checkSession({ token, refresh_token }: any) {
|
||||
return axios.post(import.meta.env.VITE_API_URL + Paths.TOKEN_REFRESH, {
|
||||
return await axios.post(import.meta.env.VITE_API_URL + Paths.TOKEN_REFRESH, {
|
||||
refresh_token,
|
||||
}, {
|
||||
headers: {
|
||||
@@ -158,70 +158,61 @@ export const Api = {
|
||||
return null;
|
||||
},
|
||||
|
||||
async SendReqBase(url: string, method: string, mydata: any, setAuthToken = false, evitaloop = false, myformdata?: any, responsedata?: any, options?: any): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
// Base per la chiamata con gestione degli errori e retry
|
||||
async SendReqBase(url, method, mydata, setAuthToken = false, evitaloop = false, myformdata, responsedata, options) {
|
||||
const mydataout = {
|
||||
...mydata,
|
||||
keyappid: import.meta.env.VITE_PAO_APP_ID,
|
||||
idapp: tools.getEnv('VITE_APP_ID'),
|
||||
}
|
||||
};
|
||||
|
||||
const userStore = useUserStore()
|
||||
const globalStore = useGlobalStore()
|
||||
const userStore = useUserStore();
|
||||
const globalStore = useGlobalStore();
|
||||
userStore.setServerCode(tools.EMPTY);
|
||||
userStore.setResStatus(0);
|
||||
|
||||
try {
|
||||
const res = await sendRequest(url, method, mydataout, myformdata, responsedata, options);
|
||||
|
||||
userStore.setServerCode(tools.EMPTY)
|
||||
userStore.setResStatus(0)
|
||||
|
||||
return new Promise((resolve, reject) => sendRequest(url, method, mydataout, myformdata, responsedata, options)
|
||||
.then(async (res) => {
|
||||
// Aggiornamento dello stato della connessione dopo 1 secondo
|
||||
setTimeout(() => {
|
||||
if (method === 'get') {
|
||||
globalStore.connData.downloading_server = 0
|
||||
if (method.toLowerCase() === 'get') {
|
||||
globalStore.connData.downloading_server = 0;
|
||||
} else {
|
||||
globalStore.connData.uploading_server = 0
|
||||
globalStore.connData.downloading_server = 0
|
||||
globalStore.connData.uploading_server = 0;
|
||||
globalStore.connData.downloading_server = 0;
|
||||
}
|
||||
}, 1000)
|
||||
}, 1000);
|
||||
|
||||
if (res.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN) {
|
||||
userStore.setServerCode(toolsext.ERR_AUTHENTICATION);
|
||||
userStore.setAuth('', '');
|
||||
return reject({ code: toolsext.ERR_AUTHENTICATION });
|
||||
throw { code: toolsext.ERR_AUTHENTICATION };
|
||||
}
|
||||
|
||||
const ret = await this.checkTokenScaduto(res.status, evitaloop, resolve, reject, url, method, mydata, setAuthToken);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
// Verifica sul token (funzione custom, che deve restituire un valore se serve un nuovo flusso)
|
||||
const ret = await this.checkTokenScaduto(res.status, evitaloop, res, null, url, method, mydata, setAuthToken);
|
||||
if (ret) return ret;
|
||||
|
||||
if (tools.isDebug())
|
||||
console.log(' ----> ', res)
|
||||
|
||||
return resolve(res)
|
||||
})
|
||||
.catch(async (error) => {
|
||||
if (tools.isDebug()) console.log(' ----> ', res);
|
||||
return res;
|
||||
} catch (error) {
|
||||
setTimeout(() => {
|
||||
if (method === 'get') {
|
||||
globalStore.connData.downloading_server = -1
|
||||
if (method.toLowerCase() === 'get') {
|
||||
globalStore.connData.downloading_server = -1;
|
||||
} else {
|
||||
globalStore.connData.uploading_server = -1
|
||||
globalStore.connData.downloading_server = -1
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
let ret = await this.checkTokenScaduto(error.status, evitaloop, resolve, reject, url, method, mydataout, setAuthToken)
|
||||
if (ret) {
|
||||
return ret
|
||||
} else {
|
||||
ret = await this.checkTokenScaduto(error.status, evitaloop, resolve, reject, url, method, mydataout, setAuthToken)
|
||||
globalStore.connData.uploading_server = -1;
|
||||
globalStore.connData.downloading_server = -1;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
const ret = await this.checkTokenScaduto(error.status, evitaloop, null, error, url, method, mydataout, setAuthToken);
|
||||
if (ret) return ret;
|
||||
console.error('Errore nella richiesta:', error);
|
||||
return reject(error);
|
||||
}))
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Creates a Promise that resolves after a specified number of milliseconds.
|
||||
* Useful for creating delayed operations or pause in async functions.
|
||||
@@ -254,43 +245,17 @@ export const Api = {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
},
|
||||
|
||||
async SendReq(
|
||||
url: string,
|
||||
method: string,
|
||||
mydata: any,
|
||||
setAuthToken = false,
|
||||
evitaloop = false,
|
||||
retryCount = 3,
|
||||
retryDelay = 5000,
|
||||
myformdata?: any,
|
||||
responsedata?: any,
|
||||
options?: any,
|
||||
): Promise<Types.AxiosSuccess | Types.AxiosError> {
|
||||
// Funzione che gestisce la chiamata con retry
|
||||
async SendReq(url, method, mydata, setAuthToken = false, evitaloop = false, retryCount = 3, retryDelay = 5000, myformdata = null, responsedata = null, options = null) {
|
||||
try {
|
||||
const response = await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop, myformdata, responsedata, options);
|
||||
return response;
|
||||
} catch (error: any) {
|
||||
let riprova = true
|
||||
try {
|
||||
riprova = (error.status !== 403);
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
return await this.SendReqBase(url, method, mydata, setAuthToken, evitaloop, myformdata, responsedata, options);
|
||||
} catch (error) {
|
||||
// Se lo status non è 403 e sono rimasti tentativi, eseguo il retry
|
||||
const riprova = error.status !== 403;
|
||||
if (retryCount > 0 && riprova) {
|
||||
// (!error.hasOwnProperty('data') || (error.hasOwnProperty('data') && !error.data.error.hasOwnProperty('code')) && (!error.hasOwnProperty('msgerr')))
|
||||
console.log(`❌❌❌ Retrying request. Attempts remaining: ${retryCount}`);
|
||||
await this.delay(retryDelay);
|
||||
return this.SendReq(
|
||||
url,
|
||||
method,
|
||||
mydata,
|
||||
setAuthToken,
|
||||
evitaloop,
|
||||
retryCount - 1,
|
||||
retryDelay,
|
||||
myformdata,
|
||||
responsedata,
|
||||
);
|
||||
return this.SendReq(url, method, mydata, setAuthToken, evitaloop, retryCount - 1, retryDelay, myformdata, responsedata);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -8289,18 +8289,18 @@ export const tools = {
|
||||
return ''
|
||||
},
|
||||
|
||||
getNameToShow(user: IUserFields, col: any = null): string {
|
||||
getNameToShow(user: IUserFields, col: any = null, options = null): string {
|
||||
const userStore = useUserStore()
|
||||
|
||||
const name = userStore.getNameToShow(user, col)
|
||||
const name = userStore.getNameToShow(user, col, options)
|
||||
|
||||
return name
|
||||
},
|
||||
|
||||
getUserNameOnlyIfToShow(user: IUserFields, col: any = null): string {
|
||||
getUserNameOnlyIfToShow(user: IUserFields, col: any = null, options = null): string {
|
||||
const userStore = useUserStore()
|
||||
|
||||
const name = userStore.getUserNameOnlyIfToShow(user, col)
|
||||
const name = userStore.getUserNameOnlyIfToShow(user, col, options)
|
||||
|
||||
return name
|
||||
},
|
||||
|
||||
@@ -1739,8 +1739,14 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
// calendarStore.editable = false
|
||||
|
||||
return Api.SendReq(`/loadsite/${myuserid}/${tools.getEnv('VITE_APP_ID')}/${import.meta.env.VITE_APP_VERSION}`, 'GET', null)
|
||||
.then((res) => {
|
||||
try {
|
||||
console.log('CHIAMA testpao...')
|
||||
const restest = await Api.SendReq(`/testpao/`, 'GET', null)
|
||||
console.log(' RISULTATO = ', restest)
|
||||
|
||||
const res = await Api.SendReq(`/loadsite/${myuserid}/${tools.getEnv('VITE_APP_ID')}/${import.meta.env.VITE_APP_VERSION}`, 'GET', null)
|
||||
if (res.status === 200) {
|
||||
|
||||
console.log('____________________________ res', res)
|
||||
this.serverError = false
|
||||
if (res.status === 200) {
|
||||
@@ -1874,7 +1880,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
}
|
||||
|
||||
return true
|
||||
}).then((res) => res).catch((error) => {
|
||||
} else {
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_TOKEN_EXPIRED) {
|
||||
|
||||
}
|
||||
@@ -1883,7 +1891,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
this.serverError = true
|
||||
this.serverMsgError = error
|
||||
return new Types.AxiosError(serv_constants.RIS_CODE_ERR, null, toolsext.ERR_GENERICO, error)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
getProvinceByProv(provstr: string) {
|
||||
|
||||
Reference in New Issue
Block a user