jellyfin-vue/layouts/default.vue

137 lines
3.2 KiB
Vue
Raw Normal View History

2020-09-02 18:34:50 +00:00
<template>
<v-app dark>
<v-navigation-drawer
v-model="drawer"
:mini-variant="miniVariant"
:clipped="clipped"
fixed
app
>
<v-list>
<v-list-item
v-for="(item, i) in items"
:key="i"
:to="item.to"
router
exact
>
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title v-text="item.title" />
</v-list-item-content>
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list>
<v-list-item
v-for="(library, i) in libraries"
:key="i"
:to="library.to"
router
exact
>
<v-list-item-action>
<v-icon>{{ library.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title v-text="library.title" />
</v-list-item-content>
</v-list-item>
</v-list>
<v-divider></v-divider>
<v-list>
<v-list-item
v-for="(item, i) in configItems"
:key="i"
:to="item.to"
router
exact
>
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title v-text="item.title" />
</v-list-item-content>
</v-list-item>
</v-list>
2020-09-02 18:34:50 +00:00
</v-navigation-drawer>
<v-app-bar :clipped-left="clipped" fixed app>
<v-app-bar-nav-icon @click.stop="drawer = !drawer" />
<v-btn icon @click.stop="miniVariant = !miniVariant">
<v-icon>mdi-{{ `chevron-${miniVariant ? 'right' : 'left'}` }}</v-icon>
</v-btn>
<v-toolbar-title v-text="title" />
<v-spacer />
2020-09-03 14:52:43 +00:00
<user-button v-if="$auth.loggedIn" />
2020-09-02 18:34:50 +00:00
</v-app-bar>
<v-main>
<v-container>
<nuxt />
</v-container>
</v-main>
2020-09-04 15:52:47 +00:00
<snackbar />
2020-09-02 18:34:50 +00:00
</v-app>
</template>
<script lang="ts">
import Vue from 'vue';
2020-09-04 18:49:07 +00:00
import { BaseItemDto } from '~/api/api';
import { getLibraryIcon } from '~/utils/items';
interface NavigationDrawerItem {
icon: string | undefined | null;
title: string | undefined | null;
to: string;
}
2020-09-03 14:52:43 +00:00
export default Vue.extend({
2020-09-02 18:34:50 +00:00
data() {
return {
items: [
{
icon: 'mdi-home',
title: 'Home',
to: '/'
}
],
configItems: [
{
icon: 'mdi-cog',
title: 'Settings',
to: '/settings'
}
],
clipped: true,
drawer: true,
libraries: {},
miniVariant: false,
2020-09-02 18:34:50 +00:00
title: 'Jellyfin'
};
},
async beforeMount() {
const userViewsRequest = await this.$userViewsApi.getUserViews({
userId: this.$auth.user.Id
});
let userViews: Array<NavigationDrawerItem> = [];
if (userViewsRequest.data.Items) {
userViews = userViewsRequest.data.Items.map(
(view: BaseItemDto): NavigationDrawerItem => {
return {
icon: getLibraryIcon(view.CollectionType),
title: view.Name,
to: `/library/${view.Id}`
};
}
);
}
this.libraries = userViews;
2020-09-02 18:34:50 +00:00
}
});
2020-09-02 18:34:50 +00:00
</script>