diff --git a/src/boot/axios.js b/src/boot/axios.js new file mode 100644 index 0000000..11b8239 --- /dev/null +++ b/src/boot/axios.js @@ -0,0 +1,5 @@ +import axios from 'axios' + +export default ({ Vue }) => { + Vue.prototype.$axios = axios +} diff --git a/src/boot/dialog.js b/src/boot/dialog.js new file mode 100644 index 0000000..5b145d3 --- /dev/null +++ b/src/boot/dialog.js @@ -0,0 +1,5 @@ +import Dialog from 'quasar' + +export default ({ Vue }) => { + Vue.use(Dialog) +} diff --git a/src/boot/dragula.js b/src/boot/dragula.js new file mode 100644 index 0000000..76abac7 --- /dev/null +++ b/src/boot/dragula.js @@ -0,0 +1,10 @@ +import Vue from 'vue' +import { Vue2Dragula } from 'vue2-dragula' + +export default ({ Vue }) => { + Vue.use(Vue2Dragula, { + logging: { + service: false // to only log methods in service (DragulaService) + } + }) +} diff --git a/src/boot/error-handler.js b/src/boot/error-handler.js new file mode 100644 index 0000000..77e6339 --- /dev/null +++ b/src/boot/error-handler.js @@ -0,0 +1,7 @@ +// import something here +import errorHandler from '../error-handler' +// leave the export, even if you don't use it +export default ({ app, router, Vue }) => { + // something to do + Vue.prototype.$errorHandler = errorHandler +} diff --git a/src/boot/globalroutines.js b/src/boot/globalroutines.js new file mode 100644 index 0000000..b3ff5a0 --- /dev/null +++ b/src/boot/globalroutines.js @@ -0,0 +1,8 @@ +import globalroutines from '../globalroutines' + +export default ({ app, router, store, Vue }) => { + // something to do + Vue.prototype.$globalroutines = globalroutines +} + + diff --git a/src/boot/guard.js b/src/boot/guard.js new file mode 100644 index 0000000..45dde93 --- /dev/null +++ b/src/boot/guard.js @@ -0,0 +1,89 @@ +// import something here + +// leave the export, even if you don't use it +export default ({ app, router, store, Vue }) => { + // something to do + + // ****************************************** + // *** Per non permettere di accedere alle pagine in cui รจ necessario essere Loggati ! *** + // ****************************************** + + // Creates a `nextMiddleware()` function which not only +// runs the default `next()` callback but also triggers +// the subsequent Middleware function. + function nextFactory(context, middleware, index) { + const subsequentMiddleware = middleware[index] + // If no subsequent Middleware exists, + // the default `next()` callback is returned. + if (!subsequentMiddleware) return context.next + + return (...parameters) => { + // Run the default Vue Router `next()` callback first. + context.next(...parameters) + // Then run the subsequent Middleware with a new + // `nextMiddleware()` callback. + const nextMiddleware = nextFactory(context, middleware, index + 1) + subsequentMiddleware({ ...context, next: nextMiddleware }) + }; + } + + router.beforeEach((to, from, next) => { + if (to.meta.middleware) { + const middleware = Array.isArray(to.meta.middleware) + ? to.meta.middleware + : [to.meta.middleware]; + + const context = { + from, + next, + router, + to, + }; + const nextMiddleware = nextFactory(context, middleware, 1) + + return middleware[0]({ ...context, next: nextMiddleware }) + } + + return next() + }) + + + /*router.beforeEach((to, from, next) => { + var accessToken = store.state.session.userSession.accessToken + // ESTANDO LOGEADO + if (accessToken) { + // SE PERMITE IR DE AREA PUBLICA A PRIVADA + if (!from.matched.some(record => record.meta.requiresAuth) && to.matched.some(record => record.meta.requiresAuth)) { + next() + } + // SE PERMITE IR DE UNA AREA PRIVADA A OTRA PRIVADA + if (from.matched.some(record => record.meta.requiresAuth) && to.matched.some(record => record.meta.requiresAuth)) { + next() + } + // NO SE PERMITE IR A UN AREA PUBLICA DESDE UN AREA PRIVADA + if (from.matched.some(record => record.meta.requiresAuth) && !to.matched.some(record => record.meta.requiresAuth)) { + next(false) + } + // SE REDIRIJE AL PANEL + if (!from.matched.some(record => record.meta.requiresAuth) && !to.matched.some(record => record.meta.requiresAuth)) { + next('/Panel') + } + // NO ESTA LOGEADO + } else { + // SE PERMITE IR DE UNA AREA PUBLICA A OTRA PUBLICA + if (!from.matched.some(record => record.meta.requiresAuth) && !to.matched.some(record => record.meta.requiresAuth)) { + next() + } + // SE PERMITE IR DE UNA AREA PRIVADA A UNA PUBLICA (LOGOUT) + if (from.matched.some(record => record.meta.requiresAuth) && !to.matched.some(record => record.meta.requiresAuth)) { + next() + } + // NO SE PERMITE IR DE UNA AREA PUBLICA A UNA PRIVADA + if (!from.matched.some(record => record.meta.requiresAuth) && to.matched.some(record => record.meta.requiresAuth)) { + // REDIRIGIR A LOGIN + next('/') + } + } + })*/ + +} diff --git a/src/boot/myconfig.js b/src/boot/myconfig.js new file mode 100644 index 0000000..64d6adc --- /dev/null +++ b/src/boot/myconfig.js @@ -0,0 +1,9 @@ +// import something here +import myconfig from '../myconfig' + +// leave the export, even if you don't use it +export default ({ Vue }) => { + //Vue.use(myconfig); + // something to do + Vue.prototype.$myconfig = myconfig +} diff --git a/src/boot/vee-validate.js b/src/boot/vee-validate.js new file mode 100644 index 0000000..d849de1 --- /dev/null +++ b/src/boot/vee-validate.js @@ -0,0 +1,5 @@ +import VeeValidate from "vee-validate"; + +export default ({ Vue }) => { + Vue.use(VeeValidate, { inject: false }) +} diff --git a/src/boot/vue-i18n.js b/src/boot/vue-i18n.js new file mode 100644 index 0000000..7e436ac --- /dev/null +++ b/src/boot/vue-i18n.js @@ -0,0 +1,46 @@ +// src/boot/i18n.js +import VueI18n from 'vue-i18n'; +import messages from 'src/statics/i18n'; +import { tools } from "../store/Modules/tools"; + +export default ({ app, store, Vue }) => { + Vue.use(VueI18n); + // Vue.config.lang = process.env.LANG_DEFAULT; + + let mylang = tools.getItemLS(tools.localStorage.lang) + + if ((navigator) && (mylang === '')) { + mylang = navigator.language + console.log(`LANG NAVIGATOR ${mylang}`) + } + + if (mylang === '') + mylang = process.env.LANG_DEFAULT; + + if (mylang.toLowerCase() === 'es-es') + mylang = 'esEs' + + console.log('MYLANG2=', mylang) + console.log('process.env.LANG_DEFAULT=', process.env.LANG_DEFAULT) + Vue.config.lang = mylang + + import(`quasar/lang/${mylang}`).then(lang => { + console.log(' ... LANGDEFAULT=', lang) + this.$q.lang.set(lang.default) + import(`src/statics/i18n`).then(function () { + }) + }) + + // console.log("PLUGINS INIT...."); + + //console.log("LANG_DEFAULT: ") + //console.log(process.env.LANG_DEFAULT) + + // Set i18n instance on app + app.lang = new VueI18n({ + locale: mylang, + fallbackLocale: mylang, + messages + }) +} + diff --git a/src/boot/vue-idb.js b/src/boot/vue-idb.js new file mode 100644 index 0000000..3b1f502 --- /dev/null +++ b/src/boot/vue-idb.js @@ -0,0 +1,20 @@ +import Vue from 'vue' +import VueIdb from 'vue-idb' + +export default ({ Vue }) => { + Vue.use(VueIdb) + +} + + +/* + + +export default new VueIdb({ + version: 1, + database: 'test', + schemas: [ + { categories: '++_id, sub_categ_id, descr_it' } + ] +}) +*/ diff --git a/src/boot/vuelidate.js b/src/boot/vuelidate.js new file mode 100644 index 0000000..30d04fc --- /dev/null +++ b/src/boot/vuelidate.js @@ -0,0 +1,5 @@ +import Vuelidate from 'vuelidate' + +export default ({ Vue }) => { + Vue.use(Vuelidate) +}