- Dynamic Pages (MyPage)
- Uploading files to the Server FTP.
This commit is contained in:
@@ -24,6 +24,7 @@ import { serv_constants } from '@src/store/Modules/serv_constants'
|
||||
import { IUserState } from '@src/model'
|
||||
import { Calendar } from 'element-ui'
|
||||
import { fieldsTable } from '@src/store/Modules/fieldsTable'
|
||||
import router from '@router'
|
||||
// import { static_data } from '@src/db/static_data'
|
||||
|
||||
let stateConnDefault = 'online'
|
||||
@@ -75,7 +76,8 @@ const state: IGlobalState = {
|
||||
disciplines: [],
|
||||
autoplaydisc: 8000,
|
||||
newstosent: [],
|
||||
mailinglist: []
|
||||
mailinglist: [],
|
||||
mypage: []
|
||||
}
|
||||
|
||||
async function getConfig(id) {
|
||||
@@ -131,6 +133,12 @@ namespace Getters {
|
||||
|
||||
}, 'showtype')
|
||||
|
||||
const getPage = b.read((mystate: IGlobalState) => (path) => {
|
||||
// const config = state.arrConfig.find(item => item._id === cat + costanti.CONFIG_ID_SHOW_TYPE_TODOS)
|
||||
return mystate.mypage.find((page) => (`/` + page.path) === path)
|
||||
|
||||
}, 'getPage')
|
||||
|
||||
const getmenu = b.read((state) => {
|
||||
// console.log('getmenu', cfgrouter.getmenu())
|
||||
|
||||
@@ -180,6 +188,8 @@ namespace Getters {
|
||||
return GlobalStore.state.opzemail
|
||||
else if (table === tools.TABMAILINGLIST)
|
||||
return GlobalStore.state.mailinglist
|
||||
else if (table === tools.TABMYPAGE)
|
||||
return GlobalStore.state.mypage
|
||||
else if (table === 'bookings')
|
||||
return CalendarStore.state.bookedevent
|
||||
else if (table === 'users')
|
||||
@@ -277,6 +287,10 @@ namespace Getters {
|
||||
return gettemplemailbyId()
|
||||
},
|
||||
|
||||
get getPage() {
|
||||
return getPage()
|
||||
},
|
||||
|
||||
get t() {
|
||||
return t()
|
||||
},
|
||||
@@ -761,6 +775,7 @@ namespace Actions {
|
||||
if (showall) {
|
||||
GlobalStore.state.newstosent = (res.data.newstosent) ? [...res.data.newstosent] : []
|
||||
GlobalStore.state.mailinglist = (res.data.mailinglist) ? [...res.data.mailinglist] : []
|
||||
GlobalStore.state.mypage = (res.data.mypage) ? [...res.data.mypage] : []
|
||||
}
|
||||
|
||||
CalendarStore.state.editable = UserStore.state.isAdmin || UserStore.state.isManager
|
||||
@@ -787,6 +802,47 @@ namespace Actions {
|
||||
})
|
||||
}
|
||||
|
||||
async function addDynamicPages(context) {
|
||||
|
||||
const arrpagesroute: IListRoutes[] = []
|
||||
for (const page of state.mypage) {
|
||||
arrpagesroute.push({
|
||||
path: '/' + page.path,
|
||||
name: undefined,
|
||||
text: page.title,
|
||||
materialIcon: page.icon,
|
||||
component: () => import('@/root/mypage/mypage.vue'),
|
||||
inmenu: page.inmenu,
|
||||
infooter: page.infooter,
|
||||
level_child: page.l_child,
|
||||
level_parent: page.l_par,
|
||||
})
|
||||
}
|
||||
|
||||
const last = {
|
||||
path: '*',
|
||||
materialIcon: 'fas fa-calendar-plus',
|
||||
name: 'otherpages.error404def',
|
||||
component: () => import('@/root/My404page/My404page.vue'),
|
||||
inmenu: false,
|
||||
infooter: false
|
||||
}
|
||||
|
||||
static_data.routes = [...static_data.routes, ...arrpagesroute, last]
|
||||
|
||||
router.addRoutes([...arrpagesroute, last])
|
||||
}
|
||||
|
||||
async function sendFile(context, formdata) {
|
||||
try {
|
||||
const { data } = await Api.postFormData('/upload', formdata)
|
||||
console.log(data)
|
||||
|
||||
} catch (e) {
|
||||
console.log('Error sendFile: ', e)
|
||||
}
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
setConta: b.dispatch(setConta),
|
||||
createPushSubscription: b.dispatch(createPushSubscription),
|
||||
@@ -802,7 +858,8 @@ namespace Actions {
|
||||
saveTable: b.dispatch(saveTable),
|
||||
DeleteRec: b.dispatch(DeleteRec),
|
||||
sendEmailTest: b.dispatch(sendEmailTest),
|
||||
DuplicateRec: b.dispatch(DuplicateRec)
|
||||
DuplicateRec: b.dispatch(DuplicateRec),
|
||||
addDynamicPages: b.dispatch(addDynamicPages)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -688,32 +688,42 @@ namespace Actions {
|
||||
|
||||
async function setGlobal(isLogged: boolean) {
|
||||
console.log('setGlobal')
|
||||
// state.isLogged = true
|
||||
if (isLogged) {
|
||||
// console.log('state.isLogged', state.isLogged)
|
||||
try {
|
||||
// state.isLogged = true
|
||||
if (isLogged) {
|
||||
// console.log('state.isLogged', state.isLogged)
|
||||
|
||||
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
|
||||
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
|
||||
GlobalStore.mutations.setleftDrawerOpen(localStorage.getItem(tools.localStorage.leftDrawerOpen) === 'true')
|
||||
GlobalStore.mutations.setCategorySel(localStorage.getItem(tools.localStorage.categorySel))
|
||||
|
||||
GlobalStore.actions.checkUpdates()
|
||||
GlobalStore.actions.checkUpdates()
|
||||
}
|
||||
|
||||
const p3 = await GlobalStore.actions.loadAfterLogin()
|
||||
|
||||
state.isLogged = isLogged
|
||||
|
||||
if (static_data.functionality.ENABLE_TODOS_LOADING)
|
||||
await Todos.actions.dbLoad({ checkPending: true })
|
||||
|
||||
if (static_data.functionality.ENABLE_PROJECTS_LOADING)
|
||||
await Projects.actions.dbLoad({ checkPending: true, onlyiffirsttime: true })
|
||||
|
||||
console.log('add routes')
|
||||
|
||||
GlobalStore.actions.addDynamicPages()
|
||||
|
||||
GlobalStore.state.finishLoading = true
|
||||
if (tools.isDebug())
|
||||
console.log('finishLoading', GlobalStore.state.finishLoading)
|
||||
|
||||
// document.dispatchEvent(new Event('custom-post-render-event'))
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error', e)
|
||||
GlobalStore.state.finishLoading = true
|
||||
}
|
||||
|
||||
const p3 = await GlobalStore.actions.loadAfterLogin()
|
||||
|
||||
state.isLogged = isLogged
|
||||
|
||||
if (static_data.functionality.ENABLE_TODOS_LOADING)
|
||||
await Todos.actions.dbLoad({ checkPending: true })
|
||||
|
||||
if (static_data.functionality.ENABLE_PROJECTS_LOADING)
|
||||
await Projects.actions.dbLoad({ checkPending: true, onlyiffirsttime: true })
|
||||
|
||||
GlobalStore.state.finishLoading = true
|
||||
if (tools.isDebug())
|
||||
console.log('finishLoading', GlobalStore.state.finishLoading)
|
||||
|
||||
// document.dispatchEvent(new Event('custom-post-render-event'))
|
||||
|
||||
return true
|
||||
// console.log('setGlobal: END')
|
||||
}
|
||||
|
||||
@@ -62,6 +62,25 @@ export const colmailinglist = [
|
||||
AddCol(DeleteRec)
|
||||
]
|
||||
|
||||
export const colmypage = [
|
||||
AddCol({ name: 'title', label_trans: 'pages.title' }),
|
||||
AddCol({ name: 'path', label_trans: 'pages.path' }),
|
||||
AddCol({ name: 'icon', label_trans: 'pages.icon' }),
|
||||
AddCol({ name: 'keywords', label_trans: 'pages.keywords' }),
|
||||
AddCol({ name: 'description', label_trans: 'pages.description' }),
|
||||
AddCol({ name: 'heightimg', label_trans: 'pages.heightimg', fieldtype: tools.FieldType.number }),
|
||||
AddCol({ name: 'imgback', label_trans: 'pages.imgback', fieldtype: tools.FieldType.string }),
|
||||
AddCol({ name: 'content', label_trans: 'pages.content', fieldtype: tools.FieldType.html }),
|
||||
AddCol({ name: 'active', label_trans: 'pages.active', fieldtype: tools.FieldType.boolean }),
|
||||
AddCol({ name: 'inmenu', label_trans: 'pages.inmenu', fieldtype: tools.FieldType.boolean }),
|
||||
AddCol({ name: 'submenu', label_trans: 'pages.submenu', fieldtype: tools.FieldType.boolean }),
|
||||
AddCol({ name: 'l_par', label_trans: 'pages.l_par', fieldtype: tools.FieldType.number }),
|
||||
AddCol({ name: 'l_child', label_trans: 'pages.l_child', fieldtype: tools.FieldType.number }),
|
||||
AddCol({ name: 'infooter', label_trans: 'pages.infooter', fieldtype: tools.FieldType.boolean }),
|
||||
AddCol(DeleteRec),
|
||||
AddCol(DuplicateRec)
|
||||
]
|
||||
|
||||
export const colopzemail = [
|
||||
AddCol({ name: 'key', label_trans: 'col.key' }),
|
||||
AddCol({ name: 'label_it', label_trans: 'col.label' }),
|
||||
@@ -338,6 +357,9 @@ export const fieldsTable = {
|
||||
return ''
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
// IColGridTable
|
||||
colTableUsers: [
|
||||
AddCol({ name: 'username', label_trans: 'reg.username' }),
|
||||
@@ -393,14 +415,16 @@ export const fieldsTable = {
|
||||
label: 'Newsletter da Inviare',
|
||||
columns: colnewstosent,
|
||||
colkey: '_id',
|
||||
collabel: 'label'
|
||||
collabel: 'label',
|
||||
onlyAdmin: true
|
||||
},
|
||||
{
|
||||
value: 'templemail',
|
||||
label: 'Template Email',
|
||||
columns: coltemplemail,
|
||||
colkey: '_id',
|
||||
collabel: 'subject'
|
||||
collabel: 'subject',
|
||||
onlyAdmin: true
|
||||
},
|
||||
{
|
||||
value: 'opzemail',
|
||||
@@ -423,13 +447,15 @@ export const fieldsTable = {
|
||||
columns: colTablePermission,
|
||||
colkey: 'value',
|
||||
collabel: 'label',
|
||||
colicon: 'icon'
|
||||
colicon: 'icon',
|
||||
noshow: true,
|
||||
},
|
||||
{
|
||||
value: 'fieldstype',
|
||||
label: 'Tipi di Campi',
|
||||
colkey: 'value',
|
||||
collabel: 'label'
|
||||
collabel: 'label',
|
||||
noshow: true,
|
||||
},
|
||||
{
|
||||
value: 'settings',
|
||||
@@ -443,6 +469,6 @@ export const fieldsTable = {
|
||||
|
||||
export const func = {
|
||||
gettablesList() {
|
||||
return fieldsTable.tablesList.filter((rec) => (rec.onlyAdmin === UserStore.state.isAdmin) || (!rec.onlyAdmin))
|
||||
return fieldsTable.tablesList.filter((rec) => (rec.onlyAdmin === UserStore.state.isAdmin) || (!rec.onlyAdmin) && (!rec.noshow))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ export const tools = {
|
||||
TABEVENTS: 'myevents',
|
||||
TABNEWSLETTER: 'newstosent',
|
||||
TABMAILINGLIST: 'mailinglist',
|
||||
TABMYPAGE: 'mypage',
|
||||
TABTEMPLEMAIL: 'templemail',
|
||||
TABOPZEMAIL: 'opzemail',
|
||||
|
||||
@@ -2669,15 +2670,15 @@ export const tools = {
|
||||
|
||||
return mywidth
|
||||
} else {
|
||||
console.log('this.getwidth(mythis) = ', this.getwidth(mythis))
|
||||
// console.log('this.getwidth(mythis) = ', this.getwidth(mythis))
|
||||
let myw = mywidth + ((this.getwidth(mythis) - mywidth) * 0.6)
|
||||
console.log('myw1 = ', myw)
|
||||
// console.log('myw1 = ', myw)
|
||||
if (myw > maxwidth)
|
||||
myw = maxwidth
|
||||
if (myw > this.getwidth(mythis) - 20)
|
||||
myw = this.getwidth(mythis) - 20
|
||||
|
||||
console.log('myw = ', myw)
|
||||
// console.log('myw = ', myw)
|
||||
return myw
|
||||
}
|
||||
},
|
||||
@@ -2823,7 +2824,8 @@ export const tools = {
|
||||
},
|
||||
isDebug() {
|
||||
return process.env.DEV
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// getLocale() {
|
||||
// if (navigator.languages && navigator.languages.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user