Files
salvato.newfreeplanet/src/rootgen/admin/userPanel/userPanel.ts

153 lines
3.8 KiB
TypeScript
Raw Normal View History

2022-07-10 01:24:54 +02:00
import { defineComponent, onMounted, ref } from 'vue'
import { computed } from 'vue'
2022-07-10 01:24:54 +02:00
import { CMyPage } from '@/components/CMyPage'
import { CCopyBtn } from '@/components/CCopyBtn'
2022-07-10 01:24:54 +02:00
import { CKeyAndValue } from '@/components/CKeyAndValue'
import { CGridTableRec } from '@/components/CGridTableRec'
import { tools } from '@store/Modules/tools'
import { static_data } from '@/db/static_data'
import { fieldsTable } from '@src/store/Modules/fieldsTable'
import { shared_consts } from '@/common/shared_vuejs'
2022-07-21 00:20:48 +02:00
import { DefaultProfile, useUserStore } from '@store/UserStore'
2022-07-10 01:24:54 +02:00
import { costanti } from '@costanti'
import { useQuasar } from 'quasar'
2022-07-21 00:20:48 +02:00
import { useNotifStore } from '@store/NotifStore'
import { INotif } from 'model'
import { IUserFields } from '@model/UserStore'
import { useI18n } from '@/boot/i18n'
import MixinUsers from '@/mixins/mixin-users'
2022-07-10 01:24:54 +02:00
export default defineComponent({
name: 'userPanel',
components: { CMyPage, CKeyAndValue, CCopyBtn },
2022-07-10 01:24:54 +02:00
setup() {
const arrfilterand: any = ref([])
const $q = useQuasar()
2022-07-10 01:24:54 +02:00
const search = ref('')
const colVisib = ref('')
const mycolumns = ref([])
2022-07-21 00:20:48 +02:00
const myuser = ref(<IUserFields>{_id: '', username: '', name: '', surname: '', profile: DefaultProfile})
const risultato = ref('')
2022-07-21 00:20:48 +02:00
const mynotif = ref('')
const title = ref('')
const notifdirtype = ref(1)
const notifidtype = ref(1)
2022-07-21 00:20:48 +02:00
const listnotif = ref(<any>[])
const listnotiftype = ref(<any>[])
2022-07-21 00:20:48 +02:00
const { t } = useI18n();
const listnotifid = computed(() => {
if (notifdirtype.value) {
const mylist: any = shared_consts.TypeNotifs_Arr.find((rec: any) => rec.value === notifdirtype.value)
if (mylist) {
for (const rec of mylist.list) {
rec.label = t(rec.labeltrans)
}
}
return mylist.list
}
return []
})
2022-07-10 01:24:54 +02:00
const userStore = useUserStore()
2022-07-21 00:20:48 +02:00
const notifStore = useNotifStore()
2022-07-10 01:24:54 +02:00
const { getMyUsername } = MixinUsers()
2022-07-10 01:24:54 +02:00
async function mounted() {
//
search.value = tools.getCookie(tools.COOK_SEARCH + 'searchpanel')
await refresh()
2022-07-21 00:20:48 +02:00
listnotif.value = shared_consts.UsersNotif_Adv_List
for (const rec of listnotif.value) {
rec.label = t(rec.labeltrans)
}
listnotiftype.value = shared_consts.TypeNotifs_Arr
for (const rec of listnotiftype.value) {
rec.label = t(rec.labeltrans)
}
2022-07-10 01:24:54 +02:00
}
function changeCol(newval: any) {
//
}
async function refresh() {
if (!!search.value)
myuser.value = await userStore.loadUserPanel(search.value)
else
2022-07-21 00:20:48 +02:00
myuser.value = {_id: '', username: '', name: '', surname: '', profile: DefaultProfile}
2022-07-10 01:24:54 +02:00
}
function db_fieldsTable() {
return fieldsTable
}
async function doSearch() {
tools.setCookie(tools.COOK_SEARCH + 'searchpanel', search.value)
await refresh()
}
async function exportListaEmail() {
risultato.value = await tools.exportListaEmail()
tools.copyStringToClipboard($q, risultato.value, false)
}
2022-07-21 00:20:48 +02:00
async function sendNotifToUser() {
if (!!myuser.value) {
const notif: INotif = {
typedir: notifdirtype.value,
typeid: notifidtype.value,
2022-07-21 00:20:48 +02:00
sender: userStore.my.username,
dest: myuser.value.username,
descr: mynotif.value,
title: title.value,
2022-07-21 00:20:48 +02:00
}
await notifStore.SendNotifEvent(notif)
}
}
2022-07-10 01:24:54 +02:00
onMounted(mounted)
return {
arrfilterand,
fieldsTable,
search,
tools,
2022-07-21 00:20:48 +02:00
shared_consts,
2022-07-10 01:24:54 +02:00
doSearch,
changeCol,
myuser,
refresh,
mycolumns,
colVisib,
exportListaEmail,
2022-07-21 00:20:48 +02:00
sendNotifToUser,
risultato,
2022-07-21 00:20:48 +02:00
mynotif,
title,
notifdirtype,
notifidtype,
2022-07-21 00:20:48 +02:00
listnotif,
listnotiftype,
listnotifid,
getMyUsername,
2022-07-10 01:24:54 +02:00
}
}
})