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: [
{
value: 0,
@@ -850,6 +849,35 @@ export const shared_consts = {
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) {
const trovatorec = this.OrderStatusStr.find((rec) => rec.value === status)
return (trovatorec) ? trovatorec.label : ''

View File

@@ -2,7 +2,7 @@
<div class="text-center">
<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;">
<template v-slot:control>
<div class="centermydiv">
@@ -21,6 +21,7 @@
</div>
<div :class="` q-ma-sm q-pa-sm col-grow popupedit `" :style="withBorder() ? `` : ``">
<CMyPopupEdit
v-bind="$attrs"
:rec="rec"

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,7 @@
v-if="listasharewithus && listasharewithus.length > 0" class="q-pa-xs"
:title="$t('pages.sharewithus')"
bgcolor="bg-white" clcolor="text-blue"
mystyle="" myclass="myshad" canopen="true">
mystyle="" myclass="myshad" :canopen="true">
<div class="flex flex-center">
@@ -55,7 +55,7 @@
v-if="listasharewithus() && listasharewithus().length > 0" class="q-pa-xs"
title="Graduatoria Attuale"
bgcolor="bg-white" clcolor="text-blue"
mystyle="" myclass="myshad" canopen="true">
mystyle="" myclass="myshad" :canopen="true">
<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')})"
bgcolor="bg-primary"
clcolor="text-white"
myclass="myshad" canopen="true" :visible="true">
myclass="myshad" :canopen="true" :visible="true">
<div v-if="showconditions">
<CVideo myvideokey="DWfQzbOCK3s"></CVideo>

View File

@@ -528,6 +528,11 @@ $heightBtn: 100%;
display: block;
}
.centermydiv2 {
margin-left: auto;
margin-right: auto;
}
.text-verified {
font-size: 1.25rem;
text-shadow: .05rem .05rem .15rem #fff;
@@ -638,6 +643,12 @@ $heightBtn: 100%;
padding: 8px;
}
.clBorderSperator {
background-color: blue;
font-size: 1rem;
padding: 4px;
}
.clBorderZoom {
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 {
IChat,
@@ -13,19 +13,37 @@ import MixinUsers from '../../../mixins/mixin-users'
import { useNotifStore } from '@store/NotifStore'
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'
export default defineComponent({
name: 'notifPopover',
components: { CTitleBanner, CMyFieldRec, CMyFieldDb },
setup(props) {
const $router = useRouter()
const userStore = useUserStore()
const notifStore = useNotifStore()
const { t } = useI18n()
const $q = useQuasar()
const loading = ref(false)
const myuser = ref({})
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>{
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) {
// $router.replace(`/notifs/${ msg.dest.username}`)
}
@@ -69,6 +100,7 @@ export default defineComponent({
function refreshdata(username: string) {
loading.value = true
userId.value = userStore.my._id
notifsel.value.dest = ''
@@ -90,9 +122,12 @@ export default defineComponent({
}
function mounted() {
myuser.value = userStore.my
refreshdata(userStore.my.username)
}
onMounted(mounted)
return {
lasts_notifs,
clickChat,
@@ -102,6 +137,12 @@ export default defineComponent({
getImgByNotif,
getNotifText,
tools,
usernotifs,
shared_consts,
userId,
myuser,
costanti,
open,
}
},
})

View File

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

View File

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

View File

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

View File

@@ -750,7 +750,10 @@ const msg_it = {
notif: 'Notifica',
notifs: 'Notifiche',
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: {
_id: 'id',

View File

@@ -2303,6 +2303,13 @@ export const colTableUsersISP = [
jointable: 'permissions',
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: 'deleted', label_trans: 'reg.deleted', fieldtype: costanti.FieldType.boolean }),
AddCol(DeleteRec),
@@ -2700,6 +2707,15 @@ export const fieldsTable = {
colicon: 'icon',
noshow: true,
},
{
value: 'usernotifs',
label: 'Notifiche',
columns: colTableGeneric,
colkey: 'value',
collabel: 'label',
colicon: 'icon',
noshow: true,
},
{
value: 'sites',
label: 'Siti',

View File

@@ -54,6 +54,7 @@ export const DefaultUser: IUserFields = {
manage_mygroups: [],
asked_friends: [],
asked_groups: [],
notifs: 15,
},
cart: {
userId: '',
@@ -99,6 +100,7 @@ export const DefaultProfile: IUserProfile = {
manage_mygroups: [],
asked_friends: [],
asked_groups: [],
notifs: 15,
}
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) {
const data = {
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.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 myarr = this.getListByTable(table)
if (costanti.TABLES_ARRAY.includes(table)) {

View File

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