Notifications

Settings Notifications
User Panel
This commit is contained in:
Paolo Arena
2022-07-23 17:44:44 +02:00
parent 6ae82f14cc
commit e2006e683b
18 changed files with 328 additions and 69 deletions

View File

@@ -850,60 +850,121 @@ export const shared_consts = {
}, },
UsersNotif: { UsersNotif: {
NEW_ADV_PROVINCE: 1, NEW_ADV_CITY: 1,
NEW_ADV_CITY: 2, NEW_ADV_PROVINCE: 2,
NEW_ADV_MY_GROUPS: 4, NEW_ADV_REGION: 4,
NEW_ADV_MY_RIS_CIRCUIT: 8, NEW_ADV_MY_GROUPS: 8,
NEW_ADV_MY_RIS_CIRCUIT: 16,
NEW_ADV_SECTOR: 32,
}, },
typeNotifs: [ TypeNotifs: {
TYPEDIR_BACHECA: 1,
ID_BACHECA_NEW_GOOD: 1,
ID_BACHECA_NEW_SERVICE: 2,
TYPEDIR_EVENTS: 2,
ID_EVENTS_NEW_REC: 1,
ID_EVENTS_REMOVE_REC: 2,
TYPEDIR_FRIENDS: 3,
ID_FRIENDS_NEW_REC: 1,
TYPEDIR_CIRCUITS: 4,
TYPEDIR_BOOKING: 5,
TYPEDIR_MSGS: 6,
ID_MSGS_NEW_REC: 1,
},
TypeNotifs_Arr: [
{ {
value: 1, // value: 1, //
labeltrans: 'typenotifs.new_rec_bacheca', labeltrans: 'typenotifs.new_rec_bacheca',
descr: 'typenotifs.new_rec_bacheca_descr', descr: 'typenotifs.new_rec_bacheca_descr',
icon:'fas fa-house-user',
list: [
{
value: 1, // ID_BACHECA_NEW_GOOD
labeltrans: 'notifsid.bacheca_new_good',
},
{
value: 2, // ID_BACHECA_NEW_SERVICE
labeltrans: 'notifsid.bacheca_new_service',
}
],
}, },
{ {
value: 2, // value: 2, //
labeltrans: 'typenotifs.events', labeltrans: 'typenotifs.events',
descr: 'typenotifs.events_descr', descr: 'typenotifs.events_descr',
icon:'fas fa-bullhorn',
list: [
{
value: 1, // ID_EVENTS_NEW_REC
labeltrans: 'notifsid.events_new',
}
],
}, },
{ {
value: 3, // value: 3, //
labeltrans: 'typenotifs.friends', labeltrans: 'typenotifs.friends',
descr: 'typenotifs.friends_descr', descr: 'typenotifs.friends_descr',
icon:'fas fa-user-plus',
list: [
{
value: 1, // ID_FRIENDS_NEW_REC
labeltrans: 'notifsid.friends_new',
}
],
}, },
{ {
value: 4, // value: 4, //
labeltrans: 'typenotifs.circuits', labeltrans: 'typenotifs.circuits',
descr: 'typenotifs.circuits_descr', descr: 'typenotifs.circuits_descr',
icon:'fas fa-coins',
}, },
{ {
value: 5, // value: 5, //
labeltrans: 'typenotifs.booking', labeltrans: 'typenotifs.booking',
descr: '', descr: '',
icon:'fas fa-book-open',
}, },
], ],
UsersNotif_Adv_List: [ UsersNotif_Adv_List: [
/*{
value: 1, // NEW_ADV_CITY
labeltrans: 'notifs.warn_city',
directory: 1,
},*/
{ {
value: 1, // NEW_ADV_PROVINCE value: 2, // NEW_ADV_PROVINCE
labeltrans: 'notifs.warn_province', labeltrans: 'notifs.warn_province',
directory: 1, directory: 1,
}, },
{ {
value: 2, // NEW_ADV_CITY value: 32, // NEW_ADV_SECTOR
labeltrans: 'notifs.warn_city', labeltrans: 'notifs.warn_sector',
directory: 1, directory: 1,
}, },
{ {
value: 4, // NEW_ADV_MY_GROUPS value: 4, // NEW_ADV_PROVINCE
labeltrans: 'notifs.warn_region',
directory: 1,
},
{
value: 8, // NEW_ADV_MY_GROUPS
labeltrans: 'notifs.warn_my_groups', labeltrans: 'notifs.warn_my_groups',
directory: 1, directory: 1,
}, },
{ {
value: 8, // NEW_ADV_MY_RIS_CIRCUIT value: 16, // NEW_ADV_MY_RIS_CIRCUIT
labeltrans: 'notifs.warn_my_ris_circuit', labeltrans: 'notifs.warn_my_ris_circuit',
directory: 1, directory: 1,
}, },

View File

@@ -2,13 +2,15 @@ import { defineComponent, onMounted, PropType, ref, watch } from 'vue'
import { useQuasar } from 'quasar' import { useQuasar } from 'quasar'
import { useI18n } from '@/boot/i18n' import { useI18n } from '@/boot/i18n'
import { useGlobalStore } from '@store/globalStore' import { useGlobalStore } from '@store/globalStore'
import { useUserStore } from '@store/UserStore'
import { fieldsTable } from '@store/Modules/fieldsTable' import { fieldsTable } from '@store/Modules/fieldsTable'
import { tools } from '@store/Modules/tools' import { tools } from '@store/Modules/tools'
import { costanti } from '@costanti' import { costanti } from '@costanti'
import { shared_consts } from '@/common/shared_vuejs' import { shared_consts } from '@/common/shared_vuejs'
import { CMyFieldDb } from '@/components/CMyFieldDb' import { CMyFieldDb } from '@/components/CMyFieldDb'
import { CDateTime } from '@/components/CDateTime' import { CDateTime } from '@/components/CDateTime'
import { toolsext } from '@src/store/Modules/toolsext'
import { computed } from 'vue'
export default defineComponent({ export default defineComponent({
name: 'CNotifSettings', name: 'CNotifSettings',
@@ -19,6 +21,9 @@ export default defineComponent({
const $q = useQuasar() const $q = useQuasar()
const { t } = useI18n() const { t } = useI18n()
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
const userStore = useUserStore()
const profile = computed(() => userStore.my.profile)
function mounted() { function mounted() {
@@ -34,6 +39,8 @@ export default defineComponent({
shared_consts, shared_consts,
fieldsTable, fieldsTable,
globalStore, globalStore,
toolsext,
profile,
} }
}, },
}) })

View File

@@ -3,10 +3,10 @@
<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">
<q-list bordered class="rounded-borders"> <q-list bordered class="rounded-borders">
<q-expansion-item v-for="(rec, index) in shared_consts.typeNotifs" <q-expansion-item v-for="(rec, index) in shared_consts.TypeNotifs_Arr"
:key="index" :key="index"
expand-separator expand-separator
icon="perm_identity" :icon="rec.icon"
:label="t(rec.labeltrans)" :label="t(rec.labeltrans)"
> >
<q-card> <q-card>
@@ -30,6 +30,61 @@
:type="costanti.FieldType.binary"> :type="costanti.FieldType.binary">
</CMyFieldDb> </CMyFieldDb>
<div v-if="rec.value === shared_consts.TypeNotifs.TYPEDIR_BACHECA">
<div
v-if="tools.isBitActive(profile.notifs.find((rec) => rec.dir === shared_consts.TypeNotifs.TYPEDIR_BACHECA).value, shared_consts.UsersNotif.NEW_ADV_SECTOR)">
<CMyFieldDb
:title="$t('sectors.sector_general')"
table="users"
mykey="profile"
mysubkey="notif_sectors"
:jointable="toolsext.TABSECTORS"
:type="costanti.FieldType.multiselect">
</CMyFieldDb>
<CMyFieldDb
:title="$t('sectors.sector_goods')"
table="users"
mykey="profile"
mysubkey="notif_sector_goods"
:jointable="toolsext.TABSECTORGOODS"
:type="costanti.FieldType.multiselect">
</CMyFieldDb>
</div>
<div
v-if="tools.isBitActive(profile.notifs.find((rec) => rec.dir === shared_consts.TypeNotifs.TYPEDIR_BACHECA).value, shared_consts.UsersNotif.NEW_ADV_REGION)">
<CMyFieldDb
:title="$t('notifs.select_regions')"
table="users"
mykey="profile"
mysubkey="notif_regions"
:jointable="toolsext.TABREGIONS"
:type="costanti.FieldType.multiselect">
</CMyFieldDb>
</div>
<div
v-if="tools.isBitActive(profile.notifs.find((rec) => rec.dir === shared_consts.TypeNotifs.TYPEDIR_BACHECA).value, shared_consts.UsersNotif.NEW_ADV_PROVINCE)">
<CMyFieldDb
:title="$t('notifs.select_provinces')"
table="users"
mykey="profile"
mysubkey="notif_provinces"
:jointable="toolsext.TABPROVINCE"
:type="costanti.FieldType.multiselect">
</CMyFieldDb>
</div>
<!--<CMyFieldDb
:title="$t('notification.cities')"
table="users"
mykey="profile"
mysubkey="notif_cities"
:jointable="toolsext.TABCITIES"
:type="costanti.FieldType.multiselect_by_server">
</CMyFieldDb>-->
</div>
</q-card-section> </q-card-section>
</q-card> </q-card>
</q-expansion-item> </q-expansion-item>

View File

@@ -42,7 +42,7 @@ export default defineComponent({
}) })
} }
watch(() => userStore.isLogged,(to, from) => { watch(() => userStore.isLogged || finishLoading.value,(to, from) => {
myroutes.value = [] myroutes.value = []
myroutes.value = static_data.routes myroutes.value = static_data.routes
}) })

View File

@@ -17,7 +17,12 @@
} }
.unread { .unread {
font-weight: bold;
}
.unread-date {
color: royalblue;
font-weight: 600;
} }
.read { .read {

View File

@@ -5,6 +5,8 @@ import {
IMessage, IMsgUsers, INotif, IMessage, IMsgUsers, INotif,
} from '@model' } from '@model'
import { date } from 'quasar'
import { tools } from '@src/store/Modules/tools' import { tools } from '@src/store/Modules/tools'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
@@ -53,7 +55,7 @@ export default defineComponent({
datenotif: new Date() datenotif: new Date()
}) })
const { getNumNotifUnread, getNumNotif, getUsernameChatByNotif, getImgByNotif, getNotifText, getTypeNotif } = MixinUsers() const { getNumNotifUnread, getNumNotif, getUsernameChatByNotif, getImgByNotif, getNotifText, getTypeDirNotif, getTypeIdNotif } = MixinUsers()
// function lasts_notifs (state: IUserState) => IMessage[] { // function lasts_notifs (state: IUserState) => IMessage[] {
// //
@@ -79,8 +81,8 @@ export default defineComponent({
}) })
function clickNotif(notif: INotif) { function clickNotif(notif: INotif) {
if (notif.link) { if (notif.openUrl) {
let mylink = tools.updateQueryStringParameter(notif.link, 'idnotif', notif._id) let mylink = tools.updateQueryStringParameter(notif.openUrl, 'idnotif', notif._id)
console.log('mylink', mylink, notif._id) console.log('mylink', mylink, notif._id)
if (mylink) { if (mylink) {
$router.replace(mylink) $router.replace(mylink)
@@ -155,7 +157,8 @@ export default defineComponent({
getUsernameChatByNotif, getUsernameChatByNotif,
getImgByNotif, getImgByNotif,
getNotifText, getNotifText,
getTypeNotif, getTypeDirNotif,
getTypeIdNotif,
tools, tools,
usernotifs, usernotifs,
shared_consts, shared_consts,

View File

@@ -28,6 +28,12 @@
</q-item-section> </q-item-section>
<q-item-section>{{ $t('notifs.setallread') }}</q-item-section> <q-item-section>{{ $t('notifs.setallread') }}</q-item-section>
</q-item> </q-item>
<q-item clickable v-close-popup @click="notifStore.deleteAll(username)">
<q-item-section side>
<q-icon name="fas fa-trash-alt"/>
</q-item-section>
<q-item-section>{{ $t('notifs.deleteall') }}</q-item-section>
</q-item>
</q-list> </q-list>
</q-menu> </q-menu>
</q-btn> </q-btn>
@@ -65,11 +71,11 @@
</div> </div>
<q-item clickable v-for="(notif, index) in lasts_notifs" :key="index" @click="clickNotif(notif)"> <q-item clickable v-for="(notif, index) in lasts_notifs" :key="index">
<!--<q-item-section avatar> <!--<q-item-section avatar>
<q-avatar> <q-avatar>
<q-item-label lines="1">{{ getTypeNotif(notif) }}</q-item-label> <q-item-label lines="1">{{ getTypeDirNotif(notif) }}</q-item-label>
</q-avatar> </q-avatar>
</q-item-section>--> </q-item-section>-->
@@ -79,19 +85,19 @@
</q-avatar> </q-avatar>
</q-item-section> </q-item-section>
<q-item-section v-ripple > <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="1" :class="(!notif.read) ? 'unread' : 'read'">{{ getNotifText(notif, false) }}</q-item-label>
<q-item-label caption lines="2"> <q-item-label caption lines="2" :class="(!notif.read) ? 'unread-date' : 'read-date'">
{{ tools.getstrDateTimeShort(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-pencil-alt"> <q-btn 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(notif._id)"> <q-item clickable v-close-popup @click="notifStore.deleteRec(username, notif._id)">
<q-item-section side> <q-item-section side>
<q-icon name="fas fa-trash-alt"/> <q-icon name="fas fa-trash-alt"/>
</q-item-section> </q-item-section>
@@ -99,7 +105,7 @@
</q-item> </q-item>
<q-item clickable v-close-popup @click="notifStore.deactivateRec(notif._id)"> <q-item clickable v-close-popup @click="notifStore.deactivateRec(notif._id)">
<q-item-section side> <q-item-section side>
<q-icon name="fas fa-trash-alt"/> <q-icon name="fas fa-bell-slash"/>
</q-item-section> </q-item-section>
<q-item-section>{{ $t('notifs.deactivate_notif') }}</q-item-section> <q-item-section>{{ $t('notifs.deactivate_notif') }}</q-item-section>
</q-item> </q-item>

View File

@@ -187,15 +187,12 @@ export default function () {
return '' return ''
} }
function getTypeNotif(msg: INotif) { function getTypeDirNotif(msg: INotif) {
if (msg) { return (msg && msg.typedir) ? msg.typedir : 0
if (msg.type) {
return msg.type
} }
} else {
return '' function getTypeIdNotif(msg: INotif) {
} return (msg && msg.typeid) ? msg.typeid : 0
return ''
} }
function getImgByNotif(notif: INotif) { function getImgByNotif(notif: INotif) {
@@ -206,7 +203,6 @@ export default function () {
} }
return { return {
getUsernameChatByMsg, getUsernameChatByMsg,
getMyUsername, getMyUsername,
@@ -232,7 +228,8 @@ export default function () {
getNumNotifUnread, getNumNotifUnread,
getNumNotif, getNumNotif,
getUsernameChatByNotif, getUsernameChatByNotif,
getTypeNotif, getTypeDirNotif,
getTypeIdNotif,
getImgByNotif, getImgByNotif,
getNotifText, getNotifText,
} }

View File

@@ -53,7 +53,8 @@ export const MsgDefault: IMessage = {
export const NotifDefault: INotif = { export const NotifDefault: INotif = {
_id: '', _id: '',
idapp: '', idapp: '',
type: 0, typedir: 0,
typeid: 0,
sender: '', sender: '',
dest: '', dest: '',
descr: '', descr: '',
@@ -80,14 +81,17 @@ export interface IMessage {
export interface INotif { export interface INotif {
_id?: any _id?: any
idapp?: string idapp?: string
type: number typedir: number
typeid: number
sender: string, sender: string,
dest: string, dest: string,
descr: string descr: string
datenotif?: Date datenotif?: Date
status?: StatusMessage status?: StatusMessage
link?: string openUrl?: string
read?: boolean read?: boolean
tablerec?: string
idrec?: string
deleted?: boolean deleted?: boolean
} }

View File

@@ -86,6 +86,11 @@ export interface IUserProfile {
mygroups: IMyGroup[] mygroups: IMyGroup[]
manage_mygroups: IMyGroup[] manage_mygroups: IMyGroup[]
notifs: IUserNotifType[] notifs: IUserNotifType[]
notif_idCities: number[]
notif_provinces: string[]
notif_regions: string[]
notif_sectors: number[]
notif_sector_goods: number[]
// in memory // in memory
asked_friends: any[] asked_friends: any[]

View File

@@ -1,5 +1,6 @@
import { defineComponent, onMounted, ref } from 'vue' import { defineComponent, onMounted, ref } from 'vue'
import { computed } from 'vue'
import { CMyPage } from '@/components/CMyPage' import { CMyPage } from '@/components/CMyPage'
import { CCopyBtn } from '@/components/CCopyBtn' import { CCopyBtn } from '@/components/CCopyBtn'
import { CKeyAndValue } from '@/components/CKeyAndValue' import { CKeyAndValue } from '@/components/CKeyAndValue'
@@ -31,12 +32,26 @@ 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 mylink = ref('') const notifdirtype = ref(1)
const notiftype = ref(1) const notifidtype = ref(1)
const listnotif = ref(<any>[]) const listnotif = ref(<any>[])
const listnotiftype = ref(<any>[])
const { t } = useI18n(); const { t } = useI18n();
const listnotifid = computed(() => {
if (notifdirtype.value) {
const mylist: any = shared_consts.TypeNotifs_Arr.find((rec: any) => rec.value === notifdirtype.value)
if (mylist) {
for (const rec of mylist.list) {
rec.label = t(rec.labeltrans)
}
}
return mylist.list
}
return []
})
const userStore = useUserStore() const userStore = useUserStore()
const notifStore = useNotifStore() const notifStore = useNotifStore()
@@ -50,6 +65,12 @@ export default defineComponent({
for (const rec of listnotif.value) { for (const rec of listnotif.value) {
rec.label = t(rec.labeltrans) rec.label = t(rec.labeltrans)
} }
listnotiftype.value = shared_consts.TypeNotifs_Arr
for (const rec of listnotiftype.value) {
rec.label = t(rec.labeltrans)
}
} }
function changeCol(newval: any) { function changeCol(newval: any) {
@@ -83,11 +104,11 @@ export default defineComponent({
if (!!myuser.value) { if (!!myuser.value) {
const notif: INotif = { const notif: INotif = {
type: notiftype.value, typedir: notifdirtype.value,
typeid: notifidtype.value,
sender: userStore.my.username, sender: userStore.my.username,
dest: myuser.value.username, dest: myuser.value.username,
descr: mynotif.value, descr: mynotif.value,
link: mylink.value,
} }
await notifStore.SendNotifEvent(notif) await notifStore.SendNotifEvent(notif)
@@ -112,9 +133,11 @@ export default defineComponent({
sendNotifToUser, sendNotifToUser,
risultato, risultato,
mynotif, mynotif,
mylink, notifdirtype,
notiftype, notifidtype,
listnotif, listnotif,
listnotiftype,
listnotifid,
} }
} }
}) })

View File

@@ -2,16 +2,18 @@
<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"> <div class="q-ma-sm row" style="min-width: 300px;">
<q-select rounded outlined v-model="notiftype" :options="listnotif" label="Tipo di Notifica" emit-value map-options>
<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>
<q-input <q-input
v-model="mynotif" type="textarea" autofocus label="Notifica da Inviare" v-model="mynotif" type="textarea" autofocus label="Notifica da Inviare"
input-class="myinput-area" input-class="myinput-area"
style="height: 100px; width: 500px;"></q-input> style="height: 100px; width: 500px;"></q-input>
<q-input
v-model="mylink" label="Link"></q-input>
<q-btn color="green" :label="`Invia Notifica a ` + myuser.username" @click="sendNotifToUser"></q-btn> <q-btn color="green" :label="`Invia Notifica a ` + myuser.username" @click="sendNotifToUser"></q-btn>
</div> </div>

View File

@@ -640,6 +640,8 @@ const msg_it = {
title_subscribed: 'Sottoscrizione a {sitename}!', title_subscribed: 'Sottoscrizione a {sitename}!',
subscribed: 'Ora potrai ricevere i messaggi e le notifiche.', subscribed: 'Ora potrai ricevere i messaggi e le notifiche.',
newVersionAvailable: 'Aggiorna', newVersionAvailable: 'Aggiorna',
provinces: 'Province',
cities: 'Comuni',
}, },
connection: { connection: {
conn: 'Connessione', conn: 'Connessione',
@@ -750,18 +752,23 @@ const msg_it = {
notread: 'Non lette', notread: 'Non lette',
settings: 'Configura Notifiche', settings: 'Configura Notifiche',
setallread: 'Segna tutte come già lette', setallread: 'Segna tutte come già lette',
deleteall: 'Cancella tutte le notifiche',
telegrammsg: 'Telegram', telegrammsg: 'Telegram',
notif: 'Notifica', notif: 'Notifica',
notifs: 'Notifiche', notifs: 'Notifiche',
nonotif: 'Nessuna Nuova Notifica', nonotif: 'Nessuna Nuova Notifica',
warn_province: 'in Provincia', warn_province: 'nelle Province',
warn_city: 'in Città', warn_sector: 'in un Settore',
warn_my_groups: 'miei Gruppi', warn_region: 'nelle Regioni',
warn_my_ris_circuit: 'miei Circuiti', warn_city: 'in una Città selezionata',
warn_my_groups: 'nei miei Gruppi',
warn_my_ris_circuit: 'nei miei Circuiti',
new_event: 'Nuovo Evento', new_event: 'Nuovo Evento',
new_friends: 'Nuove Richieste di Amicizia', new_friends: 'Nuove Richieste di Amicizia',
delete_notif: 'Elimina questa notifica', delete_notif: 'Elimina questa notifica',
deactivate_notif: 'Smetti di ricevere notifiche come questa', deactivate_notif: 'Smetti di ricevere notifiche come questa',
select_provinces: 'Scegli le Provincie da cui ricevere le notifiche',
select_regions: 'Scegli le Regioni da cui ricevere le notifiche',
}, },
typenotifs: { typenotifs: {
new_rec_bacheca: 'Annunci', new_rec_bacheca: 'Annunci',
@@ -774,6 +781,12 @@ const msg_it = {
circuits_descr: 'Avvisami:', circuits_descr: 'Avvisami:',
booking: 'Prenotazioni', booking: 'Prenotazioni',
}, },
notifsid: {
bacheca_new_good: 'Nuovo Bene',
bacheca_new_service: 'Nuovo Servizio',
events_new: 'Nuovo Evento',
friends_new: 'Nuova Richiesta di Amicizia',
},
event: { event: {
_id: 'id', _id: 'id',
typol: 'Typology', typol: 'Typology',
@@ -919,6 +932,8 @@ const msg_it = {
}, },
sectors: { sectors: {
name: 'Settore', name: 'Settore',
sector_general: 'Settori',
sector_goods: 'Settori dei Beni',
}, },
catgrps: { catgrps: {
name: 'Categoria', name: 'Categoria',
@@ -1003,6 +1018,7 @@ const msg_it = {
city: { city: {
prov: 'Provincia', prov: 'Provincia',
reg: 'Regione', reg: 'Regione',
regs: 'Regioni',
link_grp: 'Link Territoriale', link_grp: 'Link Territoriale',
}, },
annunci: { annunci: {

View File

@@ -1749,6 +1749,7 @@ export const tools = {
if (elem.meta && elem.meta.requiresAuth) { if (elem.meta && elem.meta.requiresAuth) {
visu = visu && this.isLoggedToSystem() visu = visu && this.isLoggedToSystem()
} }
// console.log('MENU visu', elem.path, visu)
return visu return visu
}, },
@@ -4003,7 +4004,7 @@ export const tools = {
let ris = true let ris = true
const online = this.getValDb('SITO_ONLINE', false, true) const online = this.getValDb('SITO_ONLINE', false, true)
ris = userStore.isAdmin && !pertutti ? true : online ris = userStore.isAdmin && !pertutti ? true : online
// console.log('isadmin', userStore.isAdmin) console.log('sito_online', ris)
return ris return ris
}, },
@@ -5537,7 +5538,7 @@ export const tools = {
}, },
getvalueAll(myval: string | Date) { getvalueAll(myval: string | Date) {
const mydate = new Date(myval); const mydate = new Date(myval)
if (mydate instanceof Date && !isNaN(mydate.valueOf())) { if (mydate instanceof Date && !isNaN(mydate.valueOf())) {
return this.getstrDateTime(mydate) return this.getstrDateTime(mydate)
} else { } else {
@@ -5556,6 +5557,30 @@ export const tools = {
} }
}, },
timeAgo(input: any) {
const date = (input instanceof Date) ? input : new Date(input)
const formatter = new Intl.RelativeTimeFormat(toolsext.getLocale() || 'it')
const ranges: any = {
years: 3600 * 24 * 365,
months: 3600 * 24 * 30,
weeks: 3600 * 24 * 7,
days: 3600 * 24,
hours: 3600,
minutes: 60,
seconds: 1
}
const secondsElapsed = (date.getTime() - Date.now()) / 1000
let key: any
for (key in ranges) {
if (ranges[key] < Math.abs(secondsElapsed)) {
// @ts-ignore
const delta = secondsElapsed / ranges[key]
// @ts-ignore
return formatter.format(Math.round(delta), key)
}
}
},
// getLocale() { // getLocale() {
// if (navigator.languages && navigator.languages.length > 0) { // if (navigator.languages && navigator.languages.length > 0) {

View File

@@ -63,6 +63,7 @@ export const toolsext = {
TABMYGROUPS: 'mygroups', TABMYGROUPS: 'mygroups',
TABSKILLS: 'skills', TABSKILLS: 'skills',
TABSECTORS: 'sectors', TABSECTORS: 'sectors',
TABSECTORGOODS: 'sectorgoods',
TABREGIONS: 'regions', TABREGIONS: 'regions',
TABCITIES: 'cities', TABCITIES: 'cities',
TABPROVINCE: 'provinces', TABPROVINCE: 'provinces',

View File

@@ -18,7 +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, 5).filter((rec) => mystate.show_all ? true : !rec.read) : [] 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.notifs) ? mystate.notifs.slice().reverse().slice(0, 5) : []
return (ctrec) return (ctrec)
@@ -33,7 +33,7 @@ export const useNotifStore = defineStore('NotifStore', {
actions: { actions: {
setNotif(notif: INotif) { setNotif(notif: INotif) {
// console.log('arrnotif', arrnotif) console.log('setNotif', notif)
if (notif) { if (notif) {
this.last_notifs = [notif, ...this.last_notifs] this.last_notifs = [notif, ...this.last_notifs]
} }
@@ -61,15 +61,42 @@ export const useNotifStore = defineStore('NotifStore', {
console.error(error) console.error(error)
return false return false
}) })
},
deleteRec(username: string, id: string) {
return Api.SendReq(`/sendnotif/del/${username}/${id}/${process.env.APP_ID}`, 'GET', null)
.then((res) => {
// console.log('res', res)
if (res) {
this.last_notifs = this.last_notifs.filter((rec) => rec._id !== id)
}
})
.catch((error) => {
console.error(error)
return false
})
}, },
deleteRec(id: string) { deleteAll(username: string, id: string) {
return Api.SendReq(`/sendnotif/delall/${username}/${process.env.APP_ID}`, 'GET', null)
.then((res) => {
// console.log('res', res)
if (res) {
this.last_notifs = []
}
})
.catch((error) => {
console.error(error)
return false
})
}, },
deactivateRec(id: string) { deactivateRec(id: string) {
return ''
}, },
async updateNotifDataFromServer({ username, lastdataread }: {username: string, lastdataread: Date}) { async updateNotifDataFromServer({ username, lastdataread }: {username: string, lastdataread: Date}) {
@@ -94,14 +121,17 @@ export const useNotifStore = defineStore('NotifStore', {
async SendNotifEvent(notif: INotif) { async SendNotifEvent(notif: INotif) {
console.log('SendNotifEvent', notif) console.log('SendNotifEvent', notif)
const userStore = useUserStore()
const data: INotif = { ...NotifDefault, ...notif } const data: INotif = { ...NotifDefault, ...notif }
data.idapp = process.env.APP_ID data.idapp = process.env.APP_ID
data.type = notif.type data.typedir = notif.typedir
data.typeid = notif.typeid
data.sender = notif.sender data.sender = notif.sender
data.dest = notif.dest data.dest = notif.dest
data.descr = notif.descr data.descr = notif.descr
data.link = notif.link
data.datenotif = tools.getDateNow() data.datenotif = tools.getDateNow()
data.read = false data.read = false
@@ -110,10 +140,12 @@ export const useNotifStore = defineStore('NotifStore', {
return Api.SendReq('/sendnotif', 'POST', data) return Api.SendReq('/sendnotif', 'POST', data)
.then((res) => { .then((res) => {
// console.log('res', res) console.log('res', res)
if (res.status === 200) { if (res.status === 200) {
if (res.data.code === serv_constants.RIS_CODE_OK) { if (res.data.code === serv_constants.RIS_CODE_OK && res.data.record) {
this.setNotif(res.data) if (res.data.record.dest === userStore.my.username) {
this.setNotif(res.data.record)
}
return true return true
} }
} }

View File

@@ -55,6 +55,11 @@ export const DefaultUser: IUserFields = {
asked_friends: [], asked_friends: [],
asked_groups: [], asked_groups: [],
notifs: [], notifs: [],
notif_idCities: [],
notif_provinces: [],
notif_regions: [],
notif_sectors: [],
notif_sector_goods: [],
}, },
cart: { cart: {
userId: '', userId: '',
@@ -101,6 +106,11 @@ export const DefaultProfile: IUserProfile = {
asked_friends: [], asked_friends: [],
asked_groups: [], asked_groups: [],
notifs: [], notifs: [],
notif_idCities: [],
notif_provinces: [],
notif_regions: [],
notif_sectors: [],
notif_sector_goods: [],
} }
export const useUserStore = defineStore('UserStore', { export const useUserStore = defineStore('UserStore', {

View File

@@ -338,13 +338,14 @@ export const useGlobalStore = defineStore('GlobalStore', {
}, },
addDynamicPages($router: Router | null) { addDynamicPages($router: Router | null) {
// console.log('this.mypage', this.mypage)
// console.log('addDynamicPages') // console.log('addDynamicPages')
const arrpagesroute: IListRoutes[] = [] const arrpagesroute: IListRoutes[] = []
for (const page of this.mypage) { for (const page of this.mypage) {
if (page.active) { if (page.active) {
// console.log('page', page.lang)
if (this.isMyLang(page)) { if (this.isMyLang(page)) {
// console.log('page.active', page.title)
// console.log('page', page.title, 'OK') // console.log('page', page.title, 'OK')
arrpagesroute.push({ arrpagesroute.push({
active: true, active: true,
@@ -416,17 +417,21 @@ export const useGlobalStore = defineStore('GlobalStore', {
if ($router) { if ($router) {
if (tools.sito_online(false)) { if (tools.sito_online(false)) {
// console.log('SITO ONLINE', arrpagesroute)
arrpagesroute.forEach(function (route: any) { arrpagesroute.forEach(function (route: any) {
$router.addRoute(route) $router.addRoute(route)
}) })
$router.addRoute(last) $router.addRoute(last)
} else { } else {
// console.log('SITO OFFLINE')
$router.addRoute(sito_offline) $router.addRoute(sito_offline)
$router.addRoute(last) $router.addRoute(last)
$router.replace('/sito_offline') $router.replace('/sito_offline')
} }
// console.log('getRoutes', $router.getRoutes())
const mypathsel = $router.currentRoute.value.fullPath const mypathsel = $router.currentRoute.value.fullPath
if (mypathsel !== '/') { if (mypathsel !== '/') {
// console.log('mypathsel', mypathsel) // console.log('mypathsel', mypathsel)
@@ -898,6 +903,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
if (res) { if (res) {
const index = this.mypage.findIndex((rec) => rec.path === path) const index = this.mypage.findIndex((rec) => rec.path === path)
if (index >= 0) { if (index >= 0) {
console.log('load page', path, '...')
this.mypage[index] = res.data.mypage this.mypage[index] = res.data.mypage
} }
return res.data.mypage return res.data.mypage
@@ -1360,8 +1366,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
if (showall) { if (showall) {
this.newstosent = (res.data.newstosent) ? [...res.data.newstosent] : [] this.newstosent = (res.data.newstosent) ? [...res.data.newstosent] : []
this.mailinglist = (res.data.mailinglist) ? [...res.data.mailinglist] : [] this.mailinglist = (res.data.mailinglist) ? [...res.data.mailinglist] : []
this.mypage = (res.data.mypage) ? [...res.data.mypage] : []
} }
this.mypage = (res.data.mypage) ? [...res.data.mypage] : []
console.log('this.mypage', this.mypage)
let isLogged = false let isLogged = false
@@ -1592,7 +1599,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
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 if (table === 'usernotifs') myarr = shared_consts.UsersNotif_Adv_List
else if (table === 'typenotifs') myarr = shared_consts.typeNotifs else if (table === 'typenotifs') myarr = shared_consts.TypeNotifs_Arr
else myarr = this.getListByTable(table) else myarr = this.getListByTable(table)
if (costanti.TABLES_ARRAY.includes(table)) { if (costanti.TABLES_ARRAY.includes(table)) {