@ -8,7 +8,22 @@
< / h2 >
< / h2 >
< div v-if ="step === 1" >
< div v-if ="step === 1" >
< p class = "text-lg p-8" > { { $t ( 'setup.msg' ) } } < / p >
< p class = "text-lg p-8" > { { $t ( 'setup.msgStepOne' ) } } < / p >
< select id = "lang" form = "form-step-one" name = "lang" >
< option
v - for = "lang in langs"
: key = "lang.value"
: value = "lang.value"
: selected = "lang.value == 'en'"
>
{ { lang . name } }
< / option >
< / select >
< form id = "form-step-one" > < / form >
< / div >
< div v-if ="step === 2" >
< p class = "text-lg p-8" > { { $t ( 'setup.msgStepTwo' ) } } < / p >
< div >
< div >
< label for = "username" class = "inline-block py-2" > { {
< label for = "username" class = "inline-block py-2" > { {
$t ( 'username' )
$t ( 'username' )
@ -16,7 +31,7 @@
< input
< input
id = "username"
id = "username"
v - model = "username"
v - model = "username"
form = "formulaire "
form = "form-step-two "
type = "text"
type = "text"
name = "username"
name = "username"
autocomplete = "username"
autocomplete = "username"
@ -32,7 +47,7 @@
< input
< input
id = "password"
id = "password"
v - model = "password"
v - model = "password"
form = "formulaire "
form = "form-step-two "
type = "password"
type = "password"
name = "password"
name = "password"
autocomplete = "new-password"
autocomplete = "new-password"
@ -46,29 +61,37 @@
} } < / Label >
} } < / Label >
< input id = "accept" v -model = " accept " type = "checkbox" name = "accept" / >
< input id = "accept" v -model = " accept " type = "checkbox" name = "accept" / >
< / div >
< / div >
< form id = "formulaire " > < / form >
< form id = "form-step-two " > < / form >
< / div >
< / div >
< div v-if ="step === 2 " >
< div v-if ="step === 3 " >
< p class = "text-lg p-8" > Host / Port section < / p >
< p class = "text-lg p-8" > Host / Port section < / p >
< / div >
< / div >
< div v-if ="step === 3 " >
< div v-if ="step === 4 " >
< p class = "text-lg p-8" > Migration section < / p >
< p class = "text-lg p-8" > Migration section < / p >
< / div >
< / div >
< div v-if ="step === 4 " >
< div v-if ="step === 5 " >
< p class = "text-lg p-8" > Validation section < / p >
< p class = "text-lg p-8" > Validation section < / p >
< / div >
< / div >
< div class = "flex justify-between items-center" >
< div class = "flex justify-between items-center" >
< IconsArrowLeftCircle
< IconsArrowLeftCircle
: class = "['size-12', { 'text-gray-500': step === 1 }]"
: class = " [
'size-12' ,
step === 1 || towardStepValide ( )
? 'text-gray-500'
: 'text-red-800 dark:text-white' ,
] "
@ click = "decreaseStep"
@ click = "decreaseStep"
/ >
/ >
< StepProgress :step ="step" / >
< StepProgress :step ="step" / >
< IconsArrowRightCircle
< IconsArrowRightCircle
: class = "['size-12', { 'text-gray-500': step === 4 }]"
: class = " [
'size-12' ,
step === 4 ? 'text-gray-500' : 'text-red-800 dark:text-white' ,
] "
@ click = "increaseStep"
@ click = "increaseStep"
/ >
/ >
< / div >
< / div >
@ -89,28 +112,36 @@ import { FetchError } from 'ofetch';
const { t } = useI18n ( ) ;
const { t } = useI18n ( ) ;
type SetupError = {
title : string ;
message : string ;
} ;
const username = ref < null | string > ( null ) ;
const username = ref < null | string > ( null ) ;
const password = ref < null | string > ( null ) ;
const password = ref < null | string > ( null ) ;
const accept = ref < boolean > ( true ) ;
const accept = ref < boolean > ( true ) ;
const authStore = useAuthStore ( ) ;
const authStore = useAuthStore ( ) ;
const step = ref ( 1 ) ;
const step = ref ( 1 ) ;
const stepInvalide = ref < number [ ] > ( [ ] ) ;
function increaseStep ( ) {
if ( step . value < 4 ) step . value += 1 ;
}
function decreaseStep ( ) {
if ( step . value > 1 ) step . value -= 1 ;
}
type SetupError = {
title : string ;
message : string ;
} ;
const setupError = ref < null | SetupError > ( null ) ;
const setupError = ref < null | SetupError > ( null ) ;
const langs = [
{
value : 'de' ,
name : 'Deutsch' ,
} ,
{
value : 'en' ,
name : 'English' ,
} ,
{
value : 'de' ,
name : 'Français' ,
} ,
] ;
/ / T O D O : i m p r o v e e r r o r h a n d l i n g
watch ( setupError , ( value ) => {
watch ( setupError , ( value ) => {
if ( value ) {
if ( value ) {
setTimeout ( ( ) => {
setTimeout ( ( ) => {
@ -119,7 +150,49 @@ watch(setupError, (value) => {
}
}
} ) ;
} ) ;
async function _newAccount ( ) {
async function increaseStep ( ) {
try {
if ( step . value === 1 ) {
/* lang */
}
if ( step . value === 2 ) {
await newAccount ( ) ;
stepInvalide . value . push ( 1 ) ;
}
if ( step . value === 3 ) {
/* host/port */
}
if ( step . value === 4 ) {
/* migration */
}
if ( step . value === 5 ) {
/* validation/welcome */
}
if ( step . value < 5 ) step . value += 1 ;
/ / e s l i n t - d i s a b l e - n e x t - l i n e @ t y p e s c r i p t - e s l i n t / n o - u n u s e d - v a r s
} catch ( error ) {
/* throw in functions */
}
}
/ / T O D O : i m p r o v e w h i l e u s e r r e l o a d t h e p a g e , m i g h t u s e s e r v e r c h e c k
/* Check if previous steps are invalide (mean successful executed). */
function towardStepValide ( ) {
return stepInvalide . value . includes ( step . value - 1 ) ;
}
function decreaseStep ( ) {
if ( towardStepValide ( ) ) return ;
if ( step . value > 1 ) step . value -= 1 ;
}
async function newAccount ( ) {
if ( ! username . value || ! password . value ) return ;
if ( ! username . value || ! password . value ) return ;
try {
try {
@ -138,6 +211,8 @@ async function _newAccount() {
message : error . data . message ,
message : error . data . message ,
} ;
} ;
}
}
/ / i n c r e a s e S t e p f n
throw error ;
}
}
}
}
< / script >
< / script >