Creazione Sito Web da pagina

This commit is contained in:
Surya Paolo
2023-12-08 14:07:39 +01:00
parent bb9ca970f8
commit 7e17869d3e
11 changed files with 306 additions and 19 deletions

View File

@@ -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=""

18
.vscode/launch.json vendored
View File

@@ -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": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/src/App.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}

View File

@@ -16,6 +16,7 @@ const msg_website_it = {
pages: {
home: 'Home',
profile: 'Profilo',
install_site: 'Installa Sito',
profile2: 'ProfiloU',
mypage2: 'mypage2',
myservice2: 'myservice2',

View File

@@ -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,

View File

@@ -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}] !',
}
},
};

View File

@@ -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,

View File

@@ -0,0 +1 @@
export {default as cfgServer} from './install_site.vue'

View File

@@ -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,
},
}

View File

View File

@@ -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,
}
},
})

View File

@@ -0,0 +1,143 @@
<template>
<q-page>
<q-banner rounded class="bg-primary text-white" style="text-align: center">
<span class="mybanner">{{ $t('install.Installazione_Sito') }}</span>
</q-banner>
<q-banner
v-if="idapp"
rounded
class="bg-positive text-white"
style="text-align: center"
>
<div>
ID APP ASSEGNATA {{ idapp }} !
</div>
</q-banner>
<form
@submit.prevent.stop="submit"
class="row justify-center text-center padding"
>
<div class="q-gutter-sm q-ma-sm">
<div>
<q-banner
rounded
class="bg-primary text-white"
style="text-align: center"
>
<span class="mybanner">{{ $t('install.title_inst') }}</span>
</q-banner>
<br />
<q-input
ref="emailRef"
v-model="form.email"
rounded
outlined
autocomplete="email"
maxlength="50"
debounce="1000"
:error="v$.email.$error"
:error-message="tools.errorMsg('email', v$.email)"
:label="$t('reg.email')"
>
<template v-slot:prepend>
<q-icon name="email" />
</template>
</q-input>
<br />
<q-input
v-model="form.idappSent"
rounded
outlined
maxlength="50"
:label="$t('install.idapp')"
>
<template v-slot:prepend>
<q-icon name="fas fa-home" />
</template>
</q-input>
<br />
<q-input
v-model="form.name"
rounded
outlined
maxlength="50"
:label="$t('install.name')"
>
<template v-slot:prepend>
<q-icon name="fas fa-home" />
</template>
</q-input>
<br />
<q-input
v-model="form.username"
rounded
outlined
maxlength="50"
:label="$t('install.username')"
>
<template v-slot:prepend>
<q-icon name="fas fa-user" />
</template>
</q-input>
<br />
<q-input
v-model="form.password"
rounded
outlined
maxlength="50"
:label="$t('install.password')"
>
<template v-slot:prepend>
<q-icon name="fas fa-key" />
</template>
</q-input>
<br />
<q-input
v-model="form.host"
rounded
outlined
:label="$t('install.domain')"
>
<template v-slot:prepend>
<q-icon name="fas fa-home" />
</template>
</q-input>
<br />
<q-input
v-model="form.code"
rounded
outlined
maxlength="50"
:label="$t('install.code')"
>
<template v-slot:prepend>
<q-icon name="fas fa-key" />
</template>
</q-input>
<br />
<div class="center q-ma-sm">
<q-btn
rounded
size="lg"
color="primary"
type="submit"
:disable="v$.$error || v$.$invalid"
>{{ $t('install.submit') }}
</q-btn>
</div>
</div>
</div>
</form>
</q-page>
</template>
<script lang="ts" src="./install_site.ts">
</script>
<style lang="scss" scoped>
@import './install_site';
</style>