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_MYHOSPS: 'myhosps',
TABLES_MYGOODS: 'mygoods',
TABLES_MYEVENTS: 'myevents',
TABLES_ENABLE_GETREC_BYID: ['mybachecas', 'myhosps'],
@@ -869,6 +870,7 @@ export const shared_consts = {
TYPEDIR_FRIENDS: 3,
ID_FRIENDS_NEW_REC: 1,
ID_FRIENDS_ACCEPTED: 2,
TYPEDIR_CIRCUITS: 4,

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
<template>
<div class="no-border" v-if="finishLoading">
<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 v-for="(myitemmenu, ind2) in myroutes" :key="ind2">
<div v-if="myitemmenu.active">

View File

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

View File

@@ -8,7 +8,7 @@
</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">
{{ $t('notifs.notifs') }}
@@ -81,20 +81,20 @@
<q-item-section avatar>
<q-avatar>
<img :src="getImgByNotif(notif)" :alt="getUsernameChatByNotif(notif)">
<img :src="notif.myimgsender" :alt="notif.sender">
</q-avatar>
</q-item-section>
<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 caption lines="2" :class="(!notif.read) ? 'unread-date' : 'read-date'">
<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="1" :class="(!notif.read) ? 'unread-date' : 'read-date'">
{{ tools.timeAgo(notif.datenotif) }}
<!--{{ // getUsernameChatByNotif(notif) }}-->
</q-item-label>
</q-item-section>
<q-item-section side>
<q-item-label>
<q-btn rounded icon="fas fa-ellipsis-h">
<q-btn dense rounded icon="fas fa-ellipsis-h">
<q-menu>
<q-list style="min-width: 150px">
<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_key_test?: string
telegram_bot_name_test?: string
telegram_support_chat?: string
pathreg_add?: string
confsite: IOption
}

View File

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

View File

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

View File

@@ -2,19 +2,27 @@
<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>
<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>
</q-select>
<div class="row">
<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>
<q-select rounded outlined v-model="notifidtype" :options="listnotifid" label="Notifica" emit-value map-options>
</q-select>
</div>
<q-input
v-model="mynotif" type="textarea" autofocus label="Notifica da Inviare"
input-class="myinput-area"
style="height: 100px; width: 500px;"></q-input>
<q-btn color="green" :label="`Invia Notifica a ` + myuser.username" @click="sendNotifToUser"></q-btn>
<div class="row">
<q-input
v-model="title" label="Titolo"
style="width: 300px;"></q-input>
<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>

View File

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

View File

@@ -18,8 +18,7 @@ export const useNotifStore = defineStore('NotifStore', {
getters: {
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.notifs) ? mystate.notifs.slice().reverse().slice(0, 5) : []
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => mystate.show_all ? true : !rec.read) : []
return (ctrec)
},
@@ -131,6 +130,7 @@ export const useNotifStore = defineStore('NotifStore', {
data.typeid = notif.typeid
data.sender = notif.sender
data.dest = notif.dest
data.title = notif.title
data.descr = notif.descr
data.datenotif = tools.getDateNow()
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 = {
table,
id
id,
idnotif
}
return Api.SendReq('/mygen/page', 'POST', data)