- Migliorata la Notifica degli Eventi su Telegram

- Gli annunci (beni/servizi/ospitalità) ora possono essere visti anche tramite un link, anche per chi non è dentro alla App.
- Aggiunto bottone "Aggiorna" per aggiornare il Saldo attuale.
- I "Conti Collettivi" ora vengono chiamati Gruppi (o Conto di Gruppo).
This commit is contained in:
Surya Paolo
2023-10-01 01:24:55 +02:00
parent bfceb64811
commit 31598e3fbd
43 changed files with 784 additions and 515 deletions

View File

@@ -51,22 +51,26 @@ export default defineComponent({
const showsendCoinTo = ref(false)
const showrules = ref(false)
const showMov = ref(false)
const animation = ref('fade')
const path = computed(() => $route.params.path ? $route.params.path.toString() : '')
const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '')
const circuitpath_loaded = ref('')
const filtroutente = ref([] as any[])
const showPic = ref(false)
const loadSaldo = ref(false)
const circuit = ref({} as ICircuit | null)
const account = computed(() => circuit.value ? userStore.getAccountByCircuitId(circuit.value._id) : null)
const account = ref(<IAccount | null>null)
const mystatus = ref(0 as number)
const users_in_circuit = ref([] as IFriends[])
const qtarem = computed(() => account.value ? circuitStore.getRemainingCoinsToSend(account.value) : 0)
const saldo = computed(() => account.value ? account.value.saldo : 0)
const qtarem = ref(0)
const saldo = ref(0)
const loading = ref(false)
const requestToEnterCircuit = ref(false)
@@ -86,215 +90,240 @@ export default defineComponent({
const cities = ref([] as ICity[])
const fidoConcesso = computed(() => account.value ? account.value.fidoConcesso : circuit.value!.fido_scoperto_default)
const qtaMax = computed(() => account.value ? account.value.qta_maxConcessa : circuit.value!.qta_max_default)
const fidoConcesso = ref(<any>0)
const qtaMax = ref(<any>0)
watch(() => path.value, (to: any, from: any) => {
loadCircuit()
if (circuitpath_loaded.value !== path.value)
loadCircuit()
})
watch(() => tabcircuit.value, (to: any, from: any) => {
tools.setCookie(tools.COOK_TAB_CIRCUIT + path.value, tabcircuit.value)
})
watch(() => circuit.value, (to: any, from: any) => {
if (to) {
loadAccount()
}
})
function loadAccount() {
// console.log('loadAccount')
account.value = circuit.value ? userStore.getAccountByCircuitId(circuit.value._id) : null
// console.log('saldo', account.value!.saldo)
fidoConcesso.value = account.value ? account.value.fidoConcesso : (circuit.value ? circuit.value.fido_scoperto_default : 0)
qtaMax.value = account.value ? account.value.qta_maxConcessa : (circuit.value ? circuit.value.qta_max_default : 0)
qtarem.value = account.value ? circuitStore.getRemainingCoinsToSend(account.value) : 0
saldo.value = account.value ? account.value.saldo : 0
}
function profile() {
return userStore.my.profile
}
async function loadCircuit() {
console.log(' *** INIZIO loadCircuit')
loading.value = true
// Carica il profilo di quest'utente
if (path.value) {
circuit.value = null
users_in_circuit.value = []
await userStore.loadCircuit(path.value, idnotif.value).then(({ data, status }: { data: any, status: number }) => {
console.log('data', data)
if (data) {
notifStore.setAsRead(idnotif.value)
users_in_circuit.value = data.users_in_circuit
circuit.value = data.circuit
} else {
circuit.value = null
users_in_circuit.value = []
}
if (!loading.value) {
loading.value = true
// Carica il profilo di quest'utente
if (path.value) {
circuitpath_loaded.value = path.value
circuit.value = null
users_in_circuit.value = []
await userStore.loadCircuit(path.value, idnotif.value).then(({ data, status }: { data: any, status: number }) => {
// console.log('data', data)
if (data) {
notifStore.setAsRead(idnotif.value)
users_in_circuit.value = data.users_in_circuit
circuit.value = data.circuit
} else {
circuit.value = null
users_in_circuit.value = []
}
mystatus.value = status
loadAccount()
searchList.value = []
if (circuit.value) {
let addquerysingle = [
mystatus.value = status
];
searchList.value = []
if (circuit.value) {
let addquerysingle = [
filterextra.value = [{
$match: {
idapp: process.env.APP_ID,
'profile.mycircuits': {
$elemMatch: { circuitname: { $eq: circuit.value.name } },
];
filterextra.value = [{
$match: {
idapp: process.env.APP_ID,
'profile.mycircuits': {
$elemMatch: { circuitname: { $eq: circuit.value.name } },
},
},
},
},
{
$lookup: {
from: 'circuits',
as: 'circuit',
let: { circuitname: circuit.value.name, idapp: '$idapp' },
pipeline: [
{
$match:
{
$lookup: {
from: 'circuits',
as: 'circuit',
let: { circuitname: circuit.value.name, idapp: '$idapp' },
pipeline: [
{
$expr:
$match:
{
$and:
[
{ $eq: ['$name', '$$circuitname'] },
{ $eq: ['$idapp', '$$idapp'] },
$expr:
{
$and:
[
{ $eq: ['$name', '$$circuitname'] },
{ $eq: ['$idapp', '$$idapp'] },
],
],
},
},
},
},
],
],
},
},
{ $unwind: '$circuit' },
{
$project: {
username: 1,
name: 1,
surname: 1,
date_reg: 1,
profile: 1, idapp: 1, 'circuit.name': 1, 'circuit._id': 1
}
},
},
{ $unwind: '$circuit' },
{
$project: {
username: 1,
name: 1,
surname: 1,
date_reg: 1,
profile: 1, idapp: 1, 'circuit.name': 1, 'circuit._id': 1
}
},
{
$lookup: {
from: 'accounts',
as: 'account',
let: { username: '$username', idapp: '$idapp', circuitId: '$circuit._id' },
pipeline: [
{
$match:
{
$lookup: {
from: 'accounts',
as: 'account',
let: { username: '$username', idapp: '$idapp', circuitId: '$circuit._id' },
pipeline: [
{
$expr:
$match:
{
$and:
[
{ $eq: ['$$username', '$username'] },
{ $eq: ['$$idapp', '$idapp'] },
{ $eq: ['$$circuitId', '$circuitId'] },
],
$expr:
{
$and:
[
{ $eq: ['$$username', '$username'] },
{ $eq: ['$$idapp', '$idapp'] },
{ $eq: ['$$circuitId', '$circuitId'] },
],
},
},
},
},
],
},
},
{ $unwind: '$account' },
]
filterextra_group.value = [{
$match: {
idapp: process.env.APP_ID,
'mycircuits': {
$elemMatch: { circuitname: { $eq: circuit.value.name } },
],
},
},
},
{ $unwind: '$account' },
]
{
$lookup: {
from: 'circuits',
as: 'circuit',
let: { circuitname: circuit.value.name, idapp: '$idapp' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$name', '$$circuitname'] },
{ $eq: ['$idapp', '$$idapp'] },
],
},
},
filterextra_group.value = [{
$match: {
idapp: process.env.APP_ID,
'mycircuits': {
$elemMatch: { circuitname: { $eq: circuit.value.name } },
},
],
},
},
},
{ $unwind: '$circuit' },
{
$project: {
groupname: 1,
title: 1,
descr: 1,
photos: 1,
surname: 1,
admins: 1,
idapp: 1,
'circuit.name': 1, 'circuit._id': 1
}
},
{
$lookup: {
from: 'accounts',
as: 'account',
let: { groupname: '$groupname', idapp: '$idapp', circuitId: '$circuit._id' },
pipeline: [
{
$match:
{
$lookup: {
from: 'circuits',
as: 'circuit',
let: { circuitname: circuit.value.name, idapp: '$idapp' },
pipeline: [
{
$expr:
$match:
{
$and:
[
{ $eq: ['$groupname', '$$groupname'] },
{ $eq: ['$idapp', '$$idapp'] },
{ $eq: ['$circuitId', '$$circuitId'] },
$expr:
{
$and:
[
{ $eq: ['$name', '$$circuitname'] },
{ $eq: ['$idapp', '$$idapp'] },
],
],
},
},
},
},
],
],
},
},
{ $unwind: '$circuit' },
{
$project: {
groupname: 1,
title: 1,
descr: 1,
photos: 1,
surname: 1,
admins: 1,
idapp: 1,
'circuit.name': 1, 'circuit._id': 1
}
},
{
$lookup: {
from: 'accounts',
as: 'account',
let: { groupname: '$groupname', idapp: '$idapp', circuitId: '$circuit._id' },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$groupname', '$$groupname'] },
{ $eq: ['$idapp', '$$idapp'] },
{ $eq: ['$circuitId', '$$circuitId'] },
},
{
$unwind: '$account',
},
{
$match: { 'account.groupname': { $exists: true, $ne: '' } }
},
]
}
arrfilterand.value = []
filtercustom_rich.value = []
],
},
},
},
],
},
if (userStore.my.username && circuit.value)
groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin()
},
{
$unwind: '$account',
},
{
$match: { 'account.groupname': { $exists: true, $ne: '' } }
},
]
}
arrfilterand.value = []
filtercustom_rich.value = []
// filtroutente.value = [{ userId: userStore.my._id }]
})
if (userStore.my.username && circuit.value)
groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin()
// filtroutente.value = [{ userId: userStore.my._id }]
})
}
loading.value = false
console.log(' ___ FINE loadCircuit')
}
loading.value = false
}
async function mounted() {
function mounted() {
tabcircuit.value = tools.getCookie(tools.COOK_TAB_CIRCUIT + path.value, 'info')
await loadCircuit()
loadCircuit()
}
@@ -329,6 +358,7 @@ export default defineComponent({
username: 1,
name: 1,
surname: 1,
lang: 1,
'profile.img': 1,
'profile.mycircuits': 1,
'profile.qualifica': 1,
@@ -430,7 +460,7 @@ export default defineComponent({
function getRegulation(reg: string) {
let strreg = reg + ''
if (!reg) {
const mystringa = t('circuit.regolamento', {nomecircuito: circuit.value!.name})
const mystringa = t('circuit.regolamento', { nomecircuito: circuit.value!.name })
return mystringa
} else {
return reg
@@ -438,6 +468,13 @@ export default defineComponent({
}
async function aggiornaSaldo() {
loadSaldo.value = true
await circuitStore.aggiornaSaldo(circuit.value!._id);
loadAccount()
loadSaldo.value = false
}
onMounted(mounted)
return {
@@ -500,6 +537,10 @@ export default defineComponent({
getRegulation,
fidoConcesso,
qtaMax,
showMov,
loadAccount,
aggiornaSaldo,
loadSaldo,
}
}
})