add some setup routes already

This commit is contained in:
2023-09-06 15:27:50 +02:00
parent 667b542893
commit 4afeb7a146
12 changed files with 136 additions and 130 deletions

View File

@@ -43,15 +43,6 @@ export default {
setupAuthRequired: true,
}
},
{
path: 'page',
name: 'setupPage',
component: () => import( '../views/SetupPageView.vue' ),
meta: {
title: 'Landing page :: Setup - libreevent',
setupAuthRequired: true,
}
},
{
path: 'complete',
name: 'setupComplete',

View File

@@ -14,24 +14,55 @@
<p>Let's start the setup by entering the setup key below! You may define a setup key in the <i>setupkey.txt</i> file of libreevent. See <a href="https://libreevent.janishutz.com/docs/setup/installation" target="_blank">here</a> for more instructions</p>
<form>
<label for="key">Your setup key</label><br>
<input type="text" v-model="formData[ 'key' ]" required name="key" id="key">
<input type="text" v-model="formData[ 'token' ]" required name="key" id="key">
</form>
<button @click="setup();" class="button">Start setup</button>
<notifications ref="notification" location="topright" size="bigger"></notifications>
</div>
</template>
<script>
import notifications from '../components/notifications.vue';
export default {
data() {
return {
formData: {},
}
},
components: {
notifications,
},
methods: {
setup () {
this.$router.push( '/setup' );
const options = {
method: 'post',
body: JSON.stringify( this.formData ),
headers: {
'Content-Type': 'application/json',
'charset': 'utf-8'
}
};
fetch( '/setup/start', options ).then( res => {
if ( res.status === 200 ) {
this.$router.push( '/setup' );
} else {
this.$refs.notification.createNotification( 'Setup key incorrect!', 5, 'error', 'normal' );
}
} );
}
},
created() {
fetch( '/setup/getKeyStatus' ).then( res => {
if ( res.status === 200 ) {
res.text().then( text => {
if ( text === 'ok' ) {
this.$router.push( '/setup' );
}
} );
}
} );
}
}
</script>

View File

@@ -1,51 +0,0 @@
<!--
* libreevent - SetupPageView.vue
*
* Created by Janis Hutz 05/14/2023, Licensed under the GPL V3 License
* https://janishutz.com, development@janishutz.com
*
*
-->
<template>
<div class="wrapper">
<div class="content">
<h1>Landing page</h1>
<p>The landing page is the page your customers see when they visit your webpage. You may select a page template <a href="https://libreevent.janishutz.com/docs/homepage/templates" target="_blank">here</a>.</p>
<p>You may find more infos about this part <a href="https://libreevent.janishutz.com/docs/setup/setup#page-setup" target="_blank">here</a></p>
<label for="template">Choose a template</label><br>
<select name="template" id="template">
<option v-for="option in options" :key="option.id" :value="option.id">{{ option.name }}</option>
</select><br>
<button @click="submit()" class="button">Continue</button>
</div>
</div>
</template>
<script>
import { useBackendStore } from '@/stores/backendStore.js';
import { mapStores } from 'pinia';
export default {
data () {
return {
options: {
'default': { 'id': 'default', 'name': 'Default' },
'none': { 'id': 'none', 'name': 'Configure later (will show an empty page)' },
},
websiteName: 'libreevent',
}
},
computed: {
...mapStores( useBackendStore )
},
methods: {
submit () {
this.backendStore.addVisitedSetupPages( 'complete', true );
this.$router.push( '/setup/complete' );
}
},
};
</script>

View File

@@ -169,8 +169,8 @@
}
},
proceed () {
this.backendStore.addVisitedSetupPages( 'page', true );
this.$router.push( 'page' );
this.backendStore.addVisitedSetupPages( 'complete', true );
this.$router.push( 'complete' );
}
},
};

View File

@@ -15,8 +15,6 @@
<a v-else class="inactive">Basic Setup</a> |
<router-link to="/setup/root" v-if="backendStore.getVisitedSetupPages[ 'root' ]">Root account</router-link>
<a v-else class="inactive">Root account</a> |
<router-link to="/setup/page" v-if="backendStore.getVisitedSetupPages[ 'page' ]">Landing page</router-link>
<a v-else class="inactive">Landing page</a> |
<router-link to="/setup/complete" v-if="backendStore.getVisitedSetupPages[ 'complete' ]">Complete</router-link>
<a v-else class="inactive">Complete</a>
</nav>
@@ -45,6 +43,17 @@
},
created () {
this.backendStore.loadVisitedSetupPages();
fetch( '/setup/getKeyStatus' ).then( res => {
if ( res.status === 200 ) {
res.text().then( text => {
if ( text != 'ok' ) {
this.$router.push( '/' );
}
} );
} else {
this.$router.push( '/' );
}
} );
},
};
</script>