Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev quickfix #219

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 118 additions & 90 deletions components/website-utils/Navbar.vue
Original file line number Diff line number Diff line change
@@ -1,117 +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' },
]
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>
33 changes: 27 additions & 6 deletions components/website-utils/OuterComponents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,22 @@ if (

<template>
<div class="flex min-h-screen w-screen flex-col">
<Navbar class="flex-grow basis-auto" :disable-sidebar="width > 800" />
<Navbar
class="flex-grow basis-auto"
:disable-sidebar="width > 800"
/>
<div
class="flex flex-grow flex-shrink basis-auto flex-row w-screen overflow-x-clip max-h-none place-content-around min-h-full"
>
<Transition name="width-fade">
<div v-show="width > 800" class="vis min-h-screen h-screen max-w-full">
<UCard class="h-full" :ui="{ rounded: 'rounded-none' }">
<div
v-show="width > 800"
class="vis min-h-screen h-screen max-w-full"
>
<UCard
class="h-full"
:ui="{ rounded: 'rounded-none' }"
>
<UVerticalNavigation :links="links" />
<div class="settingsPopupDiv">
<div class="flex">
Expand Down Expand Up @@ -113,8 +122,15 @@ if (
</span>
</div>
</template>
<UFormGroup class="inputDiv" label="Event" name="event">
<USelectMenu v-model="currentEvent" :options="events" />
<UFormGroup
class="inputDiv"
label="Event"
name="event"
>
<USelectMenu
v-model="currentEvent"
:options="events"
/>
</UFormGroup>
<br />
<UButton
Expand All @@ -126,7 +142,12 @@ if (
@click="navigateTo('/settings')"
/>
<template #footer>
<UButton block label="Logout" square @click="logout" />
<UButton
block
label="Logout"
square
@click="logout"
/>
</template>
</UCard>
</template>
Expand Down
3 changes: 3 additions & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Base page of the website. This really shouldn't be seen during normal use atm.
<template>
<h1>Please wait!</h1>
<p>If loading is taking a long time, the server may have a problem.</p>
<p>If you think there may be an issue with the </p>
<p>server please find the nearest DARC SIDE programmer.</p>
<p>Thanks!</p>
</template>

<style scoped></style>
6 changes: 6 additions & 0 deletions pages/predict.vue
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ watch(pending, () => {
class="text-red-400 dark:text-red-600 text-xs"
>not found</span
>
<span v-else></span>
</template>
</UInput>
<UInput
Expand All @@ -326,6 +327,7 @@ watch(pending, () => {
class="text-red-400 dark:text-red-600 text-xs"
>not found</span
>
<span v-else></span>
</template>
</UInput>
<UInput
Expand All @@ -339,6 +341,7 @@ watch(pending, () => {
class="text-red-400 dark:text-red-600 text-xs"
>not found</span
>
<span v-else></span>
</template>
</UInput>
</UContainer>
Expand Down Expand Up @@ -375,6 +378,7 @@ watch(pending, () => {
class="text-red-400 dark:text-red-600 text-xs"
>not found</span
>
<span v-else></span>
</template>
</UInput>
<UInput
Expand All @@ -388,6 +392,7 @@ watch(pending, () => {
class="text-red-400 dark:text-red-600 text-xs"
>not found</span
>
<span v-else></span>
</template>
</UInput>
<UInput
Expand All @@ -401,6 +406,7 @@ watch(pending, () => {
class="text-red-400 dark:text-red-600 text-xs"
>not found</span
>
<span v-else></span>
</template>
</UInput>
</UContainer>
Expand Down
2 changes: 2 additions & 0 deletions pages/scout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ async function submit() {
"
>not found</span
>
<span v-else></span>
</template>
</UInput>
</div>
Expand All @@ -216,6 +217,7 @@ async function submit() {
"
>error</span
>
<span v-else></span>
</template>
</UInput>
</div>
Expand Down
Loading