sistemare class type boolean....

This commit is contained in:
paolo
2018-11-05 22:28:59 +01:00
parent c81e816d97
commit 03d57ba50e
22 changed files with 439 additions and 339 deletions

20
.env
View File

@@ -1,11 +1,11 @@
APP_ID=1 APP_ID='1'
VUE_APP_URL=prova SVILUPPO! VUE_APP_URL='prova SVILUPPO!'
PROVA_PAOLO=PROVA SVILUPPO PROVA_PAOLO='PROVA SVILUPPO'
LANG_DEFAULT=it LANG_DEFAULT='it'
MONGODB_HOST='http://localhost:3000' MONGODB_HOST='http://localhost:3000'
PAO_APP_ID=KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF PAO_APP_ID='KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF'
MASTER_KEY=KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T MASTER_KEY='KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T'
LOGO_REG=quasar-logo-full.svg LOGO_REG='quasar-logo-full.svg'
TEST_EMAIL=paolo.arena77@gmail.com TEST_EMAIL='paolo.arena77@gmail.com'
TEST_USERNAME=paoloar77 TEST_USERNAME='paoloar77'
TEST_PASSWORD=mypassword TEST_PASSWORD='mypassword'

View File

@@ -1,14 +1,10 @@
APP_ID="1" APP_ID="1"
VUE_APP_URL= "PROVA ENV! FUNZIONA" VUE_APP_URL= "PROVA ENV! FUNZIONA"
PROVA_PAOLO= "PROVA ENV FUNZIONA!" PROVA_PAOLO= "PROVA ENV FUNZIONA!"
PAO_APP_ID="" PAO_APP_ID=""
MASTER_KEY='' MASTER_KEY=''
MONGODB_HOST='http://localhost:3000' MONGODB_HOST='http://localhost:3000'
LOGO_REG='quasar-logo-full.svg'
LOGO_REG=quasar-logo-full.svg TEST_EMAIL='a'
TEST_USERNAME='a'
TEST_EMAIL= TEST_PASSWORD='a'
TEST_USERNAME=
TEST_PASSWORD=

View File

@@ -1,5 +1,5 @@
const DotEnv = require('dotenv') const DotEnv = require('dotenv')
const parsedEnv = DotEnv.config({ debug: process.env.DEBUG }).parsed; const parsedEnv = DotEnv.config().parsed;
module.exports = function () { module.exports = function () {
// Let's stringify our variables // Let's stringify our variables

View File

@@ -12,7 +12,8 @@ module.exports = {
'<rootDir>/src/pages/**/*.vue', '<rootDir>/src/pages/**/*.vue',
'<rootDir>/src/plugins/**/*.ts', '<rootDir>/src/plugins/**/*.ts',
'<rootDir>/src/mixins/**/*.ts', '<rootDir>/src/mixins/**/*.ts',
'<rootDir>/src/directives/**/*.ts' '<rootDir>/src/directives/**/*.ts',
'<rootDir>/src/utils/**/*.ts'
], ],
coverageThreshold: { coverageThreshold: {
global: { global: {

View File

@@ -20,23 +20,27 @@
"deploy:ssr": "now dist/ssr-mat" "deploy:ssr": "now dist/ssr-mat"
}, },
"dependencies": { "dependencies": {
"vue-i18n": "^8.1.0",
"vue-property-decorator": "^7.2.0",
"vuex-class": "^0.3.1",
"axios": "^0.18.0", "axios": "^0.18.0",
"babel-runtime": "^6.0.0",
"bcrypt": "^3.0.2",
"bcryptjs": "^2.4.3",
"dotenv": "^6.1.0", "dotenv": "^6.1.0",
"element-ui": "^2.3.6", "element-ui": "^2.3.6",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"normalize.css": "^8.0.0", "normalize.css": "^8.0.0",
"npm": "^6.4.1", "npm": "^6.4.1",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"quasar-extras": "0.0.7",
"register-service-worker": "^1.0.0", "register-service-worker": "^1.0.0",
"vee-validate": "^2.1.2", "vee-validate": "^2.1.2",
"vue": "^2.5.17", "vue": "^2.5.17",
"vue-class-component": "^6.3.2", "vue-class-component": "^6.3.2",
"vue-i18n": "^8.1.0",
"vue-property-decorator": "^7.2.0",
"vue-router": "^3.0.1", "vue-router": "^3.0.1",
"vue-svgicon": "^3.1.0", "vue-svgicon": "^3.1.0",
"vuex": "^3.0.1", "vuex": "^3.0.1",
"vuex-class": "^0.3.1",
"vuex-module-decorators": "^0.4.3" "vuex-module-decorators": "^0.4.3"
}, },
"devDependencies": { "devDependencies": {
@@ -60,6 +64,9 @@
"babel-loader": "^8.0.4", "babel-loader": "^8.0.4",
"eslint": "^5.5.0", "eslint": "^5.5.0",
"jest": "^23.6.0", "jest": "^23.6.0",
"html-webpack-plugin": "^2.8.1",
"http-proxy-middleware": "^0.17.0",
"json-loader": "^0.5.4",
"node-sass": "^4.9.0", "node-sass": "^4.9.0",
"quasar-cli": "^0.17.20", "quasar-cli": "^0.17.20",
"sass-loader": "^7.0.1", "sass-loader": "^7.0.1",
@@ -67,11 +74,15 @@
"ts-jest": "^23.0.0", "ts-jest": "^23.0.0",
"ts-loader": "^5.3.0", "ts-loader": "^5.3.0",
"tslint": "^5.11.0", "tslint": "^5.11.0",
"tslint-loader": "^3.4.3",
"tslint-config-standard": "^8.0.1", "tslint-config-standard": "^8.0.1",
"typescript": "^3.1.6", "typescript": "^3.1.6",
"vue-cli-plugin-element-ui": "^1.1.2", "vue-cli-plugin-element-ui": "^1.1.2",
"vue-template-compiler": "^2.5.17", "vue-template-compiler": "^2.5.17",
"webpack": "^4.24.0" "webpack": "^2.2.1",
"webpack-dev-middleware": "^1.8.4",
"webpack-hot-middleware": "^2.18.1",
"webpack-merge": "^4.0.0"
}, },
"engines": { "engines": {
"node": ">= 8.9.0", "node": ">= 8.9.0",

View File

@@ -2,8 +2,9 @@
const path = require('path'); const path = require('path');
// Carica il file .env const webpack = require('webpack')
const envparser = require('./config/envparser'); const envparser = require('./config/envparser')
const extendTypescriptToWebpack = (config) => { const extendTypescriptToWebpack = (config) => {
config.resolve config.resolve
@@ -41,6 +42,7 @@ module.exports = function (ctx) {
], ],
supportIE: false, supportIE: false,
build: { build: {
env: envparser(),
scopeHoisting: true, scopeHoisting: true,
vueRouterMode: 'history', vueRouterMode: 'history',
vueCompiler: true, vueCompiler: true,

9
shims-vue.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
declare module '*.svg' {
import Vue from 'vue'
export default Vue
}

View File

@@ -15,34 +15,26 @@
</div> </div>
</template> </template>
<script type="text/javascript"> <script type="ts">
import { Component, Vue} from 'vue-property-decorator'
import { UserModule } from './store/modules/user'
import Header from './components/Header.vue'; import Header from './components/Header.vue';
import * as types from './store/mutation-types' @Component({
import {mapGetters, mapActions} from 'vuex'
export default {
name: 'app',
data() {
return {
backgroundColor: 'whitesmoke'
}
},
computed: {
...mapGetters("glob", ['getLayoutNeeded', 'getMobileMode'])
},
components: { components: {
appHeader: Header, appHeader: Header,
}, }
methods:{ })
...mapActions("user", { export default class App extends Vue {
tryAutoLogin: types.USER_AUTOLOGIN, backgroundColor = 'whitesmoke'
}),
}, constructor () {
created() { super()
//this.title = 'My Vue and CosmosDB Heroes App'
console.info(process.env); console.info(process.env);
this.tryAutoLogin(); UserModule.autologin()
} }
} }
</script> </script>

View File

@@ -49,70 +49,51 @@
</div> </div>
</template> </template>
<script> <script lang="ts">
import {openURL} from 'quasar'; import { Component, Vue, Watch } from 'vue-property-decorator'
import {Quasar} from 'quasar'; import { UserModule } from '../store/modules/user'
import drawer from '../layouts/drawer/drawer.vue' import drawer from '../layouts/drawer/drawer.vue'
import messagePopover from '../layouts/toolbar/messagePopover.vue' import messagePopover from '../layouts/toolbar/messagePopover.vue'
// import user from '../store/modules/user'; @Component({
import * as types from '../store/mutation-types'
import {mapGetters, mapActions} from 'vuex'
export default {
components: { components: {
drawer, drawer,
messagePopover, messagePopover,
}, },
created() { })
//this.$store.dispatch('initStocks'); export default class Header extends Vue {
}, prova = 'AA'
methods: { selectOpLang = [
openURL,
},
computed: {
...mapGetters("user", [
'getUsername',
]),
},
data: function () {
return {
prova: 'AA',
selectOpLang: [
{ label: 'Italian', icon: 'fa-facebook', value: 'it' }, { label: 'Italian', icon: 'fa-facebook', value: 'it' },
{ label: 'English (US)', icon: 'fa-flag-us', value: 'en-us' }, { label: 'English (US)', icon: 'fa-flag-us', value: 'en-us' },
{ label: 'Spanish', icon: 'fa-flag-es', value: 'es' }, { label: 'Spanish', icon: 'fa-flag-es', value: 'es' },
{ label: 'German', icon: 'fa-flag-de', value: 'de' } { label: 'German', icon: 'fa-flag-de', value: 'de' }
], ]
lang: this.$q.i18n.lang, lang = this.$q.i18n.lang
leftDrawerOpen: this.$q.platform.is.desktop leftDrawerOpen = this.$q.platform.is.desktop
}
}, @Watch('lang')
watch: { lang(lang: string) {
lang(lang) { this.$i18n.locale = snakeToCamel(lang)
this.$i18n.locale = snakeToCamel(lang); console.log("LANG LOCALE = " + this.$i18n.locale)
console.log("LANG LOCALE = " + this.$i18n.locale);
// dynamic import, so loading on demand only // dynamic import, so loading on demand only
import(`quasar-framework/i18n/${lang}`).then(lang => { import(`quasar-framework/i18n/${lang}`).then(lang => {
//console.log("lang prima = " + this.$q.i18n.lang); //console.log("lang prima = " + this.$q.i18n.lang);
this.$q.i18n.set(lang.default); this.$q.i18n.set(lang.default)
var mylang = this.$q.i18n.lang; var mylang = this.$q.i18n.lang
console.log("lang = " + this.$q.i18n.lang); console.log("lang = " + this.$q.i18n.lang)
//console.log("lang DOPO = " + this.$q.i18n.lang); //console.log("lang DOPO = " + this.$q.i18n.lang);
import(`src/i18n`).then(function () { import(`src/i18n`).then(function () {
}); })
}); })
// dynamic import, so loading on demand only // dynamic import, so loading on demand only
} }
} }
}
function snakeToCamel(str) { function snakeToCamel(str) {
return str.replace(/(-\w)/g, m => { return str.replace(/(-\w)/g, m => {

View File

@@ -1,12 +1,12 @@
<template> <template>
<div> <div>
<div id="profile" v-if="getUsername"> <div id="profile" v-if="Username">
<img :src="photo" style='height: 80px' class="inline-block"> <img :src="photo" style='height: 80px' class="inline-block">
<img src="../img/avatar-1.svg" id="avatar" class="inline-block"> <img src="../img/avatar-1.svg" id="avatar" class="inline-block">
<div id="user-name"> <div id="user-name">
<span class="text-white"> {{ getUsername }} </span> <span class="text-white"> {{ Username }} </span>
<hr> <hr>
<span class="text-white" v-if="getVerificato"> {{$t('reg.verificato')}} </span> <span class="text-white" v-if="Verificato"> {{$t('reg.verificato')}} </span>
<span class="text-white" v-else> {{$t('reg.non_verificato')}} </span> <span class="text-white" v-else> {{$t('reg.non_verificato')}} </span>
<span class="text-white"> {{ getEmail }} </span> <span class="text-white"> {{ getEmail }} </span>
</div> </div>
@@ -17,7 +17,7 @@
</div> </div>
</div> </div>
<menu-one v-if="getMenuCollapse" :links="links"></menu-one> <menu-one v-if="MenuCollapse" :links="links"></menu-one>
<menu-two v-else :links="links"></menu-two> <menu-two v-else :links="links"></menu-two>
<div class="fixed-bottom text-center light text-italic"> <div class="fixed-bottom text-center light text-italic">
@@ -26,20 +26,27 @@
</div> </div>
</template> </template>
<script type="text/javascript">
<script type="ts">
import menuOne from './menuOne.vue' import menuOne from './menuOne.vue'
import menuTwo from './menuTwo.vue' import menuTwo from './menuTwo.vue'
import * as types from '../../store/mutation-types' import * as types from '../../store/mutation-types'
import {mapGetters, mapActions} from 'vuex' import { Component, Vue, Watch, Prop } from 'vue-property-decorator'
import { GlobModule } from '../../store/modules/glob'
import { UserModule } from '../../store/modules/user';
export default { @Component({
data() { components: {
return { menuOne,
photo: '', menuTwo
user: null, }
links: { })
export default class Drawer extends Vue {
photo = ''
user = null
links = {
Dashboard: { Dashboard: {
routes: [ routes: [
{route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'Dashboard One'}, {route: '/', faIcon: 'fa fa-home', materialIcon: 'home', name: 'Dashboard One'},
@@ -67,34 +74,21 @@
show: false show: false
} }
} }
get MenuCollapse () {
return GlobModule.menuCollapse
} }
}, get Username () {
created() { return UserModule.username
var vm = this
/*firebase.auth().onAuthStateChanged(function (user) {
if (user) {
vm.user = user
vm.name = vm.user.displayName
vm.email = vm.user.email
vm.photo = vm.user.photoURL
vm.userId = vm.user.uid
} }
})*/
}, get Verificato () {
methods:{ return UserModule.verifiedEmail
...mapActions("user", ["logout"]), }
logoutHandler() { logoutHandler() {
this.logout({router: this.$router}); this.logout({ router: this.$router })
this.$q.notify(this.$t('logout.uscito')); this.$q.notify(this.$t('logout.uscito'))
}
},
computed: {
...mapGetters("glob", ['getLayoutNeeded', 'getMenuCollapse']),
...mapGetters("user", ['getUsername', 'getVerificato', 'getEmail']),
},
components: {
menuOne,
menuTwo
} }
} }
</script> </script>

View File

@@ -41,7 +41,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue, Watch, Prop } from 'vue-property-decorator' import { Component, Vue, Watch, Prop } from 'vue-property-decorator'
import { GlobModule } from '@/store/modules/glob' import { GlobModule } from '../store/modules/glob'
@Component({}) @Component({})
export default class Login extends Vue { export default class Login extends Vue {

View File

@@ -8,8 +8,8 @@ export default ({ app, store, Vue }) => {
console.log("PLUGINS INIT...."); console.log("PLUGINS INIT....");
console.log("LANG_DEFAULT: ") //console.log("LANG_DEFAULT: ")
console.log(process.env.LANG_DEFAULT) //console.log(process.env.LANG_DEFAULT)
// Set i18n instance on app // Set i18n instance on app
app.i18n = new VueI18n({ app.i18n = new VueI18n({

View File

@@ -3,8 +3,8 @@ import { RouteConfig } from 'vue-router'
const routes: RouteConfig[] = [ const routes: RouteConfig[] = [
{ path: '/', component: () => import('@/pages/Index.vue'), meta: { name: 'Home' } }, { path: '/', component: () => import('@/pages/Index.vue'), meta: { name: 'Home' } },
{ path: '/test', component: () => import('@/views/login/test.vue'), meta: { name: 'Test' } }, { path: '/test', component: () => import('@/views/login/test.vue'), meta: { name: 'Test' } },
/*
{ path: '/signup', component: () => import('@/views/login/signup.vue'), meta: { name: 'Registration' } }, { path: '/signup', component: () => import('@/views/login/signup.vue'), meta: { name: 'Registration' } },
/*
{ path: '/signin', component: () => import('@/views/login/signin.vue'), meta: { name: 'Login' } }, { path: '/signin', component: () => import('@/views/login/signin.vue'), meta: { name: 'Login' } },
{ path: '/vreg', component: () => import('@/views/login/vreg.vue'), meta: { name: 'Verify Reg' } }, { path: '/vreg', component: () => import('@/views/login/vreg.vue'), meta: { name: 'Verify Reg' } },
{ {

View File

@@ -1,13 +1,16 @@
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import { IUserState } from '@/types' import { IUserState, IGlobState } from '@/types'
Vue.use(Vuex) Vue.use(Vuex)
export interface IRootState { export interface IRootState {
user: IUserState user: IUserState
glob: IGlobState
role: IRootState role: IRootState
} }
export default new Vuex.Store<IRootState>({}) const store = new Vuex.Store<IRootState>({})
export default store

View File

@@ -9,15 +9,6 @@ import store from '@/store'
Vue.use(Vuex) Vue.use(Vuex)
export interface IGlob {
conta: number
isLoginPage: boolean
layoutNeeded: boolean
mobileMode: boolean
menuCollapse: boolean
posts: string[]
}
@Module({ dynamic: true, store, name: 'glob' }) @Module({ dynamic: true, store, name: 'glob' })
class Glob extends VuexModule { // Non occorrono i getters, basta questi qui: class Glob extends VuexModule { // Non occorrono i getters, basta questi qui:

View File

@@ -2,6 +2,8 @@ import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import { Module, VuexModule, Mutation, MutationAction, Action, getModule } from 'vuex-module-decorators' import { Module, VuexModule, Mutation, MutationAction, Action, getModule } from 'vuex-module-decorators'
import {Route} from 'vue-router'
import store from '@/store'
const bcrypt = require('bcryptjs') const bcrypt = require('bcryptjs')
@@ -10,7 +12,6 @@ import { serv_constants } from '@/store/modules/serv_constants'
import { IUserState, ILinkReg, IResult, IIdToken } from '@/types' import { IUserState, ILinkReg, IResult, IIdToken } from '@/types'
import store from '@/store'
export const ErroriMongoDb = { export const ErroriMongoDb = {
CALLING: 10, CALLING: 10,
@@ -30,7 +31,7 @@ class User extends VuexModule implements IUserState { // Non occorrono i gette
idapp: IUserState['idapp'] = process.env.APP_ID idapp: IUserState['idapp'] = process.env.APP_ID
password: IUserState['password'] = '' password: IUserState['password'] = ''
lang: IUserState['lang'] = '' lang: IUserState['lang'] = ''
ripetipassword: IUserState['ripetipassword'] = '' repeatPassword: IUserState['repeatPassword'] = ''
idToken: IUserState['idToken'] = '' idToken: IUserState['idToken'] = ''
userId: IUserState['userId'] = 0 userId: IUserState['userId'] = 0
tokens: IUserState['tokens'] = [] tokens: IUserState['tokens'] = []
@@ -98,6 +99,7 @@ class User extends VuexModule implements IUserState { // Non occorrono i gette
this.userId = data.userId this.userId = data.userId
this.idToken = data.idToken this.idToken = data.idToken
this.verifiedEmail = data.verifiedEmail this.verifiedEmail = data.verifiedEmail
// @ts-ignore
this.tokens = [ this.tokens = [
{ access: 'auth', token: data.idToken } { access: 'auth', token: data.idToken }
] ]

45
src/types/index.d.ts vendored Normal file
View File

@@ -0,0 +1,45 @@
export interface IToken {
access: string
token: string
}
export interface IUserState {
_id?: string
email?: string
username: string
idapp?: any
password?: string
lang?: string
repeatPassword?: string
idToken?: string
userId?: number
tokens?: IToken[]
verifiedEmail?: boolean
tokenforgot?: string
}
export interface IGlobState {
conta: number
isLoginPage: boolean
layoutNeeded: boolean
mobileMode: boolean
menuCollapse: boolean
posts: string[]
}
export interface ILinkReg {
idLink: string
}
export interface IIdToken {
idToken: string
}
export interface IResult {
status: number
statusText: string
}

18
src/utils/config.ts Normal file
View File

@@ -0,0 +1,18 @@
import dotenv from 'dotenv'
dotenv.config()
let path
switch (process.env.NODE_ENV) {
case 'test':
path = `${__dirname}/../../.env.test`
break
case 'production':
path = `${__dirname}/../../.env.production`
break
default:
path = `${__dirname}/../../.env.development`
}
dotenv.config({ path })
export const APP_ID = process.env.APP_ID
export const LOG_LEVEL = process.env.LOG_LEVEL

View File

@@ -11,71 +11,72 @@
<!--Prova URL : {{env('PROVA_PAOLO')}}--> <!--Prova URL : {{env('PROVA_PAOLO')}}-->
<q-field <q-field
:error="$v.form.email.$error" :error="$v.user.email.$error"
:error-label="`${errorMsg('email', $v.form.email)}`" :error-label="`${errorMsg('email', $v.user.email)}`"
> >
<q-input <q-input
v-model="form.email" v-model="user.email"
:value="form.email" v-validate="'required|email|truthy'"
@change="val => { form.email = val }" :value="user.email"
@change="val => { user.email = val }"
:before="[{icon: 'mail', handler () {}}]" :before="[{icon: 'mail', handler () {}}]"
@blur="$v.form.email.$touch" @blur="$v.user.email.$touch"
:error="$v.form.email.$error" :error="$v.user.email.$error"
:float-label="$t('reg.email')" :float-label="$t('reg.email')"
/> />
</q-field> </q-field>
<q-field <q-field
:error="$v.form.username.$error" :error="$v.user.username.$error"
:error-label="`${errorMsg('username', $v.form.username)}`" :error-label="`${errorMsg('username', $v.user.username)}`"
> >
<q-input <q-input
:value="form.username" :value="user.username"
@change="val => { form.username = val }" @change="val => { user.username = val }"
:before="[{icon: 'person', handler () {}}]" :before="[{icon: 'person', handler () {}}]"
@blur="$v.form.username.$touch" @blur="$v.user.username.$touch"
:error="$v.form.username.$error" :error="$v.user.username.$error"
:float-label="$t('reg.username')" :float-label="$t('reg.username')"
/> />
</q-field> </q-field>
<q-field <q-field
:error="$v.form.password.$error" :error="$v.user.password.$error"
:error-label="`${errorMsg('password', $v.form.password)}`" :error-label="`${errorMsg('password', $v.user.password)}`"
> >
<q-input <q-input
v-model="form.password" v-model="user.password"
:before="[{icon: 'vpn_key', handler () {}}]" :before="[{icon: 'vpn_key', handler () {}}]"
@blur="$v.form.password.$touch" @blur="$v.user.password.$touch"
:error="$v.form.password.$error" :error="$v.user.password.$error"
:float-label="$t('reg.password')" :float-label="$t('reg.password')"
/> />
</q-field> </q-field>
<q-field <q-field
:error="$v.form.repeatPassword.$error" :error="$v.user.repeatPassword.$error"
:error-label="`${errorMsg('repeatpassword', $v.form.repeatPassword)}`" :error-label="`${errorMsg('repeatpassword', $v.user.repeatPassword)}`"
> >
<q-input <q-input
v-model="form.repeatPassword" v-model="user.repeatPassword"
:before="[{icon: 'vpn_key', handler () {}}]" :before="[{icon: 'vpn_key', handler () {}}]"
@blur="$v.form.repeatPassword.$touch" @blur="$v.user.repeatPassword.$touch"
:error="$v.form.repeatPassword.$error" :error="$v.user.repeatPassword.$error"
:float-label="$t('reg.repeatPassword')" :float-label="$t('reg.repeatPassword')"
/> />
</q-field> </q-field>
<q-field <q-field
:error="$v.form.terms.$error" :error="$v.user.terms.$error"
:error-label="`${errorMsg('terms', $v.form.terms)}`" :error-label="`${errorMsg('terms', $v.user.terms)}`"
> >
<q-checkbox <q-checkbox
v-model="form.terms" v-model="user.terms"
:before="[{icon: 'vpn_key', handler () {}}]" :before="[{icon: 'vpn_key', handler () {}}]"
color="secondary" color="secondary"
@blur="$v.form.terms.$touch" @blur="$v.user.terms.$touch"
:error="$v.form.terms.$error" :error="$v.user.terms.$error"
:float-label="$t('reg.terms')" :float-label="$t('reg.terms')"
:label="$t('reg.terms')" :label="$t('reg.terms')"
/> />
@@ -92,45 +93,42 @@
</div> </div>
</template> </template>
<script> <script type="ts">
import Vue from 'vue'
import { Component, Prop } from 'vue-property-decorator'
import { UserModule } from '../../store/modules/user'
import { IUserState } from "../../types";
import {ErroriMongoDb} from '../../store/modules/user'
import { /*
required, import VeeValidate from 'vee-validate'
email, Vue.use(VeeValidate)
numeric, import { Validator } from 'vee-validate'
minValue,
minLength,
maxLength,
sameAs,
requiredUnless
} from 'vuelidate/lib/validators'
import {mapGetters, mapActions} from 'vuex' Validator.extend('truthy', {
import * as types from '../../store/mutation-types' getMessage: field => 'The ' + field + ' value is not truthy.',
validate: value => !!value
})
*/
//import {ErroriMongoDb} from '../../store/modules/user' //import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar'
import axios from 'axios';
import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar' @Component({})
export default class Signup extends Vue {
accountId: number = 0
export default { duplicate_email: boolean = false
data() { duplicate_username: boolean = false
return { user: IUserState = {
url: process.env.VUE_APP_URL,
form: {
email: process.env.TEST_EMAIL, email: process.env.TEST_EMAIL,
username: process.env.TEST_USERNAME, username: process.env.TEST_USERNAME,
password: process.env.TEST_PASSWORD, password: process.env.TEST_PASSWORD,
repeatPassword: process.env.TEST_PASSWORD, repeatPassword: process.env.TEST_PASSWORD,
dateOfBirth: '', dateOfBirth: '',
terms: true, terms: true,
},
duplicate_email: false,
duplicate_username: false,
} }
},
computed: {
/*
...mapGetters("user", [ ...mapGetters("user", [
'getUsername', 'getUsername',
'getPassword', 'getPassword',
@@ -141,10 +139,9 @@
'getUserServer', 'getUserServer',
'getServerCode', 'getServerCode',
]), ]),
env() { */
return env
}, /*
},
validations: { validations: {
isAsync: true, isAsync: true,
form: { form: {
@@ -179,88 +176,91 @@
terms: {required}, terms: {required},
} }
}, }, */
methods: { env() {
...mapActions("user", { return env
signup: types.USER_SIGNUP, }
}),
showNotif(msg) { showNotif(msg) {
this.$q.notify(msg) this.$q.notify(msg)
}, }
errorMsg(cosa, item) { errorMsg(cosa, item) {
try { try {
if (!item.$error) return ''; if (!item.$error) return ''
if (item.$params.email && !item.email) return this.$t('reg.err.email'); if (item.$params.email && !item.email) return this.$t('reg.err.email')
if (cosa === 'repeatpassword') { if (cosa === 'repeatpassword') {
if (!item.sameAsPassword) { if (!item.sameAsPassword) {
return this.$t('reg.err.sameaspassword'); return this.$t('reg.err.sameaspassword')
} }
} }
if (cosa === 'email') { if (cosa === 'email') {
//console.log("EMAIL " + item.isUnique); //console.log("EMAIL " + item.isUnique);
//console.log(item); //console.log(item);
if (!item.isUnique) return this.$t('reg.err.duplicate_email'); if (!item.isUnique) return this.$t('reg.err.duplicate_email')
} else if (cosa === 'username') { } else if (cosa === 'username') {
//console.log(item); //console.log(item);
if (!item.isUnique) return this.$t('reg.err.duplicate_username'); if (!item.isUnique) return this.$t('reg.err.duplicate_username')
} }
if (!item.required) return this.$t('reg.err.required'); if (!item.required) return this.$t('reg.err.required')
if (!item.minLength) return this.$t('reg.err.atleast') + ` ${item.$params.minLength.min} ` + this.$t('reg.err.char'); if (!item.minLength) return this.$t('reg.err.atleast') + ` ${item.$params.minLength.min} ` + this.$t('reg.err.char')
if (!item.maxLength) return this.$t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + this.$t('reg.err.char'); if (!item.maxLength) return this.$t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + this.$t('reg.err.char')
return ''; return ''
} catch (error) { } catch (error) {
//console.log("ERR : " + error); //console.log("ERR : " + error);
} }
}, }
checkErrors(riscode) { checkErrors(riscode) {
//console.log("RIS = " + riscode); //console.log("RIS = " + riscode);
if (riscode === ErroriMongoDb.DUPLICATE_EMAIL_ID) { if (riscode === ErroriMongoDb.DUPLICATE_EMAIL_ID) {
this.showNotif(this.$t('reg.err.duplicate_email')); this.showNotif(this.$t('reg.err.duplicate_email'))
} else if (riscode === ErroriMongoDb.DUPLICATE_USERNAME_ID) { } else if (riscode === ErroriMongoDb.DUPLICATE_USERNAME_ID) {
this.showNotif(this.$t('reg.err.duplicate_username')); this.showNotif(this.$t('reg.err.duplicate_username'))
} else if (riscode === ErroriMongoDb.OK) { } else if (riscode === ErroriMongoDb.OK) {
this.$router.push('/'); this.$router.push('/')
} else { } else {
this.showNotif("Errore num " + riscode); this.showNotif("Errore num " + riscode)
}
} }
},
submit() { submit() {
this.$v.form.$touch(); this.$v.user.$touch()
this.duplicate_email = false; this.duplicate_email = false
this.duplicate_username = false; this.duplicate_username = false
if (!this.form.terms) { if (!this.user.terms) {
this.showNotif(this.$t('reg.err.terms')); this.showNotif(this.$t('reg.err.terms'))
return return
} }
if (this.$v.form.$error) { if (this.$v.user.$error) {
this.showNotif(this.$t('reg.err.errore_generico')); this.showNotif(this.$t('reg.err.errore_generico'))
return return
} }
this.$q.loading.show({message: this.$t('reg.incorso')}); this.$q.loading.show({ message: this.$t('reg.incorso') })
console.log(this.form); console.log(this.user)
this.signup(this.form) UserModule.signup(this.user)
.then((riscode) => { .then((riscode) => {
this.checkErrors(riscode); this.checkErrors(riscode)
this.$q.loading.hide(); this.$q.loading.hide()
}).catch(error => { }).catch(error => {
console.log("ERROR = " + error); console.log("ERROR = " + error)
this.$q.loading.hide(); this.$q.loading.hide()
}); })
// ... // ...
} }
},
} }
</script> </script>
<style scoped> <style scoped>

View File

@@ -24,7 +24,7 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator'; import { Component, Vue, Watch } from 'vue-property-decorator';
import { UserModule } from '@/store/modules/useraa'; import { UserModule } from '../../store/modules/user';
@Component({}) @Component({})

View File

@@ -1,25 +1,55 @@
{ {
"defaultSeverity": "warning",
"extends": [
"tslint:recommended"
],
"linterOptions": {
"exclude": [
"node_modules/**"
]
},
"rules": { "rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-duplicate-variable": true,
"no-eval": true,
"no-internal-module": false,
"no-trailing-whitespace": false,
"no-var-keyword": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"semicolon": [true, "never"], "semicolon": [true, "never"],
"trailing-comma": [true, {"multiline": "never", "singleline": "never"}], "trailing-comma": [true, {"multiline": "never", "singleline": "never"}],
"quotemark": [true, "single"], "triple-equals": [
"indent": [true, "spaces", 2], true,
"interface-name": false, "allow-null-check"
"ordered-imports": false, ],
"object-literal-sort-keys": false, "typedef-whitespace": [
"max-line-length": false, true,
"member-access": false, {
"no-console": [true, "warning"], "call-signature": "nospace",
"no-consecutive-blank-lines": false, "index-signature": "nospace",
"no-empty": false "parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
} }
} }

25
tslint.json.PAO Normal file
View File

@@ -0,0 +1,25 @@
{
"defaultSeverity": "warning",
"extends": [
"tslint:recommended"
],
"linterOptions": {
"exclude": [
"node_modules/**"
]
},
"rules": {
"semicolon": [true, "never"],
"trailing-comma": [true, {"multiline": "never", "singleline": "never"}],
"quotemark": [true, "single"],
"indent": [true, "spaces", 2],
"interface-name": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"max-line-length": false,
"member-access": false,
"no-console": [true, "warning"],
"no-consecutive-blank-lines": false,
"no-empty": false
}
}