Site Configuration by Server Params (confsites and confpages)

This commit is contained in:
Surya Paolo
2022-11-28 14:00:15 +01:00
parent fab0dbbb72
commit 58dc1dfdcc
76 changed files with 2504 additions and 5004 deletions

View File

@@ -9,6 +9,7 @@ import {
IMyPage, IMySkill, IParamsPickup,
IParamsQuery,
ISettings,
ISites,
StateConnection,
} from '@model'
import { static_data } from '@src/db/static_data'
@@ -32,6 +33,8 @@ import { useTodoStore } from '@store/Todos'
import { useMessageStore } from './MessageStore'
import { useNotifStore } from '@store/NotifStore'
import { useCircuitStore } from '@store/CircuitStore'
import { routesAdmin } from '@src/router/routesAdmin'
import LandingFooter from '@src/components/LandingFooter/LandingFooter'
const stateConnDefault = 'online'
@@ -270,7 +273,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
return state.skills
else if (table === 'goods')
return state.goods
// else if (table === 'subskills')
// else if (table === 'subskills')
// return state.subSkills
else if (table === 'statusSkills')
return state.statusSkills
@@ -306,7 +309,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
},
actions: {
setValueSettingsByKey({ key, value, serv }: {key: string, value: any, serv: boolean}): any {
setValueSettingsByKey({ key, value, serv }: { key: string, value: any, serv: boolean }): any {
// Update the Server
// Update in Memory
@@ -351,6 +354,43 @@ export const useGlobalStore = defineStore('GlobalStore', {
return this.stateConnection === 'online'
},
getLangAvailable() {
let myarrLang = []
// console.log('lang Server: ', this.site.confpages.lang)
if (tools.isLangEnabled(costanti.Lang.IT)) {
myarrLang.push({
label: 'Italiano', icon: 'fa-flag-it', value: 'it', image: '../images/it.png', short: 'IT',
})
}
if (tools.isLangEnabled(costanti.Lang.EN)) {
// console.log('ENG')
myarrLang.push(
{
label: 'English', icon: 'fa-flag-us', value: 'enUs', image: '../images/gb.png', short: 'EN',
},
)
}
if (tools.isLangEnabled(costanti.Lang.ES)) {
myarrLang.push(
{
label: 'Español', icon: 'fa-flag-es', value: 'es', image: '../images/es.png', short: 'ES',
},
)
}
if (tools.isLangEnabled(costanti.Lang.FR)) {
myarrLang.push(
{ label: 'Français', icon: 'fa-facebook', value: 'fr', image: '../public/images/fr.png', short: 'FR' })
}
if (tools.isLangEnabled(costanti.Lang.DE)) {
myarrLang.push(
{ label: 'German', icon: 'fa-flag-de', value: 'de', image: '../public/images/de.png', short: 'DE' }
)
}
return myarrLang
},
addDynamicPages($router: Router | null) {
// console.log('this.mypage', this.mypage)
// console.log('addDynamicPages')
@@ -387,6 +427,10 @@ export const useGlobalStore = defineStore('GlobalStore', {
}
}
const baseroutes = static_data.getDynamicPages(this.site);
const adminRoutes = routesAdmin.routesAd(this.site);
const last = {
active: true,
order: 10000,
@@ -412,7 +456,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
if (!toolsext.sito_online(false)) {
static_data.routes = [sito_offline, last]
} else {
static_data.routes = [...static_data.baseroutes, ...arrpagesroute, last]
static_data.routes = [...baseroutes, ...adminRoutes, ...arrpagesroute, last]
}
for (const menu of static_data.routes) {
@@ -433,17 +477,13 @@ export const useGlobalStore = defineStore('GlobalStore', {
// console.log('$router', $router)
if ($router) {
if (tools.sito_online(false)) {
// console.log('SITO ONLINE', arrpagesroute)
arrpagesroute.forEach((route: any) => {
static_data.routes.forEach((route: any) => {
if (!$router.hasRoute(route.name)) {
$router.addRoute(route)
})
}
})
$router.addRoute(last)
} else {
// console.log('SITO OFFLINE')
$router.addRoute(sito_offline)
$router.addRoute(last)
if (!tools.sito_online(false)) {
$router.replace('/sito_offline')
}
@@ -587,7 +627,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
// return
// }
if (!static_data.functionality.PWA)
if (!this.site.confpages.enablePwa)
return
if (!('serviceWorker' in navigator)) {
@@ -717,7 +758,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
//
}
if (static_data.functionality.PWA) {
if (this.site.confpages.enablePwa) {
if ('serviceWorker' in navigator) {
// REMOVE ALL SUBSCRIPTION
console.log('REMOVE ALL SUBSCRIPTION...')
@@ -736,8 +777,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
}
})
}).catch((err) => {
console.error('err ready service worker', err)
})
console.error('err ready service worker', err)
})
}
}
@@ -817,7 +858,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async sendPushNotif({ params }: {params: any}) {
async sendPushNotif({ params }: { params: any }) {
return Api.SendReq('/push/send', 'POST', { params })
.then((res) => {
@@ -920,8 +961,10 @@ export const useGlobalStore = defineStore('GlobalStore', {
path = path.substring(1)
const mypage = this.getPage(`/${path}`)
console.log('mypage', mypage)
// Controlla se l'ho già caricato
if (!!mypage && (!!mypage.content || mypage.loadFirst)) {
if (!!mypage && (!!mypage.content || mypage.loadFirst || mypage.loaded)) {
return mypage
}
@@ -935,6 +978,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
if (index >= 0) {
console.log('load page', path, '...')
this.mypage[index] = res.data.mypage
this.mypage[index].loaded = true
}
return res.data.mypage
}
@@ -1045,7 +1089,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
.catch((error) => false)
},
async callFunz({ mydata }: {mydata: any}) {
async callFunz({ mydata }: { mydata: any }) {
// console.log('saveFieldValue', mydata)
return Api.SendReq('/callfunz', 'PATCH', { data: mydata })
@@ -1060,7 +1104,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async askFunz({ mydata }: {mydata: any}) {
async askFunz({ mydata }: { mydata: any }) {
// console.log('saveFieldValue', mydata)
return Api.SendReq('/askfunz', 'PATCH', { data: mydata })
@@ -1072,7 +1116,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async DeleteRec({ table, id }: {table: string, id: string}) {
async DeleteRec({ table, id }: { table: string, id: string }) {
console.log('DeleteRec', table, id)
return Api.SendReq('/delrec/' + table + '/' + id, 'DELETE', null)
@@ -1090,7 +1134,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async DeleteFile({ filename }: {filename: string}) {
async DeleteFile({ filename }: { filename: string }) {
console.log('DeleteFile', filename)
return Api.SendReq(`/delfile/${tools.getvers()}/`, 'DELETE', { filename })
@@ -1108,7 +1152,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async DuplicateRec({ table, id }: {table: string, id: string}) {
async DuplicateRec({ table, id }: { table: string, id: string }) {
console.log('DuplicateRec', id)
return Api.SendReq('/duprec/' + table + '/' + id, 'POST', null)
@@ -1126,7 +1170,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async InviaMsgADonatori({ msgobj, navemediatore, tipomsg }: {msgobj: any, navemediatore: any, tipomsg: any}) {
async InviaMsgADonatori({ msgobj, navemediatore, tipomsg }: { msgobj: any, navemediatore: any, tipomsg: any }) {
console.log('InviaMsgADonatori', msgobj)
const mydata = {
@@ -1155,7 +1199,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async InviaMsgAFlotta({ flotta, inviareale, inviaemail, tipomsg }: {flotta: any, inviareale: boolean, inviaemail: boolean, tipomsg: any}) {
async InviaMsgAFlotta({ flotta, inviareale, inviaemail, tipomsg }: { flotta: any, inviareale: boolean, inviaemail: boolean, tipomsg: any }) {
console.log('InviaMsgAFlotta')
const mydata = {
@@ -1225,7 +1269,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async GetNave({ riga, col, riga1don, col1don, ind_order }: {riga: any, col: any, riga1don: any, col1don: any, ind_order: number}) {
async GetNave({ riga, col, riga1don, col1don, ind_order }: { riga: any, col: any, riga1don: any, col1don: any, ind_order: number }) {
// console.log('GetNave')
const mydata = {
@@ -1252,7 +1296,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async GetData({ data }: {data: any}) {
async GetData({ data }: { data: any }) {
console.log('GetData')
const mydata = {
@@ -1275,7 +1319,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async GetArrDoniNavi({ ricalcola, showall }: {ricalcola: boolean, showall: boolean}) {
async GetArrDoniNavi({ ricalcola, showall }: { ricalcola: boolean, showall: boolean }) {
console.log('GetArrDoniNavi')
const mydata = {
@@ -1299,7 +1343,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async GetFlotte({ ricalcola, showall }: {ricalcola: boolean, showall: boolean}) {
async GetFlotte({ ricalcola, showall }: { ricalcola: boolean, showall: boolean }) {
console.log('GetFlotte')
const mydata = {
@@ -1323,7 +1367,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async GetFlotta({ riga, col_prima, col_ultima }: {riga: any, col_prima: any, col_ultima: any}) {
async GetFlotta({ riga, col_prima, col_ultima }: { riga: any, col_prima: any, col_ultima: any }) {
console.log('GetFlotta')
const mydata = {
@@ -1416,6 +1460,10 @@ export const useGlobalStore = defineStore('GlobalStore', {
this.mailinglist = (res.data.mailinglist) ? [...res.data.mailinglist] : []
}
this.mypage = (res.data.mypage) ? [...res.data.mypage] : []
for (const page of this.mypage) {
if (page.loadFirst)
page.loaded = true
}
this.myelems = (res.data.myelems) ? [...res.data.myelems] : []
// console.log('this.mypage', this.mypage)
@@ -1466,7 +1514,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
})
},
async sendEmailTest({ previewonly }: {previewonly: any}) {
async sendEmailTest({ previewonly }: { previewonly: any }) {
const usertosend = {
locale: tools.getLocale(),
previewonly
@@ -1634,6 +1682,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
else if (table === 'fieldstype') myarr = costanti.FieldTypeArr
else if (table === 'metodo_pagamento') myarr = tools.SelectMetodiPagamento
else if (table === 'confsite_opt') myarr = tools.ConfSiteOpt
else if (table === 'confpages_lang') myarr = costanti.ArrLang
else if (table === 'bottype') myarr = shared_consts.BotType
else if (table === 'visibility') myarr = shared_consts.Visibility
else if (table === 'cat_interesse_arcadei') myarr = shared_consts.Cat_Interesse_Arcadei
@@ -1743,7 +1792,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
if (!myelem._id)
return false
return await this.DeleteRec({table: 'myelems', id: myelem._id }).then((ris) => {
return await this.DeleteRec({ table: 'myelems', id: myelem._id }).then((ris) => {
if (ris) {
this.myelems = this.myelems.filter((rec) => rec._id !== myelem._id)
tools.showPositiveNotif($q, t('db.deletedrecord'))