[core] Improved backend setup on login page
This commit is contained in:
parent
7a705d5f9a
commit
6732921ff7
|
@ -1,46 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="row justify-center items-center content-center q-pa-md">
|
|
||||||
<q-card class="col-xs-11 col-sm-8 col-md-6 col-lg-4 justify-center items-center content-center">
|
|
||||||
<q-toolbar class="bg-primary text-white">
|
|
||||||
<q-toolbar-title>Servereinstellung</q-toolbar-title>
|
|
||||||
</q-toolbar>
|
|
||||||
<q-card-section>
|
|
||||||
<q-form class="q-gutter-md" @submit="changeUrl">
|
|
||||||
<q-input v-model="server" filled label="Server" dense />
|
|
||||||
<q-btn dense color="primary" label="Speichern" type="submit" />
|
|
||||||
</q-form>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
import { notEmpty, PersistentStorage } from '@flaschengeist/api';
|
|
||||||
import { defineComponent, ref } from 'vue';
|
|
||||||
import { api } from '@flaschengeist/api';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'PageBackend',
|
|
||||||
setup() {
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const server = ref(api.defaults.baseURL);
|
|
||||||
|
|
||||||
function changeUrl() {
|
|
||||||
if (server.value) {
|
|
||||||
void PersistentStorage.set('baseURL', server.value).then(() => {
|
|
||||||
console.log('uiuiui');
|
|
||||||
void router.push({ name: 'login' }).then(() => router.go(0));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
changeUrl,
|
|
||||||
notEmpty,
|
|
||||||
server,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
|
@ -2,9 +2,9 @@
|
||||||
<q-page padding class="fit row justify-center items-center content-center">
|
<q-page padding class="fit row justify-center items-center content-center">
|
||||||
<q-card class="col-xs-11 col-sm-8 col-md-6 col-lg-4 justify-center items-center content-center">
|
<q-card class="col-xs-11 col-sm-8 col-md-6 col-lg-4 justify-center items-center content-center">
|
||||||
<q-toolbar class="bg-primary text-white">
|
<q-toolbar class="bg-primary text-white">
|
||||||
<q-toolbar-title> Login </q-toolbar-title>
|
<q-toolbar-title>{{ backendSetup ? 'Servereinrichtung' : 'Login' }}</q-toolbar-title>
|
||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
|
<div v-if="!backendSetup">
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<q-form @submit="doLogin">
|
<q-form @submit="doLogin">
|
||||||
<q-input
|
<q-input
|
||||||
|
@ -47,10 +47,23 @@
|
||||||
v-if="$q.platform.is.capacitor || $q.platform.is.electron"
|
v-if="$q.platform.is.capacitor || $q.platform.is.electron"
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
icon="mdi-menu-down"
|
:icon="showBackendSetup ? 'mdi-menu-up' : 'mdi-menu-down'"
|
||||||
:to="{ name: 'setup_backend' }"
|
@click="showBackendSetup = !showBackendSetup"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<q-slide-transition v-if="$q.platform.is.capacitor">
|
||||||
|
<div v-show="showBackendSetup || backendSetup">
|
||||||
|
<q-separator />
|
||||||
|
<q-card-section>
|
||||||
|
<q-form ref="ServerSettingsForm" class="q-gutter-md" @submit="changeBackend">
|
||||||
|
<div class="text-h6">Backend einrichten</div>
|
||||||
|
<q-input v-model="server" filled label="Server" dense />
|
||||||
|
<q-btn dense color="primary" label="Speichern" type="submit" />
|
||||||
|
</q-form>
|
||||||
|
</q-card-section>
|
||||||
|
</div>
|
||||||
|
</q-slide-transition>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-page>
|
</q-page>
|
||||||
</template>
|
</template>
|
||||||
|
@ -58,23 +71,44 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { Loading, Notify } from 'quasar';
|
import { Loading, Notify } from 'quasar';
|
||||||
import { notEmpty, useMainStore, useUserStore } from '@flaschengeist/api';
|
import { api, notEmpty, PersistentStorage, useMainStore, useUserStore } from '@flaschengeist/api';
|
||||||
import { PasswordInput } from '@flaschengeist/api/components';
|
import { PasswordInput } from '@flaschengeist/api/components';
|
||||||
import { defineComponent, ref } from 'vue';
|
import { defineComponent, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'PageLogin',
|
name: 'PageLogin',
|
||||||
components: { PasswordInput },
|
components: { PasswordInput },
|
||||||
setup() {
|
props: {
|
||||||
|
backendSetup: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
const mainRoute = { name: 'dashboard' };
|
const mainRoute = { name: 'dashboard' };
|
||||||
|
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (mainStore.session) void router.replace(mainRoute);
|
||||||
|
});
|
||||||
|
|
||||||
/* Stuff for the real login page */
|
/* Stuff for the real login page */
|
||||||
const userid = ref('');
|
const userid = ref('');
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
|
const server = ref(api.defaults.baseURL);
|
||||||
|
const showBackendSetup = ref(!!props.backendSetup);
|
||||||
|
|
||||||
|
function changeBackend() {
|
||||||
|
if (server.value) {
|
||||||
|
void PersistentStorage.set('baseURL', server.value).then(() => {
|
||||||
|
showBackendSetup.value = false;
|
||||||
|
void router.go(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function doLogin() {
|
async function doLogin() {
|
||||||
Loading.show({ message: 'Du wirst angemeldet' });
|
Loading.show({ message: 'Du wirst angemeldet' });
|
||||||
|
@ -129,11 +163,14 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
changeBackend,
|
||||||
doLogin,
|
doLogin,
|
||||||
doReset,
|
doReset,
|
||||||
notEmpty,
|
notEmpty,
|
||||||
password,
|
password,
|
||||||
userid,
|
userid,
|
||||||
|
server,
|
||||||
|
showBackendSetup,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,12 +10,18 @@ const routes: RouteRecordRaw[] = [
|
||||||
name: 'login',
|
name: 'login',
|
||||||
path: 'login',
|
path: 'login',
|
||||||
component: () => import('pages/Login.vue'),
|
component: () => import('pages/Login.vue'),
|
||||||
|
props: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'password_reset',
|
name: 'password_reset',
|
||||||
path: 'reset',
|
path: 'reset',
|
||||||
component: () => import('pages/Reset.vue'),
|
component: () => import('pages/Reset.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/setup-backend',
|
||||||
|
name: 'setup_backend',
|
||||||
|
redirect: { name: 'login', params: { backendSetup: 1 } },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'about_out',
|
name: 'about_out',
|
||||||
path: 'about',
|
path: 'about',
|
||||||
|
@ -53,11 +59,6 @@ const routes: RouteRecordRaw[] = [
|
||||||
name: 'offline',
|
name: 'offline',
|
||||||
component: () => import('pages/Offline.vue'),
|
component: () => import('pages/Offline.vue'),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/setup-backend',
|
|
||||||
name: 'setup_backend',
|
|
||||||
component: () => import('pages/Backend.vue'),
|
|
||||||
},
|
|
||||||
// Always leave this as last one,
|
// Always leave this as last one,
|
||||||
// but you can also remove it
|
// but you can also remove it
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue