Notifiche - Tutti - non letti
This commit is contained in:
@@ -265,6 +265,7 @@ export const costanti = {
|
||||
username_chip: 12000,
|
||||
link: 12500,
|
||||
listobj: 13000,
|
||||
|
||||
},
|
||||
|
||||
FieldTypeArr: [
|
||||
@@ -276,6 +277,11 @@ export const costanti = {
|
||||
{ label: 'Select', value: 32 },
|
||||
{ label: 'Number', value: 64 },
|
||||
{ label: 'crypted', value: 9000 },
|
||||
{ label: 'object', value: 10000 },
|
||||
{ label: 'separator', value: 11000 },
|
||||
{ label: 'username_chip', value: 12000 },
|
||||
{ label: 'link', value: 12500 },
|
||||
{ label: 'listobj', value: 13000 },
|
||||
],
|
||||
|
||||
TipoVisu: {
|
||||
|
||||
@@ -1598,6 +1598,11 @@ const colTableGeneric = [
|
||||
AddCol({ name: 'label', label_trans: 'proj.longdescr' }),
|
||||
]
|
||||
|
||||
const colTableGenTrans = [
|
||||
AddCol({ name: 'value', label_trans: 'others.value' }),
|
||||
AddCol({ name: 'labeltrans', label_trans: 'proj.longdescr' }),
|
||||
]
|
||||
|
||||
export const colTableOperator = [
|
||||
AddCol({ name: 'username', label_trans: 'reg.username_short' }),
|
||||
AddCol({ name: 'name', label_trans: 'reg.name' }),
|
||||
@@ -2710,9 +2715,18 @@ export const fieldsTable = {
|
||||
{
|
||||
value: 'usernotifs',
|
||||
label: 'Notifiche',
|
||||
columns: colTableGeneric,
|
||||
columns: colTableGenTrans,
|
||||
colkey: 'value',
|
||||
collabel: 'label',
|
||||
collabel: 'labeltrans',
|
||||
colicon: 'icon',
|
||||
noshow: true,
|
||||
},
|
||||
{
|
||||
value: 'typenotifs',
|
||||
label: 'Tipi di Notifiche',
|
||||
columns: colTableGenTrans,
|
||||
colkey: 'value',
|
||||
collabel: 'labeltrans',
|
||||
colicon: 'icon',
|
||||
noshow: true,
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
ITodo,
|
||||
IUserFields,
|
||||
Privacy,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField,
|
||||
} from '@model'
|
||||
|
||||
import { addToDate } from '@quasar/quasar-ui-qcalendar'
|
||||
@@ -3527,7 +3527,7 @@ export const tools = {
|
||||
},
|
||||
|
||||
|
||||
getValDb(keystr: string, serv: boolean, def?: any, table?: string, subkey?: any, id?: any, idmain?: any): any {
|
||||
getValDb(keystr: string, serv: boolean, def?: any, table?: string, subkey?: any, id?: any, idmain?: any, specialField?: ISpecialField): any {
|
||||
const globalStore = useGlobalStore()
|
||||
const todos = useTodoStore()
|
||||
const userStore = useUserStore()
|
||||
@@ -5544,7 +5544,17 @@ export const tools = {
|
||||
return myval
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
updateQueryStringParameter(uri: string, key: string, value: string) {
|
||||
const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i')
|
||||
const separator = uri.indexOf('?') !== -1 ? '&' : '?'
|
||||
if (uri.match(re)) {
|
||||
return uri.replace(re, '$1' + key + '=' + value + '$2')
|
||||
} else {
|
||||
return uri + separator + key + '=' + value
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// getLocale() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { static_data } from '@/db/static_data'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { useTodoStore } from '@store/Todos'
|
||||
import { Router } from 'vue-router'
|
||||
import { ISpecialField } from 'model'
|
||||
|
||||
export const func_tools = {
|
||||
getLocale(vero ?: boolean): string {
|
||||
@@ -155,7 +156,7 @@ export const toolsext = {
|
||||
// this.$q.lang.set(mylang)
|
||||
},
|
||||
|
||||
getValDb(keystr: string, serv: boolean, def?: any, table?: string, subkey?: string, id?: any, idmain?: any, indrec?: number, subsubkey?: string): any | undefined {
|
||||
getValDb(keystr: string, serv: boolean, def?: any, table?: string, subkey?: string, id?: any, idmain?: any, indrec?: number, subsubkey?: string, specialField?: ISpecialField): any | undefined {
|
||||
|
||||
const todos = useTodoStore()
|
||||
const userStore = useUserStore()
|
||||
@@ -168,8 +169,23 @@ export const toolsext = {
|
||||
// @ts-ignore
|
||||
return userStore.my.profile[subkey][indrec][subsubkey]
|
||||
} else {
|
||||
// @ts-ignore
|
||||
return userStore.my.profile[subkey]
|
||||
|
||||
if (specialField && specialField.findsubkey && !!subkey) {
|
||||
// @ts-ignore
|
||||
const myrec = userStore.my.profile[subkey].filter(specialField.findsubkey)
|
||||
// console.log('loaded', myrec)
|
||||
if (myrec && myrec.length > 0 && !!specialField.paramtosetsubkey) {
|
||||
// @ts-ignore
|
||||
return myrec[0][specialField.paramtosetsubkey]
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// @ts-ignore
|
||||
return userStore.my.profile[subkey]
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (keystr) { // @ts-ignore
|
||||
|
||||
@@ -12,19 +12,21 @@ import { useUserStore } from '@store/UserStore'
|
||||
export const useNotifStore = defineStore('NotifStore', {
|
||||
state: (): INotifState => ({
|
||||
last_notifs: [],
|
||||
show_all: true
|
||||
}),
|
||||
|
||||
getters: {
|
||||
|
||||
getlasts_notifs: (mystate: INotifState) => (): INotif[] => {
|
||||
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 5) : []
|
||||
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 5).filter((rec) => mystate.show_all ? true : !rec.read) : []
|
||||
// const ctrec = (mystate.notifs) ? mystate.notifs.slice().reverse().slice(0, 5) : []
|
||||
return (ctrec)
|
||||
|
||||
},
|
||||
|
||||
getnumNotifUnread: (mystate: INotifState) => () => {
|
||||
return mystate.last_notifs.filter((notif) => !notif.read).length
|
||||
const myarr = mystate.last_notifs.filter((notif) => !notif.read)
|
||||
return (tools.isArray(myarr) ? myarr.length : 0)
|
||||
},
|
||||
|
||||
},
|
||||
@@ -37,12 +39,50 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
}
|
||||
},
|
||||
|
||||
setAsRead(idnotif: string) {
|
||||
const rec = this.last_notifs.find((rec: any) => rec._id === idnotif)
|
||||
if (rec) {
|
||||
rec.read = true
|
||||
}
|
||||
},
|
||||
|
||||
setAllRead(username: string) {
|
||||
return Api.SendReq(`/sendnotif/setall/${username}/${process.env.APP_ID}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (res) {
|
||||
for (const rec of this.last_notifs) {
|
||||
rec.read = true
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
return false
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
deleteRec(id: string) {
|
||||
|
||||
},
|
||||
|
||||
deactivateRec(id: string) {
|
||||
|
||||
},
|
||||
|
||||
async updateNotifDataFromServer({ username, lastdataread }: {username: string, lastdataread: Date}) {
|
||||
// console.log('updateNotifDataFromServer', username, lastdataread)
|
||||
|
||||
return Api.SendReq(`/sendnotif/${username}/${lastdataread}/${process.env.APP_ID}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (!!res.data && !!res.data.arrnotif) {
|
||||
this.last_notifs = res.data.arrnotif
|
||||
} else {
|
||||
this.last_notifs = []
|
||||
}
|
||||
return true
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -61,6 +101,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
data.sender = notif.sender
|
||||
data.dest = notif.dest
|
||||
data.descr = notif.descr
|
||||
data.link = notif.link
|
||||
data.datenotif = tools.getDateNow()
|
||||
data.read = false
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { defineStore } from 'pinia'
|
||||
import {
|
||||
IFriends, IMsgGlobParam,
|
||||
ISigninOptions,
|
||||
ISignupOptions, IUserFields, IUserProfile, IUserState,
|
||||
ISignupOptions, IUserFields, IUserNotifType, IUserProfile, IUserState,
|
||||
} from '@src/model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import translate from '@src/globalroutines/util'
|
||||
@@ -54,7 +54,7 @@ export const DefaultUser: IUserFields = {
|
||||
manage_mygroups: [],
|
||||
asked_friends: [],
|
||||
asked_groups: [],
|
||||
notifs: 15,
|
||||
notifs: [],
|
||||
},
|
||||
cart: {
|
||||
userId: '',
|
||||
@@ -100,7 +100,7 @@ export const DefaultProfile: IUserProfile = {
|
||||
manage_mygroups: [],
|
||||
asked_friends: [],
|
||||
asked_groups: [],
|
||||
notifs: 15,
|
||||
notifs: [],
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore('UserStore', {
|
||||
@@ -975,9 +975,10 @@ export const useUserStore = defineStore('UserStore', {
|
||||
}
|
||||
},
|
||||
|
||||
async loadUserProfile(username: string) {
|
||||
async loadUserProfile({username, idnotif}: {username: string, idnotif?: string}) {
|
||||
const data = {
|
||||
username
|
||||
username,
|
||||
idnotif
|
||||
}
|
||||
|
||||
return Api.SendReq('/users/profile', 'POST', data)
|
||||
@@ -993,7 +994,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
},
|
||||
|
||||
async setUserNotifs(notifs: number) {
|
||||
async setUserNotifs(notifs: IUserNotifType[]) {
|
||||
const data = {
|
||||
notifs
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import urlBase64ToUint8Array from '@src/js/utility'
|
||||
import translate from '@src/globalroutines/util'
|
||||
import { useTodoStore } from '@store/Todos'
|
||||
import { useMessageStore } from './MessageStore'
|
||||
import { useNotifStore } from './NotifStore'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
|
||||
|
||||
const stateConnDefault = 'online'
|
||||
@@ -1592,6 +1592,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
else if (table === toolsext.TABLOCACCOM) myarr = shared_consts.LocationAccom
|
||||
else if (table === toolsext.TABPREF) myarr = shared_consts.Preferences
|
||||
else if (table === 'usernotifs') myarr = shared_consts.UsersNotif_Adv_List
|
||||
else if (table === 'typenotifs') myarr = shared_consts.typeNotifs
|
||||
else myarr = this.getListByTable(table)
|
||||
|
||||
if (costanti.TABLES_ARRAY.includes(table)) {
|
||||
|
||||
Reference in New Issue
Block a user