2022-01-03 21:53:41 +01:00
|
|
|
import { CMyFieldDb } from '@/components/CMyFieldDb'
|
2022-02-21 13:12:04 +01:00
|
|
|
import { CMyFieldRec } from '@/components/CMyFieldRec'
|
2022-01-03 21:53:41 +01:00
|
|
|
import { CTitleBanner } from '@/components/CTitleBanner'
|
|
|
|
|
import { CProfile } from '@/components/CProfile'
|
2022-02-24 23:36:27 +01:00
|
|
|
import { CLabel } from '@/components/CLabel'
|
2022-02-12 17:02:10 +01:00
|
|
|
import { CCopyBtn } from '@/components/CCopyBtn'
|
2022-01-03 21:53:41 +01:00
|
|
|
import { CSkill } from '@/components/CSkill'
|
|
|
|
|
import { CDateTime } from '@/components/CDateTime'
|
2022-06-16 20:34:17 +02:00
|
|
|
import { CMyGroup } from '@/components/CMyGroup'
|
2022-09-02 02:25:17 +02:00
|
|
|
import { CMyCircuit } from '@/components/CMyCircuit'
|
2022-09-14 11:31:48 +02:00
|
|
|
import { CNotifAtTop } from '@src/components/CNotifAtTop'
|
2022-09-03 13:06:35 +02:00
|
|
|
import { CSendCoins } from '@/components/CSendCoins'
|
2022-08-18 05:26:21 +02:00
|
|
|
import { CMyUser } from '@/components/CMyUser'
|
2022-02-14 10:25:09 +01:00
|
|
|
import { CUserNonVerif } from '@/components/CUserNonVerif'
|
2022-01-03 21:53:41 +01:00
|
|
|
import { tools } from '@store/Modules/tools'
|
|
|
|
|
import { computed, defineComponent, onMounted, ref, watch } from 'vue'
|
|
|
|
|
import { useUserStore } from '@store/UserStore'
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
import { useGlobalStore } from '@store/globalStore'
|
|
|
|
|
import { useI18n } from '@/boot/i18n'
|
|
|
|
|
import { toolsext } from '@store/Modules/toolsext'
|
|
|
|
|
import { useQuasar } from 'quasar'
|
|
|
|
|
import { costanti } from '@costanti'
|
2022-09-02 02:25:17 +02:00
|
|
|
import { ICircuit, IMyCircuit, IMyGroup, IUserFields } from 'model'
|
2022-01-16 23:20:46 +01:00
|
|
|
import { shared_consts } from '@/common/shared_vuejs'
|
2022-02-08 23:06:22 +01:00
|
|
|
import { static_data } from '@/db/static_data'
|
2022-02-19 22:02:54 +01:00
|
|
|
import { fieldsTable } from '@store/Modules/fieldsTable'
|
2022-07-21 00:20:48 +02:00
|
|
|
import { useNotifStore } from '@store/NotifStore'
|
2022-02-12 17:02:10 +01:00
|
|
|
import MixinUsers from '@/mixins/mixin-users'
|
2022-01-03 21:53:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
2022-02-03 00:33:05 +01:00
|
|
|
name: 'myprofile',
|
2022-06-16 20:34:17 +02:00
|
|
|
components: {
|
2022-08-18 05:26:21 +02:00
|
|
|
CProfile, CTitleBanner, CMyFieldDb, CSkill, CDateTime, CCopyBtn, CUserNonVerif, CMyFieldRec, CMyUser,
|
2022-09-14 11:31:48 +02:00
|
|
|
CMyGroup, CLabel, CMyCircuit, CSendCoins, CNotifAtTop
|
2022-06-16 20:34:17 +02:00
|
|
|
},
|
2022-01-03 21:53:41 +01:00
|
|
|
props: {},
|
|
|
|
|
setup() {
|
|
|
|
|
const userStore = useUserStore()
|
2022-06-16 20:34:17 +02:00
|
|
|
const globalStore = useGlobalStore()
|
2022-01-03 21:53:41 +01:00
|
|
|
const $route = useRoute()
|
2022-01-16 23:20:46 +01:00
|
|
|
const $q = useQuasar()
|
2022-01-03 21:53:41 +01:00
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
2022-02-12 17:02:10 +01:00
|
|
|
const { getRefLink } = MixinUsers()
|
|
|
|
|
|
2022-01-20 00:38:49 +01:00
|
|
|
const animation = ref('fade')
|
|
|
|
|
|
2022-01-07 01:16:46 +01:00
|
|
|
const username = computed(() => $route.params.username ? $route.params.username.toString() : userStore.my.username)
|
2022-07-21 00:20:48 +02:00
|
|
|
const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '')
|
2022-01-03 21:53:41 +01:00
|
|
|
|
|
|
|
|
const filtroutente = ref(<any[]>[])
|
|
|
|
|
const showPic = ref(false)
|
2022-06-16 20:34:17 +02:00
|
|
|
const caricato = ref(false)
|
2022-09-03 13:06:35 +02:00
|
|
|
const showsendCoinTo = ref(false)
|
2022-01-03 21:53:41 +01:00
|
|
|
|
2022-06-16 20:34:17 +02:00
|
|
|
const myuser = ref(<IUserFields | null>null)
|
2022-01-03 21:53:41 +01:00
|
|
|
|
2022-02-28 17:42:51 +01:00
|
|
|
const actualcard = ref('mygoods')
|
|
|
|
|
|
2022-07-21 00:20:48 +02:00
|
|
|
const notifStore = useNotifStore()
|
|
|
|
|
|
2022-02-28 17:42:51 +01:00
|
|
|
const mycards = computed(() => {
|
|
|
|
|
return costanti.MAINCARDS.filter((rec: any) => rec.table)
|
|
|
|
|
})
|
|
|
|
|
|
2022-06-16 20:34:17 +02:00
|
|
|
const listgroupsfiltered = ref(<IMyGroup[]>[])
|
2022-09-02 02:25:17 +02:00
|
|
|
const listcircuitsfiltered = ref(<IMyCircuit[]>[])
|
2022-06-16 20:34:17 +02:00
|
|
|
|
2022-02-28 17:42:51 +01:00
|
|
|
|
2022-01-03 21:53:41 +01:00
|
|
|
function profile() {
|
|
|
|
|
return userStore.my.profile
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-07 01:16:46 +01:00
|
|
|
function myusername() {
|
|
|
|
|
return userStore.my.username
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-16 20:34:17 +02:00
|
|
|
async function loadProfile() {
|
2022-09-16 17:39:28 +02:00
|
|
|
console.log('loadProfile...', username.value)
|
|
|
|
|
try {
|
|
|
|
|
// Carica il profilo di quest'utente
|
|
|
|
|
if (username.value) {
|
|
|
|
|
await userStore.loadUserProfile({ username: username.value, idnotif: idnotif.value }).then((ris) => {
|
|
|
|
|
console.log('loadUserProfile = ', ris)
|
|
|
|
|
myuser.value = ris
|
|
|
|
|
if (myuser.value) {
|
|
|
|
|
filtroutente.value = [{ userId: myuser.value._id }]
|
|
|
|
|
notifStore.setAsRead(idnotif.value)
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
listgroupsfiltered.value = globalStore.mygroups.filter((grp: IMyGroup) => myuser.value!.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
listgroupsfiltered.value = []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
listcircuitsfiltered.value = myuser.value.profile.mycircuits
|
|
|
|
|
} catch (e) {
|
|
|
|
|
listcircuitsfiltered.value = []
|
|
|
|
|
}
|
2022-06-16 20:34:17 +02:00
|
|
|
|
2022-09-02 02:25:17 +02:00
|
|
|
}
|
2022-09-16 17:39:28 +02:00
|
|
|
})
|
2022-09-02 02:25:17 +02:00
|
|
|
|
2022-09-16 17:39:28 +02:00
|
|
|
}
|
|
|
|
|
caricato.value = true
|
|
|
|
|
}catch (e) {
|
|
|
|
|
console.error('ERR loadProfile', e)
|
2022-01-03 21:53:41 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-07 01:16:46 +01:00
|
|
|
watch(() => username.value, (to: any, from: any) => {
|
2022-01-03 21:53:41 +01:00
|
|
|
loadProfile()
|
|
|
|
|
})
|
|
|
|
|
|
2022-06-16 20:34:17 +02:00
|
|
|
watch(() => actualcard.value, (to: any, from: any) => {
|
|
|
|
|
loadProfile()
|
|
|
|
|
})
|
|
|
|
|
|
2022-01-03 21:53:41 +01:00
|
|
|
function mounted() {
|
|
|
|
|
loadProfile()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getImgUser() {
|
2022-06-16 20:34:17 +02:00
|
|
|
if (myuser.value)
|
|
|
|
|
return userStore.getImgByProfile(myuser.value)
|
|
|
|
|
else
|
|
|
|
|
return ''
|
2022-01-03 21:53:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkifShow(col: string) {
|
|
|
|
|
//++Todo: checkifShow Permessi !
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getLinkUserTelegram() {
|
|
|
|
|
|
2022-06-16 20:34:17 +02:00
|
|
|
if (myuser.value) {
|
|
|
|
|
if (!!myuser.value.profile.username_telegram) {
|
|
|
|
|
return 'https://t.me/' + myuser.value.profile.username_telegram
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
2022-01-03 21:53:41 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-23 23:25:19 +01:00
|
|
|
function getLinkWebSite() {
|
2022-06-16 20:34:17 +02:00
|
|
|
if (myuser.value) {
|
|
|
|
|
let site = myuser.value.profile.website!
|
|
|
|
|
if (site) {
|
|
|
|
|
if (!site.startsWith('http')) {
|
|
|
|
|
site = 'https://' + site
|
|
|
|
|
}
|
2022-01-23 23:25:19 +01:00
|
|
|
}
|
2022-06-16 20:34:17 +02:00
|
|
|
return site
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
2022-01-23 23:25:19 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-16 20:34:17 +02:00
|
|
|
function isMyRecord(username: string) {
|
2022-02-12 02:19:49 +01:00
|
|
|
return username === userStore.my.username
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-03 21:53:41 +01:00
|
|
|
onMounted(mounted)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
username,
|
|
|
|
|
profile,
|
|
|
|
|
tools,
|
|
|
|
|
costanti,
|
|
|
|
|
myuser,
|
2022-01-16 23:20:46 +01:00
|
|
|
shared_consts,
|
2022-01-03 21:53:41 +01:00
|
|
|
getImgUser,
|
|
|
|
|
checkifShow,
|
|
|
|
|
getLinkUserTelegram,
|
2022-01-23 23:25:19 +01:00
|
|
|
getLinkWebSite,
|
2022-01-03 21:53:41 +01:00
|
|
|
filtroutente,
|
|
|
|
|
showPic,
|
2022-01-07 01:16:46 +01:00
|
|
|
myusername,
|
2022-01-16 23:20:46 +01:00
|
|
|
userStore,
|
|
|
|
|
t,
|
2022-02-08 23:06:22 +01:00
|
|
|
static_data,
|
2022-01-20 00:38:49 +01:00
|
|
|
animation,
|
2022-02-12 02:19:49 +01:00
|
|
|
isMyRecord,
|
2022-02-12 17:02:10 +01:00
|
|
|
getRefLink,
|
2022-02-19 22:02:54 +01:00
|
|
|
fieldsTable,
|
2022-02-28 17:42:51 +01:00
|
|
|
mycards,
|
|
|
|
|
actualcard,
|
2022-06-16 20:34:17 +02:00
|
|
|
caricato,
|
|
|
|
|
listgroupsfiltered,
|
2022-07-21 00:20:48 +02:00
|
|
|
idnotif,
|
2022-09-03 13:06:35 +02:00
|
|
|
showsendCoinTo,
|
2022-01-03 21:53:41 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|