* navbar with protected routes

feature: #3
This commit is contained in:
2023-01-03 02:26:15 +01:00
parent 23c40c5468
commit 46dd4ef361
18 changed files with 304 additions and 443 deletions

View File

@@ -1,43 +0,0 @@
<script setup>
defineProps({
msg: {
type: String,
required: true
}
})
</script>
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
Youve successfully created a project with
<a href="https://vitejs.dev/" target="_blank" rel="noopener">Vite</a> +
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
</h3>
</div>
</template>
<style scoped>
h1 {
font-weight: 500;
font-size: 2.6rem;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.greetings h1,
.greetings h3 {
text-align: center;
}
@media (min-width: 1024px) {
.greetings h1,
.greetings h3 {
text-align: left;
}
}
</style>

114
src/components/Navbar.vue Normal file
View File

@@ -0,0 +1,114 @@
<template>
<div class="flex justify-between bg-gray-900 text-white pt-2 pb-3 pl-8">
<div class="basis-1/3 logo">
<p class="font-mono text-lg py-2">
<RouterLink to="/">Filmstudiostube</RouterLink>
</p>
</div>
<div class="flex justify-around basis-1/3 max-md:hidden">
<div v-if="!isAnonym">
<p class="py-2">Aufträge</p>
</div>
<div v-if="!isAnonym" class="nav-item">
<p class="py-2">Support</p>
</div>
<div v-if="isVerwaltung" class="nav-item">
<p class="py-2">Administration</p>
</div>
<div v-if="isAnonym" class="nav-item">
<p class="py-2">Arbeiten</p>
</div>
<div v-if="isAnonym" class="nav-item">
<p class="py-2">Kontakt</p>
</div>
<div v-if="isAnonym" class="nav-item">
<RouterLink to="/about">
<p class="py-2">Über uns</p>
</RouterLink>
</div>
</div>
<div v-if="isAnonym" class="nav-item basis-1/6 max-md:justify-end max-md:pr-5 max-md:flex max-md:basis-3/6">
<button class="bg-blue-600 hover:bg-blue-500 duration-300 text-white px-3 py-1 my-2 rounded" @click="login">
Login
</button>
</div>
<div class="pt-2 md:hidden" @click="openNavbar">
<div class="space-y-1.5 pt-2 pb-2 mr-2 pr-2 pl-2 bg-slate-100 rounded">
<span class="block w-6 h-0.5 bg-gray-500"></span>
<span class="block w-6 h-0.5 bg-gray-500"></span>
<span class="block w-6 h-0.5 bg-gray-500"></span>
</div>
</div>
</div>
<div v-if="!isNavbarClosed">
<ul class="bg-gray-900">
<li v-if="!isAnonym" class="block text-md py-4 text-white text-center">
<RouterLink to="/contracts">Aufträge</RouterLink>
</li>
<li v-if="!isAnonym" class="block text-md py-4 text-white text-center">
<RouterLink to="/support">Support</RouterLink>
</li>
<li v-if="isVerwaltung" class="block text-md py-4 text-white text-center">
<RouterLink to="/administration">Administration</RouterLink>
</li>
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
<RouterLink to="/arbeiten">Arbeiten</RouterLink>
</li>
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
<RouterLink to="/contact">Kontakt</RouterLink>
</li>
<li v-if="isAnonym" class="block text-md py-4 text-white text-center">
<RouterLink to="/about">Über uns</RouterLink>
</li>
<li v-if="isAnonym" class="block py-2 flex justify-center">
<button class="bg-blue-600 hover:bg-blue-500 duration-300 text-white px-3 py-1 my-2 rounded" @click="login">
Login
</button>
</li>
</ul>
</div>
</template>
<script>
import {keycloakSetup} from "../authentication/AuthHelper";
export default {
data() {
return {
keycloak: this.$store.state.keycloak.keycloak,
isAnonym: false,
isNavbarClosed: true
}
},
computed: {
isVerwaltung() {
if (this.$store.state.keycloak.keycloak === null){
this.isAnonym = true;
return false
}
return this.$store.state.keycloak.keycloak.realmAccess.roles.includes('verwaltung')
},
isAdmin() {
if (this.$store.state.keycloak.keycloak === null){
this.isAnonym = true;
return false
}
return this.$store.state.keycloak.keycloak.realmAccess.roles.includes('admin')
},
isEmployee() {
if (this.$store.state.keycloak.keycloak === null){
this.isAnonym = true;
return false
}
return this.$store.state.keycloak.keycloak.realmAccess.roles.includes('employeee')
}
},
methods: {
login() {
keycloakSetup()
},
openNavbar(){
this.isNavbarClosed = !this.isNavbarClosed
}
}
}
</script>

View File

@@ -1,86 +0,0 @@
<script setup>
import WelcomeItem from './WelcomeItem.vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import ToolingIcon from './icons/IconTooling.vue'
import EcosystemIcon from './icons/IconEcosystem.vue'
import CommunityIcon from './icons/IconCommunity.vue'
import SupportIcon from './icons/IconSupport.vue'
</script>
<template>
<WelcomeItem>
<template #icon>
<DocumentationIcon />
</template>
<template #heading>Documentation</template>
Vues
<a href="https://vuejs.org/" target="_blank" rel="noopener">official documentation</a>
provides you with all information you need to get started.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<ToolingIcon />
</template>
<template #heading>Tooling</template>
This project is served and bundled with
<a href="https://vitejs.dev/guide/features.html" target="_blank" rel="noopener">Vite</a>. The
recommended IDE setup is
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a> +
<a href="https://github.com/johnsoncodehk/volar" target="_blank" rel="noopener">Volar</a>. If
you need to test your components and web pages, check out
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a> and
<a href="https://on.cypress.io/component" target="_blank">Cypress Component Testing</a>.
<br />
More instructions are available in <code>README.md</code>.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<EcosystemIcon />
</template>
<template #heading>Ecosystem</template>
Get official tools and libraries for your project:
<a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
<a href="https://router.vuejs.org/" target="_blank" rel="noopener">Vue Router</a>,
<a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener">Vue Test Utils</a>, and
<a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener">Vue Dev Tools</a>. If
you need more resources, we suggest paying
<a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">Awesome Vue</a>
a visit.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<CommunityIcon />
</template>
<template #heading>Community</template>
Got stuck? Ask your question on
<a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>, our official
Discord server, or
<a href="https://stackoverflow.com/questions/tagged/vue.js" target="_blank" rel="noopener"
>StackOverflow</a
>. You should also subscribe to
<a href="https://news.vuejs.org" target="_blank" rel="noopener">our mailing list</a> and follow
the official
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
twitter account for latest news in the Vue world.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<SupportIcon />
</template>
<template #heading>Support Vue</template>
As an independent project, Vue relies on community backing for its sustainability. You can help
us by
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener">becoming a sponsor</a>.
</WelcomeItem>
</template>

View File

@@ -1,85 +0,0 @@
<template>
<div class="item">
<i>
<slot name="icon"></slot>
</i>
<div class="details">
<h3>
<slot name="heading"></slot>
</h3>
<slot></slot>
</div>
</div>
</template>
<style scoped>
.item {
margin-top: 2rem;
display: flex;
}
.details {
flex: 1;
margin-left: 1rem;
}
i {
display: flex;
place-items: center;
place-content: center;
width: 32px;
height: 32px;
color: var(--color-text);
}
h3 {
font-size: 1.2rem;
font-weight: 500;
margin-bottom: 0.4rem;
color: var(--color-heading);
}
@media (min-width: 1024px) {
.item {
margin-top: 0;
padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
}
i {
top: calc(50% - 25px);
left: -26px;
position: absolute;
border: 1px solid var(--color-border);
background: var(--color-background);
border-radius: 8px;
width: 50px;
height: 50px;
}
.item:before {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
bottom: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:after {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
top: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:first-of-type:before {
display: none;
}
.item:last-of-type:after {
display: none;
}
}
</style>