From 6522a88eb7eba50e9627f30d7b00f7597917f3d4 Mon Sep 17 00:00:00 2001 From: paolo Date: Thu, 8 Nov 2018 01:09:33 +0100 Subject: [PATCH] corretto altro ts... ora manca ancora il vuelidate --- jest.config.js | 11 +- quasar.conf.js | 13 +++ src/common/axios.ts | 48 ++++---- src/common/debounce.ts | 15 ++- src/common/index.ts | 2 + src/common/message.ts | 7 ++ src/components/Header.vue | 2 - src/config.ts | 39 +++++++ src/layouts/drawer/drawer.vue | 2 - src/mixins/mixin-router.ts | 12 ++ src/model/index.ts | 1 + src/model/other.ts | 18 +++ src/model/payload/index.ts | 4 + src/model/payload/payload-mapper.ts | 85 ++++++++++++++ src/model/payload/payload-message.ts | 6 + src/model/payload/payload.ts | 8 ++ src/model/user.ts | 2 +- src/pages/Index.vue | 129 ---------------------- src/root/home/home.scss | 3 + src/root/home/home.ts | 91 +++++++++++++++ src/root/home/home.vue | 38 +++++++ src/router/index.ts | 4 +- src/router/{routes.ts => route-config.ts} | 19 +++- src/router/route-names.ts | 4 + src/store/modules/user.ts | 2 +- src/types/index.d.ts | 18 --- src/validation/duplicate.ts | 32 +++--- src/validation/registered.ts | 20 ++-- src/views/dashboard/one/dashboard.vue | 1 - src/views/login/{signup => }/signin.vue | 4 +- src/views/login/signup/signup.html | 100 ----------------- src/views/login/signup/signup.ts | 25 ++--- src/views/login/signup/signup.vue | 105 +++++++++++++++++- tsconfig.json | 6 +- 34 files changed, 537 insertions(+), 339 deletions(-) create mode 100644 src/common/message.ts create mode 100644 src/config.ts create mode 100644 src/mixins/mixin-router.ts create mode 100644 src/model/other.ts create mode 100644 src/model/payload/index.ts create mode 100644 src/model/payload/payload-mapper.ts create mode 100644 src/model/payload/payload-message.ts create mode 100644 src/model/payload/payload.ts delete mode 100644 src/pages/Index.vue create mode 100644 src/root/home/home.scss create mode 100644 src/root/home/home.ts create mode 100644 src/root/home/home.vue rename src/router/{routes.ts => route-config.ts} (66%) create mode 100644 src/router/route-names.ts rename src/views/login/{signup => }/signin.vue (97%) delete mode 100644 src/views/login/signup/signup.html diff --git a/jest.config.js b/jest.config.js index 5fe74d2..8ac7411 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,12 +8,17 @@ module.exports = { coverageDirectory: '/test/coverage', collectCoverageFrom: [ '/src/components/**/*.vue', + '/src/common/**/*.ts', + '/src/directives/**/*.ts', '/src/layouts/**/*.vue', + '/src/mixins/**/*.ts', + '/src/model/**/*.ts', '/src/pages/**/*.vue', '/src/plugins/**/*.ts', - '/src/mixins/**/*.ts', - '/src/directives/**/*.ts', - '/src/utils/**/*.ts' + '/src/root/**/*.ts', + '/src/utils/**/*.ts', + '/src/views/**/*.ts', + '/src/views/**/*.vue', ], coverageThreshold: { global: { diff --git a/quasar.conf.js b/quasar.conf.js index f16918b..8dc9d20 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -21,6 +21,17 @@ const extendTypescriptToWebpack = (config) => { }) }; +const extendHTMLToWebpack = (config) => { + config.resolve + .extensions + .add('.html'); + config.module + .rule('html') + .test(/\.html?$/) + .use('html') + .loader('vue-html-loader') +}; + module.exports = function (ctx) { return { sourceFiles: { @@ -42,6 +53,7 @@ module.exports = function (ctx) { ], supportIE: false, build: { + showProgress: true, env: envparser(), scopeHoisting: true, vueRouterMode: 'history', @@ -51,6 +63,7 @@ module.exports = function (ctx) { // extractCSS: false, chainWebpack(config) { extendTypescriptToWebpack(config); + // extendHTMLToWebpack(config); config.resolve .alias .set('~', __dirname) diff --git a/src/common/axios.ts b/src/common/axios.ts index bfcb53f..89ffac5 100644 --- a/src/common/axios.ts +++ b/src/common/axios.ts @@ -3,60 +3,64 @@ import { AxiosError, AxiosRequestConfig, AxiosResponse -} from "axios"; -import { default as VueRouter } from "vue-router"; -import { TokenHelper } from "./token-helper"; +} from 'axios' +import { default as VueRouter } from 'vue-router' +// import { TokenHelper } from "./token-helper"; -let initialized: boolean = false; +let initialized: boolean = false interface IRequestConfig extends AxiosRequestConfig { - ignore: number[]; + ignore: number[] } function handle(status: number, exclude: number[]) { - if (exclude.length === 0) return true; - else return exclude.find(o => o === status) === undefined; + if (exclude.length === 0) return true + else return exclude.find(o => o === status) === undefined } export function UseAxios(router: VueRouter) { if (!initialized) { + // @ts-ignore Axios.interceptors.request.use((config: IRequestConfig) => { - if (!config.headers["Authorization"]) { + if (!config.headers['Authorization']) { // append authorization header - let bearerToken = TokenHelper.getBearerToken(); + /* ++Todo: disattivato per ora... + let bearerToken = TokenHelper.getBearerToken() if (bearerToken.Authorization) - Object.assign(config.headers, bearerToken); + Object.assign(config.headers, bearerToken) + */ } if (!config.maxRedirects || config.maxRedirects === 5) // ensure axios does not follow redirects, so custom response interceptor below can push to app login page - config.maxRedirects = 0; + config.maxRedirects = 0 - return config; - }); + return config + }) Axios.interceptors.response.use(undefined, (config: AxiosError) => { - let response: AxiosResponse = config.response; - let exclude = (config.config).ignore || []; + // @ts-ignore + let response: AxiosResponse = config.response + let exclude = (config.config).ignore || [] if (response.status === 401 && handle(response.status, exclude)) { let location: string = - response.headers["location"] || response.headers["Location"]; + response.headers['location'] || response.headers['Location'] if (location) { - let redirectTo = "/" + location; - window.setTimeout(() => router.replace(redirectTo), 200); + let redirectTo = '/' + location + window.setTimeout(() => router.replace(redirectTo), 200) } } if (response.status === 403 && handle(response.status, exclude)) { - window.setTimeout(() => router.replace("/forbidden"), 200); + window.setTimeout(() => router.replace('/forbidden'), 200) } - return config; - }); + return config + }) - initialized = true; + initialized = true } } diff --git a/src/common/debounce.ts b/src/common/debounce.ts index 408265b..9746188 100644 --- a/src/common/debounce.ts +++ b/src/common/debounce.ts @@ -2,8 +2,8 @@ * Returns a function, that, as long as it continues to be invoked, will not * be triggered. The function will be called after it stops being called for * N milliseconds. If `immediate` is passed, trigger the function on the - * leading edge, instead of the trailing. The function also has a property 'clear' - * that is a function which will clear the timer to prevent previously scheduled executions. + * leading edge, instead of the trailing. The function also has a property 'clear' + * that is a function which will clear the timer to prevent previously scheduled executions. * * @source underscore.js * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/ @@ -14,13 +14,17 @@ */ export function Debounce(func: Function, wait?: number, immediate?: boolean) { - let timeout, args, context, timestamp, result - if (null == wait) wait = 100 + // @ts-ignore + let timeout: any, args: any, context: any, timestamp: any, result: any + if (null == wait) + wait = 100 function later() { let last = Date.now() - timestamp + // @ts-ignore if (last < wait && last > 0) { + // @ts-ignore timeout = setTimeout(later, wait - last) } else { timeout = null @@ -33,6 +37,7 @@ export function Debounce(func: Function, wait?: number, immediate?: boolean) { let debounced = function () { + // @ts-ignore context = this args = arguments timestamp = Date.now() @@ -47,4 +52,4 @@ export function Debounce(func: Function, wait?: number, immediate?: boolean) { } return debounced -} \ No newline at end of file +} diff --git a/src/common/index.ts b/src/common/index.ts index 1d9b257..bcc0db6 100644 --- a/src/common/index.ts +++ b/src/common/index.ts @@ -1,3 +1,5 @@ export * from './pattern' export * from './axios' export * from './debounce' +export * from './message' +export { default as GlobalConfig } from '../config' diff --git a/src/common/message.ts b/src/common/message.ts new file mode 100644 index 0000000..7be3885 --- /dev/null +++ b/src/common/message.ts @@ -0,0 +1,7 @@ +export const PayloadMessageTypes = { + error: 'Error', + info: 'Info', + failure: 'Failure', + success: 'Success', + warning: 'Warning' +} \ No newline at end of file diff --git a/src/components/Header.vue b/src/components/Header.vue index 94d017a..9aa0ad4 100644 --- a/src/components/Header.vue +++ b/src/components/Header.vue @@ -59,8 +59,6 @@ // import user from '../store/modules/user'; - import * as types from '../store/mutation-types' - export default { components: { drawer, diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..763cae4 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,39 @@ + +interface IUriConfig { + auth?: string; + content?: string; + site?: string; + services?: string; +} + +const uri: IUriConfig = {}; + +const addProp = (obj: {}, propName: string, value: string) => { + Object.defineProperty(obj, propName, { + enumerable: false, + get: () => { + return '//' + window.location.host + value; + } + }); +}; + +addProp(uri, 'auth', '/auth/'); +addProp(uri, 'content', '/api/content/'); +addProp(uri, 'site', ''); +addProp(uri, 'services', '/api/'); + +const config = { + uri: uri, + claimsNamespace: '//toucan/claims', + auth: { + accessTokenKey: 'AUTH-LOCAL', + externalProviderKey: 'AUTH-EXTERNAL' + }, + uopt: 'UOPT', + xsrf: { + cookieName: 'XSRF-TOKEN', + headerName: 'X-XSRF-TOKEN' + } +}; + +export default config; diff --git a/src/layouts/drawer/drawer.vue b/src/layouts/drawer/drawer.vue index ec31234..e2a2d08 100644 --- a/src/layouts/drawer/drawer.vue +++ b/src/layouts/drawer/drawer.vue @@ -31,8 +31,6 @@ import menuOne from './menuOne.vue' import menuTwo from './menuTwo.vue' - import * as types from '../../store/mutation-types' - import { Component, Vue, Watch, Prop } from 'vue-property-decorator' import { GlobModule } from '../../store/modules/glob' import { UserModule } from '../../store/modules/user'; diff --git a/src/mixins/mixin-router.ts b/src/mixins/mixin-router.ts new file mode 100644 index 0000000..c0ed966 --- /dev/null +++ b/src/mixins/mixin-router.ts @@ -0,0 +1,12 @@ +import Vue from 'vue' +import { Route, default as VueRouter } from 'vue-router' + +export type IRouterMixinData = VueRouter + +export type IRouteMixinData = Route + +export interface IRouterMixin { + $route: IRouteMixinData + $router: IRouterMixinData +} + diff --git a/src/model/index.ts b/src/model/index.ts index 8b15480..38fd172 100644 --- a/src/model/index.ts +++ b/src/model/index.ts @@ -2,3 +2,4 @@ export * from './user' export * from './glob' export * from './signup-option' export * from './key-value' +export * from './payload'; diff --git a/src/model/other.ts b/src/model/other.ts new file mode 100644 index 0000000..4f6db48 --- /dev/null +++ b/src/model/other.ts @@ -0,0 +1,18 @@ +export interface IToken { + access: string + token: string +} + + +export interface ILinkReg { + idLink: string +} + +export interface IIdToken { + idToken: string +} + +export interface IResult { + status: number + statusText: string +} diff --git a/src/model/payload/index.ts b/src/model/payload/index.ts new file mode 100644 index 0000000..a4eea21 --- /dev/null +++ b/src/model/payload/index.ts @@ -0,0 +1,4 @@ +export { IPayload } from './payload'; +export { IPayloadMessage } from './payload-message'; +export * from './payload-mapper'; + diff --git a/src/model/payload/payload-mapper.ts b/src/model/payload/payload-mapper.ts new file mode 100644 index 0000000..07bb048 --- /dev/null +++ b/src/model/payload/payload-mapper.ts @@ -0,0 +1,85 @@ +import { AxiosError, AxiosResponse } from 'axios' +import { PayloadMessageTypes } from '@/common' +import { IPayload } from './payload' + +export { PayloadMessageTypes } from '../../common/message' + +export class PayloadMapper { + + private fromError(o: Error): IPayload { + + return { + // @ts-ignore + data: null, + message: { + messageTypeId: PayloadMessageTypes.error, + text: o.message, + title: o.name + } + } + } + + private fromAxiosError(o: AxiosError): IPayload { + + // @ts-ignore + let data: T = null + + if (o.response && isAxiosResponse(o.response)) + data = this.fromAxiosResponse(o.response).data + + return { + data: data, + message: { + messageTypeId: PayloadMessageTypes.error, + text: o.message, + title: 'Code:' + o.code + '. ' + o.name + } + } + } + + private fromAxiosResponse(o: AxiosResponse): IPayload { + + // @ts-ignore + let value: IPayload = null + + if (isPayload(o.data)) + value = o.data + else + value = { + data: o.data, + message: { + messageTypeId: PayloadMessageTypes.success, + // @ts-ignore + text: null + } + } + return value + } + + public fromObject(o: any): IPayload { + + if (isAxiosError(o)) + return this.fromAxiosError(o) + + if (o instanceof Error) + return this.fromError(o) + + if (isAxiosResponse(o)) + return this.fromAxiosResponse(o) + + // @ts-ignore + return null + } +} + +function isAxiosResponse(o: any): o is AxiosResponse { + return o instanceof Object && 'data' in o && 'config' in o && 'status' in o && 'statusText' in o && 'headers' in o +} + +function isAxiosError(o: any): o is AxiosError { + return o instanceof Object && o instanceof Error && 'config' in o +} + +function isPayload(o: any): o is IPayload { + return o instanceof Object && 'data' in o && 'message' in o +} diff --git a/src/model/payload/payload-message.ts b/src/model/payload/payload-message.ts new file mode 100644 index 0000000..d73b4c3 --- /dev/null +++ b/src/model/payload/payload-message.ts @@ -0,0 +1,6 @@ + +export interface IPayloadMessage { + text: string; + title?: string; + messageTypeId: string; +} \ No newline at end of file diff --git a/src/model/payload/payload.ts b/src/model/payload/payload.ts new file mode 100644 index 0000000..3d01257 --- /dev/null +++ b/src/model/payload/payload.ts @@ -0,0 +1,8 @@ +import { IPayloadMessage } from './payload-message' + +export interface IPayload { + + data: T + + message: IPayloadMessage +} diff --git a/src/model/user.ts b/src/model/user.ts index a437cfe..32bfd5d 100644 --- a/src/model/user.ts +++ b/src/model/user.ts @@ -1,4 +1,4 @@ -import { IToken } from '@/types' +import { IToken } from '@/model/other' export const DefaultUser = { email: '', diff --git a/src/pages/Index.vue b/src/pages/Index.vue deleted file mode 100644 index f941e6d..0000000 --- a/src/pages/Index.vue +++ /dev/null @@ -1,129 +0,0 @@ - - - - - diff --git a/src/root/home/home.scss b/src/root/home/home.scss new file mode 100644 index 0000000..6580a26 --- /dev/null +++ b/src/root/home/home.scss @@ -0,0 +1,3 @@ +.mycard { + visibility: hidden; +} diff --git a/src/root/home/home.ts b/src/root/home/home.ts new file mode 100644 index 0000000..be49148 --- /dev/null +++ b/src/root/home/home.ts @@ -0,0 +1,91 @@ +import Vue from 'vue' +import { Component, Watch, Prop } from 'vue-property-decorator' +import { GlobModule } from '@/store/modules/glob' + +require('./home.scss') + +@Component({ + +}) +export default class Home extends Vue { + text: string = '' + visibile: boolean = false + cardvisible: string = 'hidden' + displaycard: string = 'block' + + constructor() { + super() + console.log('created...') + this.initprompt() + } + + mystilecard() { + return { + visibility: this.cardvisible, + display: this.displaycard + } + } + + get conta() { + return GlobModule.conta + } + + set conta(valore) { + GlobModule.setConta(valore) + var my = this.$q.i18n.lang + this.showNotification(String(my)) + } + + showNotification(msg: string) { + this.$q.notify(msg) + } + + initprompt() { + window.addEventListener('beforeinstallprompt', function (event) { + console.log('******************************** beforeinstallprompt fired') + event.preventDefault() + console.log('§§§§§§§§§§§§§§§§§§§§ IMPOSTA DEFERRED PROMPT !!!!!!!!!!!!!!!!! ') + return false + }) + } + + test_fetch() { + fetch('https:/httpbin.org/post', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + // mode: 'no-cors', + mode: 'cors', + body: JSON.stringify({ message: 'Does this work?' }) + }).then(function (response) { + console.log(response) + if (response) + return response.json() + else + return null + }).then(function (data) { + console.log(data) + }).catch(function (err) { + console.log(err) + }) + } + + openCreatePostModal() { + console.log('APERTO ! openCreatePostModal') + + this.conta = this.conta + 1 + + this.visibile = !this.visibile + + if (this.visibile) { + this.displaycard = 'block' + this.cardvisible = 'visible' + } else { + this.displaycard = 'block' + this.cardvisible = 'hidden' + } + + } +} diff --git a/src/root/home/home.vue b/src/root/home/home.vue new file mode 100644 index 0000000..05f0125 --- /dev/null +++ b/src/root/home/home.vue @@ -0,0 +1,38 @@ + + diff --git a/src/router/index.ts b/src/router/index.ts index 4610ab8..925611d 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -2,7 +2,7 @@ import Vue from 'vue' import VueRouter, { RouterMode } from 'vue-router' import { PositionResult } from 'vue-router/types/router' -import routes from '@/router/routes' +import { RouteConfig } from './route-config' Vue.use(VueRouter) /* @@ -13,7 +13,7 @@ Vue.use(VueRouter) export default function (/* { store, ssrContext } */) { const Router = new VueRouter({ scrollBehavior: () => ({ y: 0 } as PositionResult), - routes, + routes: RouteConfig, // Leave these as is and change from quasar.conf.js instead! // quasar.conf.js -> build -> vueRouterMode diff --git a/src/router/routes.ts b/src/router/route-config.ts similarity index 66% rename from src/router/routes.ts rename to src/router/route-config.ts index c6c5602..567b042 100644 --- a/src/router/routes.ts +++ b/src/router/route-config.ts @@ -1,9 +1,17 @@ -import { RouteConfig } from 'vue-router' +import { RouteConfig as VueRouteConfig } from 'vue-router' -const routes: RouteConfig[] = [ - { path: '/', component: () => import('@/pages/Index.vue'), meta: { name: 'Home' } }, - { path: '/test', component: () => import('@/views/login/test.vue'), meta: { name: 'Test' } }, - { path: '/signup', component: () => import('@/views/login/signup/signup.vue'), meta: { name: 'Registration' } }, +import { RouteNames } from './route-names' + + +export const RouteConfig: VueRouteConfig[] = [ + { + component: () => import('@/root/home/home.vue'), + name: RouteNames.home, + path: '/', + meta: { name: 'Home' } + }, + { path: '/test', component: () => import('@/views/login/test.vue'), meta: { name: 'Test' } }, + { path: '/signup', component: () => import('@/views/login/signup/signup.vue'), meta: { name: 'Registration' } } /* { path: '/signin', component: () => import('@/views/login/signin.vue'), meta: { name: 'Login' } }, { path: '/vreg', component: () => import('@/views/login/vreg.vue'), meta: { name: 'Verify Reg' } }, @@ -29,4 +37,3 @@ const routes: RouteConfig[] = [ }*/ ] -export default routes diff --git a/src/router/route-names.ts b/src/router/route-names.ts new file mode 100644 index 0000000..18b285a --- /dev/null +++ b/src/router/route-names.ts @@ -0,0 +1,4 @@ +export const RouteNames = { + home: 'home', + login: 'login' +} diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 4630c04..09eb449 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -11,7 +11,7 @@ import * as types from '@/store/mutation-types' import { serv_constants } from '@/store/modules/serv_constants' import { IUserState } from '@/model' -import { ILinkReg, IResult, IIdToken } from '@/types' +import { ILinkReg, IResult, IIdToken } from '@/model/other' export const ErroriMongoDb = { diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 4f6db48..e69de29 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -1,18 +0,0 @@ -export interface IToken { - access: string - token: string -} - - -export interface ILinkReg { - idLink: string -} - -export interface IIdToken { - idToken: string -} - -export interface IResult { - status: number - statusText: string -} diff --git a/src/validation/duplicate.ts b/src/validation/duplicate.ts index e16b64d..a170fc5 100644 --- a/src/validation/duplicate.ts +++ b/src/validation/duplicate.ts @@ -1,23 +1,23 @@ -type t = string | number; -type fn = () => t[]; +type t = string | number +type fn = () => t[] -export function duplicate(matches: t[] | fn, ignoreCase: boolean = false) { - if (Array.isArray(matches)) return factory(matches, ignoreCase); +export function duplicate(matches: t[] | fn, ignoreCase: boolean = false): any { + if (Array.isArray(matches)) return factory(matches, ignoreCase) - return value => { - let cb = factory(matches(), ignoreCase); - return cb(value); - }; + return (value: any) => { + let cb = factory(matches(), ignoreCase) + return cb(value) + } } -function factory(values: t[], ignoreCase: boolean) { - return value => { +function factory(values: t[], ignoreCase: boolean): any { + return (value: any) => { if (value === undefined || value === null || values.length === 0) - return true; - else{ - let flags = ignoreCase ? "i" : ""; - let exp = new RegExp(`^(${value})$`, flags); - return values.find(o => exp.test(o.toString())) === undefined; + return true + else { + let flags = ignoreCase ? 'i' : '' + let exp = new RegExp(`^(${value})$`, flags) + return values.find(o => exp.test(o.toString())) === undefined } - }; + } } diff --git a/src/validation/registered.ts b/src/validation/registered.ts index 685d987..4e569b2 100644 --- a/src/validation/registered.ts +++ b/src/validation/registered.ts @@ -1,22 +1,22 @@ -import { default as Axios, AxiosResponse } from 'axios'; -import { IPayload } from '../model'; -import { GlobalConfig, PayloadMessageTypes } from '../common'; +import { default as Axios, AxiosResponse } from 'axios' +import { IPayload } from '../model' +import { GlobalConfig, PayloadMessageTypes } from '../common' -const AUTH_URL = GlobalConfig.uri.auth; -const VALIDATE_USER_URL = AUTH_URL + 'validateuser'; +const AUTH_URL = GlobalConfig.uri.auth +const VALIDATE_USER_URL = AUTH_URL + 'validateuser' export function registered(userName: string) { let config = { params: { userName: userName } - }; + } let onSuccess = (res: AxiosResponse) => { - let payload: IPayload = res.data; - return payload.message.messageTypeId !== PayloadMessageTypes.failure; + let payload: IPayload = res.data + return payload.message.messageTypeId !== PayloadMessageTypes.failure } return Axios.get(VALIDATE_USER_URL, config) - .then(onSuccess); + .then(onSuccess) -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/views/dashboard/one/dashboard.vue b/src/views/dashboard/one/dashboard.vue index f547a3f..24ae95d 100644 --- a/src/views/dashboard/one/dashboard.vue +++ b/src/views/dashboard/one/dashboard.vue @@ -58,7 +58,6 @@ import { mapActions } from 'vuex' import * as types from '../../../store/mutation-types' export default { - name: 'Home', mounted () { // Axios.all not working }, diff --git a/src/views/login/signup/signin.vue b/src/views/login/signin.vue similarity index 97% rename from src/views/login/signup/signin.vue rename to src/views/login/signin.vue index be598c9..b042860 100644 --- a/src/views/login/signup/signin.vue +++ b/src/views/login/signin.vue @@ -62,10 +62,10 @@ } from 'vuelidate/lib/validators' import {mapGetters, mapActions} from 'vuex' - import * as types from '../../../store/mutation-types' + import * as types from '../../store/mutation-types' //import {ErroriMongoDb} from '../../store/modules/user' - import {serv_constants} from "../../../store/modules/serv_constants"; + import {serv_constants} from "../../store/modules/serv_constants"; import axios from 'axios'; import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar' diff --git a/src/views/login/signup/signup.html b/src/views/login/signup/signup.html deleted file mode 100644 index 3e70ac2..0000000 --- a/src/views/login/signup/signup.html +++ /dev/null @@ -1,100 +0,0 @@ -
- -
diff --git a/src/views/login/signup/signup.ts b/src/views/login/signup/signup.ts index fa6284c..d03f46e 100644 --- a/src/views/login/signup/signup.ts +++ b/src/views/login/signup/signup.ts @@ -6,20 +6,18 @@ import { validationMixin } from 'vuelidate' import { required, minValue } from 'vuelidate/lib/validators' import { ISignupOptions, IUserState } from '@/model' import { validations, TSignup } from './signup-validate' -// import './signup.scss' + +import './signup.scss' // import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar' @Component({ mixins: [validationMixin], name: 'Signup', - // template: require('./signup.html'), validations: validations }) export default class Signup extends Vue { - myProperty: string = '' - duplicate_email: boolean = false duplicate_username: boolean = false user: ISignupOptions = { @@ -31,6 +29,7 @@ export default class Signup extends Vue { terms = true $v: any + $t: any constructor() { super() @@ -96,8 +95,7 @@ export default class Signup extends Vue { this.$q.notify(msg) } - /* - errorMsg(cosa: string, item: string) { + errorMsg(cosa: string, item: any) { try { if (!item.$error) return '' if (item.$params.email && !item.email) return this.$t('reg.err.email') @@ -109,11 +107,11 @@ export default class Signup extends Vue { } if (cosa === 'email') { - //console.log("EMAIL " + item.isUnique); - //console.log(item); + // console.log("EMAIL " + item.isUnique); + // console.log(item); if (!item.isUnique) return this.$t('reg.err.duplicate_email') } else if (cosa === 'username') { - //console.log(item); + // console.log(item); if (!item.isUnique) return this.$t('reg.err.duplicate_username') } @@ -122,12 +120,12 @@ export default class Signup extends Vue { if (!item.maxLength) return this.$t('reg.err.notmore') + ` ${item.$params.maxLength.max} ` + this.$t('reg.err.char') return '' } catch (error) { - //console.log("ERR : " + error); + // console.log("ERR : " + error); } } - checkErrors(riscode) { - //console.log("RIS = " + riscode); + checkErrors(riscode: number) { + // console.log("RIS = " + riscode); if (riscode === ErroriMongoDb.DUPLICATE_EMAIL_ID) { this.showNotif(this.$t('reg.err.duplicate_email')) } else if (riscode === ErroriMongoDb.DUPLICATE_USERNAME_ID) { @@ -135,10 +133,11 @@ export default class Signup extends Vue { } else if (riscode === ErroriMongoDb.OK) { this.$router.push('/') } else { - this.showNotif("Errore num " + riscode) + this.showNotif('Errore num ' + riscode) } } + /* submit() { diff --git a/src/views/login/signup/signup.vue b/src/views/login/signup/signup.vue index fe0f82d..ffe7666 100644 --- a/src/views/login/signup/signup.vue +++ b/src/views/login/signup/signup.vue @@ -1,8 +1,103 @@ -