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: {
NEW_ADV_PROVINCE: 1,
NEW_ADV_CITY: 2,
NEW_ADV_MY_GROUPS: 4,
NEW_ADV_MY_RIS_CIRCUIT: 8,
NEW_ADV_CITY: 1,
NEW_ADV_PROVINCE: 2,
NEW_ADV_REGION: 4,
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, //
labeltrans: 'typenotifs.new_rec_bacheca',
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, //
labeltrans: 'typenotifs.events',
descr: 'typenotifs.events_descr',
icon:'fas fa-bullhorn',
list: [
{
value: 1, // ID_EVENTS_NEW_REC
labeltrans: 'notifsid.events_new',
}
],
},
{
value: 3, //
labeltrans: 'typenotifs.friends',
descr: 'typenotifs.friends_descr',
icon:'fas fa-user-plus',
list: [
{
value: 1, // ID_FRIENDS_NEW_REC
labeltrans: 'notifsid.friends_new',
}
],
},
{
value: 4, //
labeltrans: 'typenotifs.circuits',
descr: 'typenotifs.circuits_descr',
icon:'fas fa-coins',
},
{
value: 5, //
labeltrans: 'typenotifs.booking',
descr: '',
icon:'fas fa-book-open',
},
],
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',
directory: 1,
},
{
value: 2, // NEW_ADV_CITY
labeltrans: 'notifs.warn_city',
value: 32, // NEW_ADV_SECTOR
labeltrans: 'notifs.warn_sector',
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',
directory: 1,
},
{
value: 8, // NEW_ADV_MY_RIS_CIRCUIT
value: 16, // NEW_ADV_MY_RIS_CIRCUIT
labeltrans: 'notifs.warn_my_ris_circuit',
directory: 1,
},

View File

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

View File

@@ -3,10 +3,10 @@
<div class="row items-center justify-center q-gutter-md q-ma-xs">
<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"
expand-separator
icon="perm_identity"
:icon="rec.icon"
:label="t(rec.labeltrans)"
>
<q-card>
@@ -30,6 +30,61 @@
:type="costanti.FieldType.binary">
</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>
</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 = static_data.routes
})

View File

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

View File

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

View File

@@ -28,6 +28,12 @@
</q-item-section>
<q-item-section>{{ $t('notifs.setallread') }}</q-item-section>
</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-menu>
</q-btn>
@@ -65,11 +71,11 @@
</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-avatar>
<q-item-label lines="1">{{ getTypeNotif(notif) }}</q-item-label>
<q-item-label lines="1">{{ getTypeDirNotif(notif) }}</q-item-label>
</q-avatar>
</q-item-section>-->
@@ -79,19 +85,19 @@
</q-avatar>
</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 caption lines="2">
{{ tools.getstrDateTimeShort(notif.datenotif) }}
<q-item-label caption lines="2" :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-pencil-alt">
<q-btn rounded icon="fas fa-ellipsis-h">
<q-menu>
<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-icon name="fas fa-trash-alt"/>
</q-item-section>
@@ -99,7 +105,7 @@
</q-item>
<q-item clickable v-close-popup @click="notifStore.deactivateRec(notif._id)">
<q-item-section side>
<q-icon name="fas fa-trash-alt"/>
<q-icon name="fas fa-bell-slash"/>
</q-item-section>
<q-item-section>{{ $t('notifs.deactivate_notif') }}</q-item-section>
</q-item>

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,16 +2,18 @@
<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">
<q-select rounded outlined v-model="notiftype" :options="listnotif" label="Tipo di Notifica" emit-value map-options>
<div class="q-ma-sm row" style="min-width: 300px;">
<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-input
v-model="mynotif" type="textarea" autofocus label="Notifica da Inviare"
input-class="myinput-area"
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>
</div>

View File

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

View File

@@ -1749,6 +1749,7 @@ export const tools = {
if (elem.meta && elem.meta.requiresAuth) {
visu = visu && this.isLoggedToSystem()
}
// console.log('MENU visu', elem.path, visu)
return visu
},
@@ -4003,7 +4004,7 @@ export const tools = {
let ris = true
const online = this.getValDb('SITO_ONLINE', false, true)
ris = userStore.isAdmin && !pertutti ? true : online
// console.log('isadmin', userStore.isAdmin)
console.log('sito_online', ris)
return ris
},
@@ -5537,7 +5538,7 @@ export const tools = {
},
getvalueAll(myval: string | Date) {
const mydate = new Date(myval);
const mydate = new Date(myval)
if (mydate instanceof Date && !isNaN(mydate.valueOf())) {
return this.getstrDateTime(mydate)
} 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() {
// if (navigator.languages && navigator.languages.length > 0) {

View File

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

View File

@@ -18,7 +18,7 @@ export const useNotifStore = defineStore('NotifStore', {
getters: {
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) : []
return (ctrec)
@@ -33,7 +33,7 @@ export const useNotifStore = defineStore('NotifStore', {
actions: {
setNotif(notif: INotif) {
// console.log('arrnotif', arrnotif)
console.log('setNotif', notif)
if (notif) {
this.last_notifs = [notif, ...this.last_notifs]
}
@@ -61,15 +61,42 @@ export const useNotifStore = defineStore('NotifStore', {
console.error(error)
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) {
return ''
},
async updateNotifDataFromServer({ username, lastdataread }: {username: string, lastdataread: Date}) {
@@ -94,14 +121,17 @@ export const useNotifStore = defineStore('NotifStore', {
async SendNotifEvent(notif: INotif) {
console.log('SendNotifEvent', notif)
const userStore = useUserStore()
const data: INotif = { ...NotifDefault, ...notif }
data.idapp = process.env.APP_ID
data.type = notif.type
data.typedir = notif.typedir
data.typeid = notif.typeid
data.sender = notif.sender
data.dest = notif.dest
data.descr = notif.descr
data.link = notif.link
data.datenotif = tools.getDateNow()
data.read = false
@@ -110,10 +140,12 @@ export const useNotifStore = defineStore('NotifStore', {
return Api.SendReq('/sendnotif', 'POST', data)
.then((res) => {
// console.log('res', res)
console.log('res', res)
if (res.status === 200) {
if (res.data.code === serv_constants.RIS_CODE_OK) {
this.setNotif(res.data)
if (res.data.code === serv_constants.RIS_CODE_OK && res.data.record) {
if (res.data.record.dest === userStore.my.username) {
this.setNotif(res.data.record)
}
return true
}
}

View File

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

View File

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