Notifiche all'Utente

Pannello Utente (backoffice)
This commit is contained in:
Paolo Arena
2022-07-16 14:20:22 +02:00
parent 7f25ca4717
commit 7006d62cae
17 changed files with 174 additions and 32 deletions

View File

@@ -293,7 +293,6 @@ export const shared_consts = {
], ],
People: [ People: [
{ {
value: 0, value: 0,
@@ -850,6 +849,35 @@ export const shared_consts = {
TELEGRAM: 2, TELEGRAM: 2,
}, },
UsersNotif: {
NEW_ADV_PROVINCE: 1,
NEW_ADV_CITY: 2,
NEW_ADV_MY_GROUPS: 4,
NEW_ADV_MY_RIS_CIRCUIT: 8,
},
UsersNotif_Adv_List: [
{
value: 1, // NEW_ADV_PROVINCE
label: 'notifs.warn_province',
},
{
value: 2, // NEW_ADV_CITY
label: 'notifs.warn_city',
},
{
value: 4, // NEW_ADV_MY_GROUPS
label: 'notifs.warn_my_groups',
},
{
value: 8, // NEW_ADV_MY_RIS_CIRCUIT
label: 'notifs.warn_my_ris_circuit',
},
],
getStatusStr(status: number) { getStatusStr(status: number) {
const trovatorec = this.OrderStatusStr.find((rec) => rec.value === status) const trovatorec = this.OrderStatusStr.find((rec) => rec.value === status)
return (trovatorec) ? trovatorec.label : '' return (trovatorec) ? trovatorec.label : ''

View File

@@ -2,7 +2,7 @@
<div class="text-center"> <div class="text-center">
<div class="row items-center justify-center q-gutter-md q-ma-xs"> <div class="row items-center justify-center q-gutter-md q-ma-xs">
<div class="q-ma-xs"> <div v-if="title" class="q-ma-xs">
<q-field rounded outlined bg-color="blue-1" dense style="min-width:110px;"> <q-field rounded outlined bg-color="blue-1" dense style="min-width:110px;">
<template v-slot:control> <template v-slot:control>
<div class="centermydiv"> <div class="centermydiv">
@@ -21,6 +21,7 @@
</div> </div>
<div :class="` q-ma-sm q-pa-sm col-grow popupedit `" :style="withBorder() ? `` : ``"> <div :class="` q-ma-sm q-pa-sm col-grow popupedit `" :style="withBorder() ? `` : ``">
<CMyPopupEdit <CMyPopupEdit
v-bind="$attrs" v-bind="$attrs"
:rec="rec" :rec="rec"

View File

@@ -1,4 +1,5 @@
<template> <template>
<div v-if="visuElem()" :class="mytitle ? `row items-center justify-center q-ma-xs text-center` : ``"> <div v-if="visuElem()" :class="mytitle ? `row items-center justify-center q-ma-xs text-center` : ``">
<div v-if="mytitle" class="q-ma-xs"> <div v-if="mytitle" class="q-ma-xs">

View File

@@ -302,7 +302,7 @@
{{ col.label ? col.label : t(col.label_trans) }}: {{ col.label ? col.label : t(col.label_trans) }}:
</span> </span>
<CMyToggleList <CMyToggleList
:label="col.titlepopupedit" :label="col.titlepopupedit ? col.titlepopupedit : ''"
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.addnone, col.filter)" :options="globalStore.getTableJoinByName(col.jointable, col.addall, col.addnone, col.filter)"
v-model:value="myvalue" v-model:value="myvalue"
@update:value="changevalRec" @update:value="changevalRec"
@@ -818,7 +818,7 @@
<div v-else-if="col.fieldtype === costanti.FieldType.binary"> <div v-else-if="col.fieldtype === costanti.FieldType.binary">
<CMyToggleList <CMyToggleList
:label="col.titlepopupedit" :label="col.titlepopupedit ? col.titlepopupedit : ''"
:options="globalStore.getTableJoinByName(col.jointable, col.addall, col.addnone, col.filter)" :options="globalStore.getTableJoinByName(col.jointable, col.addall, col.addnone, col.filter)"
v-model:value="scope.value" v-model:value="scope.value"
:optval="fieldsTable.getKeyByTable(col.jointable)" :optval="fieldsTable.getKeyByTable(col.jointable)"

View File

@@ -4,7 +4,7 @@
<q-toggle <q-toggle
v-if="rec.label" v-if="rec.label"
v-model="rec.valbool" v-model="rec.valbool"
:label="rec.label" :label="rec.label ? rec.label : ''"
:color="tools.getColorByIndexBest(index)" :color="tools.getColorByIndexBest(index)"
keep-color keep-color
@update:model-value="changeval"> @update:model-value="changeval">

View File

@@ -5,7 +5,7 @@
v-if="listasharewithus && listasharewithus.length > 0" class="q-pa-xs" v-if="listasharewithus && listasharewithus.length > 0" class="q-pa-xs"
:title="$t('pages.sharewithus')" :title="$t('pages.sharewithus')"
bgcolor="bg-white" clcolor="text-blue" bgcolor="bg-white" clcolor="text-blue"
mystyle="" myclass="myshad" canopen="true"> mystyle="" myclass="myshad" :canopen="true">
<div class="flex flex-center"> <div class="flex flex-center">
@@ -55,7 +55,7 @@
v-if="listasharewithus() && listasharewithus().length > 0" class="q-pa-xs" v-if="listasharewithus() && listasharewithus().length > 0" class="q-pa-xs"
title="Graduatoria Attuale" title="Graduatoria Attuale"
bgcolor="bg-white" clcolor="text-blue" bgcolor="bg-white" clcolor="text-blue"
mystyle="" myclass="myshad" canopen="true"> mystyle="" myclass="myshad" :canopen="true">
<div class="flex flex-center text-center"> <div class="flex flex-center text-center">

View File

@@ -8,7 +8,7 @@
class="q-pa-xs" :title="$t('steps.video_intro_1', {sitename: $t('ws.sitename')})" class="q-pa-xs" :title="$t('steps.video_intro_1', {sitename: $t('ws.sitename')})"
bgcolor="bg-primary" bgcolor="bg-primary"
clcolor="text-white" clcolor="text-white"
myclass="myshad" canopen="true" :visible="true"> myclass="myshad" :canopen="true" :visible="true">
<div v-if="showconditions"> <div v-if="showconditions">
<CVideo myvideokey="DWfQzbOCK3s"></CVideo> <CVideo myvideokey="DWfQzbOCK3s"></CVideo>

View File

@@ -528,6 +528,11 @@ $heightBtn: 100%;
display: block; display: block;
} }
.centermydiv2 {
margin-left: auto;
margin-right: auto;
}
.text-verified { .text-verified {
font-size: 1.25rem; font-size: 1.25rem;
text-shadow: .05rem .05rem .15rem #fff; text-shadow: .05rem .05rem .15rem #fff;
@@ -638,6 +643,12 @@ $heightBtn: 100%;
padding: 8px; padding: 8px;
} }
.clBorderSperator {
background-color: blue;
font-size: 1rem;
padding: 4px;
}
.clBorderZoom { .clBorderZoom {
border: #666cf6 solid 5px; border: #666cf6 solid 5px;
} }

View File

@@ -1,4 +1,4 @@
import { computed, defineComponent, ref } from 'vue' import { computed, defineComponent, onMounted, ref, watch } from 'vue'
import { import {
IChat, IChat,
@@ -13,19 +13,37 @@ import MixinUsers from '../../../mixins/mixin-users'
import { useNotifStore } from '@store/NotifStore' import { useNotifStore } from '@store/NotifStore'
import { useUserStore } from '@store/UserStore' import { useUserStore } from '@store/UserStore'
import { CTitleBanner } from '@/components/CTitleBanner'
import { CMyFieldRec } from '@/components/CMyFieldRec'
import { CMyFieldDb } from '@/components/CMyFieldDb'
import { shared_consts } from '@/common/shared_vuejs'
import { useI18n } from '@/boot/i18n'
import { useQuasar } from 'quasar'
import { costanti } from '@costanti'
const namespace = 'notifModule' const namespace = 'notifModule'
export default defineComponent({ export default defineComponent({
name: 'notifPopover', name: 'notifPopover',
components: { CTitleBanner, CMyFieldRec, CMyFieldDb },
setup(props) { setup(props) {
const $router = useRouter() const $router = useRouter()
const userStore = useUserStore() const userStore = useUserStore()
const notifStore = useNotifStore() const notifStore = useNotifStore()
const { t } = useI18n()
const $q = useQuasar()
const loading = ref(false) const loading = ref(false)
const myuser = ref({})
const lasts_notifs = computed(() => notifStore.getlasts_notifs) const lasts_notifs = computed(() => notifStore.getlasts_notifs)
const usernotifs = computed(() => userStore.my.profile.notifs)
const userId = ref('')
const open = ref(false)
const notifsel = ref(<INotif>{ const notifsel = ref(<INotif>{
dest: '', dest: '',
@@ -39,6 +57,19 @@ export default defineComponent({
// } // }
watch(() => usernotifs.value, async (to: any, from: any) => {
if (usernotifs.value) {
console.log('usernotifs.value', usernotifs.value, to)
const ret = await userStore.setUserNotifs(usernotifs.value)
if (ret) {
tools.showPositiveNotif($q, t('db.recupdated'))
} else {
tools.showNegativeNotif($q, t('db.recfailed'))
}
}
})
function clickChat(msg: IMessage) { function clickChat(msg: IMessage) {
// $router.replace(`/notifs/${ msg.dest.username}`) // $router.replace(`/notifs/${ msg.dest.username}`)
} }
@@ -69,6 +100,7 @@ export default defineComponent({
function refreshdata(username: string) { function refreshdata(username: string) {
loading.value = true loading.value = true
userId.value = userStore.my._id
notifsel.value.dest = '' notifsel.value.dest = ''
@@ -90,9 +122,12 @@ export default defineComponent({
} }
function mounted() { function mounted() {
myuser.value = userStore.my
refreshdata(userStore.my.username) refreshdata(userStore.my.username)
} }
onMounted(mounted)
return { return {
lasts_notifs, lasts_notifs,
clickChat, clickChat,
@@ -102,6 +137,12 @@ export default defineComponent({
getImgByNotif, getImgByNotif,
getNotifText, getNotifText,
tools, tools,
usernotifs,
shared_consts,
userId,
myuser,
costanti,
open,
} }
}, },
}) })

View File

@@ -1,32 +1,57 @@
<template> <template>
<div> <div>
<q-btn flat round dense icon="fas fa-bell" class="q-mx-xs"> <q-btn flat round dense icon="fas fa-bell" class="q-mx-xs" @click="open = !open">
<q-badge v-if="getNumNotifUnread() > 0" floating color="red">{{ getNumNotifUnread() }}</q-badge> <q-badge v-if="getNumNotifUnread() > 0" floating color="red">{{ getNumNotifUnread() }}</q-badge>
</q-btn>
<q-btn v-if="false" flat round dense icon="fas fa-bell">
<q-badge v-if="getNumNotifUnread() > 0" floating color="red">{{ getNumNotifUnread() }}</q-badge>
</q-btn>
<q-drawer v-model="open" side="right" elevated class="text-black">
<q-menu anchor="bottom right" self="top right">
<q-bar class="bg-primary text-white"> <q-bar class="bg-primary text-white">
{{ $t('notifs.notifs') }} {{ $t('notifs.notifs') }}
<q-space/> <q-space/>
<q-btn flat round color="white" icon="close" v-close-popup></q-btn> <q-btn flat round color="white" icon="close" @click="open = false"></q-btn>
</q-bar> </q-bar>
<div class="">
<CTitleBanner
class="q-pa-xs"
title="Imposta notifiche"
bgcolor="bg-green" clcolor="text-white"
mystyle="" myclass="myshad" :canopen="true">
<div> <div>
Imposta notifiche:<br> <div>Avvisami se nuovo annuncio:</div>
<q-toggle dark v-model="notifs[0]" :label="$t('notifs.warn_province')"/>
<CMyFieldDb
title=""
table="users"
mykey="profile"
mysubkey="notifs"
jointable="usernotifs"
tablesel="usernotifs"
:type="costanti.FieldType.binary">
</CMyFieldDb>
</div> </div>
<q-list bordered class="rounded-borders" style="max-width: 350px; min-width: 250px;"> </CTitleBanner>
<q-separator/> </div>
<div class="clBorderSperator"></div>
<div class="q-ma-xs">
<q-list bordered class="rounded-borders">
<div v-if="getNumNotif() === 0"> <div v-if="getNumNotif() === 0">
<q-item> <q-item>
{{ $t('notifs.nonotif') }} <q-item-label lines="1">{{ $t('notifs.nonotif') }}</q-item-label>
</q-item> </q-item>
</div> </div>
<q-item clickable v-ripple v-for="(notif, index) in lasts_notifs()" :key="index" @click="clickChat(notif)"> <q-item clickable v-ripple v-for="(notif, index) in lasts_notifs()" :key="index" @click="clickChat(notif)">
<q-item-section avatar> <q-item-section avatar>
@@ -52,14 +77,10 @@
{{ tools.getstrDateTimeShort(notif.datenotif) }} {{ tools.getstrDateTimeShort(notif.datenotif) }}
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-separator/> <q-separator/>
</q-list> </q-list>
</q-menu> </div>
</q-btn> </q-drawer>
<q-btn v-if="false" flat round dense icon="fas fa-bell">
<q-badge v-if="getNumNotifUnread() > 0" floating color="red">{{ getNumNotifUnread() }}</q-badge>
</q-btn>
</div> </div>
</template> </template>

View File

@@ -78,6 +78,7 @@ export interface IUserProfile {
req_friends: IFriends[] req_friends: IFriends[]
mygroups: IMyGroup[] mygroups: IMyGroup[]
manage_mygroups: IMyGroup[] manage_mygroups: IMyGroup[]
notifs: number
// in memory // in memory
asked_friends: any[] asked_friends: any[]

View File

@@ -2,6 +2,7 @@
<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>
<q-btn color="green" label="Invia Notifica a " @click="sendNotifToUser"></q-btn>
<!--<CCopyBtn title="Copia Dati" :texttocopy="risultato"></CCopyBtn>--> <!--<CCopyBtn title="Copia Dati" :texttocopy="risultato"></CCopyBtn>-->

View File

@@ -750,7 +750,10 @@ const msg_it = {
notif: 'Notifica', notif: 'Notifica',
notifs: 'Notifiche', notifs: 'Notifiche',
nonotif: 'Nessuna Notifica', nonotif: 'Nessuna Notifica',
warn_province: 'Avvisami se nuovo annuncio in provincia', warn_province: 'in Provincia',
warn_city: 'in Città',
warn_my_groups: 'miei Gruppi',
warn_my_ris_circuit: 'miei Circuiti',
}, },
event: { event: {
_id: 'id', _id: 'id',

View File

@@ -2303,6 +2303,13 @@ export const colTableUsersISP = [
jointable: 'permissions', jointable: 'permissions',
titlepopupedit: 'Permessi' titlepopupedit: 'Permessi'
}), }),
AddCol({
name: 'notifs',
label_trans: 'reg.notifs',
fieldtype: costanti.FieldType.binary,
jointable: 'usernotifs',
titlepopupedit: 'Notifiche'
}),
AddCol({ name: 'ipaddr', label_trans: 'reg.ipaddr' }), AddCol({ name: 'ipaddr', label_trans: 'reg.ipaddr' }),
AddCol({ name: 'deleted', label_trans: 'reg.deleted', fieldtype: costanti.FieldType.boolean }), AddCol({ name: 'deleted', label_trans: 'reg.deleted', fieldtype: costanti.FieldType.boolean }),
AddCol(DeleteRec), AddCol(DeleteRec),
@@ -2700,6 +2707,15 @@ export const fieldsTable = {
colicon: 'icon', colicon: 'icon',
noshow: true, noshow: true,
}, },
{
value: 'usernotifs',
label: 'Notifiche',
columns: colTableGeneric,
colkey: 'value',
collabel: 'label',
colicon: 'icon',
noshow: true,
},
{ {
value: 'sites', value: 'sites',
label: 'Siti', label: 'Siti',

View File

@@ -54,6 +54,7 @@ export const DefaultUser: IUserFields = {
manage_mygroups: [], manage_mygroups: [],
asked_friends: [], asked_friends: [],
asked_groups: [], asked_groups: [],
notifs: 15,
}, },
cart: { cart: {
userId: '', userId: '',
@@ -99,6 +100,7 @@ export const DefaultProfile: IUserProfile = {
manage_mygroups: [], manage_mygroups: [],
asked_friends: [], asked_friends: [],
asked_groups: [], asked_groups: [],
notifs: 15,
} }
export const useUserStore = defineStore('UserStore', { export const useUserStore = defineStore('UserStore', {
@@ -991,6 +993,21 @@ export const useUserStore = defineStore('UserStore', {
}, },
async setUserNotifs(notifs: number) {
const data = {
notifs
}
return Api.SendReq('/users/notifs', 'POST', data)
.then((ris) => {
return ris.data
}).catch((error) => {
return {}
})
},
async loadUserPanel(username: string) { async loadUserPanel(username: string) {
const data = { const data = {
username username

View File

@@ -1591,6 +1591,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
else if (table === toolsext.TABTYPEACCOM) myarr = shared_consts.TypeAccom else if (table === toolsext.TABTYPEACCOM) myarr = shared_consts.TypeAccom
else if (table === toolsext.TABLOCACCOM) myarr = shared_consts.LocationAccom else if (table === toolsext.TABLOCACCOM) myarr = shared_consts.LocationAccom
else if (table === toolsext.TABPREF) myarr = shared_consts.Preferences else if (table === toolsext.TABPREF) myarr = shared_consts.Preferences
else if (table === 'usernotifs') myarr = shared_consts.UsersNotif_Adv_List
else myarr = this.getListByTable(table) else myarr = this.getListByTable(table)
if (costanti.TABLES_ARRAY.includes(table)) { if (costanti.TABLES_ARRAY.includes(table)) {

View File

@@ -106,7 +106,7 @@
table="users" table="users"
mykey="profile" mykey="profile"
mysubkey="qualifica" mysubkey="qualifica"
maxlength="40" maxlength="100"
:showall="true" :showall="true"
:type="costanti.FieldType.string"> :type="costanti.FieldType.string">
</CMyFieldDb> </CMyFieldDb>
@@ -116,7 +116,7 @@
table="users" table="users"
mykey="profile" mykey="profile"
mysubkey="biografia" mysubkey="biografia"
maxlength="300" maxlength="1000"
hint="Scrivi chi sei e quale percorso formativo hai fatto" hint="Scrivi chi sei e quale percorso formativo hai fatto"
:showall="true" :showall="true"
:type="costanti.FieldType.string"> :type="costanti.FieldType.string">