ffplayout/components/HeaderMenu.vue

158 lines
6.2 KiB
Vue
Raw Normal View History

2020-04-15 12:10:34 -04:00
<template>
<div class="navbar bg-base-100 min-h-[52px] p-0 shadow">
2024-04-11 15:34:03 -04:00
<NuxtLink class="navbar-brand min-w-[46px] p-2" href="/">
<img src="~/assets/images/ffplayout-small.png" class="img-fluid" alt="Logo" width="30" height="30" />
2024-04-04 17:28:25 -04:00
</NuxtLink>
2024-04-29 03:35:26 -04:00
<EventStatus v-if="route.name?.toString().includes('player__')" class="z-10"/>
2024-04-04 17:28:25 -04:00
<div class="navbar-end w-1/5 grow">
2024-04-06 17:12:06 -04:00
<label class="swap swap-rotate me-2 md:hidden">
<input type="checkbox" :checked="indexStore.darkMode" @change="toggleDarkTheme" />
2024-04-09 15:08:25 -04:00
<SvgIcon name="swap-on" classes="w-5 h-5" />
<SvgIcon name="swap-off" classes="w-5 h-5" />
2024-04-06 17:12:06 -04:00
</label>
2024-04-04 17:28:25 -04:00
<div class="dropdown dropdown-end z-50">
<div tabindex="0" role="button" class="btn btn-ghost md:hidden">
2024-04-09 15:08:25 -04:00
<SvgIcon name="burger" classes="w-5 h-5" />
2024-04-04 17:28:25 -04:00
</div>
<ul class="menu menu-sm dropdown-content mt-1 z-[1] p-2 shadow bg-base-100 rounded-box w-52">
<li v-for="item in menuItems" :key="item.name" class="bg-base-100 rounded-md">
2024-04-16 12:13:28 -04:00
<NuxtLink :to="item.link" class="h-[27px] text-base" exact-active-class="is-active">
2024-04-05 12:51:50 -04:00
<span>
{{ item.name }}
</span>
</NuxtLink>
</li>
<li v-if="configStore.configGui.length > 1">
2024-04-06 17:12:06 -04:00
<details tabindex="0" @focusout="closeDropdown">
2024-04-04 17:28:25 -04:00
<summary>
2024-04-05 12:51:50 -04:00
<div class="h-[19px] text-base">
2024-04-11 15:34:03 -04:00
<span> {{ $t('button.channels') }} </span>
2024-04-05 12:51:50 -04:00
</div>
2024-04-04 17:28:25 -04:00
</summary>
<ul class="p-2">
<li v-for="(channel, index) in configStore.configGui" :key="index">
<span>
2023-01-11 04:54:25 -05:00
<a class="dropdown-item" @click="selectChannel(index)">{{ channel.name }}</a>
2024-04-04 17:28:25 -04:00
</span>
</li>
</ul>
</details>
</li>
<li class="bg-base-100 rounded-md">
2024-04-09 15:08:25 -04:00
<button class="h-[27px] text-base" exactActiveClass="is-active" @click="logout()">
2024-04-11 15:34:03 -04:00
{{ $t('button.logout') }}
2024-04-09 15:08:25 -04:00
</button>
2024-04-04 17:28:25 -04:00
</li>
</ul>
</div>
</div>
2024-04-11 15:34:03 -04:00
<div class="navbar-end hidden md:flex w-4/5 min-w-[750px]">
2024-04-04 17:28:25 -04:00
<ul class="menu menu-sm menu-horizontal px-1">
<li v-for="item in menuItems" :key="item.name" class="bg-base-100 rounded-md p-0">
2024-04-09 15:08:25 -04:00
<NuxtLink
:to="item.link"
class="px-2 h-[27px] relative text-base text-base-content"
2024-04-16 12:13:28 -04:00
active-class="is-active"
2024-04-09 15:08:25 -04:00
>
2024-04-05 12:51:50 -04:00
<span>
{{ item.name }}
</span>
</NuxtLink>
</li>
<li v-if="configStore.configGui.length > 1">
2024-04-06 17:12:06 -04:00
<details tabindex="0" @focusout="closeDropdown">
2024-04-04 17:28:25 -04:00
<summary>
2024-04-05 12:51:50 -04:00
<div class="h-[19px] text-base">
2024-04-11 15:34:03 -04:00
<span> {{ $t('button.channels') }} </span>
2024-04-04 17:28:25 -04:00
</div>
</summary>
<ul class="p-2 bg-base-100 rounded-md !mt-1 w-36" tabindex="0">
<li v-for="(channel, index) in configStore.configGui" :key="index">
2024-04-06 17:12:06 -04:00
<a class="dropdown-item" @click="selectChannel(index)">
{{ channel.name }}
</a>
2023-01-11 04:54:25 -05:00
</li>
</ul>
2024-04-04 17:28:25 -04:00
</details>
</li>
<li class="bg-base-100 rounded-md p-0">
2024-04-11 15:34:03 -04:00
<button class="h-[27px] pt-[4px] text-base" @click="logout()">
{{ $t('button.logout') }}
</button>
2024-04-06 17:12:06 -04:00
</li>
<li class="p-0">
<label class="swap swap-rotate">
<input type="checkbox" :checked="indexStore.darkMode" @change="toggleDarkTheme" />
2024-04-09 15:08:25 -04:00
<SvgIcon name="swap-on" classes="w-5 h-5" />
<SvgIcon name="swap-off" classes="w-5 h-5" />
2024-04-06 17:12:06 -04:00
</label>
2024-04-04 17:28:25 -04:00
</li>
</ul>
2020-04-15 12:10:34 -04:00
</div>
</div>
</template>
2023-01-11 04:54:25 -05:00
<script setup lang="ts">
2024-04-06 17:12:06 -04:00
const colorMode = useColorMode()
2024-04-11 15:34:03 -04:00
const { t } = useI18n()
const localePath = useLocalePath()
2024-04-29 03:35:26 -04:00
const route = useRoute()
2024-04-11 15:34:03 -04:00
const router = useRouter()
2023-01-11 04:54:25 -05:00
const authStore = useAuth()
const configStore = useConfig()
2024-04-06 17:12:06 -04:00
const indexStore = useIndex()
2020-04-15 12:10:34 -04:00
2024-04-04 17:28:25 -04:00
const menuItems = ref([
2024-04-11 15:34:03 -04:00
{ name: t('button.home'), link: localePath({ name: 'index' }) },
{ name: t('button.player'), link: localePath({ name: 'player' }) },
{ name: t('button.media'), link: localePath({ name: 'media' }) },
{ name: t('button.message'), link: localePath({ name: 'message' }) },
{ name: t('button.logging'), link: localePath({ name: 'logging' }) },
{ name: t('button.configure'), link: localePath({ name: 'configure' }) },
2024-04-04 17:28:25 -04:00
])
2024-04-06 17:12:06 -04:00
if (colorMode.value === 'dark') {
indexStore.darkMode = true
}
2024-04-04 17:28:25 -04:00
function closeDropdown($event: any) {
setTimeout(() => {
$event.target.parentNode.removeAttribute('open')
}, 200)
}
2023-01-11 04:54:25 -05:00
function logout() {
authStore.removeToken()
2024-04-11 15:34:03 -04:00
router.push(localePath({ name: 'index' }))
2023-01-11 04:54:25 -05:00
}
2023-01-11 04:54:25 -05:00
function selectChannel(index: number) {
configStore.configID = index
2023-01-11 04:54:25 -05:00
configStore.getPlayoutConfig()
2020-04-15 12:10:34 -04:00
}
2024-04-06 17:12:06 -04:00
function toggleDarkTheme() {
indexStore.darkMode = !indexStore.darkMode
if (indexStore.darkMode) {
colorMode.preference = 'dark'
} else {
colorMode.preference = 'light'
}
}
2020-04-15 12:10:34 -04:00
</script>
2024-04-04 17:28:25 -04:00
<style lang="scss" scoped>
.is-active > span::after {
background: var(--my-accent);
position: relative;
2024-04-04 17:28:25 -04:00
left: 0px;
2023-01-11 04:54:25 -05:00
content: ' ';
2024-04-04 17:28:25 -04:00
width: inherit;
height: 2px;
2024-04-04 17:28:25 -04:00
color: red;
display: block;
2024-04-04 17:28:25 -04:00
border-radius: 0.15em;
2023-01-11 04:54:25 -05:00
}
2020-04-15 12:10:34 -04:00
</style>