-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from DurhamAcademy/production
updating dev with new production changes
- Loading branch information
Showing
3 changed files
with
145 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,145 @@ | ||
<script setup lang="ts"> | ||
import LoginState from '~/utils/authorization/LoginState' | ||
import { loginStateKey } from '~/utils/keys' | ||
import PouchDB from 'pouchdb' | ||
import { eventOptions } from '~/utils/eventOptions' | ||
import { useEventKey } from '~/composables/useEventKey' | ||
import LoginState from '~/utils/authorization/LoginState'; | ||
import { loginStateKey } from '~/utils/keys'; | ||
import PouchDB from 'pouchdb'; | ||
import { eventOptions } from '~/utils/eventOptions'; | ||
import { useEventKey } from '~/composables/useEventKey'; | ||
const { | ||
usernameState, | ||
sessionState, | ||
logout, | ||
usernameState, | ||
sessionState, | ||
logout, | ||
}: { | ||
logout: () => Promise<void> | ||
// noinspection TypeScriptUnresolvedReference | ||
loginState: Ref<UnwrapRef<LoginState>> | ||
// noinspection TypeScriptUnresolvedReference | ||
sessionState: Ref<UnwrapRef<PouchDB.Authentication.SessionResponse>> | ||
// noinspection TypeScriptUnresolvedReference | ||
usernameState: Ref<UnwrapRef<string>> | ||
updateUsernameState: () => Promise<boolean> | ||
} = inject(loginStateKey)! | ||
logout: () => Promise<void>; | ||
// noinspection TypeScriptUnresolvedReference | ||
loginState: Ref<UnwrapRef<LoginState>>; | ||
// noinspection TypeScriptUnresolvedReference | ||
sessionState: Ref<UnwrapRef<PouchDB.Authentication.SessionResponse>>; | ||
// noinspection TypeScriptUnresolvedReference | ||
usernameState: Ref<UnwrapRef<string>>; | ||
updateUsernameState: () => Promise<boolean>; | ||
} = inject(loginStateKey)!; | ||
const events = eventOptions | ||
const currentEvent = useEventKey() | ||
const events = eventOptions; | ||
const currentEvent = useEventKey(); | ||
watch(currentEvent, (value) => { | ||
window.localStorage.setItem('currentEvent', value) | ||
window.dispatchEvent(new Event('event-changed')) | ||
}) | ||
watch(currentEvent, value => { | ||
window.localStorage.setItem('currentEvent', value); | ||
window.dispatchEvent(new Event('event-changed')); | ||
}); | ||
let props = defineProps({ | ||
scoutMode: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
disableSidebar: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}) | ||
scoutMode: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
disableSidebar: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}); | ||
let route = useRoute() | ||
let route = useRoute(); | ||
let isOpen = ref(false) | ||
let isOpen = ref(false); | ||
let links: VerticalNavigationLink[] = [ | ||
{ label: 'Dashboard', to: '/dashboard' }, | ||
{ label: 'Matches', to: '/matches' }, | ||
{ label: 'Teams', to: '/teams' }, | ||
{ label: 'Predict', to: '/predict' }, | ||
{ label: 'Pit', to: '/pit' }, | ||
] | ||
console.log(sessionState?.value?.userCtx?.roles) | ||
if (sessionState?.value?.userCtx?.roles?.indexOf('_admin') != -1) links.push({ label: 'Users', to: '/users' }) | ||
{ label: 'Dashboard', to: '/dashboard' }, | ||
{ label: 'Matches', to: '/matches' }, | ||
{ label: 'Teams', to: '/teams' }, | ||
{ label: 'Predict', to: '/predict' }, | ||
]; | ||
console.log(sessionState?.value?.userCtx?.roles); | ||
if (sessionState?.value?.userCtx?.roles?.indexOf('_admin') != -1) | ||
links.push({ label: 'Users', to: '/users' }); | ||
</script> | ||
|
||
<template> | ||
<div | ||
<div | ||
v-if="!disableSidebar" | ||
class="py-2.5 px-5 z-10 bg-opacity-50 bg-gray-200 dark:bg-gray-700 w-screen navbar-right sticky top-0 flex-row justify-between backdrop-blur-lg min-h-16" | ||
> | ||
<Transition name="slide-fade"> | ||
<UButton | ||
class="slide-nothing" | ||
v-if="!disableSidebar" | ||
class="py-2.5 px-5 z-10 bg-opacity-50 bg-gray-200 dark:bg-gray-700 w-screen navbar-right sticky top-0 flex-row justify-between backdrop-blur-lg min-h-16" | ||
> | ||
<Transition name="slide-fade"> | ||
<UButton | ||
class="slide-nothing" | ||
v-if="!disableSidebar" | ||
icon="i-heroicons-bars-3-20-solid" | ||
variant="ghost" | ||
@click="isOpen = !isOpen" | ||
:size="'xl'" | ||
square | ||
style="position: absolute; top: 50%; transform: translateY(-50%)" | ||
/> | ||
</Transition> | ||
</div> | ||
<USlideover v-model="isOpen" side="left" :appear="!disableSidebar"> | ||
<UCard class="flex flex-col h-screen"> | ||
<template #header> | ||
<UButton icon="i-heroicons-bars-3-20-solid" variant="ghost" @click="isOpen = !isOpen" :size="'xl'" /> | ||
</template> | ||
<UVerticalNavigation :links="links" /> | ||
<div class="settingsPopupDiv"> | ||
<UPopover> | ||
<UButton icon="i-heroicons-cog-6-tooth" square :size="'xl'" :variant="'ghost'" :color="'gray'" /> | ||
<template #panel> | ||
<UCard class="p-2"> | ||
<template #header> | ||
<div class="usernameLabel max-w-32 text-zinc-900"> | ||
{{ usernameState }} | ||
</div> | ||
</template> | ||
<UFormGroup class="inputDiv" label="Event" name="event"> | ||
<USelectMenu v-model="currentEvent" :options="events" /> | ||
</UFormGroup> | ||
<template #footer> | ||
<UButton block label="Logout" square @click="logout" /> | ||
</template> | ||
</UCard> | ||
</template> | ||
</UPopover> | ||
</div> | ||
</UCard> | ||
</USlideover> | ||
icon="i-heroicons-bars-3-20-solid" | ||
variant="ghost" | ||
@click="isOpen = !isOpen" | ||
:size="'xl'" | ||
square | ||
style="position: absolute; top: 50%; transform: translateY(-50%)" | ||
/> | ||
</Transition> | ||
</div> | ||
<USlideover | ||
v-model="isOpen" | ||
side="left" | ||
:appear="!disableSidebar" | ||
> | ||
<UCard class="flex flex-col h-screen"> | ||
<template #header> | ||
<UButton | ||
icon="i-heroicons-bars-3-20-solid" | ||
variant="ghost" | ||
@click="isOpen = !isOpen" | ||
:size="'xl'" | ||
/> | ||
</template> | ||
<UVerticalNavigation :links="links" /> | ||
<div class="settingsPopupDiv"> | ||
<UPopover> | ||
<UButton | ||
icon="i-heroicons-cog-6-tooth" | ||
square | ||
:size="'xl'" | ||
:variant="'ghost'" | ||
:color="'gray'" | ||
/> | ||
<template #panel> | ||
<UCard class="p-2"> | ||
<template #header> | ||
<div class="usernameLabel max-w-32 text-zinc-900"> | ||
{{ usernameState }} | ||
</div> | ||
</template> | ||
<UFormGroup | ||
class="inputDiv" | ||
label="Event" | ||
name="event" | ||
> | ||
<USelectMenu | ||
v-model="currentEvent" | ||
:options="events" | ||
/> | ||
</UFormGroup> | ||
<template #footer> | ||
<UButton | ||
block | ||
label="Logout" | ||
square | ||
@click="logout" | ||
/> | ||
</template> | ||
</UCard> | ||
</template> | ||
</UPopover> | ||
</div> | ||
</UCard> | ||
</USlideover> | ||
</template> | ||
|
||
<style scoped> | ||
.slide-nothing { | ||
transform: translateX(0%); | ||
transform: translateX(0%); | ||
} | ||
.usernameLabel { | ||
overflow: hidden; | ||
overflow: hidden; | ||
} | ||
.settingsPopupDiv { | ||
position: absolute; | ||
left: 4%; | ||
bottom: 2%; | ||
position: absolute; | ||
left: 4%; | ||
bottom: 2%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.