From 71ee9f6ae30683a87c6caf7ff0342777d4ca0a86 Mon Sep 17 00:00:00 2001 From: Paolo Arena Date: Thu, 2 May 2019 16:58:36 +0200 Subject: [PATCH] Directory Config for other project --- .gitignore | 9 +- src-pwa/custom-service-worker.js | 2 +- src/middleware/auth.ts | 4 +- src/model/GlobalStore.ts | 3 - src/root/home/home.vue | 1 + src/router/index.ts | 9 +- src/router/route-config.ts | 154 +------------------------------ src/store/Modules/GlobalStore.ts | 147 +---------------------------- src/store/Modules/tools.ts | 6 +- 9 files changed, 22 insertions(+), 313 deletions(-) diff --git a/.gitignore b/.gitignore index d05d86e..9eef56e 100644 --- a/.gitignore +++ b/.gitignore @@ -30,12 +30,11 @@ yarn-error.log* coverage /_PROVE /_LOCALE -deploy.sh -deploy_on_production.sh -deploy_on_test_server.sh -send_to_production.sh compileandserve.sh deploy_all.sh deploy_frontend.sh -mongodb_delete_pc_locale_paolo.sh +deploy_on_production.sh +deploy_on_test_server.sh +send_to_production.sh +send_to_test.sh serve_on_localhost.sh diff --git a/src-pwa/custom-service-worker.js b/src-pwa/custom-service-worker.js index 6fa3f71..ab44698 100644 --- a/src-pwa/custom-service-worker.js +++ b/src-pwa/custom-service-worker.js @@ -281,7 +281,7 @@ if (workbox) { // Storage workbox.routing.registerRoute( - new RegExp(/.*(?:storage.*$/), + new RegExp(/.*(?:storage)/), workbox.strategies.staleWhileRevalidate({ cacheName: 'storage', plugins: [ diff --git a/src/middleware/auth.ts b/src/middleware/auth.ts index 74b3439..12174e8 100644 --- a/src/middleware/auth.ts +++ b/src/middleware/auth.ts @@ -1,11 +1,9 @@ import { tools } from '../store/Modules/tools' -import { RouteNames } from '../router/route-names' - export default function auth({ next, router }) { const tok = tools.getItemLS(tools.localStorage.token) if (!tok) { - return router.push({ name: RouteNames.login }) + return router.push({ name: 'login' }) } return next() diff --git a/src/model/GlobalStore.ts b/src/model/GlobalStore.ts index 8abeae2..e547851 100644 --- a/src/model/GlobalStore.ts +++ b/src/model/GlobalStore.ts @@ -1,6 +1,3 @@ -import { costanti } from "@src/store/Modules/costanti" -import { UserStore } from "@store" -import { tools } from '@src/store/Modules/tools' import { IAction } from '@src/model/Projects' export interface IPost { diff --git a/src/root/home/home.vue b/src/root/home/home.vue index 8934129..8e39424 100644 --- a/src/root/home/home.vue +++ b/src/root/home/home.vue @@ -300,6 +300,7 @@ +
diff --git a/src/router/index.ts b/src/router/index.ts index 7709525..45e2825 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -2,13 +2,14 @@ import Vue from 'vue' import VueRouter, { RouterMode } from 'vue-router' import { PositionResult } from 'vue-router/types/router' -import { IMyRoute, IMyRouteRecord, routesList } from './route-config' +import { IMyRoute, IMyRouteRecord } from './route-config' import { ProgressBar } from '@src/store/Modules/Interface' import { isEqual } from 'lodash' import { UserStore } from '@store' -import { RouteNames } from '@src/router/route-names' import { tools } from '@src/store/Modules/tools' +import { cfgrouter } from '../../cfg_locale' + Vue.use(VueRouter) /* * If not building with SSR mode, you can @@ -17,7 +18,7 @@ Vue.use(VueRouter) const Router = new VueRouter({ scrollBehavior: () => ({ x: 0, y: 0 } as PositionResult), - routes: routesList, + routes: cfgrouter.routes, // Leave these as is and change from quasar.conf.js instead! // quasar.conf.js -> build -> vueRouterMode @@ -124,7 +125,7 @@ Router.beforeEach(async (to: IMyRoute, from: IMyRoute, next) => { // next('/') } - return Router.push({ name: RouteNames.login }) + return Router.push({ name: 'login' }) } } else if (to.matched.some((m) => m.meta.noAuth) && UserStore.state.isLogged) { next('/') diff --git a/src/router/route-config.ts b/src/router/route-config.ts index cf84cde..347eaa7 100644 --- a/src/router/route-config.ts +++ b/src/router/route-config.ts @@ -1,10 +1,9 @@ import { RouteConfig, Route, RouteRecord } from 'vue-router/types' -import { RouteNames } from './route-names' import { tools } from '@src/store/Modules/tools' import auth from '../middleware/auth' -import { Projects, Todos } from "@store" +import { Projects, Todos } from '@store' interface IMyMeta { title?: string, @@ -33,154 +32,3 @@ export interface IMyRouteConfig extends RouteConfig { children?: IMyRouteConfig[], meta?: IMyMeta } - -export const routesList: IMyRouteConfig[] = [ - { - path: '/', - name: RouteNames.home, - component: () => import('@/root/home/home.vue') - }, - { - path: '/signup', - name: 'Registration', - component: () => import('@/views/login/signup/signup.vue') - }, - { - path: '/signin', - name: RouteNames.login, - component: () => import('@/views/login/signin/signin.vue') - }, - { - path: '/vreg', - name: 'Verify Reg', - component: () => import('@/views/login/vreg/vreg.vue') - }, - { - path: '/todo/:category', - name: 'Todos', - component: () => import('@/views/todo-list/todo-list.vue'), - meta: { - requiresAuth: true, - async asyncData() { - await Todos.actions.dbLoad({ checkPending: false }) - } - // middleware: [auth] - } - }, - { - path: '/category', - name: 'category', - component: () => import('@/views/categories/category/category.vue') - }, - { - path: '/admin/cfgserv', - name: 'cfgserv', - component: () => import('@/views/admin/cfgServer/cfgServer.vue'), - meta: { - requiresAuth: true - // middleware: [auth] - } - }, - { - path: '/admin/testp1/:category', - name: 'Categories', - component: () => import('@/views/admin/testp1/testp1.vue') - }, - { - path: '/offline', - name: 'Offline', - component: () => import('@/views/offline/offline.vue') - }, - // { - // path: '/malaga', - // name: 'malaga', - // component: () => import('@/root/malaga/malaga.vue') - // }, - { - path: '/' + RouteNames.projectsall + '/:idProj', - name: RouteNames.projectsall, - component: () => import('@/views/projects/proj-list/proj-list.vue'), - meta: { - requiresAuth: false, - async asyncData() { - await Projects.actions.dbLoad({ checkPending: false, onlyiffirsttime: true }) - } - // middleware: [auth] - } - }, - { - path: '/' + RouteNames.myprojects + '/:idProj', - name: RouteNames.myprojects, - component: () => import('@/views/projects/proj-list/proj-list.vue'), - meta: { - requiresAuth: true, - async asyncData() { - await Projects.actions.dbLoad({ checkPending: false, onlyiffirsttime: true }) - } - // middleware: [auth] - } - }, - { - path: '/' + RouteNames.projectsshared + '/:idProj', - name: RouteNames.projectsshared, - component: () => import('@/views/projects/proj-list/proj-list.vue'), - meta: { - requiresAuth: true, - async asyncData() { - await Projects.actions.dbLoad({ checkPending: false, onlyiffirsttime: true }) - } - // middleware: [auth] - } - }, - { - path: '/' + RouteNames.listprojects, - name: RouteNames.listprojects, - component: () => import('@/views/projects/proj-list/proj-list.vue'), - meta: { - requiresAuth: true, - async asyncData() { - await Projects.actions.dbLoad({ checkPending: false, onlyiffirsttime: true }) - } - // middleware: [auth] - } - }, - { - path: '/' + RouteNames.favouriteprojects, - name: RouteNames.favouriteprojects, - component: () => import('@/views/projects/proj-list/proj-list.vue'), - meta: { - requiresAuth: true, - async asyncData() { - await Projects.actions.dbLoad({ checkPending: false, onlyiffirsttime: true }) - } - // middleware: [auth] - } - } - - - - /* - - { - path: '/requestresetpwd', - component: () => import('@/views/login/requestresetpwd.vue'), - meta: { nametranslate: 'Reset your Password' } - }, - { - path: '/updatepwd', - component: () => import('@/views/login/updatepassword.vue'), - meta: { nametranslate: 'Update your Password' } - } - - - { - path: '/simpleform', - component: () => import('@/views/form/simpleForm/simpleForm.vue'), - meta: { nametranslate: 'SimpleForm' } - }, - { - path: '/embeeded', - component: () => import('@/views/form/embeeded/embeeded.vue'), - meta: { nametranslate: 'Embeeded' } - }*/ -] diff --git a/src/store/Modules/GlobalStore.ts b/src/store/Modules/GlobalStore.ts index 59d9eda..8303f66 100644 --- a/src/store/Modules/GlobalStore.ts +++ b/src/store/Modules/GlobalStore.ts @@ -15,7 +15,8 @@ import * as ApiTables from '@src/store/Modules/ApiTables' import { GlobalStore, Projects, Todos, UserStore } from '@store' import messages from '../../statics/i18n' import globalroutines from './../../globalroutines/index' -import { RouteNames } from '@src/router/route-names' + +import { cfgrouter } from '../../../cfg_locale/index' let stateConnDefault = 'online' @@ -78,10 +79,6 @@ async function getstateConnSaved() { } } -function addRoute(myarr, values: IListRoutes) { - myarr.push(values) -} - const b = storeBuilder.module('GlobalModule', state) // Getters @@ -117,147 +114,11 @@ namespace Getters { }, 'showtype') const getmenu = b.read((state) => { - console.log('getmenu') - - const arrlista = GlobalStore.state.listatodo - const lista: IListRoutes[] = [] - - arrlista.forEach((elem: IMenuList) => { - const item: IListRoutes = { - faIcon: 'fa fa-list-alt', - materialIcon: 'todo', - name: 'pages.' + elem.description, - route: '/todo/' + elem.nametranslate - } - lista.push(item) - }) - - const SHOW_PROJINTHEMENU = false - - let arrlistafavourite = [] - let arrlistaprojtutti = [] - let arrlistaprojmiei = [] - if (SHOW_PROJINTHEMENU) { - arrlistaprojtutti = Projects.getters.listaprojects(RouteNames.projectsall) - arrlistaprojmiei = Projects.getters.listaprojects(RouteNames.myprojects) - arrlistafavourite = Projects.getters.listaprojects(RouteNames.favouriteprojects) - } - - const arrMenu: IMenuList[] = [] - - // PROGETTI -> FAVORITI : - if (arrlistafavourite.length > 0) { - arrMenu.push({ - icon: 'favorite_border', - nametranslate: 'pages.' + RouteNames.favouriteprojects, - urlroute: RouteNames.favouriteprojects, - level_parent: 0.0, - level_child: 0.5, - routes2: arrlistafavourite, - idelem: '' - }) - } - - // PROGETTI -> TUTTI : - arrMenu.push({ - icon: 'accessibility_new', - nametranslate: 'pages.' + RouteNames.projectsall, - urlroute: RouteNames.projectsall, - level_parent: 0.0, - level_child: 0.5, - routes2: [], - idelem: process.env.PROJECT_ID_MAIN - }) - - // PROGETTI -> CONDIVISI : - arrMenu.push({ - icon: 'people_outline', - nametranslate: 'pages.' + RouteNames.projectsshared, - urlroute: RouteNames.projectsshared, - level_parent: 0.0, - level_child: 0.5, - routes2: arrlistaprojtutti, - idelem: process.env.PROJECT_ID_MAIN - }) - - // PROGETTI -> PERSONALI : - arrMenu.push({ - icon: 'person', - nametranslate: 'pages.' + RouteNames.myprojects, - urlroute: RouteNames.myprojects, - level_parent: 0.0, - level_child: 0.5, - routes2: arrlistaprojmiei, - idelem: process.env.PROJECT_ID_MAIN - }) - - const listaprojectMenu: IListRoutes[] = tools.convertMenuListInListRoutes(arrMenu) - - const arrroutes: IListRoutes[] = [] - - addRoute(arrroutes, { route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'pages.home' }) // HOME - - addRoute(arrroutes, { - route: '/todo', faIcon: 'fa fa-list-alt', materialIcon: 'format_list_numbered', name: 'pages.Todo', - routes2: lista, - level_parent: 0.5, - level_child: 0.5 - }) - - const myarrproj = [] - for (const myitem of listaprojectMenu) { - addRoute(myarrproj, myitem) - } - - addRoute(arrroutes, { - route: '', faIcon: 'fa fa-list-alt', materialIcon: 'next_week', name: 'pages.projects', - routes2: myarrproj, - level_parent: 0.0, - level_child: 0.5 - }) - - console.log('arrroutes', arrroutes) - console.log('listaprojectMenu', listaprojectMenu) - // console.log('arrlistaprojmiei', arrlistaprojmiei) - - if (UserStore.state.isAdmin) { - addRoute(arrroutes, { - route: '/category', - faIcon: 'fa fa-list-alt', - materialIcon: 'category', - name: 'pages.Category', - level_parent: 0.0, - level_child: 0.0 - }) - addRoute(arrroutes, { - route: '/admin/cfgserv', - faIcon: 'fa fa-database', - materialIcon: 'event_seat', - name: 'pages.Admin', - level_parent: 0.0, - level_child: 0.0 - }) - addRoute(arrroutes, { - route: '/admin/testp1/par1', - faIcon: 'fa fa-database', - materialIcon: 'restore', - name: 'pages.Test1', - level_parent: 0.0, - level_child: 0.0 - }) - addRoute(arrroutes, { - route: '/admin/testp1/par2', - faIcon: 'fa fa-database', - materialIcon: 'restore', - name: 'pages.Test2', - level_parent: 0.0, - level_child: 0.0 - }) - } + console.log('getmenu', cfgrouter.getmenu()) state.menulinks = { Dashboard: { - routes: arrroutes, + routes: cfgrouter.getmenu(), show: true } } diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 15c54a8..0be551d 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -1567,6 +1567,10 @@ export const tools = { getprivacywritebytipoproj(tipoproj) { return Privacy.onlyme - } + }, + + addRoute(myarr, values) { + myarr.push(values) + }, }