This commit is contained in:
Douglas Barone 2023-06-28 09:37:13 -04:00
parent 49413c7ef7
commit d42769ca45
4 changed files with 59 additions and 24 deletions

View File

@ -1,13 +1,36 @@
<template> <template>
<v-app id="inspire"> <v-app id="inspire">
<v-navigation-drawer v-model="drawer"> </v-navigation-drawer> <v-navigation-drawer v-model="drawer">
<v-list>
<v-list-item>
<template v-slot:prepend>
<v-avatar :image="me?.thumbnailPhoto || undefined" />
</template>
<v-list-item-title>{{ me?.displayName }}</v-list-item-title>
<v-list-item-subtitle>
{{ me?.campus }}
</v-list-item-subtitle>
</v-list-item>
</v-list>
<template v-slot:append>
<div class="pa-2">
<v-btn block variant="text" @click="logout">
<template v-slot:prepend>
<v-icon icon="mdi-logout"></v-icon>
</template>
Logout
</v-btn>
</div>
</template>
</v-navigation-drawer>
<v-app-bar> <v-app-bar>
<v-app-bar-nav-icon @click="drawer = !drawer"></v-app-bar-nav-icon> <v-app-bar-nav-icon @click="drawer = !drawer"></v-app-bar-nav-icon>
<v-avatar rounded>
<v-img :src="me?.thumbnailPhoto || undefined" /> <v-toolbar-title
</v-avatar> ><v-icon icon="mdi-printer" /> Impressoras</v-toolbar-title
<v-toolbar-title>Application</v-toolbar-title> >
<v-spacer />
</v-app-bar> </v-app-bar>
<v-main> <v-main>
@ -20,8 +43,19 @@
import { ref } from "vue"; import { ref } from "vue";
import { useAppStore } from "@/store/app"; import { useAppStore } from "@/store/app";
import { removeJwtToken } from "@/auth";
import { useRouter } from "vue-router";
const { me } = useAppStore(); const { me } = useAppStore();
const drawer = ref(true); const drawer = ref(true);
const router = useRouter();
function logout() {
removeJwtToken();
router.push({ name: "Login" });
}
</script> </script>

View File

@ -4,8 +4,4 @@
</v-app> </v-app>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup></script>
import { ref } from "vue";
const drawer = ref(true);
</script>

View File

@ -5,22 +5,22 @@
*/ */
// Styles // Styles
import '@mdi/font/css/materialdesignicons.css' import "@mdi/font/css/materialdesignicons.css";
import 'vuetify/styles' import "vuetify/styles";
// Composables // Composables
import { createVuetify } from 'vuetify' import { createVuetify } from "vuetify";
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides // https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
export default createVuetify({ export default createVuetify({
theme: { // theme: {
themes: { // themes: {
light: { // light: {
colors: { // colors: {
primary: '#1867C0', // primary: '#1867C0',
secondary: '#5CBBF6', // secondary: '#5CBBF6',
}, // },
}, // },
}, // },
}, // },
}) });

View File

@ -64,6 +64,7 @@ import { ref, reactive } from "vue";
import { api } from "@/api"; import { api } from "@/api";
import { saveJwtToken } from "@/auth"; import { saveJwtToken } from "@/auth";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { useAppStore } from "@/store/app";
const username = ref<string>(""); const username = ref<string>("");
const password = ref<string>(""); const password = ref<string>("");
@ -75,6 +76,8 @@ const loading = ref(false);
const router = useRouter(); const router = useRouter();
const { fetchMe } = useAppStore();
async function login() { async function login() {
errors.splice(0, errors.length); errors.splice(0, errors.length);
@ -92,6 +95,8 @@ async function login() {
saveJwtToken(token); saveJwtToken(token);
await fetchMe();
router.push({ name: "Home" }); router.push({ name: "Home" });
} catch (error: any) { } catch (error: any) {
errors.push(error.message); errors.push(error.message);