First Committ

This commit is contained in:
Paolo Arena
2021-08-31 18:09:59 +02:00
commit 1d6c55807c
299 changed files with 55382 additions and 0 deletions

69
src/common/axios.ts Executable file
View File

@@ -0,0 +1,69 @@
import axios, {
AxiosError,
AxiosRequestConfig,
AxiosResponse,
} from 'axios'
// import { default as VueRouter } from 'vue-router'
import { serv_constants } from '@src/store/Modules/serv_constants'
// import { TokenHelper } from "./token-helper";
let initialized: boolean = false
interface IRequestConfig extends AxiosRequestConfig {
ignore: number[]
}
function handle(status: number, exclude: number[]) {
if (exclude.length === 0) return true
return exclude.find(o => o === status) === undefined
}
export function UseAxios(router: any) { // VueRouter
if (!initialized) {
// @ts-ignore
axios.interceptors.request.use((config: IRequestConfig) => {
if (!config.headers.Authorization) {
// append authorization header
/* ++Todo: disattivato per ora...
let bearerToken = TokenHelper.getBearerToken()
if (bearerToken.Authorization)
Object.assign(config.headers, bearerToken)
*/
}
// ensure axios does not follow redirects, so custom response interceptor below can push to app login page
if (!config.maxRedirects || (config.maxRedirects === 5)) {
config.maxRedirects = 0
}
return config
})
axios.interceptors.response.use(undefined, (config: AxiosError) => {
// @ts-ignore
const { response } = config
const exclude = (<IRequestConfig>config.config).ignore || []
if (response) {
if (response.status === 401 && handle(response.status, exclude)) {
const location: string = response.headers.location || response.headers.Location
if (location) {
const redirectTo = `/${location}`
window.setTimeout(() => router.replace(redirectTo), 200)
}
}
if (response.status === serv_constants.RIS_CODE__HTTP_FORBIDDEN_INVALID_TOKEN && handle(response.status, exclude)) {
window.setTimeout(() => router.replace('/forbidden'), 200)
}
}
return config
})
initialized = true
}
}

58
src/common/debounce.ts Executable file
View File

@@ -0,0 +1,58 @@
/**
* 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.
*
* @source underscore.js
* @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
* @param {Function} function to wrap
* @param {Number} timeout in ms (`100`)
* @param {Boolean} whether to execute at the beginning (`false`)
* @api public
*/
export function Debounce(func: Function, wait?: number, immediate?: boolean) {
// @ts-ignore
let timeout: any,
args: any,
context: any,
timestamp: any,
result: any
if (wait == null) wait = 100
function later() {
const last = Date.now() - timestamp
// @ts-ignore
if (last < wait && last > 0) {
// @ts-ignore
timeout = setTimeout(later, wait - last)
} else {
timeout = null
if (!immediate) {
result = func.apply(context, args)
context = args == null
}
}
}
return function a2() {
// @ts-ignore
context = this
// @ts-ignore
// args = arguments
timestamp = Date.now()
const callNow = immediate && !timeout
if (!timeout) {
timeout = setTimeout(later, wait)
}
if (callNow) {
result = func.apply(context, args)
context = args == null
}
return result
}
}

5
src/common/index.ts Executable file
View File

@@ -0,0 +1,5 @@
export * from './pattern'
export * from './axios'
export * from './debounce'
export * from './message'
export { default as GlobalConfig } from '../config'

8
src/common/message.ts Executable file
View File

@@ -0,0 +1,8 @@
export const PayloadMessageTypes = {
error: 'Error',
info: 'Info',
failure: 'Failure',
success: 'Success',
warning: 'Warning',
statusfound: 200,
}

20
src/common/pattern.ts Executable file
View File

@@ -0,0 +1,20 @@
export class Patterns {
/**
* Alphanumeric, spaces and dashes allowed. Min 2 characters length.
*/
public static DisplayName: RegExp = /^[0-9a-zA-Z\s-]{2,}/i
/**
* Same pattern used by JQuery userName validation
*/
public static Email: RegExp = /^((“[\w-\s]+”)|([\w-]+(?:\.[\w-]+)*)|(“[\w-\s]+”)([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}[0-9];{1,2})\]?$)/i
/**
* 6 to 20 characters string with at least one digit, one upper case letter, one lower case letter and one special symbol
*
* public static Password: RegExp = /^((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!\-]).{6,20})/i
*
* 8 to 20 characters string with at least one digit, one upper case letter, one lower case letter and one special symbol
*/
public static Password: RegExp = /^((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,30})/i
}

117
src/common/shared_nodejs.js Executable file
View File

@@ -0,0 +1,117 @@
module.exports = {
Accepted: {
CHECK_READ_GUIDELINES: 1,
CHECK_SEE_VIDEO_PRINCIPI: 2,
},
ALL_SAW_AND_ACCEPTED: 3,
// ---------------------
FILTER_EXTRALIST_NOT_REGISTERED: 1,
FILTER_EXTRALIST_NOT_CONTACTED: 2,
FILTER_EXTRALIST_WITH_NOTE: 4,
FILTER_USER_NO_ZOOM: 8,
FILTER_USER_NO_INVITANTE: 16,
FILTER_USER_NO_TELEGRAM_ID: 32,
FILTER_USER_CODICE_AUTH_TELEGRAM: 64,
FILTER_USER_NO_EMAIL_VERIFICATA: 128,
FILTER_USER_NO_DREAM: 256,
FILTER_EXTRALIST_DELETED: 512,
FILTER_USER_TELEGRAM_BLOCKED: 1024,
FILTER_ATTIVI: 2048,
FILTER_NASCOSTI: 4096,
FILTER_NAVI_NON_PRESENTI: 8192,
FILTER_QUALIFIED: 16384,
FILTER_ASK_ZOOM_VISTO: 32768,
FILTER_HOURS_MYLIST: 65536,
FILTER_HOURS_ALL: 131072,
FILTER_MISSING_PAYMENT: 262144,
FILTER_TO_MAKE_MEMBERSHIP_CARD: 524288,
FILTER_MEMBERSHIP_CARD_OK: 1048576,
REPORT_FILT_RESP: 1,
REPORT_FILT_ATTIVITA: 2,
PaymentTypes: [
'Nessuno',
'Bonifico Bancario',
'Paypal',
'In Contanti alla CNM',
],
CashType: {
None: 0,
Incoming: 1,
Outcoming: 2,
},
WalletFinalStatusType: {
None: 0,
InCommonCash: 1,
InMyWallet: 2,
},
Permissions: {
Admin: 1,
Manager: 2,
Teacher: 4,
Tutor: 8,
Editor: 16,
Zoomeri: 32,
Department: 64,
},
MessageOptions: {
Notify_ByEmail: 2,
Notify_ByPushNotification: 4,
},
TypeMsg: {
SEND_TO_ALL: 1,
SEND_TO_SOCI: 2,
SEND_TO_SOCIO_RESIDENTE: 3,
SEND_TO_CONSIGLIO: 5,
SEND_TO_NON_SOCI: 10,
SEND_TO_PAOLO: 20,
},
TypeMsg_Actions: {
NORMAL: 0,
YESNO: 1,
OPZ1_2: 2,
},
CallFunz: {
SOSTITUISCI: 345,
AGGIUNGI_NUOVO_IMBARCO: 380,
CANCELLA_IMBARCO: 385,
DAMMI_PRIMO_UTENTE_LIBERO: 390,
GET_VALBYTABLE: 400,
SET_VALBYTABLE: 410,
ZOOM_GIA_PARTECIPATO: 510,
},
OrderStatus: {
NONE: 0,
IN_CART: 1,
CHECKOUT_SENT: 2,
ORDER_CONFIRMED: 3,
PAYED: 4,
DELIVEDED: 5,
RECEIVED: 6,
CANCELED: 10,
},
OrderStatusView: {
CHECKOUT_SENT: 2,
ORDER_CONFIRMED: 3,
PAYED: 4,
RECEIVED: 6,
CANCELED: 10,
},
fieldsUserToChange() {
return ['_id', 'index', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'old_order', 'numinvitati', 'numinvitatiattivi', 'qualified']
},
};

225
src/common/shared_vuejs.ts Executable file
View File

@@ -0,0 +1,225 @@
export const shared_consts = {
Accepted: {
CHECK_READ_GUIDELINES: {
value: 1,
label: 'steps.linee_guida',
icon: 'fas fa-user-shield',
color: 'red',
},
CHECK_SEE_VIDEO_PRINCIPI: {
value: 2,
label: 'steps.video_intro',
icon: 'fas fa-tools',
color: 'green',
},
},
ALL_SAW_AND_ACCEPTED: 3,
FILTER_EXTRALIST_NOT_REGISTERED: 1,
FILTER_EXTRALIST_NOT_CONTACTED: 2,
FILTER_EXTRALIST_WITH_NOTE: 4,
FILTER_USER_NO_ZOOM: 8,
FILTER_USER_NO_INVITANTE: 16,
FILTER_USER_NO_TELEGRAM_ID: 32,
FILTER_USER_CODICE_AUTH_TELEGRAM: 64,
FILTER_USER_NO_EMAIL_VERIFICATA: 128,
FILTER_USER_NO_DREAM: 256,
FILTER_EXTRALIST_DELETED: 512,
FILTER_USER_TELEGRAM_BLOCKED: 1024,
FILTER_ATTIVI: 2048,
FILTER_NASCOSTI: 4096,
FILTER_NAVI_NON_PRESENTI: 8192,
FILTER_QUALIFIED: 16384,
FILTER_ASK_ZOOM_VISTO: 32768,
FILTER_HOURS_MYLIST: 65536,
FILTER_HOURS_ALL: 131072,
FILTER_MISSING_PAYMENT: 262144,
FILTER_TO_MAKE_MEMBERSHIP_CARD: 524288,
FILTER_MEMBERSHIP_CARD_OK: 1048576,
REPORT_FILT_RESP: 1,
REPORT_FILT_ATTIVITA: 2,
CashType: {
None: 0,
Incoming: 1,
Outcoming: 2,
},
Permissions: {
Admin: {
value: 1,
label: 'pages.Admin',
icon: 'fas fa-user-shield',
color: 'red',
},
Manager: {
value: 2,
label: 'otherpages.manage.manager',
icon: 'fas fa-tools',
color: 'green',
},
Teacher: {
value: 4,
label: 'event.teacher',
icon: 'fas fa-user-tie',
color: 'blue',
},
Tutor: {
value: 8,
label: 'dashboard.tutor',
icon: 'fas fa-user-tie',
color: 'fuchsia',
},
Editor: {
value: 16,
label: 'dashboard.Editor',
icon: 'fas fa-user-tie',
color: 'orange',
},
Zoomeri: {
value: 32,
label: 'dashboard.zoomeri',
icon: 'fas fa-user-tie',
color: 'yellow',
},
Department: {
value: 64,
label: 'pages.department',
icon: 'fas fa-user-tie',
color: 'yellow',
},
},
MessageOptions: {
Notify_ByEmail: 2,
Notify_ByPushNotification: 4,
},
TypeMsg: {
SEND_TO_ALL: 1,
SEND_TO_SOCI: 2,
SEND_TO_SOCIO_RESIDENTE: 3,
SEND_TO_NON_SOCI: 10,
SEND_TO_PAOLO: 20,
},
TypeMsg_Actions: {
NORMAL: 0,
YESNO: 1,
OPZ1_2: 2,
},
selectActions: [
{
id: 0,
label: 'Normale',
value: 0,
},
{
id: 1,
label: 'Si / No',
value: 1,
},
{
id: 2,
label: 'Opzione 1 / Opzione 2',
value: 2,
},
],
selectDestination: [
{
id: 0,
label: 'A Tutti',
value: 1,
},
{
id: 1,
label: 'Solo ai Soci',
value: 2,
},
{
id: 2,
label: 'Solo ai Soci Residenti',
value: 3,
},
{
id: 3,
label: 'Solo ai NON Soci',
value: 10,
},
{
id: 4,
label: 'a Paolo (test)',
value: 20,
},
],
OrderStatus: {
NONE: 0,
IN_CART: 1,
CHECKOUT_SENT: 2,
ORDER_CONFIRMED: 3,
PAYED: 4,
DELIVEDED: 5,
RECEIVED: 6,
CANCELED: 10,
},
OrderStatusView: [
2,
3,
4,
6,
10,
],
OrderStatusStr: [
{
label: 'Nessuno',
value: 0,
},
{
label: 'In Carrello',
value: 1,
},
{
label: 'Ordine in Lavorazione',
value: 2,
},
{
label: 'Ordine Confermato',
value: 3,
},
{
label: 'Pagato',
value: 4,
},
{
label: 'Spedito',
value: 5,
},
{
label: 'Ricevuto',
value: 6,
},
{
label: 'Cancellato',
value: 10,
},
],
getStatusStr(status: number) {
const trovatorec = this.OrderStatusStr.find((rec) => rec.value === status)
return (trovatorec) ? trovatorec.label : ''
},
fieldsUserToChange() {
return ['_id', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline', 'profile', 'news_on']
},
}