Notification: Set a new Friendship and Accepted Friendship

This commit is contained in:
Paolo Arena
2022-07-26 15:46:29 +02:00
parent e2006e683b
commit 43619ec719
15 changed files with 78 additions and 39 deletions

View File

@@ -95,6 +95,7 @@ export const shared_consts = {
TABLES_MYBACHECAS: 'mybachecas', TABLES_MYBACHECAS: 'mybachecas',
TABLES_MYHOSPS: 'myhosps', TABLES_MYHOSPS: 'myhosps',
TABLES_MYGOODS: 'mygoods', TABLES_MYGOODS: 'mygoods',
TABLES_MYEVENTS: 'myevents',
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps'], TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps'],
@@ -869,6 +870,7 @@ export const shared_consts = {
TYPEDIR_FRIENDS: 3, TYPEDIR_FRIENDS: 3,
ID_FRIENDS_NEW_REC: 1, ID_FRIENDS_NEW_REC: 1,
ID_FRIENDS_ACCEPTED: 2,
TYPEDIR_CIRCUITS: 4, TYPEDIR_CIRCUITS: 4,

View File

@@ -17,6 +17,8 @@ import { costanti } from '@costanti'
import { IColGridTable, IImgGallery, IUserFields } from 'model' import { IColGridTable, IImgGallery, IUserFields } from 'model'
import { shared_consts } from '@/common/shared_vuejs' import { shared_consts } from '@/common/shared_vuejs'
import { colCitys, fieldsTable } from '@store/Modules/fieldsTable' import { colCitys, fieldsTable } from '@store/Modules/fieldsTable'
import { useRoute } from 'vue-router'
import { useNotifStore } from '@store/NotifStore'
export default defineComponent({ export default defineComponent({
name: 'CMyCardGrpPopup', name: 'CMyCardGrpPopup',
@@ -40,12 +42,16 @@ export default defineComponent({
setup(props) { setup(props) {
const userStore = useUserStore() const userStore = useUserStore()
const notifStore = useNotifStore()
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
const $q = useQuasar() const $q = useQuasar()
const $route = useRoute()
const { t } = useI18n() const { t } = useI18n()
const showPic = ref(false) const showPic = ref(false)
const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '')
const myrec = ref({}) const myrec = ref({})
const col = ref(<IColGridTable>{}) const col = ref(<IColGridTable>{})
@@ -56,8 +62,9 @@ export default defineComponent({
function load() { function load() {
// Carica il profilo di quest'utente // Carica il profilo di quest'utente
if (props.idRec && props.idRec > 0) { if (props.idRec && props.idRec > 0) {
userStore.loadGeneric(props.table, props.idRec).then((ris) => { userStore.loadGeneric(props.table, props.idRec, idnotif.value).then((ris) => {
myrec.value = ris myrec.value = ris
notifStore.setAsRead(idnotif.value)
}) })
} else { } else {

View File

@@ -17,6 +17,8 @@ import { costanti } from '@costanti'
import { IColGridTable, IImgGallery, IUserFields } from 'model' import { IColGridTable, IImgGallery, IUserFields } from 'model'
import { shared_consts } from '@/common/shared_vuejs' import { shared_consts } from '@/common/shared_vuejs'
import { colCitys, fieldsTable } from '@store/Modules/fieldsTable' import { colCitys, fieldsTable } from '@store/Modules/fieldsTable'
import { useRoute } from 'vue-router'
import { useNotifStore } from '@store/NotifStore'
export default defineComponent({ export default defineComponent({
name: 'CMyCardPopup', name: 'CMyCardPopup',
@@ -45,8 +47,10 @@ export default defineComponent({
setup(props) { setup(props) {
const userStore = useUserStore() const userStore = useUserStore()
const notifStore = useNotifStore()
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
const $q = useQuasar() const $q = useQuasar()
const $route = useRoute()
const { t } = useI18n() const { t } = useI18n()
const showPic = ref(false) const showPic = ref(false)
@@ -54,6 +58,8 @@ export default defineComponent({
const myrec = ref(<any>{}) const myrec = ref(<any>{})
const col = ref(<IColGridTable>{}) const col = ref(<IColGridTable>{})
const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '')
function profile() { function profile() {
return userStore.my.profile return userStore.my.profile
} }
@@ -61,8 +67,9 @@ export default defineComponent({
function load() { function load() {
// Carica il profilo di quest'utente // Carica il profilo di quest'utente
if (props.idRec > 0) { if (props.idRec > 0) {
userStore.loadGeneric(props.table, props.idRec).then((ris) => { userStore.loadGeneric(props.table, props.idRec, idnotif.value).then((ris) => {
myrec.value = ris myrec.value = ris
notifStore.setAsRead(idnotif.value)
}) })
} else { } else {

View File

@@ -176,7 +176,7 @@ export default defineComponent({
) )
watch(() => props.arrvalue, (value: any, oldval: any) => { watch(() => props.arrvalue, (value: any, oldval: any) => {
console.log(' MODIF props.arrvalue', props.arrvalue) // console.log(' MODIF props.arrvalue', props.arrvalue)
update() update()
}, },
) )
@@ -268,7 +268,7 @@ export default defineComponent({
} }
function update() { function update() {
console.log('update', props.value, props) // console.log('update', props.value, props)
// console.log(' #### mounted myselect', props.options, 'arrvalue', myarrvalue.value) // console.log(' #### mounted myselect', props.options, 'arrvalue', myarrvalue.value)
let rec: any let rec: any
if (optionsreal.value) { if (optionsreal.value) {

View File

@@ -29,10 +29,9 @@ export default defineComponent({
const myroutes = ref(<IListRoutes[]>[]) const myroutes = ref(<IListRoutes[]>[])
function getmenu(): any { const getmenu = computed(() => globalStore.getmenu )
// console.log('getmenu menuOne!')
return globalStore.getmenu const islogged = computed(() => userStore.isLogged)
}
function setParentVisibilityBasedOnRoute(parent: any) { function setParentVisibilityBasedOnRoute(parent: any) {
parent.routes.forEach((item: any) => { parent.routes.forEach((item: any) => {
@@ -42,19 +41,26 @@ export default defineComponent({
}) })
} }
watch(() => userStore.isLogged || finishLoading.value,(to, from) => { function updatemenu() {
myroutes.value = []
myroutes.value = static_data.routes
})
watch(() => path, (to, from) => {
const mymenu = globalStore.getmenu const mymenu = globalStore.getmenu
// console.log('watch:', mymenu)
Object.keys(mymenu).forEach((parentName: any) => { Object.keys(mymenu).forEach((parentName: any) => {
// console.log('parentName', parentName)
// @ts-ignore // @ts-ignore
setParentVisibilityBasedOnRoute(mymenu[parentName]) setParentVisibilityBasedOnRoute(mymenu[parentName])
}) })
myroutes.value = []
myroutes.value = static_data.routes
}
watch(() => islogged.value,(to, from) => {
updatemenu()
})
watch(() => finishLoading.value,(to, from) => {
updatemenu()
})
watch(() => path, (to, from) => {
updatemenu()
}) })
/* function replaceUnderlineToSpace(text: string) { /* function replaceUnderlineToSpace(text: string) {

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="no-border" v-if="finishLoading"> <div class="no-border" v-if="finishLoading">
<q-list class="rounded-borders text-primary"> <q-list class="rounded-borders text-primary">
<div v-for="ind1 in getmenu()" :key="ind1"> <div v-for="ind1 in getmenu" :key="ind1">
<!--<div class="q-list-header">{{replaceUnderlineToSpace(index)}}</div>--> <!--<div class="q-list-header">{{replaceUnderlineToSpace(index)}}</div>-->
<div v-for="(myitemmenu, ind2) in myroutes" :key="ind2"> <div v-for="(myitemmenu, ind2) in myroutes" :key="ind2">
<div v-if="myitemmenu.active"> <div v-if="myitemmenu.active">

View File

@@ -66,11 +66,11 @@ export default defineComponent({
if (usernotifs.value) { if (usernotifs.value) {
console.log('usernotifs.value', usernotifs.value, to) console.log('usernotifs.value', usernotifs.value, to)
const ret = await userStore.setUserNotifs(usernotifs.value) const ret = await userStore.setUserNotifs(usernotifs.value)
if (ret) { /*if (ret) {
tools.showPositiveNotif($q, t('db.recupdated')) tools.showPositiveNotif($q, t('db.recupdated'))
} else { } else {
tools.showNegativeNotif($q, t('db.recfailed')) tools.showNegativeNotif($q, t('db.recfailed'))
} }*/
} }
}) })

View File

@@ -8,7 +8,7 @@
</q-btn> </q-btn>
<q-drawer v-model="open" side="right" elevated class="text-black"> <q-drawer v-model="open" side="right" elevated class="text-black" :width="350">
<q-bar class="bg-primary text-white"> <q-bar class="bg-primary text-white">
{{ $t('notifs.notifs') }} {{ $t('notifs.notifs') }}
@@ -81,20 +81,20 @@
<q-item-section avatar> <q-item-section avatar>
<q-avatar> <q-avatar>
<img :src="getImgByNotif(notif)" :alt="getUsernameChatByNotif(notif)"> <img :src="notif.myimgsender" :alt="notif.sender">
</q-avatar> </q-avatar>
</q-item-section> </q-item-section>
<q-item-section v-ripple @click="clickNotif(notif)"> <q-item-section v-ripple @click="clickNotif(notif)">
<q-item-label lines="1" :class="(!notif.read) ? 'unread' : 'read'">{{ getNotifText(notif, false) }}</q-item-label> <q-item-label lines="3" :class="(!notif.read) ? 'unread' : 'read'"><div v-html="getNotifText(notif, false)"></div></q-item-label>
<q-item-label caption lines="2" :class="(!notif.read) ? 'unread-date' : 'read-date'"> <q-item-label caption lines="1" :class="(!notif.read) ? 'unread-date' : 'read-date'">
{{ tools.timeAgo(notif.datenotif) }} {{ tools.timeAgo(notif.datenotif) }}
<!--{{ // getUsernameChatByNotif(notif) }}--> <!--{{ // getUsernameChatByNotif(notif) }}-->
</q-item-label> </q-item-label>
</q-item-section> </q-item-section>
<q-item-section side> <q-item-section side>
<q-item-label> <q-item-label>
<q-btn rounded icon="fas fa-ellipsis-h"> <q-btn dense rounded icon="fas fa-ellipsis-h">
<q-menu> <q-menu>
<q-list style="min-width: 150px"> <q-list style="min-width: 150px">
<q-item clickable v-close-popup @click="notifStore.deleteRec(username, notif._id)"> <q-item clickable v-close-popup @click="notifStore.deleteRec(username, notif._id)">

View File

@@ -169,6 +169,7 @@ export interface ISites {
telegram_bot_name?: string telegram_bot_name?: string
telegram_key_test?: string telegram_key_test?: string
telegram_bot_name_test?: string telegram_bot_name_test?: string
telegram_support_chat?: string
pathreg_add?: string pathreg_add?: string
confsite: IOption confsite: IOption
} }

View File

@@ -57,6 +57,7 @@ export const NotifDefault: INotif = {
typeid: 0, typeid: 0,
sender: '', sender: '',
dest: '', dest: '',
title: '',
descr: '', descr: '',
datenotif: new Date(), datenotif: new Date(),
read: false, read: false,
@@ -84,7 +85,9 @@ export interface INotif {
typedir: number typedir: number
typeid: number typeid: number
sender: string, sender: string,
myimgsender?: string,
dest: string, dest: string,
title: string
descr: string descr: string
datenotif?: Date datenotif?: Date
status?: StatusMessage status?: StatusMessage

View File

@@ -32,6 +32,7 @@ export default defineComponent({
const myuser = ref(<IUserFields>{_id: '', username: '', name: '', surname: '', profile: DefaultProfile}) const myuser = ref(<IUserFields>{_id: '', username: '', name: '', surname: '', profile: DefaultProfile})
const risultato = ref('') const risultato = ref('')
const mynotif = ref('') const mynotif = ref('')
const title = ref('')
const notifdirtype = ref(1) const notifdirtype = ref(1)
const notifidtype = ref(1) const notifidtype = ref(1)
@@ -109,6 +110,7 @@ export default defineComponent({
sender: userStore.my.username, sender: userStore.my.username,
dest: myuser.value.username, dest: myuser.value.username,
descr: mynotif.value, descr: mynotif.value,
title: title.value,
} }
await notifStore.SendNotifEvent(notif) await notifStore.SendNotifEvent(notif)
@@ -133,6 +135,7 @@ export default defineComponent({
sendNotifToUser, sendNotifToUser,
risultato, risultato,
mynotif, mynotif,
title,
notifdirtype, notifdirtype,
notifidtype, notifidtype,
listnotif, listnotif,

View File

@@ -2,19 +2,27 @@
<CMyPage img="" :title="$t('otherpages.admin.userpanel')" keywords="" :description="$t('otherpages.admin.userpanel')"> <CMyPage img="" :title="$t('otherpages.admin.userpanel')" keywords="" :description="$t('otherpages.admin.userpanel')">
<q-btn color="green" label="Esporta Lista Email" @click="exportListaEmail"></q-btn> <q-btn color="green" label="Esporta Lista Email" @click="exportListaEmail"></q-btn>
<div class="q-ma-sm row" style="min-width: 300px;"> <div class="q-ma-sm row bordo_stondato" style="min-width: 300px; ">
<q-select rounded outlined v-model="notifdirtype" :options="listnotiftype" label="Tipo" emit-value map-options> <div class="row">
</q-select> <q-select rounded outlined v-model="notifdirtype" :options="listnotiftype" label="Tipo" emit-value map-options>
</q-select>
<q-select rounded outlined v-model="notifidtype" :options="listnotifid" label="Notifica" emit-value map-options> <q-select rounded outlined v-model="notifidtype" :options="listnotifid" label="Notifica" emit-value map-options>
</q-select> </q-select>
</div>
<q-input <div class="row">
v-model="mynotif" type="textarea" autofocus label="Notifica da Inviare" <q-input
input-class="myinput-area" v-model="title" label="Titolo"
style="height: 100px; width: 500px;"></q-input> style="width: 300px;"></q-input>
<q-btn color="green" :label="`Invia Notifica a ` + myuser.username" @click="sendNotifToUser"></q-btn> <q-input
v-model="mynotif" label="Notifica da Inviare"
input-class="myinput-area"
style="width: 300px;"></q-input>
</div>
<br>
<q-btn class="centermydiv q-ma-sm" color="green" :label="`Invia Notifica a ` + myuser.username" @click="sendNotifToUser"></q-btn>
</div> </div>

View File

@@ -92,6 +92,7 @@ export const Api = {
idapp: process.env.APP_ID, idapp: process.env.APP_ID,
} }
console.log('INIZIO - SendReq', url)
// console.log('mydata', mydata) // console.log('mydata', mydata)
const userStore = useUserStore() const userStore = useUserStore()
@@ -138,7 +139,7 @@ export const Api = {
} }
}, 1000) }, 1000)
console.log('error', error) console.log('ERROR', error)
return reject(error) return reject(error)
})) }))
}, },

View File

@@ -18,8 +18,7 @@ export const useNotifStore = defineStore('NotifStore', {
getters: { getters: {
getlasts_notifs: (mystate: INotifState) => (): INotif[] => { getlasts_notifs: (mystate: INotifState) => (): INotif[] => {
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 10).filter((rec) => mystate.show_all ? true : !rec.read) : [] const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => mystate.show_all ? true : !rec.read) : []
// const ctrec = (mystate.notifs) ? mystate.notifs.slice().reverse().slice(0, 5) : []
return (ctrec) return (ctrec)
}, },
@@ -131,6 +130,7 @@ export const useNotifStore = defineStore('NotifStore', {
data.typeid = notif.typeid data.typeid = notif.typeid
data.sender = notif.sender data.sender = notif.sender
data.dest = notif.dest data.dest = notif.dest
data.title = notif.title
data.descr = notif.descr data.descr = notif.descr
data.datenotif = tools.getDateNow() data.datenotif = tools.getDateNow()
data.read = false data.read = false

View File

@@ -1062,10 +1062,11 @@ export const useUserStore = defineStore('UserStore', {
}, },
async loadGeneric(table: string, id: number) { async loadGeneric(table: string, id: number, idnotif: string) {
const data = { const data = {
table, table,
id id,
idnotif
} }
return Api.SendReq('/mygen/page', 'POST', data) return Api.SendReq('/mygen/page', 'POST', data)