From d5831e3dbfe8fbe2da51de063c31d8bd38ad44d2 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Thu, 2 Feb 2023 02:31:09 +0100 Subject: [PATCH] ver: 0.5.62 Conti Collettivi visibili solo se sei admin... --- .env.development | 2 +- .env.example.production | 2 +- _ALL_SITES/riso.app/.env.development | 2 +- _ALL_SITES/riso.app/.env.production | 2 +- .../terradellavisione.app/.env.development | 2 +- src/components/CSendCoins/CSendCoins.ts | 155 ++++++++++++------ src/components/CSendCoins/CSendCoins.vue | 57 +++++-- src/statics/lang/it.js | 2 +- src/store/Modules/tools.ts | 23 +++ src/store/NotifStore.ts | 1 + src/store/UserStore.ts | 19 ++- src/views/user/mycircuit/mycircuit.ts | 9 +- src/views/user/mycircuit/mycircuit.vue | 1 + 13 files changed, 196 insertions(+), 81 deletions(-) diff --git a/.env.development b/.env.development index fcc0fd2d..4327e51b 100755 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="0.5.61" +APP_VERSION="0.5.62" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL="newfreeplanet" diff --git a/.env.example.production b/.env.example.production index aff48d4d..09b41ead 100755 --- a/.env.example.production +++ b/.env.example.production @@ -1,4 +1,4 @@ -APP_VERSION="0.5.61" +APP_VERSION="0.5.62" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/riso.app/.env.development b/_ALL_SITES/riso.app/.env.development index fcc0fd2d..4327e51b 100755 --- a/_ALL_SITES/riso.app/.env.development +++ b/_ALL_SITES/riso.app/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="0.5.61" +APP_VERSION="0.5.62" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL="newfreeplanet" diff --git a/_ALL_SITES/riso.app/.env.production b/_ALL_SITES/riso.app/.env.production index 39933cbe..4cc04575 100644 --- a/_ALL_SITES/riso.app/.env.production +++ b/_ALL_SITES/riso.app/.env.production @@ -1,4 +1,4 @@ -APP_VERSION="0.5.61" +APP_VERSION="0.5.62" SERVICE_WORKER_FILE="service-worker.js" APP_ID="13" DIRECTORY_LOCAL=newfreeplanet diff --git a/_ALL_SITES/terradellavisione.app/.env.development b/_ALL_SITES/terradellavisione.app/.env.development index 3d315b35..1e07bbe1 100755 --- a/_ALL_SITES/terradellavisione.app/.env.development +++ b/_ALL_SITES/terradellavisione.app/.env.development @@ -1,4 +1,4 @@ -APP_VERSION="0.5.61" +APP_VERSION="0.5.62" SERVICE_WORKER_FILE="service-worker.js" APP_ID="14" DIRECTORY_LOCAL="newfreeplanet" diff --git a/src/components/CSendCoins/CSendCoins.ts b/src/components/CSendCoins/CSendCoins.ts index a5279769..c5e75d09 100755 --- a/src/components/CSendCoins/CSendCoins.ts +++ b/src/components/CSendCoins/CSendCoins.ts @@ -38,11 +38,6 @@ export default defineComponent({ required: false, default: null, }, - from_contocom: { - type: String, - required: false, - default: '', - }, to_contocom: { type: String, required: false, @@ -65,20 +60,29 @@ export default defineComponent({ const from_username = ref(userStore.my.username) const from_groupname = ref('') + const from_contocom = ref('') const circuitsel = ref('') const qty = ref('') const causal = ref('') + const loading = ref(false) const bothcircuits = ref([]) const groupSel = ref(null) - const circuitloaded = ref(undefined) + const circuittoload = ref(undefined) + const circuitloaded = ref({}) const circuitdest = ref(undefined) const accountloaded = ref(undefined) const accountdest = ref(undefined) const remainingCoins = ref(0) const maxsendable = ref(0) const numstep = ref(0) + const arrTypesAccounts = ref([ + { + label: t('circuit.user'), + value: costanti.AccountType.USER, + }, + ]) const tipoConto = ref(costanti.AccountType.USER) const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '') @@ -113,68 +117,112 @@ export default defineComponent({ show.value = newval }) - function aggiorna() { + async function aggiorna() { + loading.value = true groupSel.value = null + from_contocom.value = '' accountloaded.value = null - circuitloaded.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value) - if (circuitloaded.value) { - if (tipoConto.value === costanti.AccountType.USER) { - accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id) - } else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) { - groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname) - accountloaded.value = groupSel.value ? groupSel.value.account : null - } else if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) { - groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname) - accountloaded.value = groupSel.value ? groupSel.value.account : null - } + circuittoload.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value) + if (circuittoload.value) { + await userStore.loadCircuit(circuittoload.value.path, '').then(({ data, status }: { data: any, status: number }) => { + try { + arrTypesAccounts.value = [ + { + label: t('circuit.user'), + value: costanti.AccountType.USER, + }, + ] - groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin() - arrGroupsList.value = [] + if (!!data.circuit) { + circuitloaded.value = data.circuit - for (const group of groupsListAdmin.value) { - arrGroupsList.value.push({ label: group.groupname, value: group.groupname }); - } + if (tipoConto.value === costanti.AccountType.USER) { + accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id) + } else if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) { + groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname) - if (tools.iAmAdminCircuit(circuitloaded.value.name)) - arrGroupsList.value.push({ label: circuitloaded.value.name, value: circuitloaded.value.path }); + accountloaded.value = groupSel.value ? groupSel.value.account : null + } else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) { + from_contocom.value = circuitloaded.value.path + accountloaded.value = circuitloaded.value ? circuitloaded.value.account : null + } - // accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id) - if (accountloaded.value) { - remainingCoins.value = circuitStore.getRemainingCoinsToSend(accountloaded.value) - if (accountloaded.value.saldo > 0) { - maxsendable.value = accountloaded.value.saldo + accountloaded.value.fidoConcesso - } else { - maxsendable.value = accountloaded.value.fidoConcesso - } + groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin(circuitloaded.value.name) + console.log('groupsListAdmin.value', groupsListAdmin.value) - if (remainingCoins.value < 10) { - remainingCoins.value = 10 - } + arrGroupsList.value = [] - numstep.value = Math.round(maxsendable.value / 10) - if (numstep.value < 1) { - numstep.value = 1 - } + if (groupsListAdmin.value) { + for (const group of groupsListAdmin.value) { + arrGroupsList.value.push({ label: group.groupname, value: group.groupname }); + } + } - const quanti = [...Array(20).keys()].map(i => i + 1) - for (const ind of quanti) { - let valuenorm = ind * numstep.value - let value = ind * numstep.value - if (value > remainingCoins.value) { - break - } else { - const label = valuenorm.toString() - arrayMarkerLabel.value.push({ value, label }) + if (arrGroupsList.value.length > 0) { + arrTypesAccounts.value.push( + { + label: t('circuit.conticollettivi'), + value: costanti.AccountType.COLLECTIVE_ACCOUNT, + }) + } + + if (tools.iCanSendCoinsSuperUserCircuit(circuitsel.value)) { + arrTypesAccounts.value.push({ + label: t('circuit.contocom'), + value: costanti.AccountType.COMMUNITY_ACCOUNT, + }) + } + + // if (tools.iAmAdminCircuit(circuitloaded.value.name)) + // arrGroupsList.value.push({ label: circuitloaded.value.name, value: circuitloaded.value.path }); + + // accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id) + if (accountloaded.value) { + remainingCoins.value = circuitStore.getRemainingCoinsToSend(accountloaded.value) + if (accountloaded.value.saldo > 0) { + maxsendable.value = accountloaded.value.saldo + accountloaded.value.fidoConcesso + } else { + maxsendable.value = accountloaded.value.fidoConcesso + } + + if (remainingCoins.value < 10) { + remainingCoins.value = 10 + } + + numstep.value = Math.round(maxsendable.value / 10) + if (numstep.value < 1) { + numstep.value = 1 + } + + const quanti = [...Array(20).keys()].map(i => i + 1) + for (const ind of quanti) { + let valuenorm = ind * numstep.value + let value = ind * numstep.value + if (value > remainingCoins.value) { + break + } else { + const label = valuenorm.toString() + arrayMarkerLabel.value.push({ value, label }) + } + } + } } + } finally { + loading.value = false } - } - + }) } } function mounted() { + arrTypesAccounts.value = [ + { + label: t('circuit.user'), + value: costanti.AccountType.USER, + }, + ] // .... if (props.to_user) { @@ -255,7 +303,7 @@ export default defineComponent({ myrecsendcoin.groupdest = props.to_group ? props.to_group.groupname : '' myrecsendcoin.contoComDest = props.to_contocom myrecsendcoin.grouporig = tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT ? from_groupname.value : '' - myrecsendcoin.contoComOrig = tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT ? props.from_contocom : '' + myrecsendcoin.contoComOrig = tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT ? from_contocom.value : '' myrecsendcoin.dest = props.to_user ? props.to_user.username : '' @@ -302,6 +350,9 @@ export default defineComponent({ tipoConto, arrGroupsList, from_groupname, + from_contocom, + arrTypesAccounts, + loading, } }, }) diff --git a/src/components/CSendCoins/CSendCoins.vue b/src/components/CSendCoins/CSendCoins.vue index 45413bb9..9f264654 100755 --- a/src/components/CSendCoins/CSendCoins.vue +++ b/src/components/CSendCoins/CSendCoins.vue @@ -32,7 +32,7 @@ style="text-align: center" >
- {{$t('circuit.sender')}}: + {{ $t('circuit.sender') }}:
-
+
+
+ + +
- {{$t('circuit.dest')}} + {{ $t('circuit.dest') }}
@@ -115,13 +122,17 @@ + + + +
{ + if (circuit.name === circuitname) { + return true + } + }) + // console.log('ris', ris) + if (ris && ris.admins) { + const isadmin = ris.admins.find((user: IFriends) => user.username === userStore.my.username) + risultato = !!isadmin + } + + } + + return risultato + + }, + iAmPartOfThisGroup(grp: IMyGroup) { const userStore = useUserStore() return userStore.my.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0 diff --git a/src/store/NotifStore.ts b/src/store/NotifStore.ts index 792116ab..ee1b1c7c 100755 --- a/src/store/NotifStore.ts +++ b/src/store/NotifStore.ts @@ -85,6 +85,7 @@ export const useNotifStore = defineStore('NotifStore', { } }, updateArrRecNotifFromServer(arrrecnotif: INotif[]) { + console.log('arrrecnotif', arrrecnotif) if (arrrecnotif && arrrecnotif.length > 0) { this.last_notifs = arrrecnotif diff --git a/src/store/UserStore.ts b/src/store/UserStore.ts index 46b3b618..e5457ac4 100755 --- a/src/store/UserStore.ts +++ b/src/store/UserStore.ts @@ -254,8 +254,15 @@ export const useUserStore = defineStore('UserStore', { } }, - GroupsListWhereIAmAdmin(): IMyGroup[] { - return this.my.profile.manage_mygroups + GroupsListWhereIAmAdmin(circuitname: string): any { + console.log('GL', circuitname) + try { + const arr: any = this.my.profile.manage_mygroups.filter((group: IMyGroup) => (group.mycircuits!.findIndex((circ: IMyCircuit) => circ.circuitname === circuitname) >= 0)) + console.log('arr', arr) + return arr + } catch (e) { + return [] + } }, hoContiCollettiviDaAmministrare(): boolean { @@ -1288,13 +1295,21 @@ export const useUserStore = defineStore('UserStore', { }, async loadCircuit(path: string, idnotif: string) { + const notifStore = useNotifStore() const data = { path, idnotif, + lastdr: notifStore.getLastDataRead(this.my.username), } return Api.SendReq('/circuit/load', 'POST', data) .then((res) => { + if (res && res.data.arrrecnotif) { + notifStore.updateArrRecNotifFromServer(res.data.arrrecnotif) + } + if (res.data.useraccounts && res.data.useraccounts.length > 0) { + this.my.profile.useraccounts = res.data.useraccounts + } return { data: res.data, status: res.status } }).catch((error) => { return { data: null, status: error.status } diff --git a/src/views/user/mycircuit/mycircuit.ts b/src/views/user/mycircuit/mycircuit.ts index 66f3bfe6..3e405d89 100755 --- a/src/views/user/mycircuit/mycircuit.ts +++ b/src/views/user/mycircuit/mycircuit.ts @@ -101,8 +101,6 @@ export default defineComponent({ async function loadCircuit() { - tabcircuit.value = tools.getCookie(tools.COOK_TAB_CIRCUIT + path.value, 'info') - loading.value = true // Carica il profilo di quest'utente if (path.value) { @@ -285,10 +283,12 @@ export default defineComponent({ } async function mounted() { + tabcircuit.value = tools.getCookie(tools.COOK_TAB_CIRCUIT + path.value, 'info') + await loadCircuit() - if (userStore.my.username) - groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin() + if (userStore.my.username && circuit.value) + groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin(circuit.value.name) } @@ -457,6 +457,7 @@ export default defineComponent({ groupnameSel, showsendCoinTo, showrules, + loadCircuit, } } }) diff --git a/src/views/user/mycircuit/mycircuit.vue b/src/views/user/mycircuit/mycircuit.vue index d0369ea7..795109fa 100755 --- a/src/views/user/mycircuit/mycircuit.vue +++ b/src/views/user/mycircuit/mycircuit.vue @@ -207,6 +207,7 @@ :label="t('shared.info1')" name="info" icon="fas fa-info" + @click="loadCircuit()" >