diff --git a/.env.test.pcb b/.env.test.pcb index f069e6d8..458a9abf 100755 --- a/.env.test.pcb +++ b/.env.test.pcb @@ -10,7 +10,7 @@ PROVA_PAOLO="" LANG_DEFAULT="it" PAO_APP_ID="KKPPAA5KJK435J3KSS9F9D8S9F8SD98F9SDF" MASTER_KEY="KKPPSS5KJK435J3KSS9F9D8S9F8SD3CR3T" -MONGODB_HOST="https://65.108.222.97:3001" +MONGODB_HOST="https://srv.piuchebuono.app:3001" LOGO_REG='riso-logo-full.png' TEST_NAME="" TEST_SURNAME="" diff --git a/.vscode/launch.json b/.vscode/launch.json index 125ca0db..2b474c51 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -19,23 +19,5 @@ "request": "launch", "type": "node-terminal" }, - { - "command": "npm run spanorefresh", - "name": "SPA no Refresh", - "request": "launch", - "type": "node-terminal" - }, - { - "type": "node", - "request": "launch", - "name": "Launch Program", - "skipFiles": [ - "/**" - ], - "program": "${workspaceFolder}/src/App.ts", - "outFiles": [ - "${workspaceFolder}/**/*.js" - ] - } ] } diff --git a/src/db/lang/ws_it.js b/src/db/lang/ws_it.js index 65ee5f22..d67ccadf 100755 --- a/src/db/lang/ws_it.js +++ b/src/db/lang/ws_it.js @@ -16,6 +16,7 @@ const msg_website_it = { pages: { home: 'Home', profile: 'Profilo', + install_site: 'Installa Sito', profile2: 'ProfiloU', mypage2: 'mypage2', myservice2: 'myservice2', diff --git a/src/db/static_data.ts b/src/db/static_data.ts index 5b666e55..57bc4c84 100755 --- a/src/db/static_data.ts +++ b/src/db/static_data.ts @@ -55,6 +55,17 @@ function getDynamicPages(site: ISites): IListRoutes[] { inmenu: true, infooter: true, }, + { + active: true, + order: 120, + path: '/install_site', + materialIcon: 'fas fa-user', + name: 'pages.install_site', + component: () => import('@/views/admin/install_site/install_site.vue'), + meta: { requiresAuth: true }, + inmenu: false, + infooter: false, + }, { active: true, order: 120, diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js index fbd1ab41..c5debb2b 100755 --- a/src/statics/lang/it.js +++ b/src/statics/lang/it.js @@ -685,6 +685,7 @@ const msg_it = { invitante_username_not_exist: 'Inserire l\'Username della persona che fa da invitante', sameaspassword: 'Le password devono essere identiche', accetta_carta_costituzionale_on: 'Occorre accettare la sintesi della Carta Costituzionale', + site_not_created: 'Sito non creato correttamente!', }, accedi_come: 'Accedi come...', tips: { @@ -1609,6 +1610,18 @@ const msg_it = { error_cart: 'Errore durante l\'inserimento del prodotto sul carrello, riprovare.', tocart: 'al Carrello', }, + install: { + Installazione_Sito: 'Installazione Sito', + title_inst: 'Installa un nuovo Sito', + submit: 'Installa Sito', + name: 'Nome Sito (Esempio)', + domain: 'Host: (esempio.it)', + code: 'Codice Auth', + username: 'Username Admin', + password: 'Password Admin', + idapp:'Id Applicazione', + created: 'Sito Installato [IdApp = {idapp}] !', + } }, }; diff --git a/src/store/UserStore.ts b/src/store/UserStore.ts index f0dc1c09..3e624075 100755 --- a/src/store/UserStore.ts +++ b/src/store/UserStore.ts @@ -865,6 +865,24 @@ export const useUserStore = defineStore('UserStore', { }) }, + async addNewSite(paramquery: any) { + console.log(paramquery) + + this.setServerCode(tools.CALLING) + + return bcrypt.hash(paramquery.password, bcrypt.genSaltSync(12)) + .then((hashedPassword: string) => { + paramquery.password = String(hashedPassword) + + return Api.SendReq('/addNewSite', 'POST', paramquery) + .then((res) => ({ code: res.data.code, msg: res.data.msg, idapp: res.data.idapp })) + .catch((error) => { + this.setErrorCatch(error) + return this.getServerCode + }) + }) + }, + async vreg(paramquery: ILinkReg) { const usertosend = { idlink: paramquery.idlink, diff --git a/src/views/admin/install_site/index.ts b/src/views/admin/install_site/index.ts new file mode 100755 index 00000000..62a742a6 --- /dev/null +++ b/src/views/admin/install_site/index.ts @@ -0,0 +1 @@ +export {default as cfgServer} from './install_site.vue' diff --git a/src/views/admin/install_site/install_site-validate.ts b/src/views/admin/install_site/install_site-validate.ts new file mode 100755 index 00000000..ce42ab5a --- /dev/null +++ b/src/views/admin/install_site/install_site-validate.ts @@ -0,0 +1,30 @@ +import { ISignupOptions } from 'model' +import { email, minLength, required, sameAs } from '@vuelidate/validators' +// import { ValidationRuleset } from 'vuelidate' +import { complexity, complexityUser, registeredemail, registereduser, aportadorexist } from '../../../validation' + +export const validations = { + email: { + email, + required + }, + name: { + required, + }, + host: { + required, + }, + code: { + required, + }, + password: { + required, + minLength: minLength(8), + complexity, + }, + username: { + required, + minLength: minLength(8), + complexityUser, + }, +} diff --git a/src/views/admin/install_site/install_site.scss b/src/views/admin/install_site/install_site.scss new file mode 100755 index 00000000..e69de29b diff --git a/src/views/admin/install_site/install_site.ts b/src/views/admin/install_site/install_site.ts new file mode 100755 index 00000000..abc5f1f6 --- /dev/null +++ b/src/views/admin/install_site/install_site.ts @@ -0,0 +1,88 @@ +import { defineComponent, reactive, ref, watch } from 'vue' + +import { serv_constants } from '@store/Modules/serv_constants' +import { useQuasar } from 'quasar' +import { useI18n } from '@/boot/i18n' +import { useGlobalStore } from '@store/globalStore' +import { useUserStore } from '@store/UserStore' +import { useRouter } from 'vue-router' +import useVuelidate from '@vuelidate/core' +import { validations } from '@src/views/admin/install_site/install_site-validate' +import { tools } from '@store/Modules/tools' + +export default defineComponent({ + name: 'install_site', + setup() { + const $q = useQuasar() + const { t } = useI18n() + const userStore = useUserStore() + const globalStore = useGlobalStore() + const $router = useRouter() + + const emailsent = ref(false) + + const form = reactive({ + idappSent: '', + email: '', + name: '', + host: '', + code: '', + username: '', + password: '', + + }) + + const emailRef = ref(null) + const idapp = ref('') + + const v$ = useVuelidate(validations, form) + + function submit() { + console.log('submit') + + // @ts-ignore + emailRef.value!.validate() + + // @ts-ignore + if (emailRef.value!.hasError) { + // form has error + tools.showNotif($q, t('reg.err.errore_generico')) + return + } + + $q.loading.show({ message: t('reset.incorso') }) + + userStore.addNewSite({...form}) + .then((ris: any) => { + if (ris.code === serv_constants.RIS_CODE_OK) { + emailsent.value = true + idapp.value = ris.idapp + tools.showPositiveNotif($q, t('install.created', {idapp: ris.idapp})) + form.password = '' + } else + tools.showNegativeNotif($q, t('reg.err.site_not_created')) + $q.loading.hide() + }).catch((err: any) => { + console.log('ERROR = ' + err.error) + $q.loading.hide() + }) + + } + + function emailinviata() { + return emailsent.value + } + + return { + globalStore, + submit, + tools, + form, + v$, + emailsent, + emailinviata, + emailRef, + idapp, + } + }, +}) diff --git a/src/views/admin/install_site/install_site.vue b/src/views/admin/install_site/install_site.vue new file mode 100755 index 00000000..81d7d561 --- /dev/null +++ b/src/views/admin/install_site/install_site.vue @@ -0,0 +1,143 @@ + + + +